Implement no-ventilation option in calculator.
This commit is contained in:
parent
d4a0566782
commit
4f2fb894fa
3 changed files with 25 additions and 46 deletions
|
|
@ -1,4 +1,3 @@
|
|||
from cara.models import Model
|
||||
from dataclasses import dataclass
|
||||
import html
|
||||
import typing
|
||||
|
|
@ -46,7 +45,7 @@ class FormData:
|
|||
@classmethod
|
||||
def from_dict(cls, form_data: typing.Dict) -> "FormData":
|
||||
|
||||
valid_na_values = ['windows_open', 'ventilation_type', 'mechanical_ventilation_type']
|
||||
valid_na_values = ['windows_open', 'mechanical_ventilation_type']
|
||||
for name in valid_na_values:
|
||||
if not form_data.get(name, ''):
|
||||
form_data[name] = 'not-applicable'
|
||||
|
|
@ -113,10 +112,11 @@ class FormData:
|
|||
infected_finish=time_string_to_minutes(form_data['infected_finish']),
|
||||
)
|
||||
|
||||
def build_model(self) -> Model:
|
||||
def build_model(self) -> models.Model:
|
||||
return model_from_form(self)
|
||||
|
||||
def ventilation(self) -> models.Ventilation:
|
||||
always_on = models.PeriodicInterval(period=120, duration=120)
|
||||
# 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':
|
||||
|
|
@ -141,17 +141,17 @@ class FormData:
|
|||
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)
|
||||
elif self.ventilation_type == "no-ventilation":
|
||||
ventilation = models.AirChange(active=always_on, air_exch=0.)
|
||||
else:
|
||||
if self.mechanical_ventilation_type == 'air_changes':
|
||||
ventilation = models.AirChange(active=models.PeriodicInterval(period=120, duration=120),
|
||||
air_exch=self.air_changes)
|
||||
ventilation = models.AirChange(active=always_on, air_exch=self.air_changes)
|
||||
else:
|
||||
ventilation = models.HVACMechanical(active=models.PeriodicInterval(period=120, duration=120),
|
||||
q_air_mech=self.air_supply)
|
||||
ventilation = models.HVACMechanical(
|
||||
active=always_on, q_air_mech=self.air_supply)
|
||||
|
||||
if self.hepa_option:
|
||||
hepa = models.HEPAFilter(active=models.PeriodicInterval(period=120, duration=120),
|
||||
q_air_mech=250.)
|
||||
hepa = models.HEPAFilter(active=always_on, q_air_mech=250.)
|
||||
return models.MultipleVentilation((ventilation,hepa))
|
||||
else:
|
||||
return ventilation
|
||||
|
|
@ -269,7 +269,6 @@ def model_from_form(form: FormData) -> models.Model:
|
|||
def baseline_raw_form_data():
|
||||
# Note: This isn't a special "baseline". It can be updated as required.
|
||||
return {
|
||||
'RADIO_ventilation_type': 'natural',
|
||||
'activity_finish': '18:00',
|
||||
'activity_start': '09:00',
|
||||
'activity_type': 'office',
|
||||
|
|
@ -296,7 +295,7 @@ def baseline_raw_form_data():
|
|||
'simulation_name': 'Test',
|
||||
'single_event_date': '',
|
||||
'total_people': '10',
|
||||
'ventilation_type': '',
|
||||
'ventilation_type': 'natural',
|
||||
'volume_type': 'room_volume',
|
||||
'window_height': '2',
|
||||
'window_width': '2',
|
||||
|
|
@ -309,7 +308,7 @@ ACTIVITY_TYPES = {'office', 'training', 'workshop'}
|
|||
EVENT_TYPES = {'single_event', 'recurrent_event'}
|
||||
MECHANICAL_VENTILATION_TYPES = {'air_changes', 'air_supply', 'not-applicable'}
|
||||
MASK_WEARING = {'continuous', 'removed'}
|
||||
VENTILATION_TYPES = {'natural', 'mechanical', 'not-applicable'}
|
||||
VENTILATION_TYPES = {'natural', 'mechanical', 'no-ventilation'}
|
||||
VOLUME_TYPES = {'room_volume', 'room_dimensions'}
|
||||
WINDOWS_OPEN = {'always', 'interval', 'breaks', 'not-applicable'}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,9 +36,9 @@ Beta v1.0.0 <span style="float:right; font-weight:bold">Please send feedback to
|
|||
|
||||
<!-- Ventilation Options -->
|
||||
Ventilation type:
|
||||
<input type="hidden" id="ventilation_type" name="ventilation_type" value=""/>
|
||||
<input type="radio" id="mechanical" name="RADIO_ventilation_type" value="mechanical" data-enables="DIVmechanical_ventilation">Mechanical</input>
|
||||
<input type="radio" id="natural" name="RADIO_ventilation_type" value="natural" data-enables="DIVnatural_ventilation">Natural</input><br>
|
||||
<input type="radio" id="no-ventilation" name="ventilation_type" value="no-ventilation" checked>No ventilation</input>
|
||||
<input type="radio" id="mechanical" name="ventilation_type" value="mechanical" data-enables="DIVmechanical_ventilation">Mechanical</input>
|
||||
<input type="radio" id="natural" name="ventilation_type" value="natural" data-enables="DIVnatural_ventilation">Natural</input><br>
|
||||
|
||||
<div id="DIVmechanical_ventilation" style="display:none">
|
||||
<input type="radio" id="air_type_supply" name="mechanical_ventilation_type" value="air_supply" onclick="require_fields(this)">
|
||||
|
|
|
|||
|
|
@ -1,29 +1,16 @@
|
|||
/* -------Show/Hide DIVs------- */
|
||||
function show(show, var_id, obj) {
|
||||
var show = document.getElementById(show);
|
||||
if (show.style.display === "none") {
|
||||
show.style.display = "block";
|
||||
document.getElementById(var_id).value = 1;
|
||||
} else {
|
||||
show.style.display = "none";
|
||||
document.getElementById(var_id).value = 0;
|
||||
}
|
||||
require_fields(obj);
|
||||
}
|
||||
|
||||
|
||||
function on_ventilation_type_change(){
|
||||
ventilation_types = $('input[type=radio][name=RADIO_ventilation_type]');
|
||||
ventilation_types = $('input[type=radio][name=ventilation_type]');
|
||||
ventilation_types.each(function( index ) {
|
||||
if (this.checked) {
|
||||
getChildElement($(this)).show();
|
||||
require_fields(this);
|
||||
$('input[name=ventilation_type]').val(this.id);
|
||||
} else {
|
||||
getChildElement($(this)).hide();
|
||||
unrequire_fields(this);
|
||||
// Clear the inputs for this newly hidden child element.
|
||||
getChildElement($(this)).find('input').val('');
|
||||
getChildElement($(this)).find('input').not('input[type=radio]').val('');
|
||||
getChildElement($(this)).find('input[type=radio]').prop("checked", false);
|
||||
getChildElement($(this)).find('input').prop("required", false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -34,11 +21,6 @@ function getChildElement(elem) {
|
|||
return $("#" + elem.data("enables"));
|
||||
}
|
||||
|
||||
function update_windows_open(obj) {
|
||||
var windows_open = document.getElementById("windows_open");
|
||||
windows_open.value = obj.id;
|
||||
}
|
||||
|
||||
|
||||
/* -------Required fields------- */
|
||||
function require_fields(obj){
|
||||
|
|
@ -124,17 +106,11 @@ function require_natural_ventilation(option) {
|
|||
|
||||
function require_air_changes(option) {
|
||||
$("#air_changes").prop('required',option);
|
||||
if (option) {
|
||||
var mechanical_ventilation_type = document.getElementById("mechanical_ventilation_type");
|
||||
mechanical_ventilation_type.value = "air_changes";
|
||||
} }
|
||||
}
|
||||
|
||||
function require_air_supply(option) {
|
||||
$("#air_supply").prop('required',option);
|
||||
if (option) {
|
||||
var mechanical_ventilation_type = document.getElementById("mechanical_ventilation_type");
|
||||
mechanical_ventilation_type.value = "air_supply";
|
||||
} }
|
||||
}
|
||||
|
||||
function require_single_event(option) {
|
||||
$("#single_event_date").prop('required',option);
|
||||
|
|
@ -238,11 +214,15 @@ $( document ).ready(function() {
|
|||
|
||||
// When the ventilation_type changes we want to make its respective
|
||||
// children show/hide.
|
||||
ventilation_types = $('input[type=radio][name=RADIO_ventilation_type]');
|
||||
ventilation_types = $("input[type=radio][name=ventilation_type]");
|
||||
ventilation_types.change(on_ventilation_type_change);
|
||||
// Call the function now to handle forward/back button presses in the browser.
|
||||
on_ventilation_type_change();
|
||||
|
||||
$("input[name=mechanical_ventilation_type]").change(function(){
|
||||
console.log('Changed!');
|
||||
})
|
||||
|
||||
// Setup the maximum number of people at page load (to handle back/forward),
|
||||
// and update it when total people is changed.
|
||||
setMaxInfectedPeople();
|
||||
|
|
|
|||
Loading…
Reference in a new issue