From 7cb762ec1f871202b85ab40e16775955239e9111 Mon Sep 17 00:00:00 2001 From: lrdossan Date: Fri, 7 Jun 2024 18:19:38 +0200 Subject: [PATCH] fixed error with f_inf (short-range) --- caimira/models.py | 9 +++++---- caimira/tests/models/test_short_range_model.py | 6 +++--- caimira/tests/test_full_algorithm.py | 5 +++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/caimira/models.py b/caimira/models.py index e671194b..89f55915 100644 --- a/caimira/models.py +++ b/caimira/models.py @@ -1428,7 +1428,8 @@ class ShortRangeModel: Virus short-range exposure concentration, as a function of time. """ return (self._normed_concentration(concentration_model, time) * - concentration_model.virus.viral_load_in_sputum) + concentration_model.virus.viral_load_in_sputum * + concentration_model.virus.viable_to_RNA_ratio) @method_cache def _normed_short_range_concentration_cached(self, concentration_model: ConcentrationModel, time: float) -> _VectorisedFloat: @@ -1693,7 +1694,6 @@ class ExposureModel: self.exposed.activity.inhalation_rate * (1 - self.exposed.mask.inhale_efficiency())) - # In the end we multiply the final results by the fraction of infectious virus of the vD equation. return deposited_exposure def deposited_exposure_between_bounds(self, time1: float, time2: float) -> _VectorisedFloat: @@ -1744,8 +1744,9 @@ class ExposureModel: # Then we multiply by diameter-independent quantities: viral load # and fraction of infected virions deposited_exposure *= ( - self.concentration_model.virus.viral_load_in_sputum - * (1 - self.exposed.mask.inhale_efficiency())) + self.concentration_model.virus.viral_load_in_sputum * + self.concentration_model.virus.viable_to_RNA_ratio * + (1 - self.exposed.mask.inhale_efficiency())) # Long-range concentration deposited_exposure += self.long_range_deposited_exposure_between_bounds(time1, time2) diff --git a/caimira/tests/models/test_short_range_model.py b/caimira/tests/models/test_short_range_model.py index 5e20d03b..f86da130 100644 --- a/caimira/tests/models/test_short_range_model.py +++ b/caimira/tests/models/test_short_range_model.py @@ -106,9 +106,9 @@ def test_extract_between_bounds(short_range_model, time1, time2, @pytest.mark.parametrize( "time, expected_short_range_concentration", [ [8.5, 0.], - [10.5, 11.266605], - [10.6, 11.266605], - [11.0, 11.266605], + [10.5, 5.6333025], + [10.6, 5.6333025], + [11.0, 5.6333025], [12.0, 0.], ] ) diff --git a/caimira/tests/test_full_algorithm.py b/caimira/tests/test_full_algorithm.py index 3f6c7fa5..70a3e3a8 100644 --- a/caimira/tests/test_full_algorithm.py +++ b/caimira/tests/test_full_algorithm.py @@ -263,6 +263,7 @@ class SimpleShortRangeModel: we perform the integral of Np(d)*V(d) over diameter analytically """ vl = conc_model.viral_load + viable_to_RNA = conc_model.viable_to_RNA dmin = self.diameter_min dmax = self.diameter_max result = 0. @@ -273,7 +274,7 @@ class SimpleShortRangeModel: ymax = (np.log(dmax)-mu)/(sqrt2*sigma)-3.*sigma/sqrt2 result += ( (cn * famp * d0**3)/2. * np.exp(9*sigma**2/2.) * (erf(ymax) - erf(ymin)) ) - return vl * 1e-6 * result * np.pi/6. + return vl * viable_to_RNA * 1e-6 * result * np.pi/6. def concentration(self, conc_model: SimpleConcentrationModel, time: float) -> _VectorisedFloat: """ @@ -430,7 +431,7 @@ class SimpleExposureModel(SimpleConcentrationModel): res = (quad(integrand, sr_model.diameter_min,sr_model.diameter_max, epsabs=0.,limit=500)[0] - * self.viral_load * 1e-6 * (t2-t1) ) + * self.viral_load * self.viable_to_RNA * 1e-6 * (t2-t1) ) result += sr_model.breathing_rate * ( res-self.integrated_longrange_concentration(t1,t2,evaporation) )/sr_model.dilution_factor()