Events that changes parameter values


I am running simulations on chemical reaction systems. Usually for these I have some input signal and I want to investigate what happens to the system when suddenly an input is turned on. Typically I might have a variable (X), representing something which is produced under certain input (i). Typically I could model this as:
dX/dt = i - d*X
(Then X goes on to activate some system.)
using parameters I would express this as:
dX/dt = p[1] - p[2]*X
Now my input is a step, so up and until some timepoint (t0) i (that is p[1]) would be small, i_inactive. But at time t0 the input becomes i_active which is some large number. How would I do to create a callback which changes the parameter value of p[1] to a new value? I think I know how to use the affect! function to change the integrator to change the actual value of X, but how do I change the parameter values (the integrator seems to have no field for the parameter).

At worst I could make i a second variable, which have di/dt = 0, and then change it via the integrator. But this do not feel like the natural solution to the problem?


integrator.p. Note that you do need to be careful when mixing this with methods that have a lazy interpolation though, like Vern7.


Thank you, I will be careful (famous last words…).


I think it’s all but the 3 Vern algorithms (because of lazy interpolation, so only in that odd case where you’re mixing it with solving ODEs). I need to find a way to document that.


in addition it seems like the .p field is not available for the CVODE_BDF() solver.