Reaction-diffusion spaces

class strengths.RDGridSpace(w=1, h=1, d=1, cell_env=0, cell_vol=1, boundary_conditions=None, units_system=<strengths.units.UnitsSystem object>)

represent a grid of cells in 3 dimensions. each cell is associated with an environment (index). all cells have the same volume cell_vol.

Parameters:
  • w (int) – grid width

  • h (int) – grid height

  • d (int) – grid depth

  • cell_env – cell(s) environment(s)

  • cell_vol – cell(s) volume(s)

are_neighbors(position1, position2)

tells if the two positions reffres to a couple of neighbor cells. Return True is that is the case, False otherwise.

Parameters:
  • position1 (number, tuple or Coord like) – position of the first cell

  • position2 (number, tuple or Coord like) – position of the second cell

property cell_env

environment index associated with each cell (array of int). can be set from a number or an array of numbers. if set with number, this number will be applied to all cells. if set with an array, the array size must match the rdspace size. ie.

rdspace.cell_env = 0
rdspace.cell_env = [0,0,0]
property cell_vol

volume of a cell (UnitValue). can be set from a number, a UnitValue or a str. ie.

rdspace.cell_vol = 1
rdspace.cell_vol = "1 µm3"
rdspace.cell_vol = UnitValue(1, "µm3")
copy()

returns a deepcopy of the instance.

instance.copy()

# is equivalent to
# import copy

copy.deepcopy(instance)
property d

grid depth in cells (int). Cannot be set.

get_boundary_conditions()

Returns a dict of boundary conditions associated with each axis.

get_cell_coordinates(cell_index, return_type=<class 'tuple'>)

Returns the 3D (x, y, z) coordinates of the cell with the given index.

Parameters:
  • cell_index (number) – cell index

  • return_type (class/type) – type of the returned coordinates. default tuple.

Returns:

index of the species at the given position.

Return type:

int

ie.

rdspace.get_cell_index(1) # returns (1,0,0)
get_cell_env(position)

Aims to be part of the general reaction-diffusion space interface. Returns the environment index of the cell at the given position.

get_cell_env_array()

Aims to be part of the general reaction-diffusion space interface. Returns an array containting the environment index associated with each cell.

get_cell_index(position)

Returns the linear index at a given position.

Parameters:

position (number, Coord like or tuple If a number is given, it is interpreted as a linear index (the function returns int(index)). If a tuple or a Coord like object is given, those are interperted as (x,y,z) coordinates, and the index corresponding to those coordinates is returned.) – cell index or coordinates

Returns:

index of the species at the given position.

Return type:

int

ie.

rdspace.get_cell_index((1,0,0))
rdspace.get_cell_index(Coord(1,0,0))
rdspace.get_cell_index(1)
get_cell_vol(position)

Aims to be part of the general reaction-diffusion space interface. Returns the volume of the cell at the given position.

get_cell_vol_array()

Aims to be part of the general reaction-diffusion space interface. Returns an array containting the volume of each cell.

get_neighbors(position)

Returns the indices of all neighbors of the cell at the given position.

property h

grid height in cells (int). Cannot be set.

is_within_bounds(position)

Tells if a given position is within the bounds of the cell grid. returns True if the position refers to a cell inside the grid, False otherwise.

Parameters:

position (number, tuple or Coord like) – position to be evaluated

Returns:

True if the position refers to a cell inside the grid, False otherwise.

Return type:

bool

set_boundary_conditions(boundary_conditions)

Sets the boundary conditons of the system space.

size()

returns the number of cells in the grid (int). size = w*h*d

property units_system

default units system used when value that require units are given without (UnitsSystem). can be defined from a UnitsSystem or a dict. ie.

rdspace.units_system = UnitsSystem(space="µm", time="s", quantity="molecule")
rdspace.units_system = {"space"="µm", "time"="s", "quantity"="molecule"}
property w

grid width in cells (int). Cannot be set.

class strengths.RDGraphSpace(nodes=[], edges=[], units_system=<strengths.units.UnitsSystem object>)

represents a graph serving as a reaction-diffusion space. It is a generalization of the cell grid (RDGridSpace) as, each cell (node) have its own volume (cell_vol may be an array) and an arbitrary number of neighbors (defined by the edges).

Parameters:
  • nodes (array of RDGraphSpaceNode) – nodes of the graph

  • edges (array of RDGraphSpaceEdge) – edges of the graph

are_neighbors(position1, position2)

tells if the two positions reffres to a couple of neighbor cells. Return True is that is the case, False otherwise.

Parameters:
  • position1 (node index (int)) – position of the first cell

  • position2 (node index (int)) – position of the second cell

check()

checks for errors in the graph sructures (duplicated edges or invalid node indices).

copy()

returns a deepcopy of the instance.

instance.copy()

# is equivalent to
# import copy

copy.deepcopy(instance)
property edges
get_cell_env(position)

Aims to be part of the general reaction-diffusion space interface. Returns the environment index of the cell at the given position.

get_cell_env_array()

Aims to be part of the general reaction-diffusion space interface. Returns an array containting the environment index associated with each cell.

get_cell_index(position)

Returns position if it is a valid cell index. raise an Exception otherwise. The returned value is int(position) it it is in the [0, self.size()) range.

get_cell_vol(position)

Aims to be part of the general reaction-diffusion space interface. Returns the volume of the cell at the given position.

get_cell_vol_array()

Aims to be part of the general reaction-diffusion space interface. Returns an array containting the volume of each cell.

get_edge(i, j)

return the edge (i,j) or (j,i) if it exists, None otherwise.

get_neighbors(position)

Returns the indices of all neighbors of the cell at the given position.

property nodes
size()

returns the number of cells in the grid (int) (number of nodes).

property units_system

default units system used when value that require units are given without (UnitsSystem). can be defined from a UnitsSystem or a dict. ie.

rdspace.units_system = UnitsSystem(space="µm", time="s", quantity="molecule")
rdspace.units_system = {"space"="µm", "time"="s", "quantity"="molecule"}
strengths.load_rdspace(path, parent_units_system=<strengths.units.UnitsSystem object>)

Loads an RDSpace object from a JSON file.

strengths.save_rdspace(space, path)

Saves an RDSpace object as a JSON file.

strengths.rdspace_to_dict(space)

Builds a dict from a RDSpace.

strengths.rdspace_from_dict(d, parent_units_system=<strengths.units.UnitsSystem object>, base_path=None)

Builds a Reaction Diffudion Space (RDGridSpace or RDGraphSpace) from a dict.