Good question. While setting the parameters, and also changing them, is straightforward (check ModelingToolkit.setp
, or remake
, but I recommend the first), when the function changes in its entirety I believe the problem should be remade from scratch — but I am not sure of this. Others with more expertise on this manner should step in for that.
What you can do though (but I am not sure if this is what you want), is make your function be a function of a parameter. So something like (not tested),
@parameters f
I(f,t) = sin(f*t)
Then, you can relatively easily change the frequency and solve the ODE with a bunch of different frequencies when you change f
in the prob_func
of an EnsembleProblem
, for example. But, again, if the function changes, i.e. from sin(t)
to cos(t)
, I am not sure you can avoid a full re-creation of the ReactionSystem
and/or the ODEProblem
.