Newton-Raphson solver (structsolve.newton_raphson)#
Newton-Raphson solver for non-linear static analyses
The module-level constants control the step size and the divergence checks,
and they are shared with the arc-length solvers of
structsolve.arc_length.
The solver is used through Analysis.static() with
Analysis.NL_method = 'NR'.
- structsolve.newton_raphson._solver_NR(an, silent=False, initialInc=None)#
Newton-Raphson solver with load control
Used by
Analysis.static()whenNL_method='NR'. The load factor \(\lambda\) goes from zero to one in increments, solving at each increment\[\{R\} = \lambda \{F_{ext}\} - \{F_{int}(c)\} = \{0\}\]Each increment starts from a predictor that extrapolates the previous converged increment of the solution, scaled by the ratio between the new and the previous load increments. The first increment uses the linear solution as predictor.
The callables that accept the keyword argument
increceive the load factor \(\lambda\) of the step, seecallbacks, which allows configuration-dependent loads such as follower pressures.When
calc_fextaccepts the keyword argumentlbd, e.g. for prescribed displacements imposed exactly, seecallbacks, the load vector \(\{q\} = \partial R/\partial \lambda\) at \(c = 0\), \(\lambda = 0\) gives the predictor of the first increment, its linear solution \([K_0]^{-1}\{q\}\), instead of the linear solution of the reference vector, which is null under a prescribed displacement alone, and \(\lambda \|q\|\) is an additional reference of the relative convergence criterion. \(\{q\}\) is evaluated together with the tangent stiffness matrix, at the same iterate, i.e.calc_fextis called once per update of the tangent stiffness matrix, and the last \(\{q\}\) evaluated is the reference of the next convergence checks, also in the next step.By default full Newton-Raphson is used, i.e. the tangent stiffness matrix
kT = kC + kGis rebuilt at every iteration, which gives quadratic convergence whenkTis the exact Jacobian offint. Withan.modified_NR = Truethe tangent stiffness matrix is rebuilt only at the first iteration of each step and everyan.compute_every_niterations, and its LU factorization is reused in the other iterations.With
an.line_search = True, the full Newton step (eta = 1) is tried first and it is accepted if it satisfies a sufficient-decrease test on the residual norm. Otherwiseetais reduced by backtracking.See
_check_convergence()for the convergence criteria. A step that does not converge withinan.maxNumIteriterations, that diverges or that converges too slowly is repeated with the load increment multiplied byINC_CUT_FACTOR. The divergence and too-slow checks are only activated afterNUM_ITER_BEFORE_DIVERGENCE_CHECKiterations, see_check_divergence().After a step that converged without being cut, the load increment is multiplied by
INC_GROWTH_FACTOR, limited byan.maxInc. The last step is adjusted such that the analysis finishes at a load factor of exactly1.0. The analysis stops earlier, keeping the converged increments, when the load increment becomes smaller thanan.minInc.- Parameters:
- an
Analysis Analysis object, the converged load factors and solutions are appended to
an.incrementsandan.cs.- silentbool, optional
A boolean to tell whether the log messages should be printed.
- initialIncfloat or None, optional
Initial load increment,
an.initialIncis used ifNone.
- an
Convergence and divergence checks#
- structsolve.newton_raphson._check_convergence(an, R, fint, fext_total, fext_ref=None, q_ref=None)#
Check the convergence of the residual force vector
The convergence is achieved when either:
||R|| <= relTOL*max(||fext_total||, ||fint||, ||fext_ref||, ||q_ref||), using the Euclidean norm, ifan.relTOLis notNonemax(|R|) <= absTOL, ifan.absTOLis notNone
- Parameters:
- an
Analysis Analysis object with the convergence criteria.
- Rarray-like
Residual force vector.
- fintarray-like
Internal force vector.
- fext_totalarray-like
External force vector at the current load factor.
- fext_refarray-like or None, optional
Additional reference force vector, e.g. the external force vector of the current increment, useful when the load factor is close to zero.
- q_refarray-like or None, optional
Additional reference force vector, the load factor times \(\partial R/\partial \lambda\) when
calc_fextacceptslbd, seecallbacks. Under a prescribed displacement alone, the external and the internal force vectors of the reduced problem both vanish at equilibrium and cannot be the reference.
- an
- Returns:
- convergedbool
Whether the convergence criteria are satisfied.
- Rnormfloat
Euclidean norm of the residual.
- Rrelfloat
Relative residual
||R||/max(||fext_total||, ||fint||, ||fext_ref||, ||q_ref||).
- structsolve.newton_raphson._check_divergence(an, Rnorm, Rnorms, iteration, silent=False)#
Check if the iterations of a step must be stopped without convergence
The iterations are stopped when the residual is not finite, when
an.maxNumItercorrections were performed, and, afterNUM_ITER_BEFORE_DIVERGENCE_CHECKiterations, when the residual diverges or when the convergence is too slow.- Parameters:
- an
Analysis Analysis object with the convergence criteria.
- Rnormfloat
Norm of the residual at the current iteration.
- Rnormslist
Norms of the residual at the previous iterations of the step, the current norm is appended to it.
- iterationint
Current iteration, starting at 1.
- silentbool, optional
A boolean to tell whether the log messages should be printed.
- an
- Returns:
- stopbool
Whether the iterations must be stopped.
- structsolve.newton_raphson._NR_iterations(an, c, dc, total, fext, kT0=None, silent=False, lbd_dependent=False, q=None)#
Newton-Raphson iterations at a fixed load factor
- Parameters:
- an
Analysis Analysis object.
- carray-like
Solution at the last converged state.
- dcarray-like
Predictor of the solution increment.
- totalfloat
Load factor.
- fextarray-like
External force vector for a unit load factor.
- kT0sparse matrix or None, optional
Tangent stiffness matrix used in the first iteration when
an.modified_NR=True. IfNoneit is calculated atc + dc.- silentbool, optional
A boolean to tell whether the log messages should be printed.
- lbd_dependentbool, optional
Whether
calc_fextacceptslbd, seecallbacks;total*q, with \(\{q\} = \partial R/\partial \lambda\), is then an additional reference of the relative convergence criterion, see_check_convergence(). \(\{q\}\) is evaluated together with the tangent stiffness matrix, at the same iterate, and the last one evaluated is the reference until the next update of the tangent.- qarray-like or None, optional
The last \(\{q\}\) evaluated before these iterations, the reference until the first update of the tangent stiffness matrix, used only when
lbd_dependent=True.
- an
- Returns:
- convergedbool
Whether the iterations converged.
- dcarray-like
Solution increment, such that
c + dcis the solution.- qarray-like or None
The last \(\{q\}\) evaluated,
Nonewhenlbd_dependent=False.
Constants#
- structsolve.newton_raphson.NUM_ITER_BEFORE_DIVERGENCE_CHECK = 5#
Number of iterations of a step before the divergence and too-slow checks are activated. A non-monotonic residual in the first iterations is normal, especially in postbuckling
- structsolve.newton_raphson.DIVERGENCE_FACTOR = 1000.0#
A step diverged when its residual norm becomes larger than this factor times the residual norm at the start of the step
- structsolve.newton_raphson.TOO_SLOW_WINDOW = 5#
The convergence is too slow when the smallest residual norm of the last
TOO_SLOW_WINDOWiterations is not at leasttoo_slow_TOL(relative) smaller than the smallest residual norm of the previous iterations
- structsolve.newton_raphson.LINE_SEARCH_ALPHA = 0.0001#
Constant of the sufficient-decrease (Armijo) test of the line search
- structsolve.newton_raphson.INC_GROWTH_FACTOR = 1.1111#
Factor used to increase the load increment after a step that converged without being cut
- structsolve.newton_raphson.INC_CUT_FACTOR = 0.5#
Factor used to reduce the load increment when a step fails to converge