goo.molecule

class goo.molecule.DiffusionSystem(molecules: list[Molecule], grid_size: Tuple[int, int, int] = (50, 50, 50), grid_center: Tuple[int, int, int] = (0, 0, 0), time_step: float = 0.1, total_time: int = 1, element_size=(0.5, 0.5, 0.5))[source]

Bases: object

A diffusion system that simulates the diffusion of molecules in a 3D grid. It also handles the secretion and sensing of molecular signals by cells.

Parameters:
  • molecules (list[Molecule]) – The list of molecules in the system.

  • grid_size (Tuple[int, int, int], optional) – The size of the 3D grid. Defaults to (25, 25, 25).

  • grid_center (Tuple[int, int, int], optional) – The center of the 3D grid. Defaults to (0, 0, 0).

  • time_step (float, optional) – The time step of the simulation. Defaults to 0.1.

  • total_time (int, optional) – The total time of the simulation. Defaults to 10.

  • element_size (Tuple[float, float, float], optional) – The size of each element in the grid. Defaults to (1.0, 1.0, 1.0).

build_kdtree()[source]

Initialize the grid and build its corresponding KD-Tree.

diffuse()[source]

Simulate the diffusion of molecules in the grid using the Laplace operator.

get_ball_concentrations(center, radius)[source]

Get concentrations of all molecules in a sphere with given center and radius.

get_concentration(mol, point)[source]

Add molecule value to a certain point at a given voxel in the grid.

get_coords_concentrations(mol, center, radius)[source]

Get a list of coordinates and a list of molecule concentration for each coordinate.

simulate_diffusion()[source]

Simulate the diffusion of molecules in the grid.

update_concentration(mol, point, value)[source]

Add molecule value to a certain point at a given voxel in the grid.

class goo.molecule.Molecule(name: str, conc: float, D: float, gradient: str | None = None)[source]

Bases: object

A molecule involved in the diffusion system.

Parameters:
  • name (str) – The name of the molecule.

  • conc (float) – The initial concentration of the molecule.

  • D (float) – The diffusion rate of the molecule.

  • gradient (str, optional) – The gradient of the molecule. Defaults to None.