move ventilation to dedicated function and use piecewise temperature function
This commit is contained in:
parent
6af1f19d66
commit
6c2a843e67
1 changed files with 27 additions and 22 deletions
|
|
@ -83,8 +83,32 @@ class FormData:
|
|||
return model_from_form(self, tmp_raw_form_data)
|
||||
|
||||
def ventilation(self) -> models.Ventilation:
|
||||
# TODO
|
||||
pass
|
||||
# Initializes a ventilation instance as a window if 'natural' is selected, or as a HEPA-filter otherwise
|
||||
if self.ventilation_type == 'natural':
|
||||
if self.windows_open == 'always':
|
||||
period, duration = 120, 120
|
||||
else:
|
||||
period, duration = 15, 120
|
||||
# I multiply the opening width by the number of windows to simulate the correct window area
|
||||
if self.event_type == 'single_event':
|
||||
month_number = int(self.single_event_date.split('/')[1])
|
||||
month = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][month_number]
|
||||
else:
|
||||
month = self.recurrent_event_month[:3]
|
||||
|
||||
inside_temp = models.PiecewiseConstant((0, 24), (293,))
|
||||
outside_temp = models.GenevaTemperatures[month]
|
||||
|
||||
ventilation = models.WindowOpening(active=models.PeriodicInterval(period=period, duration=duration),
|
||||
inside_temp=inside_temp, outside_temp=outside_temp, cd_b=0.6,
|
||||
window_height=self.window_height,
|
||||
opening_length=self.opening_distance * self.windows_number)
|
||||
else:
|
||||
q_air_mech = self.air_changes + self.air_supply
|
||||
ventilation = models.HEPAFilter(active=models.PeriodicInterval(period=120, duration=120),
|
||||
q_air_mech=q_air_mech)
|
||||
|
||||
return ventilation
|
||||
|
||||
def present_interval(self) -> models.Interval:
|
||||
coffee_period = (self.activity_finish - self.activity_start) // self.coffee_breaks
|
||||
|
|
@ -149,25 +173,6 @@ def model_from_form(form: FormData, tmp_raw_form_data) -> models.Model:
|
|||
volume = int(float(d['floor_area']) * form.ceiling_height)
|
||||
room = models.Room(volume=volume)
|
||||
|
||||
# Initializes a ventilation instance as a window if 'natural' is selected, or as a HEPA-filter otherwise
|
||||
if d['ventilation_type'] == 'natural':
|
||||
if d['windows_open'] == 'always':
|
||||
period, duration = 120, 120
|
||||
else:
|
||||
period, duration = 15, 120
|
||||
# I multiply the opening width by the number of windows to simulate the correct window area
|
||||
ventilation = models.WindowOpening(active=models.PeriodicInterval(period=period, duration=duration),
|
||||
inside_temp=models.PiecewiseConstant((0, 24), (293, )),
|
||||
# TODO: This should be based on the month etc.
|
||||
outside_temp=models.PiecewiseConstant((0, 24), (283, )),
|
||||
cd_b=0.6,
|
||||
window_height=float(d['window_height']),
|
||||
opening_length=float(d['opening_distance']) * int(d['windows_number']))
|
||||
else:
|
||||
q_air_mech = float(d['air_changes']) if d['air_type'] == 'air_changes' else float(d['air_supply'])
|
||||
ventilation = models.HEPAFilter(active=models.PeriodicInterval(period=120, duration=120),
|
||||
q_air_mech=q_air_mech)
|
||||
|
||||
# Initializes the virus as SARS_Cov_2
|
||||
virus = models.Virus.types['SARS_CoV_2']
|
||||
|
||||
|
|
@ -195,7 +200,7 @@ def model_from_form(form: FormData, tmp_raw_form_data) -> models.Model:
|
|||
# Initializes and returns a model with the attributes defined above
|
||||
return models.Model(
|
||||
room=room,
|
||||
ventilation=ventilation,
|
||||
ventilation=form.ventilation(),
|
||||
infected=models.InfectedPerson(
|
||||
virus=virus,
|
||||
presence=form.present_interval(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue