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
Simulation time vector (this is a brand new instance from the settings.tvec property method)
Simulation time step
Methods
Build the full model.
Flush initialization values from junctions
Allow model populations to be retrieved by name rather than index.
Run the full model.
Replace IDs with references
Replace references with IDs
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 link values
Update parameter values
- 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 theJunctionCompartment
. 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 thatModel.junctions
is in the correct order)- Return type:
- relink()[source]¶
Replace IDs with references
This is the reverse operation of
Model.unlink()
where IDs are replaced with object references.- Return type:
- t¶
Simulation time vector (this is a brand new instance from the settings.tvec property method)
- unlink()[source]¶
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:
- 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:
- update_links()[source]¶
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:
- update_pars()[source]¶
Update parameter values
Run through all parameters and characteristics, updating as required. This takes place in stages :rtype:
None
Characteristics that are dependencies of parameters are updated
- Parameters are updated in dependency order
The parameter function is evaluated
The parameter is overwritten by programs
The parameter is updated with the population aggregation calculation
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).