Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remake does not respect initial conditions of unknowns determined by initialization equations #2841

Open
hersle opened this issue Jul 3, 2024 · 3 comments · May be fixed by #2844
Open

Remake does not respect initial conditions of unknowns determined by initialization equations #2841

hersle opened this issue Jul 3, 2024 · 3 comments · May be fixed by #2844
Assignees
Labels
bug Something isn't working

Comments

@hersle
Copy link
Contributor

hersle commented Jul 3, 2024

This example fails (but passes with the commented line uncommented):

using Test
using ModelingToolkit
using ModelingToolkit: t_nounits as t, D_nounits as D
using DifferentialEquations

@variables x(t)
@named sys = ODESystem([D(x) ~ 0], t; initialization_eqs = [x ~ 1.0]) # test fails with this uncommented
#@named sys = ODESystem([D(x) ~ 0], t; defaults = [x => 1.0]) # test passes with this uncommented
ssys = structural_simplify(sys)

prob1 = ODEProblem(ssys, [], (0.0, 1.0), [])
prob2 = remake(prob1, u0 = [x => 2.0])
sol2 = solve(prob2)
@test sol2[x][begin] == 2.0
@hersle hersle added the bug Something isn't working label Jul 3, 2024
@hersle
Copy link
Contributor Author

hersle commented Jul 3, 2024

I can kind of understand why. If I say that x ~ 1.0 during initialization, it would be inconsistent to override that with x => 2.0 in remake. But then I think remake could throw an error to avoid ambiguity.

@ChrisRackauckas
Copy link
Member

This should fail with an initialization failure. @AayushSabharwal I think we discussed this one, the initialization problem needs to be rebuilt if the choices for the initial conditions change.

@AayushSabharwal
Copy link
Member

Right, I'll think of a way to build that infrastructure

@AayushSabharwal AayushSabharwal linked a pull request Jul 5, 2024 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants