Skip to content

Commit

Permalink
Add check whether relaxation is better than the full step
Browse files Browse the repository at this point in the history
  • Loading branch information
SouthEndMusic committed Aug 29, 2024
1 parent 951df5d commit d3ce2ac
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/OrdinaryDiffEqNonlinearSolve/src/newton.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d3ce2ac

Please sign in to comment.