You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
solve fails when called on nonlinear systems of equations with vectorial tolerances.
This is for both reltol and abstol.
Since NonlinearSolve is used internally to solve inconsistent DAE initializations in DifferentialEquations.jl, this causes crashes when solving DAEs with a vector supplied for reltol (in fact, this happens for vector-valued abstol as well, if SciML/OrdinaryDiffEq.jl#1214 has been patched out). I think this is a good motivation to consider this a bug either in NonlinearSolve or OrdinaryDiffEqNonlinearSolve.
Reproducable Test
using NonlinearSolve, StaticArrays
f(u, p) = u .* u .-2
u0 =@SVector[1.0, 1.0]
solver =solve(NonlinearProblem(f, u0), reltol=[1e-3, 1e-4])
Stacktrace
ERROR: MethodError: no method matching Float64(::Vector{Float64})
The type `Float64` exists, but no method is defined for this combination of argument types when trying to construct it.
Closest candidates are:Float64(::IrrationalConstants.Halfπ)
@ IrrationalConstants ~/.julia/packages/IrrationalConstants/vp5v4/src/macro.jl:112Float64(::IrrationalConstants.Twoinvπ)
@ IrrationalConstants ~/.julia/packages/IrrationalConstants/vp5v4/src/macro.jl:112Float64(::IrrationalConstants.Inv2π)
@ IrrationalConstants ~/.julia/packages/IrrationalConstants/vp5v4/src/macro.jl:112...
Stacktrace:
[1] convert_real(::Type{Float64}, x::Vector{Float64})
@ NonlinearSolveBase.Utils ~/.julia/packages/NonlinearSolveBase/Kek5u/src/utils.jl:91
[2] get_tolerance(η::Vector{Float64}, ::Type{Float64})
@ NonlinearSolveBase ~/.julia/packages/NonlinearSolveBase/Kek5u/src/common_defaults.jl:37
[3] get_tolerance(::SVector{2, Float64}, η::Vector{Float64}, ::Type{Float64})
@ NonlinearSolveBase ~/.julia/packages/NonlinearSolveBase/Kek5u/src/common_defaults.jl:43
[4] init_termination_cache(prob::NonlinearProblem{…}, abstol::Nothing, reltol::Vector{…}, du::SVector{…}, u::SVector{…}, tc::AbsNormSafeBestTerminationMode{…}, ::Val{…})
@ NonlinearSolveBase ~/.julia/packages/NonlinearSolveBase/Kek5u/src/termination_conditions.jl:295
[5] init_termination_cache(prob::NonlinearProblem{…}, abstol::Nothing, reltol::Vector{…}, du::SVector{…}, u::SVector{…}, ::Nothing, callee::Val{…})
@ NonlinearSolveBase ~/.julia/packages/NonlinearSolveBase/Kek5u/src/termination_conditions.jl:286
[6] __init(::NonlinearProblem{…}, ::GeneralizedFirstOrderAlgorithm{…}; stats::SciMLBase.NLStats, alias_u0::Bool, maxiters::Int64, abstol::Nothing, reltol::Vector{…}, maxtime::Nothing, termination_condition::Nothing, internalnorm::Function, linsolve_kwargs::@NamedTuple{}, initializealg::NonlinearSolveBase.NonlinearSolveDefaultInit, kwargs::@Kwargs{…})
@ NonlinearSolveFirstOrder ~/.julia/packages/NonlinearSolveFirstOrder/3kzAL/src/solve.jl:156
[7] __solve(::NonlinearProblem{…}, ::GeneralizedFirstOrderAlgorithm{…}; kwargs::@Kwargs{…})
@ NonlinearSolveBase ~/.julia/packages/NonlinearSolveBase/Kek5u/src/solve.jl:5
[8] macro expansion
@ ~/.julia/packages/NonlinearSolveBase/Kek5u/src/solve.jl:173 [inlined]
[9] __generated_polysolve(::NonlinearProblem{…}, ::NonlinearSolvePolyAlgorithm{…}; stats::SciMLBase.NLStats, alias_u0::Bool, verbose::Bool, initializealg::NonlinearSolveBase.NonlinearSolveDefaultInit, kwargs::@Kwargs{…})
@ NonlinearSolveBase ~/.julia/packages/NonlinearSolveBase/Kek5u/src/solve.jl:130
[10] __generated_polysolve
@ ~/.julia/packages/NonlinearSolveBase/Kek5u/src/solve.jl:130 [inlined]
[11] #__solve#154
@ ~/.julia/packages/NonlinearSolveBase/Kek5u/src/solve.jl:127 [inlined]
[12] __solve
@ ~/.julia/packages/NonlinearSolveBase/Kek5u/src/solve.jl:124 [inlined]
[13] #__solve#18
@ ~/.julia/packages/NonlinearSolve/IChU2/src/default.jl:27 [inlined]
[14] __solve
@ ~/.julia/packages/NonlinearSolve/IChU2/src/default.jl:24 [inlined]
[15] #__solve#72
@ ~/.julia/packages/DiffEqBase/R2Vjs/src/solve.jl:1438 [inlined]
[16] __solve
@ ~/.julia/packages/DiffEqBase/R2Vjs/src/solve.jl:1429 [inlined]
[17] #solve_call#44
@ ~/.julia/packages/DiffEqBase/R2Vjs/src/solve.jl:634 [inlined]
[18] solve_call
@ ~/.julia/packages/DiffEqBase/R2Vjs/src/solve.jl:591 [inlined]
[19] #solve_up#53
@ ~/.julia/packages/DiffEqBase/R2Vjs/src/solve.jl:1107 [inlined]
[20] solve_up
@ ~/.julia/packages/DiffEqBase/R2Vjs/src/solve.jl:1101 [inlined]
[21] #solve#52
@ ~/.julia/packages/DiffEqBase/R2Vjs/src/solve.jl:1095 [inlined]
[22] top-level scope
@ ~/Projects/scratchpad/dae_vector_init_bug/nonlinear_solve.jl:5
Some type information was truncated. Use `show(err)` to see complete type
Environment
Julia Version 1.11.2
NonlinearSolve v4.3.0
The text was updated successfully, but these errors were encountered:
Description
solve
fails when called on nonlinear systems of equations with vectorial tolerances.This is for both reltol and abstol.
Since NonlinearSolve is used internally to solve inconsistent DAE initializations in DifferentialEquations.jl, this causes crashes when solving DAEs with a vector supplied for reltol (in fact, this happens for vector-valued abstol as well, if SciML/OrdinaryDiffEq.jl#1214 has been patched out). I think this is a good motivation to consider this a bug either in NonlinearSolve or OrdinaryDiffEqNonlinearSolve.
Reproducable Test
Stacktrace
Environment
The text was updated successfully, but these errors were encountered: