sizespectrum / mizer

Multi-species size-based ecological modelling in R
https://sizespectrum.org/mizer
38 stars 43 forks source link

Add a callback function to `project()` #236

Open gustavdelius opened 3 years ago

gustavdelius commented 3 years ago

This callback function will be called every time a simulation timestep is saved, i.e., at intervals of t_save. The callback function should be able to update the params object used in the simulation, so that one can implement a time-dependence in the rates, for example. This would be useful for experiments with time-dependent temperature for example. Currently this requires the user to write custom functions for all time-dependent rates. In future they could use the callback function to rescale the rate arrays in the params object and then let the standard mizer rate functions do their job.

gustavdelius commented 3 years ago

Experimentally I decided to introduce two callback functions. save_callback is called only when a result is saved (i.e. at intervals of t_save), whereas step_callback is called at every time step (i.e. at intervals of dt). I'll see which one people will use more. The code is in the callback branch of the mizer repository. So to test it out first do

remotes::install_github("sizespectrum/mizer@callback")