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

Symbolic indexing fails for Nonlinear problem integrators #662

Closed
TorkelE opened this issue Apr 8, 2024 · 4 comments · Fixed by SciML/NonlinearSolve.jl#406
Closed

Symbolic indexing fails for Nonlinear problem integrators #662

TorkelE opened this issue Apr 8, 2024 · 4 comments · Fixed by SciML/NonlinearSolve.jl#406
Assignees
Labels
bug Something isn't working

Comments

@TorkelE
Copy link
Member

TorkelE commented Apr 8, 2024

A rather niche situation. It was discussed in private correspondence that it probably should work though, but realised there wasn't actually an issue to keep track of it, so raising one here.

using ModelingToolkit, NonlinearSolve

# Creates our system.
@parameters p d
@variables X(t)
eqs = [0 ~ sin(X+p) - d*sqrt(X+1)]
@mtkbuild nlsys = NonlinearSystem(eqs, [X], [p, d])

# Creates an integrator.
nlprob = NonlinearProblem(nlsys, [X => 1.0], [p => 2.0, d => 3.0])
nint = init(nlprob, NewtonRaphson())

# All yield errors.
nint[X]
nint[nlsys.X]
nint[:X]
nint.ps[p]
nint.ps[nlsys.p]
nint.ps[:p]
@TorkelE
Copy link
Member Author

TorkelE commented Jun 9, 2024

A slight follow-up on this. Is it intentional that you cannot use setu on NonlinearProblem integrators (but setp, getp, and getu` all works)? I don't really see in what situation this actually makes sense to do (but neither updating parameters, that was why I got confused).

using ModelingToolkit, NonlinearSolve

# Creates our system.
@parameters p d
@variables t X(t)
eqs = [0 ~ sin(X+p) - d*sqrt(X+1)]
@mtkbuild nlsys = NonlinearSystem(eqs, [X], [p, d])

# Creates an integrator.
nlprob = NonlinearProblem(nlsys, [X => 1.0], [p => 2.0, d => 3.0])
nint = init(nlprob, NewtonRaphson())

nint[X] # works
nint[nlsys.X] # works
nint[:X] # works
nint.ps[p] # works
nint.ps[nlsys.p] # works
nint.ps[:p] # works
nint[X] = 1 # Error
nint[nlsys.X] = 1 # Error
nint[:X] = 1 # Error
nint.ps[p] = 1 # works
nint.ps[nlsys.p] = 1 # works
nint.ps[:p] = 1 # works

@ChrisRackauckas
Copy link
Member

Not intentional, just missing an overload.

@AayushSabharwal
Copy link
Member

setindex! doesn't work, setu does. I'll add the setindex! method

@AayushSabharwal
Copy link
Member

SciML/NonlinearSolve.jl#447

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