Changed tests - inside temp is now a property of Room
This commit is contained in:
parent
5b715937d2
commit
52300df16b
10 changed files with 66 additions and 86 deletions
|
|
@ -244,7 +244,7 @@ class FormData:
|
|||
humidity = 0.3
|
||||
else:
|
||||
humidity = 0.5
|
||||
room = models.Room(volume=volume, humidity=humidity)
|
||||
room = models.Room(volume=volume, inside_temp=models.PiecewiseConstant((0, 24), (293,)), humidity=humidity)
|
||||
|
||||
infected_population = self.infected_population()
|
||||
|
||||
|
|
@ -329,13 +329,11 @@ class FormData:
|
|||
window_interval = always_on
|
||||
|
||||
outside_temp = self.outside_temp()
|
||||
inside_temp = models.PiecewiseConstant((0, 24), (293,))
|
||||
|
||||
ventilation: models.Ventilation
|
||||
if self.window_type == 'window_sliding':
|
||||
ventilation = models.SlidingWindow(
|
||||
active=window_interval,
|
||||
inside_temp=inside_temp,
|
||||
outside_temp=outside_temp,
|
||||
window_height=self.window_height,
|
||||
opening_length=self.opening_distance,
|
||||
|
|
@ -344,7 +342,6 @@ class FormData:
|
|||
elif self.window_type == 'window_hinged':
|
||||
ventilation = models.HingedWindow(
|
||||
active=window_interval,
|
||||
inside_temp=inside_temp,
|
||||
outside_temp=outside_temp,
|
||||
window_height=self.window_height,
|
||||
window_width=self.window_width,
|
||||
|
|
|
|||
|
|
@ -243,19 +243,29 @@ class ModelWidgets(View):
|
|||
|
||||
def _build_room(self, node):
|
||||
room_volume = widgets.IntSlider(value=node.volume, min=10, max=150)
|
||||
inside_temp = widgets.IntSlider(value=node.inside_temp.values[0]-273.15, min=15., max=25.)
|
||||
|
||||
def on_value_change(change):
|
||||
def on_volume_change(change):
|
||||
node.volume = change['new']
|
||||
|
||||
def on_insidetemp_change(change):
|
||||
node.inside_temp.values = (change['new']+273.15,)
|
||||
|
||||
# TODO: Link the state back to the widget, not just the other way around.
|
||||
room_volume.observe(on_value_change, names=['value'])
|
||||
room_volume.observe(on_volume_change, names=['value'])
|
||||
inside_temp.observe(on_insidetemp_change, names=['value'])
|
||||
|
||||
def on_state_change():
|
||||
room_volume.value = node.volume
|
||||
inside_temp.value = node.inside_temp
|
||||
|
||||
node.dcs_observe(on_state_change)
|
||||
|
||||
widget = collapsible(
|
||||
[widget_group(
|
||||
[[widgets.Label('Room volume (m³)'), room_volume]]
|
||||
[[widgets.Label('Room volume (m³)'), room_volume],
|
||||
[widgets.Label('Inside temperature (℃)'), inside_temp],
|
||||
]
|
||||
)],
|
||||
title='Specification of workplace',
|
||||
)
|
||||
|
|
@ -281,7 +291,6 @@ class ModelWidgets(View):
|
|||
def _build_window(self, node) -> WidgetGroup:
|
||||
period = widgets.IntSlider(value=node.active.period, min=0, max=240)
|
||||
interval = widgets.IntSlider(value=node.active.duration, min=0, max=240)
|
||||
inside_temp = widgets.IntSlider(value=node.inside_temp.values[0]-273.15, min=15., max=25.)
|
||||
|
||||
def on_period_change(change):
|
||||
node.active.period = change['new']
|
||||
|
|
@ -289,13 +298,9 @@ class ModelWidgets(View):
|
|||
def on_interval_change(change):
|
||||
node.active.duration = change['new']
|
||||
|
||||
def insidetemp_change(change):
|
||||
node.inside_temp.values = (change['new']+273.15,)
|
||||
|
||||
# TODO: Link the state back to the widget, not just the other way around.
|
||||
period.observe(on_period_change, names=['value'])
|
||||
interval.observe(on_interval_change, names=['value'])
|
||||
inside_temp.observe(insidetemp_change, names=['value'])
|
||||
|
||||
outsidetemp_widgets = {
|
||||
'Fixed': self._build_outsidetemp(node.outside_temp),
|
||||
|
|
@ -327,10 +332,6 @@ class ModelWidgets(View):
|
|||
widgets.Label('Duration of opening (minutes)', layout=auto_width),
|
||||
interval,
|
||||
),
|
||||
(
|
||||
widgets.Label('Inside temperature (℃)', layout=auto_width),
|
||||
inside_temp,
|
||||
),
|
||||
(
|
||||
widgets.Label('Outside temperature scheme', layout=auto_width),
|
||||
outsidetemp_w,
|
||||
|
|
@ -485,10 +486,9 @@ class ModelWidgets(View):
|
|||
|
||||
baseline_model = models.ExposureModel(
|
||||
concentration_model=models.ConcentrationModel(
|
||||
room=models.Room(volume=75),
|
||||
room=models.Room(volume=75, inside_temp=models.PiecewiseConstant((0., 24.), (293.15,))),
|
||||
ventilation=models.SlidingWindow(
|
||||
active=models.PeriodicInterval(period=120, duration=15),
|
||||
inside_temp=models.PiecewiseConstant((0., 24.), (293.15,)),
|
||||
outside_temp=models.PiecewiseConstant((0., 24.), (283.15,)),
|
||||
window_height=1.6, opening_length=0.6,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -57,15 +57,6 @@ _VectorisedFloat = typing.Union[float, np.ndarray]
|
|||
_VectorisedInt = typing.Union[int, np.ndarray]
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Room:
|
||||
#: The total volume of the room
|
||||
volume: _VectorisedFloat
|
||||
|
||||
#: The humidity in the room (from 0 to 1 - e.g. 0.5 is 50% humidity)
|
||||
humidity: _VectorisedFloat = 0.5
|
||||
|
||||
|
||||
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]
|
||||
|
|
@ -195,6 +186,18 @@ class PiecewiseConstant:
|
|||
)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Room:
|
||||
#: The total volume of the room
|
||||
volume: _VectorisedFloat
|
||||
|
||||
#: The temperature inside the room (Kelvin).
|
||||
inside_temp: PiecewiseConstant = PiecewiseConstant((0, 24), (293,))
|
||||
|
||||
#: The humidity in the room (from 0 to 1 - e.g. 0.5 is 50% humidity)
|
||||
humidity: _VectorisedFloat = 0.5
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class _VentilationBase:
|
||||
"""
|
||||
|
|
@ -207,7 +210,7 @@ class _VentilationBase:
|
|||
mechanical air exchange through a filter.
|
||||
|
||||
"""
|
||||
def transition_times(self) -> typing.Set[float]:
|
||||
def transition_times(self, room: Room) -> typing.Set[float]:
|
||||
raise NotImplementedError("Subclass must implement")
|
||||
|
||||
def air_exchange(self, room: Room, time: float) -> _VectorisedFloat:
|
||||
|
|
@ -228,7 +231,7 @@ class Ventilation(_VentilationBase):
|
|||
#: The interval in which the ventilation is active.
|
||||
active: Interval
|
||||
|
||||
def transition_times(self) -> typing.Set[float]:
|
||||
def transition_times(self, room: Room) -> typing.Set[float]:
|
||||
return self.active.transition_times()
|
||||
|
||||
|
||||
|
|
@ -243,10 +246,10 @@ class MultipleVentilation(_VentilationBase):
|
|||
"""
|
||||
ventilations: typing.Tuple[_VentilationBase, ...]
|
||||
|
||||
def transition_times(self) -> typing.Set[float]:
|
||||
def transition_times(self, room: Room) -> typing.Set[float]:
|
||||
transitions = set()
|
||||
for ventilation in self.ventilations:
|
||||
transitions.update(ventilation.transition_times())
|
||||
transitions.update(ventilation.transition_times(room))
|
||||
return transitions
|
||||
|
||||
def air_exchange(self, room: Room, time: float) -> _VectorisedFloat:
|
||||
|
|
@ -265,9 +268,6 @@ class WindowOpening(Ventilation):
|
|||
#: The interval in which the window is open.
|
||||
active: Interval
|
||||
|
||||
#: The temperature inside the room (Kelvin).
|
||||
inside_temp: PiecewiseConstant
|
||||
|
||||
#: The temperature outside of the window (Kelvin).
|
||||
outside_temp: PiecewiseConstant
|
||||
|
||||
|
|
@ -292,9 +292,10 @@ class WindowOpening(Ventilation):
|
|||
"""
|
||||
raise NotImplementedError("Unknown discharge coefficient")
|
||||
|
||||
def transition_times(self) -> typing.Set[float]:
|
||||
transitions = super().transition_times()
|
||||
transitions.update(self.inside_temp.transition_times)
|
||||
def transition_times(self, room: Room) -> typing.Set[float]:
|
||||
transitions = super().transition_times(room)
|
||||
print(room.inside_temp.transition_times)
|
||||
transitions.update(room.inside_temp.transition_times)
|
||||
transitions.update(self.outside_temp.transition_times)
|
||||
return transitions
|
||||
|
||||
|
|
@ -304,7 +305,7 @@ class WindowOpening(Ventilation):
|
|||
return 0.
|
||||
|
||||
# Reminder, no dependence on time in the resulting calculation.
|
||||
inside_temp: _VectorisedFloat = self.inside_temp.value(time)
|
||||
inside_temp: _VectorisedFloat = room.inside_temp.value(time)
|
||||
outside_temp: _VectorisedFloat = self.outside_temp.value(time)
|
||||
|
||||
# The inside_temperature is forced to be always at least min_deltaT degree
|
||||
|
|
@ -439,20 +440,20 @@ class Virus:
|
|||
#: Pre-populated examples of Viruses.
|
||||
types: typing.ClassVar[typing.Dict[str, "Virus"]]
|
||||
|
||||
def halflife(self, humidity: _VectorisedFloat, inside_temp: _VectorisedFloat) -> _VectorisedFloat:
|
||||
def halflife(self, humidity: _VectorisedFloat, inside_temp: PiecewiseConstant, time: float) -> _VectorisedFloat:
|
||||
# Biological decay (inactivation of the virus in air) - virus
|
||||
# dependent and function of humidity
|
||||
raise NotImplementedError
|
||||
|
||||
def decay_constant(self, humidity: _VectorisedFloat, inside_temp: _VectorisedFloat) -> _VectorisedFloat:
|
||||
def decay_constant(self, humidity: _VectorisedFloat, inside_temp: PiecewiseConstant, time: float) -> _VectorisedFloat:
|
||||
# Viral inactivation per hour (h^-1) (function of humidity)
|
||||
return np.log(2) / self.halflife(humidity, inside_temp)
|
||||
return np.log(2) / self.halflife(humidity, inside_temp, time)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class SARSCoV2(Virus):
|
||||
|
||||
def halflife(self, humidity: _VectorisedFloat, inside_temp: _VectorisedFloat) -> _VectorisedFloat:
|
||||
def halflife(self, humidity: _VectorisedFloat, inside_temp: PiecewiseConstant, time: float) -> _VectorisedFloat:
|
||||
"""
|
||||
Half-life changes with humidity level. Here is implemented a simple
|
||||
piecewise constant model (for more details see A. Henriques et al,
|
||||
|
|
@ -460,7 +461,8 @@ class SARSCoV2(Virus):
|
|||
"""
|
||||
# Updated to use the formula from Dabish et al. https://doi.org/10.1080/02786826.2020.1829536
|
||||
# with a minimum at hl = 1.1
|
||||
return max(1.1, (0.693/(0.16030 + 0.04018((inside_temp-20.615)/10.585)+0.2176((humidity-45.235)/28.665)+0.1)))
|
||||
inside_temp = inside_temp.value(time)
|
||||
return max(1.1, (0.693/(0.16030 + 0.04018*(((inside_temp-274.15)-20.615)/10.585)+0.02176*((humidity-45.235)/28.665)+0.1)))
|
||||
|
||||
|
||||
Virus.types = {
|
||||
|
|
@ -919,7 +921,7 @@ class ConcentrationModel:
|
|||
k = (vg * 3600) / h
|
||||
#todo: Inside_temp needs to be exposed/added to the room;
|
||||
return (
|
||||
k + self.virus.decay_constant(self.room.humidity, self.room.inside_temp)
|
||||
k + self.virus.decay_constant(self.room.humidity, self.room.inside_temp, time)
|
||||
+ self.ventilation.air_exchange(self.room, time)
|
||||
)
|
||||
|
||||
|
|
@ -950,7 +952,7 @@ class ConcentrationModel:
|
|||
"""
|
||||
state_change_times = {0.}
|
||||
state_change_times.update(self.infected.presence.transition_times())
|
||||
state_change_times.update(self.ventilation.transition_times())
|
||||
state_change_times.update(self.ventilation.transition_times(self.room))
|
||||
return sorted(state_change_times)
|
||||
|
||||
@method_cache
|
||||
|
|
|
|||
|
|
@ -60,7 +60,6 @@ def test_ventilation_slidingwindow(baseline_form: model_generator.FormData):
|
|||
|
||||
window = models.SlidingWindow(
|
||||
active=models.PeriodicInterval(period=120, duration=10, start=minutes_since_midnight(9 * 60)),
|
||||
inside_temp=models.PiecewiseConstant((0, 24), (293,)),
|
||||
outside_temp=baseline_window.outside_temp,
|
||||
window_height=1.6, opening_length=0.6,
|
||||
)
|
||||
|
|
@ -92,7 +91,6 @@ def test_ventilation_hingedwindow(baseline_form: model_generator.FormData):
|
|||
|
||||
window = models.HingedWindow(
|
||||
active=models.PeriodicInterval(period=120, duration=10, start=minutes_since_midnight(9 * 60)),
|
||||
inside_temp=models.PiecewiseConstant((0, 24), (293,)),
|
||||
outside_temp=baseline_window.outside_temp,
|
||||
window_height=1.6, window_width=1., opening_length=0.6,
|
||||
)
|
||||
|
|
@ -106,7 +104,7 @@ def test_ventilation_hingedwindow(baseline_form: model_generator.FormData):
|
|||
|
||||
|
||||
def test_ventilation_mechanical(baseline_form: model_generator.FormData):
|
||||
room = models.Room(75)
|
||||
room = models.Room(volume=75, inside_temp=models.PiecewiseConstant((0, 24), (293,)))
|
||||
mech = models.HVACMechanical(
|
||||
active=models.PeriodicInterval(period=120, duration=120),
|
||||
q_air_mech=500.,
|
||||
|
|
@ -121,7 +119,7 @@ def test_ventilation_mechanical(baseline_form: model_generator.FormData):
|
|||
|
||||
|
||||
def test_ventilation_airchanges(baseline_form: model_generator.FormData):
|
||||
room = models.Room(75)
|
||||
room = models.Room(75, inside_temp=models.PiecewiseConstant((0, 24), (293,)))
|
||||
airchange = models.AirChange(
|
||||
active=models.PeriodicInterval(period=120, duration=120),
|
||||
air_exch=3.,
|
||||
|
|
@ -153,7 +151,6 @@ def test_ventilation_window_hepa(baseline_form: model_generator.FormData):
|
|||
# Now build the equivalent ventilation instance directly, and compare.
|
||||
window = models.SlidingWindow(
|
||||
active=models.PeriodicInterval(period=120, duration=10, start=minutes_since_midnight(9 * 60)),
|
||||
inside_temp=models.PiecewiseConstant((0, 24), (293,)),
|
||||
outside_temp=baseline_window.outside_temp,
|
||||
window_height=1.6, opening_length=0.6,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import pytest
|
|||
@pytest.fixture
|
||||
def baseline_concentration_model():
|
||||
model = models.ConcentrationModel(
|
||||
room=models.Room(volume=75),
|
||||
room=models.Room(volume=75, inside_temp=models.PiecewiseConstant((0., 24.), (293,))),
|
||||
ventilation=models.AirChange(
|
||||
active=models.SpecificInterval(((0., 24.), )),
|
||||
air_exch=30.,
|
||||
|
|
@ -55,7 +55,6 @@ def exposure_model_w_outside_temp_changes(baseline_exposure_model: models.Exposu
|
|||
baseline_exposure_model, {
|
||||
'concentration_model.ventilation': models.SlidingWindow(
|
||||
active=models.PeriodicInterval(2.2 * 60, 1.8 * 60),
|
||||
inside_temp=models.PiecewiseConstant((0., 24.), (293,)),
|
||||
outside_temp=cara.data.GenevaTemperatures['Jan'],
|
||||
window_height=1.6,
|
||||
opening_length=0.6,
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ def test_concentration_model_vectorisation(override_params):
|
|||
|
||||
always = models.PeriodicInterval(240, 240) # TODO: This should be a thing on an interval.
|
||||
c_model = models.ConcentrationModel(
|
||||
models.Room(defaults['volume'], defaults['humidity']),
|
||||
models.Room(defaults['volume'], models.PiecewiseConstant((0., 24.), (293,)), defaults['humidity']),
|
||||
models.AirChange(always, defaults['air_change']),
|
||||
models.InfectedPopulation(
|
||||
number=1,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ def test_no_mask_superspeading_emission_rate(baseline_concentration_model):
|
|||
def baseline_periodic_window():
|
||||
return models.SlidingWindow(
|
||||
active=models.PeriodicInterval(period=120, duration=15),
|
||||
inside_temp=models.PiecewiseConstant((0., 24.), (293,)),
|
||||
outside_temp=models.PiecewiseConstant((0., 24.), (283,)),
|
||||
window_height=1.6, opening_length=0.6,
|
||||
)
|
||||
|
|
@ -27,7 +26,7 @@ def baseline_periodic_window():
|
|||
|
||||
@pytest.fixture
|
||||
def baseline_room():
|
||||
return models.Room(volume=75)
|
||||
return models.Room(volume=75, inside_temp=models.PiecewiseConstant((0., 24.), (293,)))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
@ -131,11 +130,10 @@ def test_periodic_hepa(baseline_periodic_hepa, baseline_room):
|
|||
],
|
||||
)
|
||||
def test_multiple_ventilation_HEPA_window(baseline_periodic_hepa, time, expected_value):
|
||||
room = models.Room(volume=68.)
|
||||
room = models.Room(volume=68., inside_temp=models.PiecewiseConstant((0., 24.),(293.15,)))
|
||||
tempOutside = models.PiecewiseConstant((0., 1., 2.5),(273.15, 283.15))
|
||||
tempInside = models.PiecewiseConstant((0., 24.),(293.15,))
|
||||
window = models.SlidingWindow(active=models.SpecificInterval([(1 / 60, 24.)]),
|
||||
inside_temp=tempInside,outside_temp=tempOutside,
|
||||
outside_temp=tempOutside,
|
||||
window_height=1.,opening_length=0.6)
|
||||
vent = models.MultipleVentilation([window, baseline_periodic_hepa])
|
||||
npt.assert_allclose(vent.air_exchange(room,time), expected_value, rtol=1e-5)
|
||||
|
|
@ -143,12 +141,12 @@ def test_multiple_ventilation_HEPA_window(baseline_periodic_hepa, time, expected
|
|||
|
||||
def test_multiple_ventilation_HEPA_window_transitions(baseline_periodic_hepa):
|
||||
tempOutside = models.PiecewiseConstant((0., 1., 2.5),(273.15, 283.15))
|
||||
tempInside = models.PiecewiseConstant((0., 24.),(293.15,))
|
||||
room = models.Room(68, models.PiecewiseConstant((0., 24.),(293.15,)))
|
||||
window = models.SlidingWindow(active=models.SpecificInterval([(1 / 60, 24.)]),
|
||||
inside_temp=tempInside,outside_temp=tempOutside,
|
||||
outside_temp=tempOutside,
|
||||
window_height=1.,opening_length=0.6)
|
||||
vent = models.MultipleVentilation([window, baseline_periodic_hepa])
|
||||
assert set(vent.transition_times()) == set([0.0, 1/60, 0.25, 1.0, 2.0, 2.25,
|
||||
assert set(vent.transition_times(room)) == set([0.0, 1/60, 0.25, 1.0, 2.0, 2.25,
|
||||
2.5, 4.0, 4.25, 6.0, 6.25, 8.0, 8.25, 10.0, 10.25, 12.0, 12.25,
|
||||
14.0, 14.25, 16.0, 16.25, 18.0, 18.25, 20.0, 20.25, 22.0, 22.25, 24.])
|
||||
|
||||
|
|
@ -188,14 +186,13 @@ def test_multiple_ventilation_HEPA_HVAC_AirChange(volume, expected_value):
|
|||
)
|
||||
def test_windowopening(time, expected_value):
|
||||
tempOutside = models.PiecewiseConstant((0., 10., 24.),(273.15, 283.15))
|
||||
tempInside = models.PiecewiseConstant((0., 24.), (293.15,))
|
||||
w = models.SlidingWindow(
|
||||
active=models.SpecificInterval([(0., 24.)]),
|
||||
inside_temp=tempInside,outside_temp=tempOutside,
|
||||
outside_temp=tempOutside,
|
||||
window_height=1., opening_length=0.6,
|
||||
)
|
||||
npt.assert_allclose(
|
||||
w.air_exchange(models.Room(volume=68), time), expected_value, rtol=1e-5
|
||||
w.air_exchange(models.Room(volume=68, inside_temp=models.PiecewiseConstant((0., 24.), (293.15, ))), time), expected_value, rtol=1e-5
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -223,10 +220,9 @@ def build_hourly_dependent_model(
|
|||
outside_temp = temperatures[month]
|
||||
|
||||
model = models.ConcentrationModel(
|
||||
room=models.Room(volume=75),
|
||||
room=models.Room(volume=75, inside_temp=models.PiecewiseConstant((0., 24.), (293, ))),
|
||||
ventilation=models.SlidingWindow(
|
||||
active=models.SpecificInterval(intervals_open),
|
||||
inside_temp=models.PiecewiseConstant((0., 24.), (293, )),
|
||||
outside_temp=outside_temp,
|
||||
window_height=1.6, opening_length=0.6,
|
||||
),
|
||||
|
|
@ -246,10 +242,9 @@ def build_hourly_dependent_model(
|
|||
|
||||
def build_constant_temp_model(outside_temp, intervals_open=((7.5, 8.5),)):
|
||||
model = models.ConcentrationModel(
|
||||
room=models.Room(volume=75),
|
||||
room=models.Room(volume=75, inside_temp=models.PiecewiseConstant((0., 24.), (293,))),
|
||||
ventilation=models.SlidingWindow(
|
||||
active=models.SpecificInterval(intervals_open),
|
||||
inside_temp=models.PiecewiseConstant((0., 24.), (293,)),
|
||||
outside_temp=models.PiecewiseConstant((0., 24.), (outside_temp,)),
|
||||
window_height=1.6, opening_length=0.6,
|
||||
),
|
||||
|
|
@ -271,7 +266,6 @@ def build_hourly_dependent_model_multipleventilation(month, intervals_open=((7.5
|
|||
vent = models.MultipleVentilation((
|
||||
models.SlidingWindow(
|
||||
active=models.SpecificInterval(intervals_open),
|
||||
inside_temp=models.PiecewiseConstant((0., 24.), (293,)),
|
||||
outside_temp=data.GenevaTemperatures[month],
|
||||
window_height=1.6, opening_length=0.6,
|
||||
),
|
||||
|
|
@ -281,7 +275,7 @@ def build_hourly_dependent_model_multipleventilation(month, intervals_open=((7.5
|
|||
),
|
||||
))
|
||||
model = models.ConcentrationModel(
|
||||
room=models.Room(volume=75),
|
||||
room=models.Room(volume=75, inside_temp=models.PiecewiseConstant((0., 24.), (293,))),
|
||||
ventilation=vent,
|
||||
infected=models.EmittingPopulation(
|
||||
number=1,
|
||||
|
|
|
|||
|
|
@ -40,10 +40,10 @@ def test_type_annotations():
|
|||
@pytest.fixture
|
||||
def baseline_mc_concentration_model() -> cara.monte_carlo.ConcentrationModel:
|
||||
mc_model = cara.monte_carlo.ConcentrationModel(
|
||||
room=cara.monte_carlo.Room(volume=cara.monte_carlo.sampleable.Normal(75, 20)),
|
||||
room=cara.monte_carlo.Room(volume=cara.monte_carlo.sampleable.Normal(75, 20),
|
||||
inside_temp=cara.models.PiecewiseConstant((0., 24.), (293,))),
|
||||
ventilation=cara.monte_carlo.SlidingWindow(
|
||||
active=cara.models.PeriodicInterval(period=120, duration=120),
|
||||
inside_temp=cara.models.PiecewiseConstant((0., 24.), (293,)),
|
||||
outside_temp=cara.models.PiecewiseConstant((0., 24.), (283,)),
|
||||
window_height=1.6, opening_length=0.6,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -45,12 +45,11 @@ def shared_office_mc():
|
|||
Corresponds to the 1st line of Table 4 in https://doi.org/10.1101/2021.10.14.21264988
|
||||
"""
|
||||
concentration_mc = mc.ConcentrationModel(
|
||||
room=models.Room(volume=50, humidity=0.5),
|
||||
room=models.Room(volume=50, inside_temp=models.PiecewiseConstant((0., 24.), (298,)), humidity=0.5),
|
||||
ventilation=models.MultipleVentilation(
|
||||
ventilations=(
|
||||
models.SlidingWindow(
|
||||
active=models.PeriodicInterval(period=120, duration=120),
|
||||
inside_temp=models.PiecewiseConstant((0., 24.), (298,)),
|
||||
outside_temp=data.GenevaTemperatures['Jun'],
|
||||
window_height=1.6,
|
||||
opening_length=0.2,
|
||||
|
|
@ -88,12 +87,11 @@ def classroom_mc():
|
|||
Corresponds to the 2nd line of Table 4 in https://doi.org/10.1101/2021.10.14.21264988
|
||||
"""
|
||||
concentration_mc = mc.ConcentrationModel(
|
||||
room=models.Room(volume=160, humidity=0.3),
|
||||
room=models.Room(volume=160, inside_temp=models.PiecewiseConstant((0., 24.), (293,)), humidity=0.3),
|
||||
ventilation=models.MultipleVentilation(
|
||||
ventilations=(
|
||||
models.SlidingWindow(
|
||||
active=models.PeriodicInterval(period=120, duration=120),
|
||||
inside_temp=models.PiecewiseConstant((0., 24.), (293,)),
|
||||
outside_temp=TorontoTemperatures['Dec'],
|
||||
window_height=1.6,
|
||||
opening_length=0.2,
|
||||
|
|
@ -348,12 +346,11 @@ def test_report_models(mc_model, expected_pi, expected_new_cases,
|
|||
def test_small_shared_office_Geneva(mask_type, month, expected_pi,
|
||||
expected_dose, expected_ER):
|
||||
concentration_mc = mc.ConcentrationModel(
|
||||
room=models.Room(volume=33, humidity=0.5),
|
||||
room=models.Room(volume=33, inside_temp=models.PiecewiseConstant((0., 24.), (293,)), humidity=0.5),
|
||||
ventilation=models.MultipleVentilation(
|
||||
(
|
||||
models.SlidingWindow(
|
||||
active=models.SpecificInterval(((0., 24.),)),
|
||||
inside_temp=models.PiecewiseConstant((0., 24.), (293,)),
|
||||
outside_temp=data.GenevaTemperatures[month],
|
||||
window_height=1.5, opening_length=0.2,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ from cara import models
|
|||
def baseline_slidingwindow():
|
||||
return models.SlidingWindow(
|
||||
active=models.SpecificInterval(((0, 4), (5, 9))),
|
||||
inside_temp=models.PiecewiseConstant((0, 24), (293,)),
|
||||
outside_temp=models.PiecewiseConstant((0, 24), (283,)),
|
||||
window_height=1.6, opening_length=0.6,
|
||||
)
|
||||
|
|
@ -21,14 +20,13 @@ def baseline_slidingwindow():
|
|||
def baseline_hingedwindow():
|
||||
return models.HingedWindow(
|
||||
active=models.SpecificInterval(((0, 4), (5, 9))),
|
||||
inside_temp=models.PiecewiseConstant((0, 24), (293,)),
|
||||
outside_temp=models.PiecewiseConstant((0, 24), (283,)),
|
||||
window_height=1.6, opening_length=0.6, window_width=1.,
|
||||
)
|
||||
|
||||
|
||||
def test_number_of_windows(baseline_slidingwindow):
|
||||
room = models.Room(75)
|
||||
room = models.Room(volume=75, inside_temp=models.PiecewiseConstant((0, 24), (293,)))
|
||||
two_windows = dataclasses.replace(baseline_slidingwindow, number_of_windows=2)
|
||||
|
||||
one_window_exchange = baseline_slidingwindow.air_exchange(room, 1)
|
||||
|
|
@ -63,9 +61,6 @@ def test_hinged_window(baseline_hingedwindow, window_width,
|
|||
{'outside_temp': models.PiecewiseConstant(
|
||||
(0, 2, 3), (np.array([20, 30, 28]), np.array([25, 30, 27]))
|
||||
)},
|
||||
{'inside_temp': models.PiecewiseConstant(
|
||||
(0, 20), (np.array([20, 30, 25]), )
|
||||
)},
|
||||
]
|
||||
)
|
||||
def test_hinged_window_vectorisation(override_params):
|
||||
|
|
@ -73,11 +68,10 @@ def test_hinged_window_vectorisation(override_params):
|
|||
'window_height': 0.15,
|
||||
'window_width': 0.15,
|
||||
'opening_length': 0.15,
|
||||
'inside_temp': models.PiecewiseConstant((0, 2, 3), (20, 25)),
|
||||
'outside_temp': models.PiecewiseConstant((0, 2, 3), (10, 15)),
|
||||
}
|
||||
defaults.update(override_params)
|
||||
room = models.Room(volume=75)
|
||||
room = models.Room(volume=75, inside_temp=models.PiecewiseConstant((0, 2, 3), (20, 25)))
|
||||
t = 0.5
|
||||
window = models.HingedWindow(models.PeriodicInterval(60, 30), **defaults)
|
||||
if {'window_height', 'opening_length', 'window_width'}.intersection(override_params):
|
||||
|
|
|
|||
Loading…
Reference in a new issue