atomica.model.Model

class atomica.model.Model(settings, framework, parset, progset=None, program_instructions=None)[source]

Bases: object

A class to wrap up multiple populations within model and handle cross-population transitions.

Attributes

t

Simulation time vector (this is a brand new instance from the settings.tvec property method)

dt

Simulation time step

Methods

build

Build the full model.

flush_junctions

Flush initialization values from junctions

get_pop

Allow model populations to be retrieved by name rather than index.

process

Run the full model.

relink

Replace IDs with references

unlink

Replace references with IDs

update_comps

Set the compartment values at self._t_index+1 based on the current values at self._t_index and the link values at self._t_index.

update_links

Update link values

update_pars

Update parameter values

build(parset)[source]

Build the full model.

dt

Simulation time step

flush_junctions()[source]

Flush initialization values from junctions

If junctions have been initialized with nonzero values as a mcv1 for initializing the downstream compartments, then the junctions need to be flushed into the downstream compartments at the start of the simulation. This is done using the .flush() method of the JunctionCompartment. The order of the loop is important if junctions flow into other junctions - this needs to be computed from the graph prior to calling this method (so that Model.junctions is in the correct order)

Return type

None

get_pop(pop_name)[source]

Allow model populations to be retrieved by name rather than index.

process()[source]

Run the full model.

Return type

None

Replace IDs with references

This is the reverse operation of Model.unlink() where IDs are replaced with object references.

Return type

None

t

Simulation time vector (this is a brand new instance from the settings.tvec property method)

Replace references with IDs

This method replaces all references with IDs so that there are no circular references that prevent pickling. This operation is reversed using Model.relink(). These get called automatically when pickling and unpickling.

Note that primary storage of the variables is in the population objects, so that is the one place where the variables remain in-scope.

Return type

None

update_comps()[source]

Set the compartment values at self._t_index+1 based on the current values at self._t_index and the link values at self._t_index. Values are updated by iterating over all outgoing links

Return type

None

Update link values

This method takes the current parameter values in the model, and uses them to populate associated links. This requires conversion between parameter units and actual flow rates.

Methods that populate links by means other than parameter e.g. Compartment.resolve_outflows or Junction.balance also get called here.

Return type

None

update_pars()[source]

Update parameter values

Run through all parameters and characteristics, updating as required. This takes place in stages

  1. Characteristics that are dependencies of parameters are updated

  2. Parameters are updated in dependency order
    1. The parameter function is evaluated

    2. The parameter is overwritten by programs

    3. The parameter is updated with the population aggregation calculation

    4. The parameter value is constrained

The parameters are updated parameter-at-a-time (across populations) so that the population aggregation can be carried out.

Only parameters that are required for transitions or that are overwritten by programs are modified here - otherwise, parameter values are computed in vector calculations either before integration (if the value is purely from the databook) or after integration (if the parameter depends on any flow rates or compartment sizes).

Return type

None