From 8f973136e049991867aa202c9d7d2b179aecaf13 Mon Sep 17 00:00:00 2001 From: Phil Elson Date: Mon, 9 Nov 2020 09:40:11 +0100 Subject: [PATCH] Allow WindowOpening to have more than one window of the given dimensions. --- cara/apps/calculator/model_generator.py | 19 ++++++------ .../templates/calculator.form.html.j2 | 2 +- cara/models.py | 31 +++++++++++++------ cara/tests/test_ventilation.py | 25 +++++++++++++++ 4 files changed, 56 insertions(+), 21 deletions(-) create mode 100644 cara/tests/test_ventilation.py diff --git a/cara/apps/calculator/model_generator.py b/cara/apps/calculator/model_generator.py index ef4e74fa..71ac9acd 100644 --- a/cara/apps/calculator/model_generator.py +++ b/cara/apps/calculator/model_generator.py @@ -120,12 +120,9 @@ class FormData: # 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 == 'interval': - period, duration = 120, 10 - elif self.windows_number == 'breaks': - # TODO: Implement windows open in breaks - period, duration = 120, 120 + window_interval = models.PeriodicInterval(120, 10) else: - period, duration = 120, 120 + window_interval = always_on if self.event_type == 'single_event': month_number = int(self.single_event_date.split('/')[1]) @@ -136,11 +133,13 @@ class FormData: inside_temp = models.PiecewiseConstant((0, 24), (293,)) outside_temp = models.GenevaTemperatures[month] - # 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=inside_temp, outside_temp=outside_temp, cd_b=0.6, - window_height=self.window_height, - opening_length=self.opening_distance * self.windows_number) + ventilation = models.WindowOpening( + active=window_interval, + inside_temp=inside_temp, outside_temp=outside_temp, cd_b=0.6, + window_height=self.window_height, + opening_length=self.opening_distance, + number_of_windows=self.windows_number, + ) elif self.ventilation_type == "no-ventilation": ventilation = models.AirChange(active=always_on, air_exch=0.) else: diff --git a/cara/apps/calculator/templates/calculator.form.html.j2 b/cara/apps/calculator/templates/calculator.form.html.j2 index df4ccb91..74f3c3f7 100644 --- a/cara/apps/calculator/templates/calculator.form.html.j2 +++ b/cara/apps/calculator/templates/calculator.form.html.j2 @@ -51,7 +51,7 @@ Beta v1.0.0 Please send feedback to