Skip to content

Commit

Permalink
Default to PolyAlgorithm instead of Newton
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Feb 22, 2024
1 parent c7802ca commit 769d850
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion 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
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 769d850

Please sign in to comment.