@@ -543,6 +543,7 @@ function SciMLBase.remake_initialization_data(
543
543
if u0 === missing && p === missing
544
544
return odefn. initialization_data
545
545
end
546
+
546
547
if ! (eltype (u0) <: Pair ) && ! (eltype (p) <: Pair )
547
548
oldinitdata = odefn. initialization_data
548
549
oldinitdata === nothing && return nothing
@@ -658,6 +659,18 @@ function SciMLBase.late_binding_update_u0_p(
658
659
prob, sys:: AbstractSystem , u0, p, t0, newu0, newp)
659
660
supports_initialization (sys) || return newu0, newp
660
661
u0 === missing && return newu0, (p === missing ? copy (newp) : newp)
662
+ # If the user passes `p` to `remake` but not `u0` and `u0` isn't empty,
663
+ # and if the system supports initialization (so it has initial parameters),
664
+ # and if the initialization solves for `u0`,
665
+ # THEN copy the values of `Initial`s to `newu0`.
666
+ if u0 === missing && newu0 != = nothing && p != = missing && supports_initialization (sys) && prob. f. initialization_data != = nothing && prob. f. initialization_data. initializeprobmap != = nothing
667
+ if ArrayInterface. ismutable (newu0)
668
+ copyto! (newu0, getu (sys, Initial .(unknowns (sys)))(newp))
669
+ else
670
+ T = StaticArrays. similar_type (newu0)
671
+ newu0 = T (getu (sys, Initial .(unknowns (sys)))(newp))
672
+ end
673
+ end
661
674
# non-symbolic u0 updates initials...
662
675
if ! (eltype (u0) <: Pair )
663
676
# if `p` is not provided or is symbolic
0 commit comments