Closed TorkelE closed 2 months ago
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
Not intentional, just missing an overload.
setindex!
doesn't work, setu
does. I'll add the setindex!
method
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.