Skip to content

Commit adb8af8

Browse files
fix: fix remake with value dependent on indepvar
1 parent bd081d0 commit adb8af8

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/remake.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,9 @@ function _updated_u0_p_symmap(prob, u0, ::Val{true}, p, ::Val{true}, t0)
711711
end
712712

713713
varmap = merge(u0, p)
714+
if is_time_dependent(prob)
715+
varmap[only(independent_variable_symbols(prob))] = t0
716+
end
714717
for (k, v) in u0
715718
u0[k] = symbolic_type(v) === NotSymbolic() ? v : symbolic_evaluate(v, varmap)
716719
end

test/downstream/modelingtoolkit_remake.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,12 @@ end
239239
prob2 = remake(prob; u0 = [x => p], p = [:p => 2.0])
240240
@test prob2[x] 2.0
241241
end
242+
243+
@testset "remake dependent on indepvar" begin
244+
@variables x(t)
245+
@parameters p
246+
@mtkbuild sys = ODESystem([D(x) ~ x * p], t)
247+
prob = ODEProblem(sys, [x => 1.0], (0.0, 1.0), [p => 1.0])
248+
prob2 = remake(prob; u0 = [x => t + 3.0])
249+
@test prob2[x] 3.0
250+
end

0 commit comments

Comments
 (0)