phac-nml-phrsd / wem

Wastewater Epidemic Model
MIT License
14 stars 2 forks source link

simulation time steps smaller than 1 crashes #12

Closed davidchampredon closed 2 years ago

davidchampredon commented 2 years ago

By default, the simulation time step is one day, translated into the model parameters as prm.model$sim.steps = 1.

When sim.steps is larger than one, say 2, it means the ODE solver will integrate on a time grid twice as fine, i.e. every 1/2 = 0.5 day. This seems to work (one of the annoying side effect, is that all "incidence" variables are halved, but that's still correct).

When sim.steps is smaller than 1, the code crashes. In this case, we integrate on a coarser time grid, say every 2 days if sim.steps=0.5. And the benefit of doing this would be to speed up the code (typically for fitting, after correcting the incidence variables).

This is probably a rounding type of error (?). To debug, start looking in simul.R, near line 220:

n.time.steps <- horizon * sim.steps
    dt       <- seq(0, horizon, length.out = n.time.steps+1)
davidchampredon commented 2 years ago

partially fixed with a331bd81aa3fbd28b02c212a89bb6c4cdd72491e. Will not try harder, because no speed gain (surprisingly) when sim.steps<1 and sim.steps=1 is the most convenient.