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).

diffuse(mol_idx)[source]

Update the concentration of molecules based on diffusion.

get_concentration(mol_idx, index)[source]

Get the concentration value of a molecule at a given voxel in the grid.

property gradient: list[Molecule, str]

The gradient of the molecules in the system.

property grid_size: tuple

The size of the 3D grid.

property molecules: list[Molecule]

The list of molecules in the system.

simulate()[source]

Run the diffusion simulation over the total time.

property time_step: float

The time step of the simulation.

property total_time: int

The total time of the simulation.

update_concentration(mol_idx, index, value)[source]

Update the concentration value of a molecule 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.

property D: float

The diffusion rate of the molecule.

property conc: float

The concentration of the molecule.

property gradient: str

The gradient of the molecule.

property name: str

Name of the molecule. Also defines the name of related forces and collections of effectors.