NewtonKrylov
- class cubie.integrators.matrix_free_solvers.NewtonKrylov(precision: type[float16] | type[float32] | type[float64] | dtype[float16] | dtype[float32] | dtype[float64], solver_width: int, linear_solver: LinearSolverBase, norm: CorrectionNorm | None = None, **kwargs)[source]
Bases:
MatrixFreeSolverFactory for Newton–Krylov solver device functions.
Uses a matrix-free linear solver for each Newton correction.
- Parameters:
precision (PrecisionDType) – Numerical precision for computations.
solver_width (int) – Solver vector length.
linear_solver (LinearSolverBase) –
LinearSolverBaseinstance for solving linear systems.**kwargs – Forwarded to
NewtonKrylovConfigand the norm factory. Includes prefixed tolerance parameters (newton_atol,newton_rtol).
- __init__(precision: type[float16] | type[float32] | type[float64] | dtype[float16] | dtype[float32] | dtype[float64], solver_width: int, linear_solver: LinearSolverBase, norm: CorrectionNorm | None = None, **kwargs) None[source]
Initialize NewtonKrylov with parameters.
- Parameters:
precision (PrecisionDType) – Numerical precision for computations.
solver_width (int) – Solver vector length.
linear_solver (LinearSolverBase) – Inner linear solver, constructed with
zero_initial_guess=True.norm (CorrectionNorm, optional) – Correction norm. Defaults to DIRK scaling.
**kwargs – Newton solver settings.
- build() NewtonKrylovCache[source]
Compile the Newton solver.
- property krylov_atol: ndarray
Return the Krylov absolute tolerance array from nested linear solver.
- property krylov_rtol: ndarray
Return the Krylov relative tolerance array from nested linear solver.
- class cubie.integrators.matrix_free_solvers.NewtonKrylovConfig(precision: type[float16] | type[float32] | type[float64] | dtype[float16] | dtype[float32] | dtype[float64], instance_label: str = '', solver_width: int = 0, norm_fn: Callable | None = None, max_iters: int = 8, use_cached_auxiliaries: bool = False, residual_fn: Callable | None = None, krylov_linear_solver_fn: Callable | None = None, delta_location: str = 'local', residual_location: str = 'local', krylov_iters_local_location: str = 'local', prev_theta_location: str = 'local', *, jit_flags: JITFlags = NOTHING, unroll: UnrollFlags = NOTHING)[source]
Bases:
MatrixFreeSolverConfigConfiguration for NewtonKrylov solver compilation.
- precision
Numerical precision for computations.
- Type:
PrecisionDType
- norm_fn
Compiled correction norm for convergence checks.
- Type:
Optional[Callable]
- residual_fn
Device function evaluating residuals.
- Type:
Optional[Callable]
- krylov_linear_solver_fn
Device function for solving linear systems.
- Type:
Optional[Callable]
- krylov_iters_local_location
Memory location for the single-element Krylov iteration counter buffer.
- Type:
Notes
Tolerance arrays (newton_atol, newton_rtol) are managed by the solver’s norm factory and accessed via NewtonKrylov.newton_atol/newton_rtol properties.