Skip to content

Dynamic Number of Occupants (Infected)

Luis Aleixo requested to merge feature/piecewise_presence into master

Closes #297 (closed)

This feature enables to simulate a scenario with dynamic number of occupants throughout the simulation time. For example, if we consider a CO2ConcentrationModel with a presence time between 8h-10h (1 person), 10h-11h (3 people), 12h-13h (0 people), and 13-17h (2 people), it is expected that the concentration slopes between any of these intervals are different:

Screenshot_2023-03-17_at_09.26.00

To this end, the Population method was modified to consider an IntPiecewiseConstant(PiecewiseConstant) for the number of people attribute, while the presence can be set as None in this case:

Population=(
        number=IntPiecewiseConstant((8, 10, 12, 13, 17), (1, 3, 0, 2)),
        presence=None,
        ...
)

This way, one can profit from the value() method of the PiecewiseContant class to get the number of people present at a given time when calculating the concentration -> every occurrence of the population.number was replaced by population.number.value(time) and every occurrence of population.presence was replaced by population.number.interval(). The _normed_concentration method was adapted to normalize the concentration_at_last_state_change by the correct number of present people at a given time, to avoid unexpected jumps in the concentration line.

It is important to note that the code was developed to allow a back-compatibility with the static number of occupants, which means that the previous way of creating a static Population object is still possible/working. Some __post_init__ validation was added in order to recognise which structure the model should consider.

Feature implemented only for the infected occupants. A solution for the exposed may be developed with an upcoming MR. This means that the number of exposed occupants is still static.

Tests were added to compare the old-method way of calculate the concentration at a given time vs. the new way of doing it.

Edited by Luis Aleixo

Merge request reports