Solve a nonlinear system by damped Newton iteration.
Forms the Newton direction from , then applies
backtracking to reduce the squared-residual merit function. info=0
indicates residual convergence (max-norm below tol); info=1
indicates the iteration limit.
See the module-level callback example.
| Type | Intent | Optional | Attributes | Name | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
public subroutine fun(x, f, J)Arguments
|
||||||||||||||||||||||||||||||||||
| real(kind=dp), | intent(inout) | :: | x(:) |
Initial guess; last iterate on return. |
||||||||||||||||||||||||||||||
| real(kind=dp), | intent(in) | :: | tol |
Absolute residual convergence tolerance. |
||||||||||||||||||||||||||||||
| integer, | intent(in) | :: | max_iter |
Maximum Newton iterations. |
||||||||||||||||||||||||||||||
| integer, | intent(out) | :: | its |
Iteration count at termination. |
||||||||||||||||||||||||||||||
| integer, | intent(out) | :: | info |
0 = converged (max-norm of residuals below |
||||||||||||||||||||||||||||||
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=dp), | public | :: | J(size(X),size(X)) |
Jacobian matrix |
|||
| real(kind=dp), | public | :: | Jp(size(X)) | ||||
| real(kind=dp), | public | :: | alpha |
Backtracking step length |
|||
| real(kind=dp), | public | :: | dx(size(X)) | ||||
| real(kind=dp), | public | :: | f(size(X)) |
Residual or scalar equation value. |
|||
| real(kind=dp), | public | :: | f_norm | ||||
| real(kind=dp), | public | :: | ftrial(size(X)) | ||||
| real(kind=dp), | public | :: | grad_phi_p | ||||
| integer, | public | :: | k |
Loop/index or term index. |
|||
| integer, | public | :: | n |
Number of unknowns |
|||
| real(kind=dp), | public | :: | phi_trial | ||||
| real(kind=dp), | public | :: | phi_x | ||||
| real(kind=dp), | public | :: | xtrial(size(X)) |