Skip to content

Commit

Permalink
feat: perform limited DAE initialization for null integrators/solutions
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSabharwal committed Sep 16, 2024
1 parent 6079a64 commit c4c28a0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,9 @@ end
function build_null_integrator(prob::AbstractDEProblem, args...;
kwargs...)
sol = solve(prob, args...; kwargs...)
# The DAE initialization in `build_null_solution` may change the parameter
# object `prob.p` via `@set!`, hence use the "new" prob instead of the "old" one.
prob = sol.prob
return NullODEIntegrator{
isinplace(prob), typeof(prob), eltype(prob.tspan), typeof(sol),
typeof(prob.f), typeof(prob.p)
Expand Down Expand Up @@ -675,7 +678,12 @@ function build_null_solution(prob::AbstractDEProblem, args...;
end

timeseries = [Float64[] for i in 1:length(ts)]


if SciMLBase.has_initializeprob(prob.f) && SciMLBase.has_initializeprobpmap(prob.f)
initializeprob = prob.f.initializeprob
nlsol = solve(initializeprob)
@set! prob.p = prob.f.initializeprobpmap(prob, nlsol)
end
build_solution(prob, nothing, ts, timeseries, retcode = ReturnCode.Success)
end

Expand Down

0 comments on commit c4c28a0

Please sign in to comment.