From 0fc28f129bd263b51a4b42f640d5a2a5c52e57cc Mon Sep 17 00:00:00 2001 From: Luis Aleixo Date: Fri, 10 Jun 2022 16:08:07 +0200 Subject: [PATCH 01/11] Input fields with units (and respective resizing adjustments) --- cara/apps/calculator/static/js/form.js | 25 +++++++-- .../templates/base/calculator.form.html.j2 | 53 +++++++++---------- 2 files changed, 48 insertions(+), 30 deletions(-) diff --git a/cara/apps/calculator/static/js/form.js b/cara/apps/calculator/static/js/form.js index e4597acc..dc20b3b4 100644 --- a/cara/apps/calculator/static/js/form.js +++ b/cara/apps/calculator/static/js/form.js @@ -183,7 +183,6 @@ function require_mask(option) { function require_hepa(option) { require_input_field("#hepa_amount", option); - set_disabled_status("#hepa_amount", !option); } function require_input_field(id, option) { @@ -236,6 +235,20 @@ function on_ventilation_type_change() { }); } +function on_hepa_option_change() { + hepa_option = $('input[type=radio][name=hepa_option]') + hepa_option.each(function (index) { + if (this.checked) { + getChildElement($(this)).show(); + require_fields(this); + } + else { + getChildElement($(this)).hide(); + require_fields(this); + } + }) +} + function on_wearing_mask_change() { wearing_mask = $('input[type=radio][name=mask_wearing_option]') wearing_mask.each(function (index) { @@ -711,6 +724,12 @@ $(document).ready(function () { // Call the function now to handle forward/back button presses in the browser. on_ventilation_type_change(); + // When the hepa filtration option changes we want to make its respective + // children show/hide. + $("input[type=radio][name=hepa_option]").change(on_hepa_option_change); + // Call the function now to handle forward/back button presses in the browser. + on_hepa_option_change(); + // When the mask_wearing_option changes we want to make its respective // children show/hide. $("input[type=radio][name=mask_wearing_option]").change(on_wearing_mask_change); @@ -861,8 +880,8 @@ $(document).ready(function () {
-
-

+
+

diff --git a/cara/apps/templates/base/calculator.form.html.j2 b/cara/apps/templates/base/calculator.form.html.j2 index dd43228d..294cda4f 100644 --- a/cara/apps/templates/base/calculator.form.html.j2 +++ b/cara/apps/templates/base/calculator.form.html.j2 @@ -88,11 +88,11 @@
-
+
- +
-
+
@@ -101,7 +101,7 @@
- +
@@ -109,7 +109,7 @@
- +
@@ -189,21 +189,21 @@
HEPA filtration:
-
-
- - - - -
-
- -
-
+
+ + + + +
+
+
+
+

Face masks: From f5ef650cea8f5430c909cbea64e37613d6a8f101 Mon Sep 17 00:00:00 2001 From: Luis Aleixo Date: Mon, 13 Jun 2022 10:50:54 +0200 Subject: [PATCH 02/11] Added default frequency of 1 hour for window opening --- cara/apps/calculator/model_generator.py | 7 ++---- cara/apps/calculator/static/js/form.js | 12 ++++------ .../templates/base/calculator.form.html.j2 | 7 +++--- .../templates/base/calculator.report.html.j2 | 3 +-- cara/apps/templates/base/userguide.html.j2 | 2 +- .../apps/calculator/test_model_generator.py | 23 ++++++++----------- 6 files changed, 21 insertions(+), 33 deletions(-) diff --git a/cara/apps/calculator/model_generator.py b/cara/apps/calculator/model_generator.py index 8e92f361..e9557012 100644 --- a/cara/apps/calculator/model_generator.py +++ b/cara/apps/calculator/model_generator.py @@ -71,7 +71,6 @@ class FormData: virus_type: str volume_type: str windows_duration: float - windows_frequency: float window_height: float window_type: str window_width: float @@ -129,7 +128,6 @@ class FormData: 'window_height': 0., 'window_width': 0., 'windows_duration': 0., - 'windows_frequency': 0., 'windows_number': 0, 'window_opening_regime': 'windows_open_permanently', 'short_range_option': 'short_range_no', @@ -324,11 +322,11 @@ class FormData: return outside_temp def ventilation(self) -> models._VentilationBase: - always_on = models.PeriodicInterval(period=120, duration=120) + always_on = models.PeriodicInterval(period=60, duration=60) # 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, min(self.infected_start, self.exposed_start)/60) + window_interval = models.PeriodicInterval(60, self.windows_duration, min(self.infected_start, self.exposed_start)/60) else: window_interval = always_on @@ -717,7 +715,6 @@ def baseline_raw_form_data() -> typing.Dict[str, typing.Union[str, float]]: 'virus_type': 'SARS_CoV_2', 'volume_type': 'room_volume_explicit', 'windows_duration': '', - 'windows_frequency': '', 'window_height': '2', 'window_type': 'window_sliding', 'window_width': '2', diff --git a/cara/apps/calculator/static/js/form.js b/cara/apps/calculator/static/js/form.js index dc20b3b4..cc48a193 100644 --- a/cara/apps/calculator/static/js/form.js +++ b/cara/apps/calculator/static/js/form.js @@ -125,7 +125,6 @@ function require_natural_ventilation(option) { if (!option) { require_input_field("#window_width", option); require_input_field("#windows_duration", option); - require_input_field("#windows_frequency", option); } } @@ -146,9 +145,7 @@ function require_air_supply(option) { function require_venting(option) { require_input_field("#windows_duration", option); - require_input_field("#windows_frequency", option); set_disabled_status("#windows_duration", !option); - set_disabled_status("#windows_frequency", !option); } function require_lunch(id, option) { @@ -404,14 +401,13 @@ function validate_form(form) { } }); - //Validate window venting duration < venting frequency + //Validate window venting duration > 60 minutes. if (!$("#windows_duration").hasClass("disabled")) { var windowsDurationObj = document.getElementById("windows_duration"); - var windowsFrequencyObj = document.getElementById("windows_frequency"); - removeErrorFor(windowsFrequencyObj); + removeErrorFor(windowsDurationObj); - if (parseInt(windowsDurationObj.value) >= parseInt(windowsFrequencyObj.value)) { - insertErrorFor(windowsFrequencyObj, "Duration >= Frequency"); + if (parseInt(windowsDurationObj.value) > 60.) { + insertErrorFor(windowsDurationObj, "Duration > 60 minutes."); submit = false; } } diff --git a/cara/apps/templates/base/calculator.form.html.j2 b/cara/apps/templates/base/calculator.form.html.j2 index 294cda4f..19d73af7 100644 --- a/cara/apps/templates/base/calculator.form.html.j2 +++ b/cara/apps/templates/base/calculator.form.html.j2 @@ -237,9 +237,8 @@
-
- - +
+

@@ -575,7 +574,7 @@ Ventilation data:
  • Mechanical ventilation = the HVAC supply of fresh air. Check the flow rates with the concerned technical department.
  • -
  • Natural ventilation = the type of window opening. The opening distance is between the fixed frame and movable part when open (commonly used values are window height of 1.6m and window opening between 0.15m and 0.6m). In case of periodic opening, specify the duration (e.g. for 10 min) and frequency (e.g. every 60 min).
  • +
  • Natural ventilation = the type of window opening. The opening distance is between the fixed frame and movable part when open (commonly used values are window height of 1.6m and window opening between 0.15m and 0.6m). In case of periodic opening, specify the duration (e.g. 10 min) per hour.
  • HEPA filtration = the air flow of the device. The following values are based on the different fan velocities of a specific commercial device proposed by the HSE Unit:
    • Level 6 (max) = 430 m3/h (noisy),
    • diff --git a/cara/apps/templates/base/calculator.report.html.j2 b/cara/apps/templates/base/calculator.report.html.j2 index c6ca579a..900c87cb 100644 --- a/cara/apps/templates/base/calculator.report.html.j2 +++ b/cara/apps/templates/base/calculator.report.html.j2 @@ -325,8 +325,7 @@
    • Opening distance: {{ form.opening_distance }} m

    • Windows open: {% if form.window_opening_regime == "windows_open_periodically" %} - Periodically for {{ form.windows_duration | readable_minutes}} - every {{ form.windows_frequency | readable_minutes}} + Periodically for {{ form.windows_duration | readable_minutes}} every 1 hour. {% elif form.window_opening_regime == "windows_open_permanently" %} Permanently {% endif %} diff --git a/cara/apps/templates/base/userguide.html.j2 b/cara/apps/templates/base/userguide.html.j2 index 893637c2..8c03120f 100644 --- a/cara/apps/templates/base/userguide.html.j2 +++ b/cara/apps/templates/base/userguide.html.j2 @@ -95,7 +95,7 @@ If there are multiple windows of different sizes, you should take an average.

      When using natural ventilation, the circulation of air is simulated as a function of the difference between the temperature inside the room and the outside air temperature. The average outdoor temperature for each hour of the day has been computed for every month of the year based on historical data for Geneva, Switzerland. It is therefore very important to enter the correct time and date in the event data section. -Finally, you must specify if the windows are open permanently (at all the times), or periodically (in intervals for a certain duration and frequency - both in minutes) - e.g. open the window for 10 minutes (duration) every 60 minutes (frequency).

      +Finally, you must specify if the windows are open permanently (at all the times), or periodically (in intervals for a certain duration per hour - in minutes) - e.g. open the window for 10 minutes (duration) every 1 hour.


      No ventilation


      diff --git a/cara/tests/apps/calculator/test_model_generator.py b/cara/tests/apps/calculator/test_model_generator.py index cd7de105..a00bde34 100644 --- a/cara/tests/apps/calculator/test_model_generator.py +++ b/cara/tests/apps/calculator/test_model_generator.py @@ -45,8 +45,7 @@ def test_blend_expiration(mask_type): def test_ventilation_slidingwindow(baseline_form: model_generator.FormData): baseline_form.ventilation_type = 'natural_ventilation' - baseline_form.windows_duration = 10 - baseline_form.windows_frequency = 120 + baseline_form.windows_duration = 5 baseline_form.window_opening_regime = 'windows_open_periodically' baseline_form.window_type = 'window_sliding' baseline_form.event_month = 'December' @@ -59,13 +58,13 @@ 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, start=9), + active=models.PeriodicInterval(period=60, duration=5, start=9), 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=60, duration=60), air_exch=0.25, ) ventilation = models.MultipleVentilation((window, ach)) @@ -75,8 +74,7 @@ def test_ventilation_slidingwindow(baseline_form: model_generator.FormData): def test_ventilation_hingedwindow(baseline_form: model_generator.FormData): baseline_form.ventilation_type = 'natural_ventilation' - baseline_form.windows_duration = 10 - baseline_form.windows_frequency = 120 + baseline_form.windows_duration = 5 baseline_form.window_opening_regime = 'windows_open_periodically' baseline_form.window_type = 'window_hinged' baseline_form.event_month = 'December' @@ -90,12 +88,12 @@ 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, start=9), + active=models.PeriodicInterval(period=60, duration=5, start=9), 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=60, duration=60), air_exch=0.25, ) ventilation = models.MultipleVentilation((window, ach)) @@ -135,8 +133,7 @@ def test_ventilation_airchanges(baseline_form: model_generator.FormData): def test_ventilation_window_hepa(baseline_form: model_generator.FormData): baseline_form.ventilation_type = 'natural_ventilation' - baseline_form.windows_duration = 10 - baseline_form.windows_frequency = 120 + baseline_form.windows_duration = 5 baseline_form.window_opening_regime = 'windows_open_periodically' baseline_form.event_month = 'December' baseline_form.window_height = 1.6 @@ -150,16 +147,16 @@ 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=9), + active=models.PeriodicInterval(period=60, duration=5, start=9), 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=60, duration=60), q_air_mech=250., ) ach = models.AirChange( - active=models.PeriodicInterval(period=120, duration=120), + active=models.PeriodicInterval(period=60, duration=60), air_exch=0.25, ) ventilation = models.MultipleVentilation((window, hepa, ach)) From ee7e00c9a2de3bb1aab1c4a029bc6c41c89f67b5 Mon Sep 17 00:00:00 2001 From: Luis Aleixo Date: Mon, 13 Jun 2022 11:00:17 +0200 Subject: [PATCH 03/11] Removed units from input placeholders --- .../templates/base/calculator.form.html.j2 | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/cara/apps/templates/base/calculator.form.html.j2 b/cara/apps/templates/base/calculator.form.html.j2 index 19d73af7..fd8e1fd1 100644 --- a/cara/apps/templates/base/calculator.form.html.j2 +++ b/cara/apps/templates/base/calculator.form.html.j2 @@ -93,7 +93,7 @@
- +
@@ -104,7 +104,7 @@
- +
@@ -112,7 +112,7 @@
- +
@@ -194,7 +194,7 @@
-
+
@@ -203,7 +203,7 @@
-
+
@@ -211,11 +211,11 @@
-
+

@@ -301,7 +301,7 @@
-
+
From 624ea51e4881483514de2aeea908077cb7bcc788 Mon Sep 17 00:00:00 2001 From: Luis Aleixo Date: Mon, 13 Jun 2022 11:04:39 +0200 Subject: [PATCH 04/11] Typo in docstring --- cara/apps/calculator/static/js/form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cara/apps/calculator/static/js/form.js b/cara/apps/calculator/static/js/form.js index cc48a193..fafb63dd 100644 --- a/cara/apps/calculator/static/js/form.js +++ b/cara/apps/calculator/static/js/form.js @@ -401,7 +401,7 @@ function validate_form(form) { } }); - //Validate window venting duration > 60 minutes. + //Validate window venting duration < 60 minutes. if (!$("#windows_duration").hasClass("disabled")) { var windowsDurationObj = document.getElementById("windows_duration"); removeErrorFor(windowsDurationObj); From c4b632407019e3f587fb3ab7703bb16d473da84a Mon Sep 17 00:00:00 2001 From: Luis Aleixo Date: Mon, 13 Jun 2022 17:19:05 +0200 Subject: [PATCH 05/11] Short range interaction - changed "shouting" to "shouting/singing" UI --- cara/apps/calculator/static/js/form.js | 2 +- cara/apps/templates/base/calculator.report.html.j2 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cara/apps/calculator/static/js/form.js b/cara/apps/calculator/static/js/form.js index fafb63dd..7471ccea 100644 --- a/cara/apps/calculator/static/js/form.js +++ b/cara/apps/calculator/static/js/form.js @@ -865,7 +865,7 @@ $(document).ready(function () { - +
diff --git a/cara/apps/templates/base/calculator.report.html.j2 b/cara/apps/templates/base/calculator.report.html.j2 index 900c87cb..67b579a8 100644 --- a/cara/apps/templates/base/calculator.report.html.j2 +++ b/cara/apps/templates/base/calculator.report.html.j2 @@ -384,7 +384,7 @@