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
Copy file name to clipboardExpand all lines: src/initialization.jl
+49-4Lines changed: 49 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -68,6 +68,51 @@ function Base.showerror(io::IO, e::OverrideInitMissingAlgorithm)
68
68
"OverrideInit specified but no NonlinearSolve.jl algorithm provided. Provide an algorithm via the `nlsolve_alg` keyword argument to `get_initial_values`.")
69
69
end
70
70
71
+
struct NoNonlinearSolverError <:Exception
72
+
end
73
+
74
+
function Base.showerror(io::IO, err::NoNonlinearSolverError)
75
+
println(io, """
76
+
This problem requires initialization and thus a nonlinear solve, but no nonlinear \
77
+
solve has been loaded. If you are using OrdinaryDiffEq, import the \
78
+
`OrdinaryDiffEqNonlinearSolve` package or pass a custom `nlsolve` into the \
79
+
`initializealg`. If you are not using `OrdinaryDiffEq`, please open an issue in \
80
+
the appropriate library with an MWE.
81
+
""")
82
+
end
83
+
84
+
"""
85
+
$(TYPEDSIGNATURES)
86
+
87
+
Given a user-provided nonlinear solve algorithm `alg`, `iip::Union{Val{true}, Val{false}}`
88
+
indicating whether the initialization problem is in-place or not, the initial state
89
+
vector of the initialization problem, the initialization problem (either a
90
+
`NonlinearProblem` or `NonlinearLeastSquaresProblem`) and a boolean `autodiff`
91
+
indicating whether to use `AutoForwardDiff` or `AutoFiniteDiff`, return a nonlinear
92
+
solve algorithm to use for solving the initialization. If `alg` is not nothing, it will
93
+
be returned as-is. If the initialization problem is trivial (`u === nothing`) the trivial
94
+
`nothing` algorithm will be used. Otherwise, requires `NonlinearSolve.jl` to
95
+
automatically find an appropriate solver.
96
+
"""
97
+
override_init_get_nlsolve(alg, iip, u, prob, autodiff =false) = alg
98
+
99
+
for iip in (Val{true}, Val{false}), prob in (NonlinearProblem, NonlinearLeastSquaresProblem)
0 commit comments