SciML / SteadyStateDiffEq.jl

Solvers for steady states in scientific machine learning (SciML)
Other
30 stars 22 forks source link

Passing Callbacks to DynamicSS #59

Closed axla-io closed 1 year ago

axla-io commented 1 year ago

This is a PR that enables passing callbacks to DynamicSS. In the current implementation no user inputted callback will be sent to the solver.

So I'm imagining something like this.

ChrisRackauckas commented 1 year ago

Oops, shouldn't merge quite yet. Can you add a test?

axla-io commented 1 year ago

Ah! Yes sure!

axla-io commented 1 year ago

I've added a saving callback test now. There might be a bug present because I have to set save_everystep = true and save_start = true in both the callback definition and the solve call for the test to work. Though this does not seem to be related to the functionality added by this PR.

i.e. this doesn't work:

using DiffEqCallbacks
u0 = zeros(2)
prob = SteadyStateProblem(f, u0)
saved_values = SavedValues(Float64, Vector{Float64})
cb = SavingCallback((u, t, integrator) -> copy(u), saved_values,
                    save_everystep = false, save_start = false)
sol = solve(prob, DynamicSS(Rodas5()), callback = cb)
@test sol.retcode == ReturnCode.Success
@test length(saved_values.saveval) == 1