Closed aabills closed 8 months ago
The problem is that p
is not a keyword argument for NonlinearProblem
, so passing p
as you are doing it gets pushed into prob.kwargs
instead:
julia> prob = NonlinearProblem(mwe, [5.2], p=p)
NonlinearProblem with uType Vector{Float64}. In-place: true
u0: 1-element Vector{Float64}:
5.2
julia> prob.p
SciMLBase.NullParameters()
julia> prob.kwargs
pairs(::NamedTuple) with 1 entry:
:p => [5.0]
It works if you don't do this -
using NonlinearSolve
function mwe(out, u, p)
out[1] = u[1] - p[1]
end
p = [5.0]
prob = NonlinearProblem(mwe, [5.2], p)
prob.p
prob.kwargs
u = solve(prob, NewtonRaphson())
prob2 = remake(prob, p=[6.0])
u2 = solve(prob2, NewtonRaphson())
julia> u
u: 1-element Vector{Float64}:
5.0
julia> u2
u: 1-element Vector{Float64}:
6.0
We should probably catch and throw an error if someone does p = ...
.
MWE:
Results in:
But when looking at
?remake
:I don't know if this is expected behavior (and maybe should result in an error or a warning) or should just be fixed, but I felt like it should be reported as it can result in a silent wrong answer.