diff --git a/cara/models.py b/cara/models.py index dd8262bb..69f642a6 100644 --- a/cara/models.py +++ b/cara/models.py @@ -287,9 +287,8 @@ class Model: elif t0 < t <= t1: # Concentration while infected present. init_concentration = self.concentration(t0) - time_present = t - t0 - fac = np.exp(-IVRR * time_present) - return ((ER + Ni) / (IVRR * V)) * (1 - fac) + init_concentration * fac + fac = np.exp(IVRR * (t0 - t)) + return ((ER * Ni) / (IVRR * V)) * (1 - fac) + init_concentration * fac else: # Concentration while infected not present. end_concentration = self.concentration(t1) diff --git a/cara/tests/test_known_quantities.py b/cara/tests/test_known_quantities.py index 8976a558..b87a318b 100644 --- a/cara/tests/test_known_quantities.py +++ b/cara/tests/test_known_quantities.py @@ -64,7 +64,7 @@ def test_r0(baseline_model): concentrations = [baseline_model.concentration(t) for t in ts] npt.assert_allclose( concentrations, - [0.000000e+00, 2.909211e-01, 1.273836e-04, 2.909210e-01, 5.577662e-08], + [0.000000e+00, 2.891970e-01, 1.266287e-04, 2.891969e-01, 5.544607e-08], rtol=1e-5 )