atomica.model.TimedLink¶
- class atomica.model.TimedLink(pop, parameter, source, dest)[source]¶
Bases:
Link
A TimedLink connects two TimedCompartments
A TimedLink should be used between two TimedCompartments if it is important to preserve the ‘time until forced removal’ when making the transition. For example, a vaccinated individual with 3 years of protection remaining may need to move to a vaccinated+latent state, for instance. In that case, they would still have 3 years remaining in vaccinated+latent.
The value for the TimedLink corresponds to the number of people in each time bin from the source compartment. If there is a mismatch in durations across the TimedLink endpoints, it is up to the destination compartment to resolve them.
A TimedLink should _not_ be used for the timed outflow of a TimedCompartment as people flowing out of a timed outflow all originate at the same time.
Attributes
Variable code name
Link total flow
Unique identifier for the integration object
The units for the quantity, used for plotting and for validation.
Reference back to the Population containing this object
Methods
Create and wire up a new link
Produce a time series plot
Preallocate data storage
relink
Make the variable a dependency
unlink
Updated link flow rate
- classmethod create(pop, parameter, source, dest)¶
Create and wire up a new link
This method instantiates a Link (including of derived types) and also wires it up to the population, parameter, source, and destination compartments. This allows the
Link
constructor to be used without needing the entire population infrastructure- Parameters:
pop – A
Population
instance that will contain the newLink
parameter – A
Parameter
instance that will supply values for the newLink
source – A
Compartment
instance to transfer fromdest – A
Compartment
instance to transfer to
- Returns:
The newly created
Link
instance
- id¶
Unique identifier for the integration object
- property name: str¶
Variable code name
This is implemented as a property method because the
id
of theVariable
is a tuple containing the population name and the variable code name, so this property method returns just the variable code name portion. That way, storage does not need to be duplicated.- Returns:
A code name
- plot()¶
Produce a time series plot
This is a quick function to make a basic line plot of this
Variable
. Mainly intended for debugging. Production-ready plots should be generated using the plotting library functions instead
- pop¶
Reference back to the Population containing this object
- preallocate(tvec, dt)[source]¶
Preallocate data storage
Note that TimedLinks preallocate their internal storage based on the preallocated size of the source TimedCompartment. Therefore, it must be preallocated after the compartments have been preallocated.
- set_dynamic(**kwargs)¶
Make the variable a dependency
For Compartments and Links, this does nothing. For Characteristics and Parameters, it will set the dynamic flag, but in addition, any validation constraints e.g. a Parameter that depends on Links cannot itself be dynamic, will be enforced.
This method generally must be overloaded in derived classes e.g.
Parameter.set_dynamic()
- Return type:
- units¶
The units for the quantity, used for plotting and for validation. Note that the default
'unknown'
units are distinct to dimensionless units, which have value''
- update(ti, converted_frac)[source]¶
Updated link flow rate
For TimedLink instances, we update at all of the time indices
- property vals: array¶
Link total flow
This returns link outflow obtained by summing over the people in each time bin at each point in time
- Returns:
A numpy array with the link flow rate