flows

This module contains the classes which are used to calculate inter-compartmental flow rates. As a user of the framework you should not have to use these classes directly.

class summer.flows.CrudeBirthFlow(name: str, dest: summer.compartment.Compartment, param: Union[float, Callable[float, float]], adjustments: Optional[List[summer.adjust.BaseAdjustment]] = None)

Bases: summer.flows.BaseEntryFlow

A flow that calculates births using a ‘crude birth rate’ method. The number of births will be determined by the product of the birth rate and total population.

Parameters
  • name – The flow name.

  • dest – The destination compartment.

  • param – The fraction of the population to be born per timestep.

  • adjustments – Adjustments to the flow rate.

get_net_flow(compartment_values: numpy.ndarray, time: float)float

Returns the net flow value at a given time.

class summer.flows.DeathFlow(name: str, source: summer.compartment.Compartment, param: Union[float, Callable[float, float]], adjustments: Optional[List[summer.adjust.BaseAdjustment]] = None)

Bases: summer.flows.BaseExitFlow

A flow representing deaths. Calculated from a fractional death rate.

Parameters
  • name – The flow name.

  • dest – The destination compartment.

  • param – The fraction of the population who die per timestep.

  • adjustments – Adjustments to the flow rate.

get_net_flow(compartment_values: numpy.ndarray, time: float)float

Returns the net flow value at a given time.

is_death_flow = True
class summer.flows.FunctionFlow(name: str, source: summer.compartment.Compartment, dest: summer.compartment.Compartment, param: Union[float, Callable[float, float]], adjustments: Optional[List[summer.adjust.BaseAdjustment]] = None)

Bases: summer.flows.BaseTransitionFlow

A flow that transfers people from a source to a destination based on a user-defined function. Note that the rate is NOT multiplied by the size of the source compartment. This can be used to define more complex flows if required. Important to be careful that compartment sizes do not go negative with these flows, as this is not guaranteed.

Parameters
  • name – The flow name.

  • source – The source compartment.

  • dest – The destination compartment.

  • param – A function that returns the flow rate, before adjustments. See get_net_flow for this function’s arguments.

  • adjustments – Adjustments to the flow rate.

get_net_flow(compartments: List[summer.compartment.Compartment], compartment_values: numpy.ndarray, flows: List[summer.flows.BaseFlow], flow_rates: numpy.ndarray, derived_values: dict, time: float)float

Returns the net flow value at a given time.

class summer.flows.ImportFlow(name: str, dest: summer.compartment.Compartment, param: Union[float, Callable[float, float]], adjustments: Optional[List[summer.adjust.BaseAdjustment]] = None)

Bases: summer.flows.BaseEntryFlow

Calculates importation, where people enter the destination compartment from outside the system. The number of people imported per timestep is independent of the source compartment, because there isn’t a source compartment.

Parameters
  • name – The flow name.

  • dest – The destination compartment.

  • param – The number of people to be imported per timestep.

  • adjustments – Adjustments to the flow rate.

get_net_flow(compartment_values: numpy.ndarray, time: float)float

Returns the net flow value at a given time.

class summer.flows.InfectionDensityFlow(name: str, source: summer.compartment.Compartment, dest: summer.compartment.Compartment, param: Union[float, Callable[float, float]], find_infectious_multiplier: Callable[[summer.compartment.Compartment, summer.compartment.Compartment], float], adjustments: Optional[List[summer.adjust.BaseAdjustment]] = None)

Bases: summer.flows.BaseInfectionFlow

An infection flow that should use the number of infectious people to calculate the force of infection factor.

class summer.flows.InfectionFrequencyFlow(name: str, source: summer.compartment.Compartment, dest: summer.compartment.Compartment, param: Union[float, Callable[float, float]], find_infectious_multiplier: Callable[[summer.compartment.Compartment, summer.compartment.Compartment], float], adjustments: Optional[List[summer.adjust.BaseAdjustment]] = None)

Bases: summer.flows.BaseInfectionFlow

An infection flow that should use the prevalence of infectious people to calculate the force of infection factor.

class summer.flows.ReplacementBirthFlow(name: str, dest: summer.compartment.Compartment, param: Union[float, Callable[float, float]], adjustments: Optional[List[summer.adjust.BaseAdjustment]] = None)

Bases: summer.flows.BaseEntryFlow

A flow that calculates births by replacing total deaths. The total number of deaths will be supplied by the parameter function.

Parameters
  • name – The flow name.

  • dest – The destination compartment.

  • param – The total number of deaths per timestep.

  • adjustments – Adjustments to the flow rate.

get_net_flow(compartment_values: numpy.ndarray, time: float)float

Returns the net flow value at a given time.

class summer.flows.TransitionFlow(name: str, source: summer.compartment.Compartment, dest: summer.compartment.Compartment, param: Union[float, Callable[float, float]], adjustments: Optional[List[summer.adjust.BaseAdjustment]] = None)

Bases: summer.flows.BaseTransitionFlow

A flow that transfers people from a source to a destination based on the population of the source compartment and the fractional flow rate.

Parameters
  • name – The flow name.

  • source – The source compartment.

  • dest – The destination compartment.

  • param – The fraction of the source compartment to transfer per timestep.

  • adjustments – Adjustments to the flow rate.

get_net_flow(compartment_values: numpy.ndarray, time: float)float

Returns the net flow value at a given time.