Improvement of integration method in quanta_exposure
The computation of quanta_exposure in ExposureModel is dramatically improved, using a fully analytic formula instead of an approximated trapezoidal integration. This required the definition of a new method state_change_times
in the ExposureModel (analogous to the one in the ConcentrationModel).
Integration accuracy was evaluated with a new test - expected values were obtained with the previous method but strongly refined, for proper validation (trapz integration with 10'000 points per interval, instead of 50). The expected values of r0 for a few tests in test_known_quantities
were also re-evaluated with a very fine trapz integration (100'000 points per interval).
The algorithm computation efficiency is increased by a factor 10 with respect to the previous (anyway less accurate) version - 100'000 runs took between 20 and 30 ms vs. ~250 ms with the previous version (on a MacBook). Moreover, with the trapz method, an accuracy of 1e-7 (for the test test_exposure_model_integral_accuracy
) could be reached only with at least 1'000 points in the integration interval, which is at least ~100 times slower (the same 100'000 runs took ~4 seconds).
In general, results might differ by a fraction of a percent w.r.t. the previous version (anyway towards a better accuracy).
Solves #155 (closed)