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() when NL_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 inc receive the load factor \(\lambda\) of the step, see callbacks, which allows configuration-dependent loads such as follower pressures.

When calc_fext accepts the keyword argument lbd, e.g. for prescribed displacements imposed exactly, see callbacks, 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_fext is 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 + kG is rebuilt at every iteration, which gives quadratic convergence when kT is the exact Jacobian of fint. With an.modified_NR = True the tangent stiffness matrix is rebuilt only at the first iteration of each step and every an.compute_every_n iterations, 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. Otherwise eta is reduced by backtracking.

See _check_convergence() for the convergence criteria. A step that does not converge within an.maxNumIter iterations, that diverges or that converges too slowly is repeated with the load increment multiplied by INC_CUT_FACTOR. The divergence and too-slow checks are only activated after NUM_ITER_BEFORE_DIVERGENCE_CHECK iterations, see _check_divergence().

After a step that converged without being cut, the load increment is multiplied by INC_GROWTH_FACTOR, limited by an.maxInc. The last step is adjusted such that the analysis finishes at a load factor of exactly 1.0. The analysis stops earlier, keeping the converged increments, when the load increment becomes smaller than an.minInc.

Parameters:
anAnalysis

Analysis object, the converged load factors and solutions are appended to an.increments and an.cs.

silentbool, optional

A boolean to tell whether the log messages should be printed.

initialIncfloat or None, optional

Initial load increment, an.initialInc is used if None.

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, if an.relTOL is not None

  • max(|R|) <= absTOL, if an.absTOL is not None

Parameters:
anAnalysis

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_fext accepts lbd, see callbacks. 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.

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.maxNumIter corrections were performed, and, after NUM_ITER_BEFORE_DIVERGENCE_CHECK iterations, when the residual diverges or when the convergence is too slow.

Parameters:
anAnalysis

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.

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:
anAnalysis

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. If None it is calculated at c + dc.

silentbool, optional

A boolean to tell whether the log messages should be printed.

lbd_dependentbool, optional

Whether calc_fext accepts lbd, see callbacks; 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.

Returns:
convergedbool

Whether the iterations converged.

dcarray-like

Solution increment, such that c + dc is the solution.

qarray-like or None

The last \(\{q\}\) evaluated, None when lbd_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_WINDOW iterations is not at least too_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