Skip to content

Commit

Permalink
fix: fix remake_initializeprob handling of no pre-existing initiali…
Browse files Browse the repository at this point in the history
…zeprob
  • Loading branch information
AayushSabharwal committed Dec 4, 2024
1 parent 24d39af commit a4f30c7
Showing 1 changed file with 4 additions and 27 deletions.
31 changes: 4 additions & 27 deletions src/systems/nonlinear/initializesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -291,33 +291,10 @@ function SciMLBase.remake_initialization_data(sys::ODESystem, odefn, u0, t0, p,
end
else
# there is no initializeprob, so the original problem construction
# had no solvable parameters and had the differential variables
# specified in `u0map`.
if u0 === missing
# the user didn't pass `u0` to `remake`, so they want to retain
# existing values. Fill the differential variables in `u0map`,
# initialization will either be elided or solve for the algebraic
# variables
diff_idxs = isdiffeq.(equations(sys))
for i in eachindex(dvs)
diff_idxs[i] || continue
u0map[dvs[i]] = newu0[i]
end
end
if p === missing
# the user didn't pass `p` to `remake`, so they want to retain
# existing values. Fill all parameters in `pmap` so that none of
# them are solvable.
for p in ps
pmap[p] = getp(sys, p)(newp)
end
end
# all non-solvable parameters need values regardless
for p in ps
haskey(pmap, p) && continue
is_parameter_solvable(p, pmap, defs, guesses) && continue
pmap[p] = getp(sys, p)(newp)
end
# had all variables specified in `u0map`, all parameters specified
# and no parameter dependencies specified.
add_fallbacks!(u0map, dvs, to_varmap(Dict(dvs .=> newu0), dvs))
add_fallbacks!(pmap, ps, to_varmap(Dict(k => getp(sys, k)(newp) for k in ps), ps))
end
if t0 === nothing
t0 = 0.0
Expand Down

0 comments on commit a4f30c7

Please sign in to comment.