added methods to generate CO2 model
This commit is contained in:
parent
6bfebc76d4
commit
e67960e035
2 changed files with 29 additions and 5 deletions
|
|
@ -304,9 +304,8 @@ class FormData:
|
|||
|
||||
if total_percentage != 100:
|
||||
raise ValueError(f'The sum of all respiratory activities should be 100. Got {total_percentage}.')
|
||||
|
||||
|
||||
def build_mc_model(self) -> mc.ExposureModel:
|
||||
|
||||
def initialize_room(self) -> models.Room:
|
||||
# Initializes room with volume either given directly or as product of area and height
|
||||
if self.volume_type == 'room_volume_explicit':
|
||||
volume = self.room_volume
|
||||
|
|
@ -323,7 +322,10 @@ class FormData:
|
|||
humidity = float(self.humidity)
|
||||
inside_temp = self.inside_temp
|
||||
|
||||
room = models.Room(volume=volume, inside_temp=models.PiecewiseConstant((0, 24), (inside_temp,)), humidity=humidity)
|
||||
return models.Room(volume=volume, inside_temp=models.PiecewiseConstant((0, 24), (inside_temp,)), humidity=humidity)
|
||||
|
||||
def build_mc_model(self) -> mc.ExposureModel:
|
||||
room = self.initialize_room()
|
||||
|
||||
infected_population = self.infected_population()
|
||||
|
||||
|
|
@ -357,6 +359,21 @@ class FormData:
|
|||
def build_model(self, sample_size=DEFAULT_MC_SAMPLE_SIZE) -> models.ExposureModel:
|
||||
return self.build_mc_model().build_model(size=sample_size)
|
||||
|
||||
def build_CO2_model(self, sample_size=DEFAULT_MC_SAMPLE_SIZE) -> models.CO2ConcentrationModel:
|
||||
population = mc.Population(
|
||||
number=self.total_people,
|
||||
presence=self.infected_present_interval(),
|
||||
mask=models.Mask.types[self.mask_type],
|
||||
activity=activity_distributions[ACTIVITIES[ACTIVITY_TYPES.index(self.activity_type)]['activity']],
|
||||
host_immunity=0.,
|
||||
)
|
||||
# Builds a CO2 concentration model based on model inputs
|
||||
return mc.CO2ConcentrationModel(
|
||||
room=self.initialize_room(),
|
||||
ventilation=self.ventilation(),
|
||||
CO2_emitters=population,
|
||||
).build_model(size=sample_size)
|
||||
|
||||
def tz_name_and_utc_offset(self) -> typing.Tuple[str, float]:
|
||||
"""
|
||||
Return the timezone name (e.g. CET), and offset, in hours, that need to
|
||||
|
|
|
|||
|
|
@ -133,7 +133,13 @@ def calculate_report_data(form: FormData, model: models.ExposureModel) -> typing
|
|||
for time1, time2 in zip(times[:-1], times[1:])
|
||||
])
|
||||
|
||||
prob = np.array(model.infection_probability())
|
||||
CO2_model: models.CO2ConcentrationModel = form.build_CO2_model()
|
||||
CO2_concentrations = [
|
||||
np.array(CO2_model.concentration(float(time))).mean()
|
||||
for time in times
|
||||
]
|
||||
|
||||
prob = np.array(model.infection_probability()).mean()
|
||||
prob_dist_count, prob_dist_bins = np.histogram(prob/100, bins=100, density=True)
|
||||
prob_probabilistic_exposure = np.array(model.total_probability_rule()).mean()
|
||||
expected_new_cases = np.array(model.expected_new_cases()).mean()
|
||||
|
|
@ -158,6 +164,7 @@ def calculate_report_data(form: FormData, model: models.ExposureModel) -> typing
|
|||
"prob_probabilistic_exposure": prob_probabilistic_exposure,
|
||||
"expected_new_cases": expected_new_cases,
|
||||
"uncertainties_plot_src": uncertainties_plot_src,
|
||||
"CO2_concentrations": CO2_concentrations,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue