Skip to content

Commit fae7a7a

Browse files
feat: perform limited DAE initialization for null integrators/solutions
1 parent af23a65 commit fae7a7a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/solve.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,9 @@ end
626626
function build_null_integrator(prob::AbstractDEProblem, args...;
627627
kwargs...)
628628
sol = solve(prob, args...; kwargs...)
629+
# The DAE initialization in `build_null_solution` may change the parameter
630+
# object `prob.p` via `@set!`, hence use the "new" prob instead of the "old" one.
631+
prob = sol.prob
629632
return NullODEIntegrator{
630633
isinplace(prob), typeof(prob), eltype(prob.tspan), typeof(sol),
631634
typeof(prob.f), typeof(prob.p)
@@ -675,7 +678,12 @@ function build_null_solution(prob::AbstractDEProblem, args...;
675678
end
676679

677680
timeseries = [Float64[] for i in 1:length(ts)]
678-
681+
682+
if SciMLBase.has_initializeprob(prob.f) && SciMLBase.has_initializeprobpmap(prob.f)
683+
initializeprob = prob.f.initializeprob
684+
nlsol = solve(initializeprob)
685+
@set! prob.p = prob.f.initializeprobpmap(prob, nlsol)
686+
end
679687
build_solution(prob, nothing, ts, timeseries, retcode = ReturnCode.Success)
680688
end
681689

0 commit comments

Comments
 (0)