2021-05-03 11:46:03 +00:00
|
|
|
|
# This module is part of CARA. Please see the repository at
|
|
|
|
|
|
# https://gitlab.cern.ch/cara/cara for details of the license and terms of use.
|
2021-03-28 03:53:47 +00:00
|
|
|
|
"""
|
|
|
|
|
|
This module implements the core CARA models.
|
|
|
|
|
|
|
|
|
|
|
|
The CARA model is a flexible, object-oriented numerical model. It is designed
|
|
|
|
|
|
to allow the user to swap-out and extend its various components. One of the
|
|
|
|
|
|
major abstractions of the model is the distinction between virus concentration
|
|
|
|
|
|
(:class:`ConcentrationModel`) and virus exposure (:class:`ExposureModel`).
|
|
|
|
|
|
|
|
|
|
|
|
The concentration component is a recursive (on model time) model and therefore in order
|
|
|
|
|
|
to optimise its execution certain layers of caching are implemented. This caching
|
|
|
|
|
|
mandates that the models in this module, once instantiated, are immutable and
|
|
|
|
|
|
deterministic (i.e. running the same model twice will result in the same answer).
|
|
|
|
|
|
|
|
|
|
|
|
In order to apply stochastic / non-deterministic analyses therefore you must
|
|
|
|
|
|
introduce the randomness before constructing the models themselves; the
|
|
|
|
|
|
:mod:`cara.monte_carlo` module is a good example of doing this - that module uses
|
|
|
|
|
|
the models defined here to allow you to construct a ConcentrationModel containing
|
|
|
|
|
|
parameters which are expressed as probability distributions. Under the hood the
|
|
|
|
|
|
``cara.monte_carlo.ConcentrationModel`` implementation simply samples all of those
|
|
|
|
|
|
probability distributions to produce many instances of the deterministic model.
|
|
|
|
|
|
|
|
|
|
|
|
The models in this module have been designed for flexibility above performance,
|
|
|
|
|
|
particularly in the single-model case. By using the natural expressiveness of
|
|
|
|
|
|
Python we benefit from a powerful, readable and extendable implementation. A
|
|
|
|
|
|
useful feature of the implementation is that we are able to benefit from numpy
|
|
|
|
|
|
vectorisation in the case of wanting to run multiple-parameterisations of the model
|
|
|
|
|
|
at the same time. In order to benefit from this feature you must construct the models
|
|
|
|
|
|
with an array of parameter values. The values must be either scalar, length 1 arrays,
|
|
|
|
|
|
or length N arrays, where N is the number of parameterisations to run; N must be
|
|
|
|
|
|
the same for all parameters of a single model.
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
2020-11-12 20:21:02 +00:00
|
|
|
|
from dataclasses import dataclass
|
2020-10-20 07:11:28 +00:00
|
|
|
|
import typing
|
|
|
|
|
|
|
2021-04-07 08:15:48 +00:00
|
|
|
|
import numpy as np
|
|
|
|
|
|
from scipy.interpolate import interp1d
|
2021-05-31 09:29:49 +00:00
|
|
|
|
import scipy.integrate
|
2021-04-07 08:15:48 +00:00
|
|
|
|
|
2021-03-28 04:46:34 +00:00
|
|
|
|
if not typing.TYPE_CHECKING:
|
|
|
|
|
|
from memoization import cached
|
|
|
|
|
|
else:
|
|
|
|
|
|
# Workaround issue https://github.com/lonelyenvoy/python-memoization/issues/18
|
|
|
|
|
|
# by providing a no-op cache decorator when type-checking.
|
|
|
|
|
|
cached = lambda *cached_args, **cached_kwargs: lambda function: function # noqa
|
|
|
|
|
|
|
2021-08-05 13:48:24 +00:00
|
|
|
|
from .utils import method_cache
|
|
|
|
|
|
|
2020-11-12 20:21:02 +00:00
|
|
|
|
from .dataclass_utils import nested_replace
|
2020-10-20 07:11:28 +00:00
|
|
|
|
|
2020-11-04 20:09:55 +00:00
|
|
|
|
|
2021-03-28 05:32:42 +00:00
|
|
|
|
# Define types for items supporting vectorisation. In the future this may be replaced
|
|
|
|
|
|
# by ``np.ndarray[<type>]`` once/if that syntax is supported. Note that vectorization
|
|
|
|
|
|
# implies 1d arrays: multi-dimensional arrays are not supported.
|
|
|
|
|
|
_VectorisedFloat = typing.Union[float, np.ndarray]
|
|
|
|
|
|
_VectorisedInt = typing.Union[int, np.ndarray]
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-20 07:11:28 +00:00
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
|
|
class Room:
|
2021-03-28 05:32:42 +00:00
|
|
|
|
#: The total volume of the room
|
|
|
|
|
|
volume: _VectorisedFloat
|
2020-10-20 07:11:28 +00:00
|
|
|
|
|
2021-05-26 08:19:52 +00:00
|
|
|
|
#: The humidity in the room (from 0 to 1 - e.g. 0.5 is 50% humidity)
|
2021-08-05 13:48:24 +00:00
|
|
|
|
humidity: _VectorisedFloat = 0.5
|
2021-05-26 08:19:52 +00:00
|
|
|
|
|
2020-10-20 07:11:28 +00:00
|
|
|
|
|
2021-01-05 15:30:16 +00:00
|
|
|
|
Time_t = typing.TypeVar('Time_t', float, int)
|
|
|
|
|
|
BoundaryPair_t = typing.Tuple[Time_t, Time_t]
|
|
|
|
|
|
BoundarySequence_t = typing.Union[typing.Tuple[BoundaryPair_t, ...], typing.Tuple]
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-27 05:27:38 +00:00
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
|
|
class Interval:
|
|
|
|
|
|
"""
|
|
|
|
|
|
Represents a collection of times in which a "thing" happens.
|
|
|
|
|
|
|
|
|
|
|
|
The "thing" may be when an action is taken, such as opening a window, or
|
|
|
|
|
|
entering a room.
|
|
|
|
|
|
|
2020-10-27 14:06:28 +00:00
|
|
|
|
Note that all intervals are open at the start, and closed at the end. So a
|
2020-10-27 13:47:45 +00:00
|
|
|
|
simple start, stop interval follows::
|
|
|
|
|
|
|
|
|
|
|
|
start < t <= end
|
|
|
|
|
|
|
2020-10-27 05:27:38 +00:00
|
|
|
|
"""
|
2021-01-05 15:30:16 +00:00
|
|
|
|
def boundaries(self) -> BoundarySequence_t:
|
2020-10-27 14:06:28 +00:00
|
|
|
|
return ()
|
|
|
|
|
|
|
|
|
|
|
|
def transition_times(self) -> typing.Set[float]:
|
|
|
|
|
|
transitions = set()
|
|
|
|
|
|
for start, end in self.boundaries():
|
|
|
|
|
|
transitions.update([start, end])
|
|
|
|
|
|
return transitions
|
|
|
|
|
|
|
2020-10-27 05:27:38 +00:00
|
|
|
|
def triggered(self, time: float) -> bool:
|
|
|
|
|
|
"""Whether the given time falls inside this interval."""
|
2020-10-27 14:06:28 +00:00
|
|
|
|
for start, end in self.boundaries():
|
|
|
|
|
|
if start < time <= end:
|
|
|
|
|
|
return True
|
2020-10-27 05:27:38 +00:00
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-27 13:47:45 +00:00
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
|
|
class SpecificInterval(Interval):
|
|
|
|
|
|
#: A sequence of times (start, stop), in hours, that the infected person
|
|
|
|
|
|
#: is present. The flattened list of times must be strictly monotonically
|
|
|
|
|
|
#: increasing.
|
2021-01-05 15:30:16 +00:00
|
|
|
|
present_times: BoundarySequence_t
|
2020-10-27 13:47:45 +00:00
|
|
|
|
|
2021-01-05 15:30:16 +00:00
|
|
|
|
def boundaries(self) -> BoundarySequence_t:
|
2020-10-27 14:06:28 +00:00
|
|
|
|
return self.present_times
|
2020-10-27 13:47:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
2020-10-27 05:27:38 +00:00
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
|
|
class PeriodicInterval(Interval):
|
2020-10-27 13:34:45 +00:00
|
|
|
|
#: How often does the interval occur (minutes).
|
2021-01-05 15:30:16 +00:00
|
|
|
|
period: float
|
2020-10-27 05:27:38 +00:00
|
|
|
|
|
2020-10-27 13:34:45 +00:00
|
|
|
|
#: How long does the interval occur for (minutes).
|
2020-10-27 05:27:38 +00:00
|
|
|
|
#: A value greater than :data:`period` signifies the event is permanently
|
|
|
|
|
|
#: occurring, a value of 0 signifies that the event never happens.
|
2021-01-05 15:30:16 +00:00
|
|
|
|
duration: float
|
2020-10-27 05:27:38 +00:00
|
|
|
|
|
2021-01-05 15:30:16 +00:00
|
|
|
|
def boundaries(self) -> BoundarySequence_t:
|
2020-11-20 10:08:02 +00:00
|
|
|
|
if self.period == 0 or self.duration == 0:
|
|
|
|
|
|
return tuple()
|
2020-10-27 13:34:45 +00:00
|
|
|
|
result = []
|
|
|
|
|
|
for i in np.arange(0, 24, self.period / 60):
|
2021-08-05 13:48:24 +00:00
|
|
|
|
# NOTE: It is important that the time type is float, not np.float, in
|
|
|
|
|
|
# order to allow hashability (for caching).
|
|
|
|
|
|
result.append((float(i), float(i+self.duration/60)))
|
2020-10-27 13:34:45 +00:00
|
|
|
|
return tuple(result)
|
|
|
|
|
|
|
2020-10-27 05:27:38 +00:00
|
|
|
|
|
2020-11-04 19:57:49 +00:00
|
|
|
|
@dataclass(frozen=True)
|
2020-11-05 08:10:07 +00:00
|
|
|
|
class PiecewiseConstant:
|
2020-11-05 11:08:08 +00:00
|
|
|
|
|
2020-11-09 15:08:58 +00:00
|
|
|
|
# TODO: implement rather a periodic version (24-hour period), where
|
|
|
|
|
|
# transition_times and values have the same length.
|
|
|
|
|
|
|
2020-11-04 19:57:49 +00:00
|
|
|
|
#: transition times at which the function changes value (hours).
|
|
|
|
|
|
transition_times: typing.Tuple[float, ...]
|
|
|
|
|
|
|
|
|
|
|
|
#: values of the function between transitions
|
2021-04-07 08:15:48 +00:00
|
|
|
|
values: typing.Tuple[_VectorisedFloat, ...]
|
2020-11-04 19:57:49 +00:00
|
|
|
|
|
|
|
|
|
|
def __post_init__(self):
|
|
|
|
|
|
if len(self.transition_times) != len(self.values)+1:
|
|
|
|
|
|
raise ValueError("transition_times should contain one more element than values")
|
2020-11-04 22:35:06 +00:00
|
|
|
|
if tuple(sorted(set(self.transition_times))) != self.transition_times:
|
2020-11-04 19:57:49 +00:00
|
|
|
|
raise ValueError("transition_times should not contain duplicated elements and should be sorted")
|
2021-04-07 08:25:00 +00:00
|
|
|
|
shapes = [np.array(v).shape for v in self.values]
|
|
|
|
|
|
if not all(shapes[0] == shape for shape in shapes):
|
|
|
|
|
|
raise ValueError("All values must have the same shape")
|
2020-11-04 19:57:49 +00:00
|
|
|
|
|
2021-04-07 08:15:48 +00:00
|
|
|
|
def value(self, time) -> _VectorisedFloat:
|
2020-11-05 11:08:08 +00:00
|
|
|
|
if time <= self.transition_times[0]:
|
2020-11-04 19:57:49 +00:00
|
|
|
|
return self.values[0]
|
2021-01-05 15:30:16 +00:00
|
|
|
|
elif time > self.transition_times[-1]:
|
2020-11-05 11:08:08 +00:00
|
|
|
|
return self.values[-1]
|
|
|
|
|
|
|
2021-01-05 15:30:16 +00:00
|
|
|
|
for t1, t2, value in zip(self.transition_times[:-1],
|
|
|
|
|
|
self.transition_times[1:], self.values):
|
|
|
|
|
|
if t1 < time <= t2:
|
|
|
|
|
|
break
|
|
|
|
|
|
return value
|
2020-11-04 19:57:49 +00:00
|
|
|
|
|
|
|
|
|
|
def interval(self) -> Interval:
|
|
|
|
|
|
# build an Interval object
|
|
|
|
|
|
present_times = []
|
2021-01-05 17:59:43 +00:00
|
|
|
|
for t1, t2, value in zip(self.transition_times[:-1],
|
|
|
|
|
|
self.transition_times[1:], self.values):
|
2020-11-04 19:57:49 +00:00
|
|
|
|
if value:
|
2021-04-07 08:15:48 +00:00
|
|
|
|
present_times.append((t1, t2))
|
2021-01-05 15:30:16 +00:00
|
|
|
|
return SpecificInterval(present_times=tuple(present_times))
|
2020-11-04 19:57:49 +00:00
|
|
|
|
|
2021-04-07 08:15:48 +00:00
|
|
|
|
def refine(self, refine_factor=10) -> "PiecewiseConstant":
|
2020-11-09 15:08:58 +00:00
|
|
|
|
# build a new PiecewiseConstant object with a refined mesh,
|
|
|
|
|
|
# using a linear interpolation in-between the initial mesh points
|
2021-01-05 17:59:43 +00:00
|
|
|
|
refined_times = np.linspace(self.transition_times[0], self.transition_times[-1],
|
|
|
|
|
|
(len(self.transition_times)-1) * refine_factor+1)
|
2021-04-07 08:15:48 +00:00
|
|
|
|
interpolator = interp1d(
|
|
|
|
|
|
self.transition_times,
|
|
|
|
|
|
np.concatenate([self.values, self.values[-1:]], axis=0),
|
|
|
|
|
|
axis=0)
|
2021-01-05 17:59:43 +00:00
|
|
|
|
return PiecewiseConstant(
|
2021-08-05 13:48:24 +00:00
|
|
|
|
# NOTE: It is important that the time type is float, not np.float, in
|
|
|
|
|
|
# order to allow hashability (for caching).
|
|
|
|
|
|
tuple(float(time) for time in refined_times),
|
2021-04-07 08:15:48 +00:00
|
|
|
|
tuple(interpolator(refined_times)[:-1]),
|
2021-01-05 17:59:43 +00:00
|
|
|
|
)
|
2020-11-09 15:08:58 +00:00
|
|
|
|
|
2020-11-04 19:57:49 +00:00
|
|
|
|
|
2020-10-20 07:11:28 +00:00
|
|
|
|
@dataclass(frozen=True)
|
2021-01-05 17:59:43 +00:00
|
|
|
|
class _VentilationBase:
|
2020-10-20 12:44:29 +00:00
|
|
|
|
"""
|
2020-10-27 05:27:38 +00:00
|
|
|
|
Represents a mechanism by which air can be exchanged (replaced/filtered)
|
|
|
|
|
|
in a time dependent manner.
|
|
|
|
|
|
|
|
|
|
|
|
The nature of the various air exchange schemes means that it is expected
|
|
|
|
|
|
for subclasses of Ventilation to exist. Known subclasses include
|
|
|
|
|
|
WindowOpening for window based air exchange, and HEPAFilter, for
|
|
|
|
|
|
mechanical air exchange through a filter.
|
|
|
|
|
|
|
2020-10-20 12:44:29 +00:00
|
|
|
|
"""
|
2020-11-05 21:16:03 +00:00
|
|
|
|
def transition_times(self) -> typing.Set[float]:
|
2021-01-05 17:59:43 +00:00
|
|
|
|
raise NotImplementedError("Subclass must implement")
|
2020-11-05 08:52:58 +00:00
|
|
|
|
|
2021-03-28 05:32:42 +00:00
|
|
|
|
def air_exchange(self, room: Room, time: float) -> _VectorisedFloat:
|
2020-10-26 07:21:31 +00:00
|
|
|
|
"""
|
2020-11-05 19:50:36 +00:00
|
|
|
|
Returns the rate at which air is being exchanged in the given room
|
|
|
|
|
|
at a given time (in hours).
|
2020-10-26 07:21:31 +00:00
|
|
|
|
|
2020-10-27 14:06:28 +00:00
|
|
|
|
Note that whilst the time is known inside this function, it may not
|
|
|
|
|
|
be used to vary the result unless the specific time used is declared
|
|
|
|
|
|
as part of a state change in the interval (e.g. when air_exchange == 0).
|
2020-10-20 12:44:29 +00:00
|
|
|
|
|
2020-10-27 05:27:38 +00:00
|
|
|
|
"""
|
2020-10-27 14:06:28 +00:00
|
|
|
|
return 0.
|
2020-10-20 12:44:29 +00:00
|
|
|
|
|
2020-10-27 05:27:38 +00:00
|
|
|
|
|
2020-11-05 19:50:58 +00:00
|
|
|
|
@dataclass(frozen=True)
|
2021-01-05 17:59:43 +00:00
|
|
|
|
class Ventilation(_VentilationBase):
|
|
|
|
|
|
#: The interval in which the ventilation is active.
|
|
|
|
|
|
active: Interval
|
|
|
|
|
|
|
|
|
|
|
|
def transition_times(self) -> typing.Set[float]:
|
|
|
|
|
|
return self.active.transition_times()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
|
|
class MultipleVentilation(_VentilationBase):
|
2020-11-05 19:50:58 +00:00
|
|
|
|
"""
|
|
|
|
|
|
Represents a mechanism by which air can be exchanged (replaced/filtered)
|
|
|
|
|
|
in a time dependent manner.
|
|
|
|
|
|
|
|
|
|
|
|
Group together different sources of ventilations.
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
2021-01-05 17:59:43 +00:00
|
|
|
|
ventilations: typing.Tuple[_VentilationBase, ...]
|
2020-11-05 19:50:58 +00:00
|
|
|
|
|
2020-11-05 21:16:03 +00:00
|
|
|
|
def transition_times(self) -> typing.Set[float]:
|
2020-11-05 19:50:58 +00:00
|
|
|
|
transitions = set()
|
|
|
|
|
|
for ventilation in self.ventilations:
|
|
|
|
|
|
transitions.update(ventilation.transition_times())
|
2020-11-05 21:16:03 +00:00
|
|
|
|
return transitions
|
2020-11-05 19:50:58 +00:00
|
|
|
|
|
2021-03-28 05:32:42 +00:00
|
|
|
|
def air_exchange(self, room: Room, time: float) -> _VectorisedFloat:
|
2020-11-05 19:50:58 +00:00
|
|
|
|
"""
|
2020-11-12 11:20:39 +00:00
|
|
|
|
Returns the rate at which air is being exchanged in the given room
|
2020-11-05 19:50:58 +00:00
|
|
|
|
at a given time (in hours).
|
|
|
|
|
|
"""
|
2021-03-28 05:32:42 +00:00
|
|
|
|
return np.array([
|
|
|
|
|
|
ventilation.air_exchange(room, time)
|
|
|
|
|
|
for ventilation in self.ventilations
|
|
|
|
|
|
]).sum(axis=0)
|
2020-11-05 19:50:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
2020-10-27 05:27:38 +00:00
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
|
|
class WindowOpening(Ventilation):
|
|
|
|
|
|
#: The interval in which the window is open.
|
|
|
|
|
|
active: Interval
|
2020-10-20 12:44:29 +00:00
|
|
|
|
|
2020-11-09 08:40:11 +00:00
|
|
|
|
#: The temperature inside the room (Kelvin).
|
|
|
|
|
|
inside_temp: PiecewiseConstant
|
2020-10-20 12:44:29 +00:00
|
|
|
|
|
2020-11-09 08:40:11 +00:00
|
|
|
|
#: The temperature outside of the window (Kelvin).
|
|
|
|
|
|
outside_temp: PiecewiseConstant
|
2020-10-20 14:10:52 +00:00
|
|
|
|
|
2020-12-01 07:22:51 +00:00
|
|
|
|
#: The height of the window (m).
|
2021-04-07 08:15:48 +00:00
|
|
|
|
window_height: _VectorisedFloat
|
2020-10-20 14:10:52 +00:00
|
|
|
|
|
2020-12-01 07:22:51 +00:00
|
|
|
|
#: The length of the opening-gap when the window is open (m).
|
2021-04-07 08:15:48 +00:00
|
|
|
|
opening_length: _VectorisedFloat
|
2020-11-09 08:40:11 +00:00
|
|
|
|
|
|
|
|
|
|
#: The number of windows of the given dimensions.
|
|
|
|
|
|
number_of_windows: int = 1
|
|
|
|
|
|
|
2020-12-01 07:22:51 +00:00
|
|
|
|
#: Minimum difference between inside and outside temperature (K).
|
2020-11-11 13:12:12 +00:00
|
|
|
|
min_deltaT: float = 0.1
|
|
|
|
|
|
|
2020-11-23 14:29:23 +00:00
|
|
|
|
@property
|
2021-04-15 20:07:55 +00:00
|
|
|
|
def discharge_coefficient(self) -> _VectorisedFloat:
|
2020-12-02 11:10:14 +00:00
|
|
|
|
"""
|
|
|
|
|
|
Discharge coefficient (or cd_b): what portion effective area is
|
|
|
|
|
|
used to exchange air (0 <= discharge_coefficient <= 1).
|
|
|
|
|
|
To be implemented in subclasses.
|
|
|
|
|
|
"""
|
|
|
|
|
|
raise NotImplementedError("Unknown discharge coefficient")
|
2020-11-23 14:29:23 +00:00
|
|
|
|
|
2020-11-05 21:16:03 +00:00
|
|
|
|
def transition_times(self) -> typing.Set[float]:
|
2020-11-05 08:52:58 +00:00
|
|
|
|
transitions = super().transition_times()
|
2020-11-05 20:47:44 +00:00
|
|
|
|
transitions.update(self.inside_temp.transition_times)
|
|
|
|
|
|
transitions.update(self.outside_temp.transition_times)
|
2020-11-05 08:52:58 +00:00
|
|
|
|
return transitions
|
|
|
|
|
|
|
2021-03-28 05:32:42 +00:00
|
|
|
|
def air_exchange(self, room: Room, time: float) -> _VectorisedFloat:
|
2020-10-27 05:27:38 +00:00
|
|
|
|
# If the window is shut, no air is being exchanged.
|
|
|
|
|
|
if not self.active.triggered(time):
|
|
|
|
|
|
return 0.
|
2020-10-20 12:44:29 +00:00
|
|
|
|
|
2020-11-12 11:06:33 +00:00
|
|
|
|
# Reminder, no dependence on time in the resulting calculation.
|
2021-04-15 20:07:55 +00:00
|
|
|
|
inside_temp: _VectorisedFloat = self.inside_temp.value(time)
|
|
|
|
|
|
outside_temp: _VectorisedFloat = self.outside_temp.value(time)
|
2020-10-27 14:06:28 +00:00
|
|
|
|
|
2020-11-12 11:06:33 +00:00
|
|
|
|
# The inside_temperature is forced to be always at least min_deltaT degree
|
|
|
|
|
|
# warmer than the outside_temperature. Further research needed to
|
|
|
|
|
|
# handle the buoyancy driven ventilation when the temperature gradient
|
|
|
|
|
|
# is inverted.
|
2021-04-15 20:07:55 +00:00
|
|
|
|
inside_temp = np.maximum(inside_temp, outside_temp + self.min_deltaT) # type: ignore
|
2020-11-12 11:06:33 +00:00
|
|
|
|
temp_gradient = (inside_temp - outside_temp) / outside_temp
|
|
|
|
|
|
root = np.sqrt(9.81 * self.window_height * temp_gradient)
|
2020-11-09 08:40:11 +00:00
|
|
|
|
window_area = self.window_height * self.opening_length * self.number_of_windows
|
2020-12-01 14:29:35 +00:00
|
|
|
|
return (3600 / (3 * room.volume)) * self.discharge_coefficient * window_area * root
|
2020-12-01 07:22:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
|
|
class SlidingWindow(WindowOpening):
|
2020-12-02 11:11:09 +00:00
|
|
|
|
"""
|
|
|
|
|
|
Sliding window, or side-hung window (with the hinge perpendicular to
|
|
|
|
|
|
the horizontal plane).
|
|
|
|
|
|
"""
|
2020-12-01 07:22:51 +00:00
|
|
|
|
@property
|
2021-04-15 20:07:55 +00:00
|
|
|
|
def discharge_coefficient(self) -> _VectorisedFloat:
|
2020-12-02 11:11:09 +00:00
|
|
|
|
"""
|
|
|
|
|
|
Average measured value of discharge coefficient for sliding or
|
|
|
|
|
|
side-hung windows.
|
|
|
|
|
|
"""
|
2020-12-01 07:22:51 +00:00
|
|
|
|
return 0.6
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
|
|
class HingedWindow(WindowOpening):
|
2020-12-02 11:12:19 +00:00
|
|
|
|
"""
|
|
|
|
|
|
Top-hung or bottom-hung hinged window (with the hinge parallel to
|
|
|
|
|
|
horizontal plane).
|
|
|
|
|
|
"""
|
2020-12-01 07:22:51 +00:00
|
|
|
|
#: Window width (m).
|
2021-04-07 08:15:48 +00:00
|
|
|
|
window_width: _VectorisedFloat = 0.0
|
2020-12-01 07:22:51 +00:00
|
|
|
|
|
2020-12-02 17:58:55 +00:00
|
|
|
|
def __post_init__(self):
|
2021-04-07 08:15:48 +00:00
|
|
|
|
if self.window_width is 0.0:
|
2020-12-02 17:58:55 +00:00
|
|
|
|
raise ValueError('window_width must be set')
|
|
|
|
|
|
|
2020-12-01 07:22:51 +00:00
|
|
|
|
@property
|
2021-04-15 20:07:55 +00:00
|
|
|
|
def discharge_coefficient(self) -> _VectorisedFloat:
|
2020-12-02 11:12:19 +00:00
|
|
|
|
"""
|
|
|
|
|
|
Simple model to compute discharge coefficient for top or bottom
|
|
|
|
|
|
hung hinged windows, in the absence of empirical test results
|
|
|
|
|
|
from manufacturers.
|
|
|
|
|
|
From an excel spreadsheet calculator (Richard Daniels, Crawford
|
|
|
|
|
|
Wright, Benjamin Jones - 2018) from the UK government -
|
|
|
|
|
|
see Section 8.3 of BB101 and Section 11.3 of
|
|
|
|
|
|
ESFA Output Specification Annex 2F on Ventilation opening areas.
|
|
|
|
|
|
"""
|
2021-04-07 08:15:48 +00:00
|
|
|
|
window_ratio = np.array(self.window_width / self.window_height)
|
|
|
|
|
|
coefs = np.empty(window_ratio.shape + (2, ), dtype=np.float64)
|
|
|
|
|
|
|
|
|
|
|
|
coefs[window_ratio < 0.5] = (0.06, 0.612)
|
|
|
|
|
|
coefs[np.bitwise_and(0.5 <= window_ratio, window_ratio < 1)] = (0.048, 0.589)
|
|
|
|
|
|
coefs[np.bitwise_and(1 <= window_ratio, window_ratio < 2)] = (0.04, 0.563)
|
|
|
|
|
|
coefs[window_ratio >= 2] = (0.038, 0.548)
|
2021-04-15 20:07:55 +00:00
|
|
|
|
M, cd_max = coefs.T
|
2021-04-07 08:15:48 +00:00
|
|
|
|
|
2020-12-02 17:58:55 +00:00
|
|
|
|
window_angle = 2.*np.rad2deg(np.arcsin(self.opening_length/(2.*self.window_height)))
|
2020-12-01 07:22:51 +00:00
|
|
|
|
return cd_max*(1-np.exp(-M*window_angle))
|
2020-10-20 12:44:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass(frozen=True)
|
2020-10-27 05:27:38 +00:00
|
|
|
|
class HEPAFilter(Ventilation):
|
|
|
|
|
|
#: The interval in which the HEPA filter is operating.
|
|
|
|
|
|
active: Interval
|
2020-10-20 12:44:29 +00:00
|
|
|
|
|
2020-10-27 14:06:28 +00:00
|
|
|
|
#: The rate at which the HEPA exchanges air (when switched on)
|
2020-11-05 17:46:32 +00:00
|
|
|
|
# in m^3/h
|
2021-04-29 07:13:57 +00:00
|
|
|
|
q_air_mech: _VectorisedFloat
|
2020-10-20 12:44:29 +00:00
|
|
|
|
|
2021-03-28 05:32:42 +00:00
|
|
|
|
def air_exchange(self, room: Room, time: float) -> _VectorisedFloat:
|
2020-10-27 05:27:38 +00:00
|
|
|
|
# If the HEPA is off, no air is being exchanged.
|
|
|
|
|
|
if not self.active.triggered(time):
|
|
|
|
|
|
return 0.
|
2020-10-27 14:06:28 +00:00
|
|
|
|
# Reminder, no dependence on time in the resulting calculation.
|
2020-10-20 12:44:29 +00:00
|
|
|
|
return self.q_air_mech / room.volume
|
2020-10-20 07:11:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
2020-11-05 17:46:32 +00:00
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
|
|
class HVACMechanical(Ventilation):
|
|
|
|
|
|
#: The interval in which the mechanical ventilation (HVAC) is operating.
|
|
|
|
|
|
active: Interval
|
|
|
|
|
|
|
|
|
|
|
|
#: The rate at which the HVAC exchanges air (when switched on)
|
|
|
|
|
|
# in m^3/h
|
2021-04-29 07:13:57 +00:00
|
|
|
|
q_air_mech: _VectorisedFloat
|
2020-11-05 17:46:32 +00:00
|
|
|
|
|
2021-03-28 05:32:42 +00:00
|
|
|
|
def air_exchange(self, room: Room, time: float) -> _VectorisedFloat:
|
2020-11-05 17:46:32 +00:00
|
|
|
|
# If the HVAC is off, no air is being exchanged.
|
|
|
|
|
|
if not self.active.triggered(time):
|
|
|
|
|
|
return 0.
|
|
|
|
|
|
# Reminder, no dependence on time in the resulting calculation.
|
|
|
|
|
|
return self.q_air_mech / room.volume
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
|
|
class AirChange(Ventilation):
|
|
|
|
|
|
#: The interval in which the ventilation is operating.
|
|
|
|
|
|
active: Interval
|
|
|
|
|
|
|
2020-11-12 11:20:39 +00:00
|
|
|
|
#: The rate (in h^-1) at which the ventilation exchanges all the air
|
2020-11-05 17:46:32 +00:00
|
|
|
|
# of the room (when switched on)
|
2021-03-28 05:32:42 +00:00
|
|
|
|
air_exch: _VectorisedFloat
|
2020-11-05 17:46:32 +00:00
|
|
|
|
|
2021-03-28 05:32:42 +00:00
|
|
|
|
def air_exchange(self, room: Room, time: float) -> _VectorisedFloat:
|
2020-11-05 17:46:32 +00:00
|
|
|
|
# No dependence on the room volume.
|
|
|
|
|
|
# If off, no air is being exchanged.
|
|
|
|
|
|
if not self.active.triggered(time):
|
|
|
|
|
|
return 0.
|
|
|
|
|
|
# Reminder, no dependence on time in the resulting calculation.
|
|
|
|
|
|
return self.air_exch
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-20 07:11:28 +00:00
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
|
|
class Virus:
|
|
|
|
|
|
#: RNA copies / mL
|
2021-03-28 05:53:19 +00:00
|
|
|
|
viral_load_in_sputum: _VectorisedFloat
|
2020-10-20 07:11:28 +00:00
|
|
|
|
|
2021-08-06 08:24:25 +00:00
|
|
|
|
#: Dose to initiate infection, in RNA copies
|
|
|
|
|
|
infectious_dose: _VectorisedFloat
|
2020-10-20 07:11:28 +00:00
|
|
|
|
|
|
|
|
|
|
#: Pre-populated examples of Viruses.
|
|
|
|
|
|
types: typing.ClassVar[typing.Dict[str, "Virus"]]
|
|
|
|
|
|
|
2021-05-26 08:19:52 +00:00
|
|
|
|
def halflife(self, humidity: _VectorisedFloat) -> _VectorisedFloat:
|
|
|
|
|
|
# Biological decay (inactivation of the virus in air) - virus
|
|
|
|
|
|
# dependent and function of humidity
|
|
|
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
|
|
|
|
def decay_constant(self, humidity: _VectorisedFloat) -> _VectorisedFloat:
|
|
|
|
|
|
# Viral inactivation per hour (h^-1) (function of humidity)
|
|
|
|
|
|
return np.log(2) / self.halflife(humidity)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
|
|
class SARSCoV2(Virus):
|
|
|
|
|
|
|
|
|
|
|
|
def halflife(self, humidity: _VectorisedFloat) -> _VectorisedFloat:
|
|
|
|
|
|
"""
|
|
|
|
|
|
Half-life changes with humidity level. Here is implemented a simple
|
|
|
|
|
|
piecewise constant model (for more details see A. Henriques et al,
|
|
|
|
|
|
CERN-OPEN-2021-004, DOI: 10.17181/CERN.1GDQ.5Y75)
|
|
|
|
|
|
"""
|
|
|
|
|
|
halflife = np.empty_like(humidity)
|
|
|
|
|
|
halflife[humidity <= 0.4] = 3.8
|
|
|
|
|
|
halflife[humidity > 0.4] = 1.1
|
|
|
|
|
|
return halflife
|
2020-10-20 07:11:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virus.types = {
|
2021-05-26 08:19:52 +00:00
|
|
|
|
'SARS_CoV_2': SARSCoV2(
|
2021-03-09 08:38:47 +00:00
|
|
|
|
viral_load_in_sputum=1e9,
|
2020-10-20 07:11:28 +00:00
|
|
|
|
# No data on coefficient for SARS-CoV-2 yet.
|
2021-05-26 12:47:30 +00:00
|
|
|
|
# It is somewhere between 1000 or 10 SARS-CoV viruses,
|
|
|
|
|
|
# as per https://www.dhs.gov/publication/st-master-question-list-covid-19
|
|
|
|
|
|
# 50 comes from Buonanno et al.
|
2021-08-06 08:24:25 +00:00
|
|
|
|
infectious_dose=50.,
|
2020-10-20 07:11:28 +00:00
|
|
|
|
),
|
2021-05-26 08:19:52 +00:00
|
|
|
|
'SARS_CoV_2_B117': SARSCoV2(
|
2021-03-09 08:38:47 +00:00
|
|
|
|
# also called VOC-202012/01
|
|
|
|
|
|
viral_load_in_sputum=1e9,
|
2021-08-06 08:24:25 +00:00
|
|
|
|
infectious_dose=30.,
|
2021-03-09 08:38:47 +00:00
|
|
|
|
),
|
2021-05-26 08:19:52 +00:00
|
|
|
|
'SARS_CoV_2_P1': SARSCoV2(
|
2021-03-09 08:38:47 +00:00
|
|
|
|
viral_load_in_sputum=1e9,
|
2021-08-06 08:24:25 +00:00
|
|
|
|
infectious_dose=1/0.045,
|
2021-03-09 08:38:47 +00:00
|
|
|
|
),
|
2021-06-25 09:10:04 +00:00
|
|
|
|
'SARS_CoV_2_B16172': SARSCoV2(
|
|
|
|
|
|
viral_load_in_sputum=1e9,
|
2021-08-06 08:24:25 +00:00
|
|
|
|
infectious_dose=30/1.6,
|
2021-06-25 09:10:04 +00:00
|
|
|
|
),
|
2020-10-20 07:11:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass(frozen=True)
|
2021-05-30 17:28:51 +00:00
|
|
|
|
class Mask:
|
2020-10-20 07:11:28 +00:00
|
|
|
|
#: Filtration efficiency of masks when inhaling.
|
2021-04-28 12:22:23 +00:00
|
|
|
|
η_inhale: _VectorisedFloat
|
2020-10-20 07:11:28 +00:00
|
|
|
|
|
2021-05-30 17:28:51 +00:00
|
|
|
|
#: Global factor applied to filtration efficiency of masks when exhaling.
|
2021-05-31 15:12:18 +00:00
|
|
|
|
factor_exhale: float = 1.
|
2021-05-26 21:39:33 +00:00
|
|
|
|
|
2021-05-30 17:28:51 +00:00
|
|
|
|
#: Pre-populated examples of Masks.
|
|
|
|
|
|
types: typing.ClassVar[typing.Dict[str, "Mask"]]
|
2021-05-26 21:39:33 +00:00
|
|
|
|
|
|
|
|
|
|
def exhale_efficiency(self, diameter: float) -> _VectorisedFloat:
|
2021-05-30 17:28:51 +00:00
|
|
|
|
"""
|
|
|
|
|
|
Overall exhale efficiency, including the effect of the leaks.
|
|
|
|
|
|
See CERN-OPEN-2021-004 (doi: 10.17181/CERN.1GDQ.5Y75), and Ref.
|
|
|
|
|
|
therein (Asadi 2020).
|
|
|
|
|
|
Obtained from measurements of filtration efficiency and of
|
|
|
|
|
|
the leakage through the sides.
|
2021-05-31 04:55:07 +00:00
|
|
|
|
Diameter is in microns.
|
2021-05-30 17:28:51 +00:00
|
|
|
|
"""
|
2021-05-31 04:55:07 +00:00
|
|
|
|
if diameter < 0.5:
|
2021-05-26 21:39:33 +00:00
|
|
|
|
eta_out = 0.
|
2021-05-31 04:55:07 +00:00
|
|
|
|
elif diameter < 0.94614:
|
|
|
|
|
|
eta_out = 0.5893 * diameter + 0.1546
|
|
|
|
|
|
elif diameter < 3.:
|
|
|
|
|
|
eta_out = 0.0509 * diameter + 0.664
|
2021-05-26 21:39:33 +00:00
|
|
|
|
else:
|
|
|
|
|
|
eta_out = 0.8167
|
2021-05-30 17:28:51 +00:00
|
|
|
|
return eta_out*self.factor_exhale
|
2021-05-26 21:39:33 +00:00
|
|
|
|
|
|
|
|
|
|
def inhale_efficiency(self) -> _VectorisedFloat:
|
2021-05-30 17:28:51 +00:00
|
|
|
|
"""
|
|
|
|
|
|
Overall inhale efficiency, including the effect of the leaks.
|
|
|
|
|
|
"""
|
2021-05-26 21:39:33 +00:00
|
|
|
|
return self.η_inhale
|
2020-10-20 07:11:28 +00:00
|
|
|
|
|
2021-05-26 21:39:33 +00:00
|
|
|
|
|
2021-05-30 17:28:51 +00:00
|
|
|
|
Mask.types = {
|
|
|
|
|
|
'No mask': Mask(0, 0),
|
2020-10-20 07:11:28 +00:00
|
|
|
|
'Type I': Mask(
|
2021-05-27 11:44:03 +00:00
|
|
|
|
η_inhale=0.5, # (CERN-OPEN-2021-004)
|
2021-05-26 21:39:33 +00:00
|
|
|
|
),
|
2021-05-30 17:28:51 +00:00
|
|
|
|
'FFP2': Mask(
|
2021-05-26 21:39:33 +00:00
|
|
|
|
η_inhale=0.865, # (94% penetration efficiency + 8% max inward leakage -> EN 149)
|
|
|
|
|
|
),
|
2020-10-20 07:11:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass(frozen=True)
|
2021-05-27 11:40:46 +00:00
|
|
|
|
class _ExpirationBase:
|
|
|
|
|
|
"""
|
|
|
|
|
|
Represents the expiration of aerosols by a person.
|
|
|
|
|
|
Subclasses of _ExpirationBase represent different models.
|
|
|
|
|
|
"""
|
2021-05-30 17:28:51 +00:00
|
|
|
|
#: Pre-populated examples of Expirations.
|
2021-05-27 11:40:46 +00:00
|
|
|
|
types: typing.ClassVar[typing.Dict[str, "_ExpirationBase"]]
|
|
|
|
|
|
|
2021-05-30 17:28:51 +00:00
|
|
|
|
def aerosols(self, mask: Mask):
|
2021-05-31 07:30:43 +00:00
|
|
|
|
"""
|
|
|
|
|
|
total volume of aerosols expired per volume of air (mL/cm^3).
|
|
|
|
|
|
"""
|
2021-05-27 11:40:46 +00:00
|
|
|
|
raise NotImplementedError("Subclass must implement")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
|
|
class Expiration(_ExpirationBase):
|
2021-05-27 16:26:37 +00:00
|
|
|
|
"""
|
|
|
|
|
|
BLO model for the expiration (G. Johnson et al., Modality of human
|
|
|
|
|
|
expired aerosol size distributions, Journal of Aerosol Science,
|
|
|
|
|
|
vol. 42, no. 12, pp. 839 – 851, 2011,
|
|
|
|
|
|
https://doi.org/10.1016/j.jaerosci.2011.07.009).
|
2021-05-28 05:08:23 +00:00
|
|
|
|
Here all diameters (d) are in microns.
|
2021-05-27 16:26:37 +00:00
|
|
|
|
"""
|
2021-05-27 16:35:54 +00:00
|
|
|
|
#: factors assigned to resp. the B, L and O modes. They are
|
|
|
|
|
|
# charateristics of the kind of expiratory activity (e.g. breathing,
|
|
|
|
|
|
# speaking, singing, or shouting).
|
2021-05-27 16:26:37 +00:00
|
|
|
|
BLO_factors: typing.Tuple[float, float, float]
|
|
|
|
|
|
|
2021-05-31 21:23:42 +00:00
|
|
|
|
@cached()
|
2021-05-31 09:08:42 +00:00
|
|
|
|
def aerosols(self, mask: Mask):
|
2021-05-31 07:30:43 +00:00
|
|
|
|
""" Result is in mL.cm^-3 """
|
2021-05-28 05:08:23 +00:00
|
|
|
|
def volume(d):
|
|
|
|
|
|
return (np.pi * d**3) / 6.
|
2021-05-27 16:26:37 +00:00
|
|
|
|
|
2021-05-28 05:08:23 +00:00
|
|
|
|
def _Bmode(d: float) -> float:
|
2021-05-27 16:26:37 +00:00
|
|
|
|
# B-mode (see ref. above).
|
2021-05-31 14:41:41 +00:00
|
|
|
|
return ( (1 / d) * (0.1 / (np.sqrt(2 * np.pi) * 0.262364)) *
|
|
|
|
|
|
np.exp(-1 * (np.log(d) - 0.989541) ** 2 / (2 * 0.262364 ** 2)))
|
2021-05-27 16:26:37 +00:00
|
|
|
|
|
2021-05-28 05:08:23 +00:00
|
|
|
|
def _Lmode(d: float) -> float:
|
2021-05-27 16:26:37 +00:00
|
|
|
|
# L-mode (see ref. above).
|
2021-05-31 14:41:41 +00:00
|
|
|
|
return ( (1 / d) * (1.0 / (np.sqrt(2 * np.pi) * 0.506818)) *
|
|
|
|
|
|
np.exp(-1 * (np.log(d) - 1.38629) ** 2 / (2 * 0.506818 ** 2)))
|
2021-05-27 16:26:37 +00:00
|
|
|
|
|
2021-05-28 05:08:23 +00:00
|
|
|
|
def _Omode(d: float) -> float:
|
2021-05-27 16:26:37 +00:00
|
|
|
|
# O-mode (see ref. above).
|
2021-05-31 14:41:41 +00:00
|
|
|
|
return ( (1 / d) * (0.0010008 / (np.sqrt(2 * np.pi) * 0.585005)) *
|
|
|
|
|
|
np.exp(-1 * (np.log(d) - 4.97673) ** 2 / (2 * 0.585005 ** 2)))
|
2021-05-27 16:26:37 +00:00
|
|
|
|
|
2021-05-28 05:08:23 +00:00
|
|
|
|
def integrand(d: float) -> float:
|
|
|
|
|
|
return (self.BLO_factors[0] * _Bmode(d) +
|
|
|
|
|
|
self.BLO_factors[1] * _Lmode(d) +
|
|
|
|
|
|
self.BLO_factors[2] * _Omode(d)
|
2021-05-31 14:41:41 +00:00
|
|
|
|
) * volume(d) * (1 - mask.exhale_efficiency(d))
|
2021-05-27 16:26:37 +00:00
|
|
|
|
|
2021-05-31 14:41:41 +00:00
|
|
|
|
# final result converted from microns^3/cm3 to mL/cm^3
|
|
|
|
|
|
return scipy.integrate.quad(integrand, 0.1, 30.)[0]*1e-12
|
2021-05-27 16:26:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
2021-05-31 09:08:42 +00:00
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
|
|
class MultipleExpiration(_ExpirationBase):
|
|
|
|
|
|
"""
|
|
|
|
|
|
Represents an expiration of aerosols.
|
|
|
|
|
|
Group together different modes of expiration, that represent
|
|
|
|
|
|
each the main expiration mode for a certain fraction of time (given by
|
|
|
|
|
|
the weights).
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
expirations: typing.Tuple[_ExpirationBase, ...]
|
|
|
|
|
|
weights: typing.Tuple[float, ...]
|
|
|
|
|
|
|
|
|
|
|
|
def __post_init__(self):
|
|
|
|
|
|
if len(self.expirations) != len(self.weights):
|
|
|
|
|
|
raise ValueError("expirations and weigths should contain the"
|
|
|
|
|
|
"same number of elements")
|
|
|
|
|
|
|
|
|
|
|
|
def aerosols(self, mask: Mask):
|
|
|
|
|
|
return np.array([
|
|
|
|
|
|
weight * expiration.aerosols(mask) / sum(self.weights)
|
|
|
|
|
|
for weight,expiration in zip(self.weights,self.expirations)
|
|
|
|
|
|
]).sum(axis=0)
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-05-27 11:40:46 +00:00
|
|
|
|
_ExpirationBase.types = {
|
2021-05-31 09:08:42 +00:00
|
|
|
|
'Breathing': Expiration((1., 0., 0.)),
|
|
|
|
|
|
'Talking': Expiration((1., 1., 1.)),
|
2021-05-31 14:41:41 +00:00
|
|
|
|
'Shouting': Expiration((1., 5., 5.)),
|
|
|
|
|
|
'Singing': Expiration((1., 5., 5.)),
|
2020-10-20 07:11:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
|
|
class Activity:
|
2021-06-01 07:22:15 +00:00
|
|
|
|
#: Inhalation rate in m^3/h
|
2021-05-11 16:18:19 +00:00
|
|
|
|
inhalation_rate: _VectorisedFloat
|
2021-06-01 07:22:15 +00:00
|
|
|
|
|
|
|
|
|
|
#: Exhalation rate in m^3/h
|
2021-05-11 16:18:19 +00:00
|
|
|
|
exhalation_rate: _VectorisedFloat
|
2020-10-20 07:11:28 +00:00
|
|
|
|
|
|
|
|
|
|
#: Pre-populated examples of activities.
|
|
|
|
|
|
types: typing.ClassVar[typing.Dict[str, "Activity"]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Activity.types = {
|
2020-11-16 15:08:08 +00:00
|
|
|
|
'Seated': Activity(0.51, 0.51),
|
|
|
|
|
|
'Standing': Activity(0.57, 0.57),
|
2020-11-17 18:15:33 +00:00
|
|
|
|
'Light activity': Activity(1.25, 1.25),
|
|
|
|
|
|
'Moderate activity': Activity(1.78, 1.78),
|
2020-10-20 07:11:28 +00:00
|
|
|
|
'Heavy exercise': Activity(3.30, 3.30),
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass(frozen=True)
|
2020-11-10 14:45:39 +00:00
|
|
|
|
class Population:
|
|
|
|
|
|
"""
|
|
|
|
|
|
Represents a group of people all with exactly the same behaviour and
|
|
|
|
|
|
situation.
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
#: How many in the population.
|
|
|
|
|
|
number: int
|
|
|
|
|
|
|
|
|
|
|
|
#: The times in which the people are in the room.
|
2020-10-27 13:47:45 +00:00
|
|
|
|
presence: Interval
|
2020-11-10 14:45:39 +00:00
|
|
|
|
|
|
|
|
|
|
#: The kind of mask being worn by the people.
|
2021-05-30 17:28:51 +00:00
|
|
|
|
mask: Mask
|
2020-11-10 14:45:39 +00:00
|
|
|
|
|
|
|
|
|
|
#: The physical activity being carried out by the people.
|
2020-10-20 07:11:28 +00:00
|
|
|
|
activity: Activity
|
|
|
|
|
|
|
|
|
|
|
|
def person_present(self, time):
|
2020-10-27 13:47:45 +00:00
|
|
|
|
return self.presence.triggered(time)
|
2020-10-20 07:11:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
2020-11-10 14:45:39 +00:00
|
|
|
|
@dataclass(frozen=True)
|
2021-09-16 11:55:04 +00:00
|
|
|
|
class _PopulationWithVirus(Population):
|
2020-11-10 14:45:39 +00:00
|
|
|
|
#: The virus with which the population is infected.
|
|
|
|
|
|
virus: Virus
|
|
|
|
|
|
|
2021-08-06 12:29:47 +00:00
|
|
|
|
@method_cache
|
2021-03-28 05:53:19 +00:00
|
|
|
|
def emission_rate_when_present(self) -> _VectorisedFloat:
|
2020-11-10 15:46:35 +00:00
|
|
|
|
"""
|
2021-09-16 11:55:04 +00:00
|
|
|
|
The emission rate if the infected population is present
|
|
|
|
|
|
(in virions / h). It should not be a function of time.
|
2020-11-10 15:46:35 +00:00
|
|
|
|
"""
|
2021-09-16 11:55:04 +00:00
|
|
|
|
raise NotImplementedError("Subclass must implement")
|
2020-10-20 07:11:28 +00:00
|
|
|
|
|
2021-09-14 14:11:44 +00:00
|
|
|
|
def emission_rate(self, time) -> _VectorisedFloat:
|
2020-11-10 14:45:39 +00:00
|
|
|
|
"""
|
2021-09-16 11:55:04 +00:00
|
|
|
|
The emission rate of the population vs time.
|
2020-11-10 14:45:39 +00:00
|
|
|
|
"""
|
2020-10-20 07:11:28 +00:00
|
|
|
|
# Note: The original model avoids time dependence on the emission rate
|
|
|
|
|
|
# at the cost of implementing a piecewise (on time) concentration function.
|
2020-11-10 15:46:35 +00:00
|
|
|
|
|
2020-10-20 07:11:28 +00:00
|
|
|
|
if not self.person_present(time):
|
2020-11-10 16:25:19 +00:00
|
|
|
|
return 0.
|
2020-10-20 07:11:28 +00:00
|
|
|
|
|
2020-11-10 15:46:35 +00:00
|
|
|
|
# Note: It is essential that the value of the emission rate is not
|
|
|
|
|
|
# itself a function of time. Any change in rate must be accompanied
|
|
|
|
|
|
# with a declaration of state change time, as is the case for things
|
|
|
|
|
|
# like Ventilation.
|
|
|
|
|
|
|
2020-11-10 16:25:19 +00:00
|
|
|
|
return self.emission_rate_when_present()
|
2020-10-20 07:11:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
2021-09-16 11:55:04 +00:00
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
|
|
class EmittingPopulation(_PopulationWithVirus):
|
|
|
|
|
|
#: The emission rate of a single individual, in virions / h.
|
|
|
|
|
|
known_individual_emission_rate: float
|
|
|
|
|
|
|
|
|
|
|
|
@method_cache
|
|
|
|
|
|
def emission_rate_when_present(self) -> _VectorisedFloat:
|
|
|
|
|
|
"""
|
|
|
|
|
|
The emission rate if the infected population is present.
|
|
|
|
|
|
"""
|
|
|
|
|
|
return self.known_individual_emission_rate * self.number
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
|
|
class InfectedPopulation(_PopulationWithVirus):
|
|
|
|
|
|
#: The type of expiration that is being emitted whilst doing the activity.
|
|
|
|
|
|
expiration: _ExpirationBase
|
|
|
|
|
|
|
|
|
|
|
|
@method_cache
|
|
|
|
|
|
def emission_rate_when_present(self) -> _VectorisedFloat:
|
|
|
|
|
|
"""
|
|
|
|
|
|
The emission rate if the infected population is present.
|
|
|
|
|
|
Note that the rate is not currently time-dependent.
|
|
|
|
|
|
"""
|
|
|
|
|
|
# Emission Rate (virions / h)
|
|
|
|
|
|
# Note on units: exhalation rate is in m^3/h, aerosols in mL/cm^3
|
|
|
|
|
|
# and viral load in virus/mL -> 1e6 conversion factor
|
|
|
|
|
|
|
|
|
|
|
|
aerosols = self.expiration.aerosols(self.mask)
|
|
|
|
|
|
|
|
|
|
|
|
ER = (self.virus.viral_load_in_sputum *
|
|
|
|
|
|
self.activity.exhalation_rate *
|
|
|
|
|
|
10 ** 6 *
|
|
|
|
|
|
aerosols)
|
|
|
|
|
|
|
|
|
|
|
|
return ER * self.number
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-20 07:11:28 +00:00
|
|
|
|
@dataclass(frozen=True)
|
2020-11-10 16:19:19 +00:00
|
|
|
|
class ConcentrationModel:
|
2020-10-20 07:11:28 +00:00
|
|
|
|
room: Room
|
2021-01-05 17:59:43 +00:00
|
|
|
|
ventilation: _VentilationBase
|
2021-09-16 11:55:04 +00:00
|
|
|
|
infected: _PopulationWithVirus
|
2020-10-20 07:11:28 +00:00
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
|
def virus(self):
|
|
|
|
|
|
return self.infected.virus
|
|
|
|
|
|
|
2021-04-06 12:28:52 +00:00
|
|
|
|
def infectious_virus_removal_rate(self, time: float) -> _VectorisedFloat:
|
2021-06-04 08:24:02 +00:00
|
|
|
|
# Particle deposition on the floor (value from CERN-OPEN-2021-04)
|
2021-06-04 03:45:25 +00:00
|
|
|
|
vg = 1.88e-4
|
2020-10-20 07:11:28 +00:00
|
|
|
|
# Height of the emission source to the floor - i.e. mouth/nose (m)
|
|
|
|
|
|
h = 1.5
|
|
|
|
|
|
# Deposition rate (h^-1)
|
|
|
|
|
|
k = (vg * 3600) / h
|
|
|
|
|
|
|
2021-08-05 13:48:24 +00:00
|
|
|
|
return (
|
|
|
|
|
|
k + self.virus.decay_constant(self.room.humidity)
|
|
|
|
|
|
+ self.ventilation.air_exchange(self.room, time)
|
|
|
|
|
|
)
|
2020-10-20 07:11:28 +00:00
|
|
|
|
|
2021-08-06 12:29:47 +00:00
|
|
|
|
@method_cache
|
2021-09-14 14:11:44 +00:00
|
|
|
|
def _normed_concentration_limit(self, time: float) -> _VectorisedFloat:
|
2021-05-04 06:57:40 +00:00
|
|
|
|
"""
|
|
|
|
|
|
Provides a constant that represents the theoretical asymptotic
|
2021-05-05 10:45:02 +00:00
|
|
|
|
value reached by the concentration when time goes to infinity,
|
|
|
|
|
|
if all parameters were to stay time-independent.
|
2021-09-14 14:11:44 +00:00
|
|
|
|
This is normalized by the emission rate, the latter acting as a
|
|
|
|
|
|
multiplicative constant factor for the concentration model that
|
|
|
|
|
|
can be put back in front of the concentration after the time
|
|
|
|
|
|
dependence has been solved for.
|
2021-05-04 06:57:40 +00:00
|
|
|
|
"""
|
2021-09-14 14:11:44 +00:00
|
|
|
|
if not self.infected.person_present(time):
|
|
|
|
|
|
return 0.
|
2021-05-03 13:01:42 +00:00
|
|
|
|
V = self.room.volume
|
|
|
|
|
|
IVRR = self.infectious_virus_removal_rate(time)
|
|
|
|
|
|
|
2021-09-14 14:11:44 +00:00
|
|
|
|
return 1. / (IVRR * V)
|
2021-05-03 13:01:42 +00:00
|
|
|
|
|
2021-08-06 07:51:20 +00:00
|
|
|
|
@method_cache
|
2021-08-05 13:48:24 +00:00
|
|
|
|
def state_change_times(self) -> typing.List[float]:
|
2020-10-26 19:12:54 +00:00
|
|
|
|
"""
|
|
|
|
|
|
All time dependent entities on this model must provide information about
|
|
|
|
|
|
the times at which their state changes.
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
2021-08-06 13:16:48 +00:00
|
|
|
|
state_change_times = {0.}
|
2020-10-27 14:06:28 +00:00
|
|
|
|
state_change_times.update(self.infected.presence.transition_times())
|
2020-11-05 08:52:58 +00:00
|
|
|
|
state_change_times.update(self.ventilation.transition_times())
|
2020-10-27 05:27:38 +00:00
|
|
|
|
return sorted(state_change_times)
|
|
|
|
|
|
|
2021-09-13 10:00:06 +00:00
|
|
|
|
@method_cache
|
|
|
|
|
|
def _first_presence_time(self) -> float:
|
|
|
|
|
|
"""
|
|
|
|
|
|
First presence time. Before that, the concentration is zero.
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
return self.infected.presence.boundaries()[0][0]
|
|
|
|
|
|
|
2021-08-05 13:48:24 +00:00
|
|
|
|
def last_state_change(self, time: float) -> float:
|
2020-10-27 05:27:38 +00:00
|
|
|
|
"""
|
2021-08-06 07:29:12 +00:00
|
|
|
|
Find the most recent/previous state change.
|
2020-10-27 05:27:38 +00:00
|
|
|
|
|
2021-08-06 07:51:20 +00:00
|
|
|
|
Find the nearest time less than the given one. If there is a state
|
|
|
|
|
|
change exactly at ``time`` the previous state change is returned
|
|
|
|
|
|
(except at ``time == 0``).
|
|
|
|
|
|
|
2020-10-27 05:27:38 +00:00
|
|
|
|
"""
|
2021-08-06 07:51:20 +00:00
|
|
|
|
times = self.state_change_times()
|
2021-08-06 08:01:31 +00:00
|
|
|
|
t_index: int = np.searchsorted(times, time) # type: ignore
|
2021-08-06 07:51:20 +00:00
|
|
|
|
# Search sorted gives us the index to insert the given time. Instead we
|
|
|
|
|
|
# want to get the index of the most recent time, so reduce the index by
|
|
|
|
|
|
# one unless we are already at 0.
|
|
|
|
|
|
t_index = max([t_index - 1, 0])
|
|
|
|
|
|
return times[t_index]
|
2020-10-26 19:12:54 +00:00
|
|
|
|
|
2021-08-05 13:48:24 +00:00
|
|
|
|
def _next_state_change(self, time: float) -> float:
|
2021-05-03 10:35:10 +00:00
|
|
|
|
"""
|
|
|
|
|
|
Find the nearest future state change.
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
for change_time in self.state_change_times():
|
|
|
|
|
|
if change_time >= time:
|
|
|
|
|
|
return change_time
|
2021-05-05 19:03:36 +00:00
|
|
|
|
raise ValueError(
|
|
|
|
|
|
f"The requested time ({time}) is greater than last available "
|
|
|
|
|
|
f"state change time ({change_time})"
|
|
|
|
|
|
)
|
2021-05-03 10:35:10 +00:00
|
|
|
|
|
2021-08-05 13:48:24 +00:00
|
|
|
|
@method_cache
|
2021-09-14 14:11:44 +00:00
|
|
|
|
def _normed_concentration_cached(self, time: float) -> _VectorisedFloat:
|
|
|
|
|
|
# A cached version of the _normed_concentration method. Use this
|
|
|
|
|
|
# method if you expect that there may be multiple concentration
|
|
|
|
|
|
# calculations for the same time (e.g. at state change times).
|
|
|
|
|
|
return self._normed_concentration(time)
|
2021-06-05 16:38:57 +00:00
|
|
|
|
|
2021-09-14 14:11:44 +00:00
|
|
|
|
def _normed_concentration(self, time: float) -> _VectorisedFloat:
|
2021-05-05 10:45:02 +00:00
|
|
|
|
"""
|
2021-09-14 14:11:44 +00:00
|
|
|
|
Virus exposure concentration, as a function of time, and
|
|
|
|
|
|
normalized by the emission rate.
|
2021-05-05 10:45:02 +00:00
|
|
|
|
The formulas used here assume that all parameters (ventilation,
|
|
|
|
|
|
emission rate) are constant between two state changes - only
|
|
|
|
|
|
the value of these parameters at the next state change, are used.
|
|
|
|
|
|
|
|
|
|
|
|
Note that time is not vectorised. You can only pass a single float
|
|
|
|
|
|
to this method.
|
|
|
|
|
|
"""
|
2021-09-13 10:00:06 +00:00
|
|
|
|
# The model always starts at t=0, but we avoid running concentration calculations
|
|
|
|
|
|
# before the first presence as an optimisation.
|
|
|
|
|
|
if time <= self._first_presence_time():
|
2020-10-27 13:34:45 +00:00
|
|
|
|
return 0.0
|
2021-05-05 19:03:36 +00:00
|
|
|
|
next_state_change_time = self._next_state_change(time)
|
|
|
|
|
|
IVRR = self.infectious_virus_removal_rate(next_state_change_time)
|
2021-09-14 14:11:44 +00:00
|
|
|
|
conc_limit = self._normed_concentration_limit(next_state_change_time)
|
2020-10-27 13:34:45 +00:00
|
|
|
|
|
2020-10-27 05:27:38 +00:00
|
|
|
|
t_last_state_change = self.last_state_change(time)
|
2021-09-14 14:11:44 +00:00
|
|
|
|
conc_at_last_state_change = self._normed_concentration_cached(t_last_state_change)
|
2020-10-27 05:27:38 +00:00
|
|
|
|
|
2020-10-27 13:34:45 +00:00
|
|
|
|
delta_time = time - t_last_state_change
|
|
|
|
|
|
fac = np.exp(-IVRR * delta_time)
|
2021-09-14 14:11:44 +00:00
|
|
|
|
return conc_limit * (1 - fac) + conc_at_last_state_change * fac
|
|
|
|
|
|
|
|
|
|
|
|
def concentration(self, time: float) -> _VectorisedFloat:
|
|
|
|
|
|
"""
|
|
|
|
|
|
Virus exposure concentration, as a function of time.
|
|
|
|
|
|
|
|
|
|
|
|
Note that time is not vectorised. You can only pass a single float
|
|
|
|
|
|
to this method.
|
|
|
|
|
|
"""
|
|
|
|
|
|
return (self._normed_concentration(time) *
|
|
|
|
|
|
self.infected.emission_rate_when_present())
|
2020-10-26 18:10:53 +00:00
|
|
|
|
|
2021-08-06 09:50:06 +00:00
|
|
|
|
@method_cache
|
2021-09-14 14:11:44 +00:00
|
|
|
|
def normed_integrated_concentration(self, start: float, stop: float) -> _VectorisedFloat:
|
2021-05-10 17:13:09 +00:00
|
|
|
|
"""
|
2021-09-14 14:11:44 +00:00
|
|
|
|
Get the integrated concentration dose between the times start and stop,
|
|
|
|
|
|
normalized by the emission rate.
|
2021-05-10 17:13:09 +00:00
|
|
|
|
"""
|
2021-09-13 10:00:06 +00:00
|
|
|
|
if stop <= self._first_presence_time():
|
|
|
|
|
|
return 0.0
|
2021-05-10 17:13:09 +00:00
|
|
|
|
state_change_times = self.state_change_times()
|
|
|
|
|
|
req_start, req_stop = start, stop
|
2021-09-14 14:11:44 +00:00
|
|
|
|
total_normed_concentration = 0.
|
2021-05-10 17:13:09 +00:00
|
|
|
|
for interval_start, interval_stop in zip(state_change_times[:-1], state_change_times[1:]):
|
2021-05-10 18:23:54 +00:00
|
|
|
|
if req_start > interval_stop or req_stop < interval_start:
|
2021-05-10 17:13:09 +00:00
|
|
|
|
continue
|
|
|
|
|
|
# Clip the current interval to the requested range.
|
|
|
|
|
|
start = max([interval_start, req_start])
|
|
|
|
|
|
stop = min([interval_stop, req_stop])
|
|
|
|
|
|
|
2021-09-14 14:11:44 +00:00
|
|
|
|
conc_start = self._normed_concentration_cached(start)
|
2021-05-10 17:13:09 +00:00
|
|
|
|
|
|
|
|
|
|
next_conc_state = self._next_state_change(stop)
|
2021-09-14 14:11:44 +00:00
|
|
|
|
conc_limit = self._normed_concentration_limit(next_conc_state)
|
2021-05-10 17:13:09 +00:00
|
|
|
|
IVRR = self.infectious_virus_removal_rate(next_conc_state)
|
|
|
|
|
|
delta_time = stop - start
|
2021-09-14 14:11:44 +00:00
|
|
|
|
total_normed_concentration += (
|
2021-05-10 17:13:09 +00:00
|
|
|
|
conc_limit * delta_time +
|
|
|
|
|
|
(conc_limit - conc_start) * (np.exp(-IVRR*delta_time)-1) / IVRR
|
|
|
|
|
|
)
|
2021-09-14 14:11:44 +00:00
|
|
|
|
return total_normed_concentration
|
|
|
|
|
|
|
|
|
|
|
|
def integrated_concentration(self, start: float, stop: float) -> _VectorisedFloat:
|
|
|
|
|
|
"""
|
|
|
|
|
|
Get the integrated concentration dose between the times start and stop.
|
|
|
|
|
|
"""
|
|
|
|
|
|
return (self.normed_integrated_concentration(start, stop) *
|
|
|
|
|
|
self.infected.emission_rate_when_present())
|
2021-05-10 17:13:09 +00:00
|
|
|
|
|
2020-10-26 18:10:53 +00:00
|
|
|
|
|
2020-11-10 14:45:39 +00:00
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
|
|
class ExposureModel:
|
|
|
|
|
|
#: The virus concentration model which this exposure model should consider.
|
2020-11-10 16:19:19 +00:00
|
|
|
|
concentration_model: ConcentrationModel
|
2020-11-10 14:45:39 +00:00
|
|
|
|
|
|
|
|
|
|
#: The population of non-infected people to be used in the model.
|
|
|
|
|
|
exposed: Population
|
|
|
|
|
|
|
2020-11-11 08:50:54 +00:00
|
|
|
|
#: The number of times the exposure event is repeated (default 1).
|
|
|
|
|
|
repeats: int = 1
|
|
|
|
|
|
|
2021-06-01 07:22:15 +00:00
|
|
|
|
#: The fraction of viruses actually deposited in the respiratory tract
|
|
|
|
|
|
fraction_deposited: _VectorisedFloat = 0.6
|
|
|
|
|
|
|
2021-09-14 14:11:44 +00:00
|
|
|
|
def _normed_exposure(self) -> _VectorisedFloat:
|
|
|
|
|
|
"""
|
|
|
|
|
|
The number of virus per meter^3, normalized by the emission rate
|
|
|
|
|
|
of the infected population.
|
|
|
|
|
|
"""
|
|
|
|
|
|
normed_exposure = 0.0
|
2020-10-26 18:10:53 +00:00
|
|
|
|
|
2020-11-10 14:45:39 +00:00
|
|
|
|
for start, stop in self.exposed.presence.boundaries():
|
2021-09-14 14:11:44 +00:00
|
|
|
|
normed_exposure += self.concentration_model.normed_integrated_concentration(start, stop)
|
2021-05-10 17:13:09 +00:00
|
|
|
|
|
2021-09-14 14:11:44 +00:00
|
|
|
|
return normed_exposure * self.repeats
|
|
|
|
|
|
|
|
|
|
|
|
def exposure(self) -> _VectorisedFloat:
|
|
|
|
|
|
"""The number of virus per meter^3."""
|
|
|
|
|
|
return (self._normed_exposure() *
|
|
|
|
|
|
self.concentration_model.infected.emission_rate_when_present())
|
2020-11-10 14:45:39 +00:00
|
|
|
|
|
2021-04-28 12:22:23 +00:00
|
|
|
|
def infection_probability(self) -> _VectorisedFloat:
|
2021-08-06 08:24:25 +00:00
|
|
|
|
exposure = self.exposure()
|
2020-10-26 18:10:53 +00:00
|
|
|
|
|
|
|
|
|
|
inf_aero = (
|
2020-11-10 14:45:39 +00:00
|
|
|
|
self.exposed.activity.inhalation_rate *
|
2021-05-26 21:39:33 +00:00
|
|
|
|
(1 - self.exposed.mask.inhale_efficiency()) *
|
2021-06-01 07:22:15 +00:00
|
|
|
|
exposure * self.fraction_deposited
|
2020-10-26 18:10:53 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# Probability of infection.
|
2021-08-06 08:24:25 +00:00
|
|
|
|
return (1 - np.exp(-(inf_aero/self.concentration_model.virus.infectious_dose))) * 100
|
2020-11-10 14:45:39 +00:00
|
|
|
|
|
2021-04-28 12:22:23 +00:00
|
|
|
|
def expected_new_cases(self) -> _VectorisedFloat:
|
2020-11-10 14:45:39 +00:00
|
|
|
|
prob = self.infection_probability()
|
|
|
|
|
|
exposed_occupants = self.exposed.number
|
|
|
|
|
|
return prob * exposed_occupants / 100
|
2020-11-12 20:21:02 +00:00
|
|
|
|
|
2021-04-28 12:22:23 +00:00
|
|
|
|
def reproduction_number(self) -> _VectorisedFloat:
|
2020-11-12 20:21:02 +00:00
|
|
|
|
"""
|
|
|
|
|
|
The reproduction number can be thought of as the expected number of
|
|
|
|
|
|
cases directly generated by one infected case in a population.
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
if self.concentration_model.infected.number == 1:
|
|
|
|
|
|
return self.expected_new_cases()
|
|
|
|
|
|
|
|
|
|
|
|
# Create an equivalent exposure model but with precisely
|
|
|
|
|
|
# one infected case.
|
|
|
|
|
|
single_exposure_model = nested_replace(
|
|
|
|
|
|
self, {'concentration_model.infected.number': 1}
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
return single_exposure_model.expected_new_cases()
|