Commit b50233b0 authored by Luis Aleixo's avatar Luis Aleixo
Browse files

Consideration on the time the first person (either infected or exposed)...

Consideration on the time the first person (either infected or exposed) arrives at the enclosed space
parent 8ec08c08
Pipeline #3256921 passed with stage
in 3 minutes and 27 seconds
......@@ -301,11 +301,11 @@ class FormData:
return outside_temp
def ventilation(self) -> models._VentilationBase:
always_on = models.PeriodicInterval(period=120, duration=120)
always_on = models.PeriodicInterval(period=120, duration=120, start=0)
# Initializes a ventilation instance as a window if 'natural_ventilation' is selected, or as a HEPA-filter otherwise
if self.ventilation_type == 'natural_ventilation':
if self.window_opening_regime == 'windows_open_periodically':
window_interval = models.PeriodicInterval(self.windows_frequency, self.windows_duration)
window_interval = models.PeriodicInterval(self.windows_frequency, self.windows_duration, min(self.infected_start, self.exposed_start))
else:
window_interval = always_on
......
......@@ -487,7 +487,7 @@ baseline_model = models.ExposureModel(
concentration_model=models.ConcentrationModel(
room=models.Room(volume=75),
ventilation=models.SlidingWindow(
active=models.PeriodicInterval(period=120, duration=15),
active=models.PeriodicInterval(period=120, duration=15, start=8),
inside_temp=models.PiecewiseConstant((0., 24.), (293.15,)),
outside_temp=models.PiecewiseConstant((0., 24.), (283.15,)),
window_height=1.6, opening_length=0.6,
......@@ -540,7 +540,7 @@ class CARAStateBuilder(state.StateBuilder):
)
# Initialise the HVAC state
s._states['Mechanical'].dcs_update_from(
models.HVACMechanical(models.PeriodicInterval(period=24*60, duration=24*60), 500.)
models.HVACMechanical(models.PeriodicInterval(period=24*60, duration=24*60, start=0), 500.)
)
return s
......
......@@ -124,12 +124,15 @@ class PeriodicInterval(Interval):
#: A value greater than :data:`period` signifies the event is permanently
#: occurring, a value of 0 signifies that the event never happens.
duration: float
#: Time at which the first person (infected or exposed) arrives at the enclosed space.
start: float
def boundaries(self) -> BoundarySequence_t:
if self.period == 0 or self.duration == 0:
return tuple()
result = []
for i in np.arange(0, 24, self.period / 60):
for i in np.arange(self.start, 24, self.period / 60):
# 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)))
......
......@@ -59,14 +59,14 @@ def test_ventilation_slidingwindow(baseline_form: model_generator.FormData):
assert isinstance(baseline_window, models.SlidingWindow)
window = models.SlidingWindow(
active=models.PeriodicInterval(period=120, duration=10),
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,
)
ach = models.AirChange(
active=models.PeriodicInterval(period=120, duration=120),
active=models.PeriodicInterval(period=120, duration=120, start=0),
air_exch=0.25,
)
ventilation = models.MultipleVentilation((window, ach))
......@@ -91,13 +91,13 @@ def test_ventilation_hingedwindow(baseline_form: model_generator.FormData):
assert isinstance(baseline_window, models.HingedWindow)
window = models.HingedWindow(
active=models.PeriodicInterval(period=120, duration=10),
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,
)
ach = models.AirChange(
active=models.PeriodicInterval(period=120, duration=120),
active=models.PeriodicInterval(period=120, duration=120, start=0),
air_exch=0.25,
)
ventilation = models.MultipleVentilation((window, ach))
......@@ -108,7 +108,7 @@ def test_ventilation_hingedwindow(baseline_form: model_generator.FormData):
def test_ventilation_mechanical(baseline_form: model_generator.FormData):
room = models.Room(75)
mech = models.HVACMechanical(
active=models.PeriodicInterval(period=120, duration=120),
active=models.PeriodicInterval(period=120, duration=120, start=0),
q_air_mech=500.,
)
baseline_form.ventilation_type = 'mechanical_ventilation'
......@@ -123,7 +123,7 @@ def test_ventilation_mechanical(baseline_form: model_generator.FormData):
def test_ventilation_airchanges(baseline_form: model_generator.FormData):
room = models.Room(75)
airchange = models.AirChange(
active=models.PeriodicInterval(period=120, duration=120),
active=models.PeriodicInterval(period=120, duration=120, start=0),
air_exch=3.,
)
baseline_form.ventilation_type = 'mechanical_ventilation'
......@@ -152,17 +152,17 @@ 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),
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,
)
hepa = models.HEPAFilter(
active=models.PeriodicInterval(period=120, duration=120),
active=models.PeriodicInterval(period=120, duration=120, start=0),
q_air_mech=250.,
)
ach = models.AirChange(
active=models.PeriodicInterval(period=120, duration=120),
active=models.PeriodicInterval(period=120, duration=120, start=0),
air_exch=0.25,
)
ventilation = models.MultipleVentilation((window, hepa, ach))
......
......@@ -48,7 +48,7 @@ def exposure_model_w_outside_temp_changes(baseline_exposure_model: models.Exposu
exp_model = cara.dataclass_utils.nested_replace(
baseline_exposure_model, {
'concentration_model.ventilation': models.SlidingWindow(
active=models.PeriodicInterval(2.2 * 60, 1.8 * 60),
active=models.PeriodicInterval(2.2 * 60, 1.8 * 60, 0),
inside_temp=models.PiecewiseConstant((0., 24.), (293,)),
outside_temp=cara.data.GenevaTemperatures['Jan'],
window_height=1.6,
......
......@@ -24,7 +24,7 @@ def test_concentration_model_vectorisation(override_params):
}
defaults.update(override_params)
always = models.PeriodicInterval(240, 240) # TODO: This should be a thing on an interval.
always = models.PeriodicInterval(240, 240, 0) # TODO: This should be a thing on an interval.
c_model = models.ConcentrationModel(
models.Room(defaults['volume'], defaults['humidity']),
models.AirChange(always, defaults['air_change']),
......
......@@ -36,7 +36,7 @@ class KnownNormedconcentration(models.ConcentrationModel):
return self.normed_concentration_function(time)
halftime = models.PeriodicInterval(120, 60)
halftime = models.PeriodicInterval(120, 60, 0)
populations = [
# A simple scalar population.
models.Population(
......
......@@ -18,7 +18,7 @@ def test_no_mask_superspeading_emission_rate(baseline_model):
@pytest.fixture
def baseline_periodic_window():
return models.SlidingWindow(
active=models.PeriodicInterval(period=120, duration=15),
active=models.PeriodicInterval(period=120, duration=15, start=0),
inside_temp=models.PiecewiseConstant((0., 24.), (293,)),
outside_temp=models.PiecewiseConstant((0., 24.), (283,)),
window_height=1.6, opening_length=0.6,
......@@ -33,7 +33,7 @@ def baseline_room():
@pytest.fixture
def baseline_periodic_hepa():
return models.HEPAFilter(
active=models.PeriodicInterval(period=120, duration=15),
active=models.PeriodicInterval(period=120, duration=15, start=0),
q_air_mech=514.74,
)
......@@ -63,7 +63,7 @@ def build_model(interval_duration):
model = models.ConcentrationModel(
room=models.Room(volume=75),
ventilation=models.HEPAFilter(
active=models.PeriodicInterval(period=120, duration=interval_duration),
active=models.PeriodicInterval(period=120, duration=interval_duration, start=0),
q_air_mech=500.,
),
infected=models.EmittingPopulation(
......
......@@ -42,7 +42,7 @@ def baseline_mc_model() -> cara.monte_carlo.ConcentrationModel:
mc_model = cara.monte_carlo.ConcentrationModel(
room=cara.monte_carlo.Room(volume=cara.monte_carlo.sampleable.Normal(75, 20)),
ventilation=cara.monte_carlo.SlidingWindow(
active=cara.models.PeriodicInterval(period=120, duration=120),
active=cara.models.PeriodicInterval(period=120, duration=120, start=0),
inside_temp=cara.models.PiecewiseConstant((0., 24.), (293,)),
outside_temp=cara.models.PiecewiseConstant((0., 24.), (283,)),
window_height=1.6, opening_length=0.6,
......
......@@ -25,13 +25,13 @@ def shared_office_mc():
ventilation = models.MultipleVentilation(
ventilations=(
models.SlidingWindow(
active=models.PeriodicInterval(period=120, duration=120),
active=models.PeriodicInterval(period=120, duration=120, start=0),
inside_temp=models.PiecewiseConstant((0., 24.), (298,)),
outside_temp=data.GenevaTemperatures['Jun'],
window_height=1.6,
opening_length=0.2,
),
models.AirChange(active=models.PeriodicInterval(period=120, duration=120), air_exch=0.25),
models.AirChange(active=models.PeriodicInterval(period=120, duration=120, start=0), air_exch=0.25),
)
),
infected=mc.InfectedPopulation(
......@@ -67,13 +67,13 @@ def classroom_mc():
ventilation = models.MultipleVentilation(
ventilations=(
models.SlidingWindow(
active=models.PeriodicInterval(period=120, duration=120),
active=models.PeriodicInterval(period=120, duration=120, start=0),
inside_temp=models.PiecewiseConstant((0., 24.), (293,)),
outside_temp=data.TorontoTemperatures['Dec'],
window_height=1.6,
opening_length=0.2,
),
models.AirChange(active=models.PeriodicInterval(period=120, duration=120), air_exch=0.25),
models.AirChange(active=models.PeriodicInterval(period=120, duration=120, start=0), air_exch=0.25),
)
),
infected=mc.InfectedPopulation(
......@@ -107,8 +107,8 @@ def ski_cabin_mc():
concentration_mc = mc.ConcentrationModel(
room=models.Room(volume=10, humidity=0.3),
ventilation=models.MultipleVentilation(
(models.AirChange(active=models.PeriodicInterval(period=120, duration=120), air_exch=0.0),
models.AirChange(active=models.PeriodicInterval(period=120, duration=120), air_exch=0.25))),
(models.AirChange(active=models.PeriodicInterval(period=120, duration=120, start=0), air_exch=0.0),
models.AirChange(active=models.PeriodicInterval(period=120, duration=120, start=0), air_exch=0.25))),
infected=mc.InfectedPopulation(
number=1,
presence=models.SpecificInterval(((0, 20/60),)),
......@@ -141,7 +141,7 @@ def skagit_chorale_mc():
concentration_mc = mc.ConcentrationModel(
room=models.Room(volume=810, humidity=0.5),
ventilation=models.AirChange(
active=models.PeriodicInterval(period=120, duration=120),
active=models.PeriodicInterval(period=120, duration=120, start=0),
air_exch=0.7),
infected=mc.InfectedPopulation(
number=1,
......@@ -180,7 +180,7 @@ def bus_ride_mc():
concentration_mc = mc.ConcentrationModel(
room=models.Room(volume=45, humidity=0.5),
ventilation=models.AirChange(
active=models.PeriodicInterval(period=120, duration=120),
active=models.PeriodicInterval(period=120, duration=120, start=0),
air_exch=1.25),
infected=mc.InfectedPopulation(
number=1,
......
......@@ -79,7 +79,7 @@ def test_hinged_window_vectorisation(override_params):
defaults.update(override_params)
room = models.Room(volume=75)
t = 0.5
window = models.HingedWindow(models.PeriodicInterval(60, 30), **defaults)
window = models.HingedWindow(models.PeriodicInterval(60, 30, 0), **defaults)
if {'window_height', 'opening_length', 'window_width'}.intersection(override_params):
assert isinstance(window.discharge_coefficient, np.ndarray)
else:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment