Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check whether relaxation is better than the full step #2443

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions lib/OrdinaryDiffEqNonlinearSolve/src/newton.jl
Original file line number Diff line number Diff line change
@@ -456,8 +456,11 @@ function relax!(dz, nlsolver::AbstractNLSolver, integrator::DEIntegrator, f::TF,
end
α0 = one(eltype(ustep))
ϕ0, dϕ0 = ϕdϕ(zero(α0))
α, _ = linesearch(ϕ, dϕ, ϕdϕ, α0, ϕ0, dϕ0)
@.. dz = dz * α
α, ϕα = linesearch(ϕ, dϕ, ϕdϕ, α0, ϕ0, dϕ0)
# Check whether relaxation is better than the full step
if ϕα < ϕ(1)
@.. dz = dz * α
end
return dz
end
end
@@ -510,8 +513,11 @@ function relax(dz, nlsolver::AbstractNLSolver, integrator::DEIntegrator, f::TF,
end
α0 = one(eltype(dz))
ϕ0, dϕ0 = ϕdϕ(zero(α0))
α, _ = linesearch(ϕ, dϕ, ϕdϕ, α0, ϕ0, dϕ0)
dz = dz * α
α, ϕα = linesearch(ϕ, dϕ, ϕdϕ, α0, ϕ0, dϕ0)
# Check whether relaxation is better than the full step
if ϕα < ϕ(1)
dz = dz * α
end
return dz
end
end