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

Cannot (re)make problems with defaults involving the independent parameter #2799

Closed
hersle opened this issue Jun 12, 2024 · 2 comments · Fixed by #2820
Closed

Cannot (re)make problems with defaults involving the independent parameter #2799

hersle opened this issue Jun 12, 2024 · 2 comments · Fixed by #2820
Assignees
Labels
bug Something isn't working

Comments

@hersle
Copy link
Contributor

hersle commented Jun 12, 2024

Currently, it seems to me that remake cannot reinitialize a system using defaults that involve the independent parameter (often t). It would be nice if this worked:

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

@variables x(t) y(t)
@mtkbuild sys = ODESystem([D(x) ~ 0, D(y) ~ 0], t; defaults = [y => t])
prob = ODEProblem(sys, unknowns(sys) .=> NaN, (1.0, 2.0), []) # uninitialized problem

# I expect one or more (preferably all) of these to initialize y = t = 1.0 from the default
prob1 = remake(prob, use_defaults = true, u0 = [x => 0.0])
prob2 = remake(prob, use_defaults = true, u0 = [x => 0.0], tspan = (1.0, 2.0))
prob3 = remake(prob, use_defaults = true, u0 = [x => 0.0], tspan = (1.0, 2.0), p = [t => 1.0])

All three fail with slightly different error messages.

@hersle hersle added the bug Something isn't working label Jun 12, 2024
@hersle hersle changed the title Cannot remake problems with defaults involving the independent parameter Cannot (re)make problems with defaults involving the independent parameter Jun 25, 2024
@hersle
Copy link
Contributor Author

hersle commented Jun 25, 2024

More fundamentally, it is not possible to make (not remake) an ODEProblem with defaults involving the independent parameter:

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

@variables x(t)
@mtkbuild sys = ODESystem([D(x) ~ 0], t; defaults = [x => t])
prob = ODEProblem(structural_simplify(sys), [], (1.0, 2.0), [])

I should probably have reported this first. I add it here since it is very related.

@ChrisRackauckas
Copy link
Member

Yeah that shouldn't be too hard to solve.

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