Skip to content

newton_raphson

gripyth.solving.newton_raphson

Newton-Raphson solver.

FUNCTION DESCRIPTION
newton_raphson

Solves for field iteratively using the Newton-Raphson method.

newton_raphson

newton_raphson(
    assemble: Callable[
        [NDArray[float64]],
        tuple[NDArray[float64], NDArray[float64]],
    ],
    field: NDArray[float64],
    active_dof: NDArray[int32],
    i_row: NDArray[int32],
    j_col: NDArray[int32],
    d_rhs_tract: NDArray[float64] | None = None,
    max_iter: int = 500,
    min_iter: int = 1,
    res_tol: float = 1e-06,
) -> tuple[NDArray[float64], float64, float64]

Solves for field iteratively using the Newton-Raphson method.

assemble is a function object that accepts field and returns (K_vector, residual), i.e. the vectorized elements of the system stiffness matrix and the residual vector of the field. It is typically, if not always, implemented as a closure in the caller's scope, as it will require knowledge of model attributes, such as mesh and material, in order to call the actual assembly routine. In other words, the closure separates what is relevant to the Newton-Raphson method from everything that is not.

active_dof is an array of indices into field marking the active degrees of freedom. i_row and j_col are the sparse-matrix indices corresponding to K_vector. They are thus expected to not change over Newton-Raphson iterations. d_rhs_tract is an optional right-hand side of tractions, assumed to be zero if not provided. min_iter and max_iter restrict the number of Newton-Raphson iterations to be performed to reach convergence. res_tol is the tolerance for the norm of the residual vector that determines if convergence has been reached.

Returns the solution of field as well as residual norms from the first and last iteration.

Raises ArithmeticError if the Newton-Raphson solver failed to converge.