NewtonKrylov
- class cubie.integrators.matrix_free_solvers.NewtonKrylov(precision: type[float16] | type[float32] | type[float64] | dtype[float16] | dtype[float32] | dtype[float64], n: int, linear_solver: LinearSolver, **kwargs)[source]
Bases:
MatrixFreeSolverFactory for Newton–Krylov solver device functions.
Implements damped Newton iteration using a matrix-free linear solver for the correction equation.
- Parameters:
precision (PrecisionDType) – Numerical precision for computations.
n (int) – Size of state vectors.
linear_solver (LinearSolver) –
LinearSolverinstance for solving linear systems.**kwargs – Forwarded to
NewtonKrylovConfigand the norm factory. Includes prefixed tolerance parameters (newton_atol,newton_rtol).
See also
NewtonKrylovConfigConfiguration container for this factory.
MatrixFreeSolverParent class providing norm and tolerance management.
LinearSolverInner linear solver used for the Newton correction equation.
- __init__(precision: type[float16] | type[float32] | type[float64] | dtype[float16] | dtype[float32] | dtype[float64], n: int, linear_solver: LinearSolver, **kwargs) None[source]
Initialize NewtonKrylov with parameters.
- Parameters:
precision (PrecisionDType) – Numerical precision for computations.
n (int) – Size of state vectors.
linear_solver (LinearSolver) – LinearSolver instance for solving linear systems.
**kwargs – Optional parameters passed to NewtonKrylovConfig. See NewtonKrylovConfig for available parameters. Tolerance parameters (newton_atol, newton_rtol) are passed to the norm factory. None values are ignored.
- build() NewtonKrylovCache[source]
Compile Newton-Krylov solver device function.
- Returns:
Container with compiled newton_krylov_solver device function.
- Return type:
- Raises:
ValueError – If residual_function or linear_solver is None when build() is called.
- property settings_dict: Dict[str, Any]
Return merged Newton and linear solver configuration.
Combines Newton-level settings from compile_settings with linear solver settings from nested linear_solver instance, plus tolerance arrays from the norm factory.
- Returns:
Merged configuration dictionary containing both Newton parameters, linear solver parameters, and tolerance arrays.
- Return type:
- class cubie.integrators.matrix_free_solvers.NewtonKrylovConfig(precision: type[float16] | type[float32] | type[float64] | dtype[float16] | dtype[float32] | dtype[float64], instance_label: str = '', prefixed_attributes: Set[str] = NOTHING, n: int = 0, max_iters: int = 100, norm_device_function: Callable | None = None, residual_function: Callable | None = None, linear_solver_function: Callable | None = None, newton_damping: float = 0.5, newton_max_backtracks: int = 8, delta_location: str = 'local', residual_location: str = 'local', residual_temp_location: str = 'local', stage_base_bt_location: str = 'local', krylov_iters_local_location: str = 'local')[source]
Bases:
MatrixFreeSolverConfigConfiguration for NewtonKrylov solver compilation.
- precision
Numerical precision for computations.
- Type:
PrecisionDType
- norm_device_function
Compiled norm function for convergence checks.
- Type:
Optional[Callable]
- residual_function
Device function evaluating residuals.
- Type:
Optional[Callable]
- linear_solver_function
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.