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

Indexing a residual of an InitializationProblem #3260

Open
1-Bart-1 opened this issue Dec 4, 2024 · 0 comments
Open

Indexing a residual of an InitializationProblem #3260

1-Bart-1 opened this issue Dec 4, 2024 · 0 comments

Comments

@1-Bart-1
Copy link

1-Bart-1 commented Dec 4, 2024

As described here: https://discourse.julialang.org/t/indexing-a-residual-of-an-initializationproblem/123356?u=bart_van_de_lint
Symbolic indexing on the residual of a solution is not possible yet. This would be a good debugging tool. I would suggest this feature to work similarly to normal symbolic indexing. So instead of sol[symbol] it would work like sol.resid[symbol].

Example:

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

@parameters g
@variables x(t) y(t) [state_priority = 10] λ(t)
eqs = [D(D(x)) ~ λ * x
       D(D(y)) ~ λ * y - g
       x^2 + y^2 ~ 1]
@mtkbuild pend = ODESystem(eqs, t)

iprob = ModelingToolkit.InitializationProblem(pend, 0.0,
    [x => 1, y => 0.0, D(y) => 2.0, λ => 1], [g => 1], guesses ==> 1])
using NonlinearSolve
sol = solve(iprob)
sol.resid[x] # indexing the residual
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant