Skip to content

Commit 32e3ffa

Browse files
fix: fix remake with value dependent on indepvar
1 parent a56253e commit 32e3ffa

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
@@ -713,6 +713,9 @@ function _updated_u0_p_symmap(prob, u0, ::Val{true}, p, ::Val{true}, t0)
713713
end
714714

715715
varmap = merge(u0, p)
716+
if is_time_dependent(prob)
717+
varmap[only(independent_variable_symbols(prob))] = t0
718+
end
716719
for (k, v) in u0
717720
u0[k] = symbolic_type(v) === NotSymbolic() ? v : symbolic_evaluate(v, varmap)
718721
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)