neml2.solvers¶
Python-native linear and nonlinear solvers.
_result–RetCode,NonlinearResult.dense_lu–DenseLU.schur_complement–SchurComplement.newton–Newton.newton_linesearch–NewtonWithLineSearch._helpers– private reduction / scaling helpers.
- class neml2.solvers.DenseLU[source]¶
Bases:
objectDense LU linear solver. Assembles the (possibly) sparse matrix into a dense one and uses a standard LU decomposition.
The dense-vs-block-diagonal dispatch is implicit in the wrapped
Tensoroperand:Tensor.solveforwards totorch.linalg.solveon the trailing matrix dims, so leading sub-batch axes (if any) batch naturally as independent LUs per site – no special-case code at this layer.- SECTION = 'Solvers'¶
- classmethod from_hit(node, factory)[source]¶
- Parameters:
node (nmhit.Node)
factory (_NativeInputFile)
- Return type:
- hit = <neml2.schema.HitSchema object>¶
- solve(A: AssembledMatrix, b: AssembledVector) AssembledVector[source]¶
- solve(A: AssembledMatrix, b: AssembledMatrix) AssembledMatrix
- class neml2.solvers.Newton(*, linear_solver=None, atol=1e-10, rtol=1e-08, miters=25, verbose=False)[source]¶
Bases:
objectThe standard Newton-Raphson solver which always takes the ‘full’ Newton step.
- Parameters:
- SECTION = 'Solvers'¶
Inherited by
NewtonWithLineSearch.
- classmethod from_hit(node, factory)[source]¶
- Parameters:
node (nmhit.Node)
factory (_NativeInputFile)
- Return type:
- hit = <neml2.schema.HitSchema object>¶
- solve(system)[source]¶
Solve the nonlinear system via the shared C++ Newton solver.
The iteration control (convergence test, line search) lives in C++ and is shared with the AOTI runtime; this wrapper supplies the residual / Newton-step callbacks (the
RHS/NewtonStepexport modules, run eagerly) plus the per-group layouts, then commits the converged iterate back into the system.- Parameters:
system (ModelNonlinearSystem)
- Return type:
- class neml2.solvers.NewtonWithLineSearch(*, linear_solver=None, atol=1e-10, rtol=1e-08, miters=25, verbose=False, linesearch_type='BACKTRACKING', max_linesearch_iterations=10, linesearch_cutback=2.0, linesearch_stopping_criteria=0.001, check_negative_criterion=False)[source]¶
Bases:
NewtonThe Newton-Raphson solver with line search.
- Parameters:
- classmethod from_hit(node, factory)[source]¶
- Parameters:
node (nmhit.Node)
factory (_NativeInputFile)
- Return type:
- hit = <neml2.schema.HitSchema object>¶
- class neml2.solvers.NonlinearResult(ret, iterations)[source]¶
Bases:
objectResult metadata returned by a nonlinear solve.
- class neml2.solvers.RetCode(value)[source]¶
Bases:
EnumNonlinear solver return code.
- FAILURE = 2¶
- MAXITER = 1¶
- SUCCESS = 0¶
- class neml2.solvers.SchurComplement(*, residual_primary_group=0, unknown_primary_group=0, primary_solver=None, schur_solver=None)[source]¶
Bases:
objectSchur complement linear solver. Solves a block-partitioned system
A x = bby forming and solving the Schur complement of the primary block.The six-step factorisation reads naturally on top of the
Tensor-backedAssembledMatrix/AssembledVectorarithmetic –A_pp.solve(...),A_sp @ Y,A_ss - A_sp @ Yall forward to the typed primitive.- SECTION = 'Solvers'¶
- classmethod from_hit(node, factory)[source]¶
- Parameters:
node (nmhit.Node)
factory (_NativeInputFile)
- Return type:
- hit = <neml2.schema.HitSchema object>¶
- solve(A: AssembledMatrix, b: AssembledVector) AssembledVector[source]¶
- solve(A: AssembledMatrix, b: AssembledMatrix) AssembledMatrix