Skip to content

Commit a4f30c7

Browse files
fix: fix remake_initializeprob handling of no pre-existing initializeprob
1 parent 24d39af commit a4f30c7

File tree

1 file changed

+4
-27
lines changed

1 file changed

+4
-27
lines changed

src/systems/nonlinear/initializesystem.jl

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -291,33 +291,10 @@ function SciMLBase.remake_initialization_data(sys::ODESystem, odefn, u0, t0, p,
291291
end
292292
else
293293
# there is no initializeprob, so the original problem construction
294-
# had no solvable parameters and had the differential variables
295-
# specified in `u0map`.
296-
if u0 === missing
297-
# the user didn't pass `u0` to `remake`, so they want to retain
298-
# existing values. Fill the differential variables in `u0map`,
299-
# initialization will either be elided or solve for the algebraic
300-
# variables
301-
diff_idxs = isdiffeq.(equations(sys))
302-
for i in eachindex(dvs)
303-
diff_idxs[i] || continue
304-
u0map[dvs[i]] = newu0[i]
305-
end
306-
end
307-
if p === missing
308-
# the user didn't pass `p` to `remake`, so they want to retain
309-
# existing values. Fill all parameters in `pmap` so that none of
310-
# them are solvable.
311-
for p in ps
312-
pmap[p] = getp(sys, p)(newp)
313-
end
314-
end
315-
# all non-solvable parameters need values regardless
316-
for p in ps
317-
haskey(pmap, p) && continue
318-
is_parameter_solvable(p, pmap, defs, guesses) && continue
319-
pmap[p] = getp(sys, p)(newp)
320-
end
294+
# had all variables specified in `u0map`, all parameters specified
295+
# and no parameter dependencies specified.
296+
add_fallbacks!(u0map, dvs, to_varmap(Dict(dvs .=> newu0), dvs))
297+
add_fallbacks!(pmap, ps, to_varmap(Dict(k => getp(sys, k)(newp) for k in ps), ps))
321298
end
322299
if t0 === nothing
323300
t0 = 0.0

0 commit comments

Comments
 (0)