Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: minor updates to SteadyStateDiff #82

Merged
merged 1 commit into from
Aug 30, 2024
Merged

Conversation

avik-pal
Copy link
Member

  • changing to explicit imports, so that we can remove DiffEqBae once NonlinearSolveBase is ready
  • Rodas5 seems to give incorrect results on get_du(integrator) -- changed the tests at least temporarily to use Tsit5

@avik-pal
Copy link
Member Author

julia> sol = solve(prob, DynamicSS(Rodas5()); abstol = 1e-9, reltol = 1e-9)
(integrator.u, integrator.uprev, t, get_du(integrator)) = ([0.00019998000133326593, 9.998000233313312e-9], [0.0, 0.0], 9.999999999999999e-5, [0.0, 0.0])
retcode: Terminated
Interpolation: specialized 4rd order "free" stiffness-aware interpolation
t: 2-element Vector{Float64}:
 0.0
 9.999999999999999e-5
u: 2-element Vector{Vector{Float64}}:
 [0.0, 0.0]
 [0.00019998000133326593, 9.998000233313312e-9]
retcode: Success
u: 2-element Vector{Float64}:
 0.00019998000133326593
 9.998000233313312e-9

julia> sol = solve(prob, DynamicSS(Tsit5()); abstol = 1e-9, reltol = 1e-9)
(integrator.u, integrator.uprev, t, get_du(integrator)) = ([0.00019998000133326663, 9.998000233313266e-9], [0.0, 0.0], 9.999999999999999e-5, [1.9996000399973335, 0.00019994000933233337])
(integrator.u, integrator.uprev, t, get_du(integrator)) = ([0.002197581773691028, 1.207341413014797e-6], [0.00019998000133326663, 9.998000233313266e-9], 0.0010999999999999998, [1.995604836452618, 0.002192752408038969])

@oscardssmith: Chris mentioned you might know what is going on here ("it must just be giving k1")

@avik-pal
Copy link
Member Author

@ChrisRackauckas the SciMLSensitivity test failures you mentioned the other day, have the same issue.

function G(p)
    tmp_prob = remake(prob, u0 = convert.(eltype(p), prob.u0), p = p)
    sol = solve(tmp_prob, DynamicSS(Tsit5()); abstol = 1e-14, reltol = 1e-14)
    A = convert(Array, sol)
    g(A, p, nothing)
end
res1 = ForwardDiff.gradient(G, p)
res2 = Calculus.gradient(G, p)

^This fixes it (only changing the solver)

@avik-pal avik-pal marked this pull request as ready for review August 30, 2024 15:12
@oscardssmith
Copy link
Contributor

oscardssmith commented Aug 30, 2024

does Rodas5P work? It's almost always better than Rodas5.

@avik-pal
Copy link
Member Author

No Rodas5P doesn't work, TRBDF2 does work

@oscardssmith
Copy link
Contributor

@ChrisRackauckas shouldn't fsallast be an accurate derivative?

@ChrisRackauckas
Copy link
Member

If it's an FSAL method SciML/OrdinaryDiffEq.jl#2445

@ChrisRackauckas ChrisRackauckas merged commit fc8bd7d into master Aug 30, 2024
3 checks passed
@ChrisRackauckas ChrisRackauckas deleted the ap/updates branch August 30, 2024 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants