added additional ventilation option

This commit is contained in:
Luis Aleixo 2023-06-22 17:39:52 +02:00
parent 8329376a58
commit 7a01d39fba
4 changed files with 37 additions and 28 deletions

View file

@ -315,7 +315,7 @@ class CO2FormData:
)
def ventilation_transition_times(self, last_present_time) -> typing.Tuple[float, ...]:
if self.ventilation_type == 'natural_ventilation' and self.window_opening_regime == 'windows_open_periodically':
if self.ventilation_type == 'from_fitting' and self.window_opening_regime == 'windows_open_periodically':
transition_times = sorted(models.PeriodicInterval(self.windows_frequency,
self.windows_duration, min(self.infected_start, self.exposed_start)/60).transition_times())
return tuple(filter(lambda x: x < last_present_time, transition_times))

View file

@ -439,10 +439,24 @@ class FormData:
def ventilation(self) -> models._VentilationBase:
always_on = models.PeriodicInterval(period=120, duration=120)
periodic_interval = models.PeriodicInterval(self.windows_frequency, self.windows_duration, min(self.infected_start, self.exposed_start)/60)
if self.CO2_data_option:
ventilations = []
if self.ventilation_type == 'from_fitting' and self.window_opening_regime == 'windows_open_periodically':
for index, time in enumerate(sorted(list(periodic_interval.transition_times()))[:-1]):
if index < len(self.CO2_fitting_result['ventilation_values']):
ventilations.append(models.AirChange(active=models.SpecificInterval(present_times=((time, time + self.windows_duration/60), )),
air_exch=self.CO2_fitting_result['ventilation_values'][index]))
else: break
else:
ventilations.append(models.AirChange(active=always_on, air_exch=self.CO2_fitting_result['ventilation_values'][0]))
return models.MultipleVentilation(tuple(ventilations))
# 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 = periodic_interval
else:
window_interval = always_on

View file

@ -244,6 +244,9 @@ function removeInvalid(id) {
}
function on_ventilation_type_change() {
if ($('input[type=radio][id=from_fitting').is(':checked')) $('#DIVfrom_fitting').after($('#window_opening_regime'));
else $('#DIVopening_distance').after($('#window_opening_regime'));
ventilation_types = $('input[type=radio][name=ventilation_type]');
ventilation_types.each(function (index) {
if (this.checked) {
@ -494,25 +497,12 @@ function on_coffee_break_option_change() {
}
function ventilation_from_fitting(condition) {
let CO2_data_options = $('input[type=radio][name=ventilation_type]');
let hepa_options = $('input[type=radio][name=hepa_option]');
if (condition) {
$('input[type=radio][id=no_ventilation]').click();
CO2_data_options.each(function (index){
$(this).prop("disabled", true);
});
hepa_options.each(function (index){
$(this).prop("disabled", true);
});
$('#DIVhepa_amount').after($('#window_opening_regime'));
$('input[type=radio][id=from_fitting]').click();
$('#DIVfrom_fitting').after($('#window_opening_regime'));
}
else {
CO2_data_options.each(function (index){
$(this).prop("disabled", false);
});
hepa_options.each(function (index){
$(this).prop("disabled", false);
});
$('input[type=radio][id=no_ventilation]').click();
$('#DIVopening_distance').after($('#window_opening_regime'));
}
}

View file

@ -197,16 +197,18 @@
<div class='sub_title'>Ventilation type:</div>
<div class="split">
<div>
<input type="radio" id="no_ventilation" name="ventilation_type" value="no_ventilation" checked>
<label for="no_ventilation">No ventilation</label>
<input class="ml-2" type="radio" id="mechanical_ventilation" name="ventilation_type" value="mechanical_ventilation" data-enables="#DIVmechanical_ventilation">
<label for="mechanical_ventilation">Mechanical</label>
</div>
<div>
<input type="radio" id="natural_ventilation" name="ventilation_type" value="natural_ventilation" data-enables="#DIVnatural_ventilation" data-toggle="modal" data-target="#warning_modal">
<label for="natural_ventilation">Natural</label><br>
</div>
<div>
<input type="radio" id="no_ventilation" name="ventilation_type" value="no_ventilation" checked>
<label for="no_ventilation">No ventilation</label>
<input class="ml-2" type="radio" id="mechanical_ventilation" name="ventilation_type" value="mechanical_ventilation" data-enables="#DIVmechanical_ventilation">
<label for="mechanical_ventilation">Mechanical</label>
</div>
<div>
<input type="radio" id="natural_ventilation" name="ventilation_type" value="natural_ventilation" data-enables="#DIVnatural_ventilation" data-toggle="modal" data-target="#warning_modal">
<label for="natural_ventilation">Natural</label>
<input class="ml-2" type="radio" id="from_fitting" name="ventilation_type" value="from_fitting" data-enables="#DIVfrom_fitting">
<label for="from_fitting">Fitting</label>
</div>
</div>
<!-- Modal -->
@ -296,6 +298,9 @@
</div>
</div>
</div>
<br/>
<div id="DIVfrom_fitting" style="display:none">
</div>
<br/>
<div class='sub_title'>HEPA filtration:</div>