Skip to content

Commit

Permalink
fix: fix remake with value dependent on indepvar
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSabharwal committed Oct 29, 2024
1 parent a56253e commit 32e3ffa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/remake.jl
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,9 @@ function _updated_u0_p_symmap(prob, u0, ::Val{true}, p, ::Val{true}, t0)
end

varmap = merge(u0, p)
if is_time_dependent(prob)
varmap[only(independent_variable_symbols(prob))] = t0
end
for (k, v) in u0
u0[k] = symbolic_type(v) === NotSymbolic() ? v : symbolic_evaluate(v, varmap)
end
Expand Down
9 changes: 9 additions & 0 deletions test/downstream/modelingtoolkit_remake.jl
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,12 @@ end
prob2 = remake(prob; u0 = [x => p], p = [:p => 2.0])
@test prob2[x] 2.0
end

@testset "remake dependent on indepvar" begin
@variables x(t)
@parameters p
@mtkbuild sys = ODESystem([D(x) ~ x * p], t)
prob = ODEProblem(sys, [x => 1.0], (0.0, 1.0), [p => 1.0])
prob2 = remake(prob; u0 = [x => t + 3.0])
@test prob2[x] 3.0
end

0 comments on commit 32e3ffa

Please sign in to comment.