Simulation

This module contains functionality to configure and run simulations.

Define Agent Properties

AgentSettings

A template for defining an agent.

RodMechanicsSettings

Defines properties of to the RodMechanics struct.

MorsePotentialF32

Define interaction properties of the agent.

Running a Simulation

Configuration

Bundles all information required for a simulation.

run_simulation_with_agents()

Executes the simulation and returns a CellContainer.

class AgentSettings(**kwds)

Bases: object

Contains settings needed to specify properties of the RodAgent

to_rod_agent_dict()

Converts the class to a dictionary

growth_rate

Rate with which the length of the bacterium grows

growth_rate_distr

See RodAgent

interaction

Settings for the interaction part of RodAgent. See also MorsePotentialF32.

mechanics

Settings for the mechanics part of RodAgent. See also RodMechanicsSettings.

neighbor_reduction

Reduces the growth rate with multiplier $((max - N)/max)^q $

spring_length_threshold

Threshold when the bacterium divides

class Configuration(**kwds)

Bases: object

Contains all settings needed to configure the simulation

static deserialize(data)

TODO

static from_json(json_string)

Deserializes this struct from a json string

static from_toml(filename)

Parses the content of a given toml file and returns a Configuration object which contains the given values. See also from_toml_string().

static from_toml_string(toml_string)

Parses the contents of a given string and returns a Configuration. See also from_toml_string().

to_hash()

Attempts to create a hash from the contents of this Configuration. Warning: This feature is experimental.

to_json()

Serializes this struct to the json format

domain_height

We assume that the domain is a thin 3D slice. This specifies the height of the domain.

domain_size

Overall domain size of the simulation. This may determine an upper bound on the number of agents which can be put into the simulation.

dt

Time increment

gel_pressure

See [cellular_raza-building_blocks::CartesianSubDomainRods]

n_saves

Interval in which results will be saved

n_threads

Number of threads used for solving the system.

n_voxels

Number of voxels used to solve the system. This may yield performance improvements but specifying a too high number will yield incorrect results. See also https://cellular-raza.com/internals/concepts/domain/decomposition/.

rng_seed

Initial seed for randomizations. This can be useful to run multiple simulations with identical parameters but slightly varying initial conditions.

show_progressbar

Specifies if a progress bar should be shown during the solving process.

storage_location

Store results in this given path. Only takes effect if more StorageOptions than memory are utilized.

storage_options

Define in which format to store results. Only uses memory by default

storage_suffix

Appends a suffix to the date which is generated automatically.

surface_friction

See [cellular_raza-building_blocks::CartesianCuboidRods]

surface_friction_distance

See [cellular_raza-building_blocks::CartesianCuboidRods]

t0

Starting time

t_max

Maximum solving time

class PhysicalInteraction(pyobject)

Bases: object

Describes all possible interaction variants

inner()

Extracts a copy of the inner value

radius

Obtains the radius of the interaction

strength

Getter for the strength of the interaction

class RodAgent(pos, vel, interaction, diffusion_constant=0.0, spring_tension=1.0, rigidity=2.0, spring_length=3.0, damping=1.0, growth_rate=0.1, growth_rate_distr=Ellipsis, spring_length_threshold=6.0, neighbor_reduction=None)

Bases: object

A basic cell-agent which makes use of RodMechanics

growth_rate

Rate with which the cell grows in units 1/MIN.

growth_rate_distr

Determines the mean and width of distribution for sampling new values of growth rate.

neighbor_reduction

Reduces the growth rate with multiplier $((max - N)/max)^q $

pos

Position of the agent given by a matrix containing all vertices in order.

radius

The interaction radius as given by the [MorsePotentialF32] interaction struct.

spring_length_threshold

Threshold at which the cell will divide in units MICROMETRE.

vel

Velocity of the agent given by a matrix containing all velocities at vertices in order.

class RodMechanicsSettings

Bases: object

Contains all settings required to construct RodMechanics

damping

Damping constant

diffusion_constant

Controls magnitude of32 stochastic motion

pos
rigidity

Stif32fness at each joint connecting two edges

spring_length

Target spring length

spring_tension

Spring tension between individual vertices

vel
class StorageOption

Bases: object

Define how to store results of the simulation.

We currently support saving results in a [sled] database, or as a json file by using [serde_json].

Memory = StorageOption.Memory
Ron = StorageOption.Ron
SerdeJson = StorageOption.SerdeJson
Sled = StorageOption.Sled
SledTemp = StorageOption.SledTemp
generate_agents(n_agents, agent_settings, config, rng_seed=0, dx=Ellipsis, randomize_positions=0.0, n_vertices=8)

Uses the generate_positions() function to generate positions and then sets parameters of the generated agents from the supplied AgentSettings.

generate_positions(n_agents, agent_settings, config, rng_seed=0, dx=Ellipsis, randomize_positions=0.0, n_vertices=8)

Creates positions for multiple RodAgent which can be used for simulation purposes.

run_simulation_with_agents(config, agents)

Executes a simulation given a Configuration and a list of RodAgent.

sort_cellular_identifiers(identifiers)

Sorts an iterator of CellIdentifier deterministically.

This function is usefull for generating identical masks every simulation run. This function is implemented as standalone since sorting of a CellIdentifier is typically not supported.

Parameters:

identifiers (list) – A list of CellIdentifier

Returns:

The sorted list.

Return type:

list

class MorsePotentialF32

Famous Morse potential for diatomic molecules. See the documentation at cellular_raza-building_blocks::MorsePotentialF32.

class MiePotentialF32

See documentation at cellular_raza-building_blocks::MiePotentialF32.