Skip to content

Commit

Permalink
Merge pull request #205 from SciML/ap/default
Browse files Browse the repository at this point in the history
Default to PolyAlgorithm instead of Newton
  • Loading branch information
ChrisRackauckas authored Feb 24, 2024
2 parents c7802ca + 7456fbe commit 66bd9cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "DiffEqCallbacks"
uuid = "459566f4-90b8-5000-8ac3-15dfb0a30def"
authors = ["Chris Rackauckas <[email protected]>"]
version = "3.0.0"
version = "3.0.1"

[deps]
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Expand Down Expand Up @@ -30,15 +30,15 @@ ForwardDiff = "0.10.36"
Functors = "0.4"
LinearAlgebra = "1.10"
Markdown = "1.10"
NonlinearSolve = "3.6"
NonlinearSolve = "3.7.2"
ODEProblemLibrary = "0.1.5"
OrdinaryDiffEq = "6.68"
Parameters = "0.12"
QuadGK = "2.4"
RecipesBase = "1.3.4"
RecursiveArrayTools = "3.9"
SciMLBase = "2.26"
SciMLSensitivity = "7.49"
SciMLSensitivity = "7.56"
StaticArrays = "1.8"
StaticArraysCore = "1.4"
Sundials = "4.19.2"
Expand Down
17 changes: 6 additions & 11 deletions src/manifold.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ end
SciMLBase.isinplace(::NonAutonomousFunction{iip}) where {iip} = iip

"""
ManifoldProjection(g; nlsolve = missing, save = true, nlls = Val(true),
isinplace = Val(true), autonomous = nothing, resid_prototype = nothing,
kwargs...)
ManifoldProjection(g; nlsolve = nothing, save = true, nlls = Val(true),
isinplace = Val(true), autonomous = nothing, resid_prototype = nothing, kwargs...)
In many cases, you may want to declare a manifold on which a solution lives. Mathematically,
a manifold `M` is defined by a function `g` as the set of points where `g(u) = 0`. An
Expand Down Expand Up @@ -45,7 +44,8 @@ properties.
## Keyword Arguments
- `nlsolve`: A nonlinear solver as defined in the
[NonlinearSolve.jl format](https://docs.sciml.ai/NonlinearSolve/stable/basics/solve/)
[NonlinearSolve.jl format](https://docs.sciml.ai/NonlinearSolve/stable/basics/solve/).
Defaults to a PolyAlgorithm.
- `save`: Whether to do the standard saving (applied after the callback)
- `nlls`: If the problem is a nonlinear least squares problem. `nlls = Val(false)`
generates a `NonlinearProblem` which is typically faster than
Expand Down Expand Up @@ -127,15 +127,10 @@ function Manifold_initialize(
u_modified!(integrator, false)
end

# Since this is applied to every point, we can reasonably assume that the solution is close
# to the initial guess, so we would want to use NewtonRaphson / RobustMultiNewton instead of
# the default one.
function ManifoldProjection(g; nlsolve = missing, save = true, nlls = Val(true),
function ManifoldProjection(g; nlsolve = nothing, save = true, nlls = Val(true),
isinplace = Val(true), autonomous = nothing, resid_prototype = nothing,
kwargs...)
# `nothing` is a valid solver, so this need to be `missing`
_nlls = SciMLBase._unwrap_val(nlls)
_nlsolve = nlsolve === missing ? (_nlls ? GaussNewton() : NewtonRaphson()) : nlsolve
iip = SciMLBase._unwrap_val(isinplace)
if autonomous === nothing
if iip
Expand All @@ -145,7 +140,7 @@ function ManifoldProjection(g; nlsolve = missing, save = true, nlls = Val(true),
end
end
affect! = ManifoldProjection{iip, _nlls, SciMLBase._unwrap_val(autonomous)}(
g, _nlsolve, resid_prototype, kwargs)
g, nlsolve, resid_prototype, kwargs)
condition = (u, t, integrator) -> true
return DiscreteCallback(condition, affect!; initialize = Manifold_initialize,
save_positions = (false, save))
Expand Down

0 comments on commit 66bd9cc

Please sign in to comment.