SciML / SciMLBase.jl

The Base interface of the SciML ecosystem
https://docs.sciml.ai/SciMLBase/stable
MIT License
127 stars 92 forks source link

Include remake in example for ODEProblem #488

Open nonsciencemark opened 11 months ago

nonsciencemark commented 11 months ago

Adding four lines for remake of ODEProblem would save new users a lot of time remaking the same ODE while changing parameters e.g.,

using SciMLBase
function lorenz!(du,u,p,t)
  du[1] = 10.0(u[2]-u[1])
  du[2] = u[1]*(28.0-u[3]) - u[2]
  du[3] = u[1]*u[2] - (8/3)*u[3]
end
u0 = [1.0;0.0;0.0]
tspan = (0.0,100.0)
prob = ODEProblem(lorenz!,u0,tspan)

# Test that it worked
using OrdinaryDiffEq
sol = solve(prob,Tsit5())
using Plots; plot(sol,vars=(1,2,3))

# Try with new u0 and tspan
prob = remake(prob; u0 = [2.0;0.0;0.0], tspan = (0.0,50.0))
sol = solve(prob,Tsit5())
using Plots; plot(sol,vars=(1,2,3))
ChrisRackauckas commented 11 months ago

I think it's reasonable. You mean add it to the first tutorial?

nonsciencemark commented 11 months ago

Yes. I think that examples of remake like above would be useful in in the first tutorial as well as in line 82 in the source so that it's visible with ?ODEProblem[^but].

There are also cases in the problem library which ?ODEProblem leads to that create new ODEProblems instead of using remake.

Also the part of the FAQ that mentions this functionality could be renamed so that it is more easily findable. Not sure what synonyms would be appropriate but searching e.g., "update/change/modify parameters/state/tspan" don't seem to get you to this information.

[^but]: maybe this would lead to bloat creep, but it does already have plot

ChrisRackauckas commented 11 months ago

100% agreed.

There are also cases in the problem library which ?ODEProblem leads to that create new ODEProblems instead of using remake.

It would be good to get an issue open there. Those cases were probably just implemented before remake was created, so it was never updated.

Also the part of the FAQ that mentions this functionality could be renamed so that it is more easily findable. Not sure what synonyms would be appropriate but searching e.g., "update/change/modify parameters/state/tspan" don't seem to get you to this information.

"Updating or modifying states and parameters of an already built problem" ?

nonsciencemark commented 11 months ago

"Updating or modifying states and parameters of an already built problem"

I think that would be better, yes.

It would be good to get an issue open there

Will open a new issue over there when I have a bit of time