Newton Krylov¶
newton_krylov
¶
Explicit eager NumPy Newton-GMRES with checked residuals and backtracking.
This implementation has data-dependent host decisions and supplies no automatic differentiation rule. It never constructs a dense Jacobian or probes a basis.
NewtonKrylovConfig(max_iterations=8, rtol=1e-08, atol=1e-10, damping=1.0, linear_options=(lambda: LinearSolveOptions(rtol=1e-06, atol=0.0))(), max_backtracks=12, backtrack_factor=0.5, armijo=0.0001)
dataclass
¶
Bases: NewtonConfig
Outer RMS tolerances, inner true-residual gate and Armijo backtracking.
Inherited max_iterations is a maximum number of applied Newton updates,
not an exact unroll count. The outer gate is atol + rtol * initial_rms.
Inner options independently use the checked linear solver's L2 gate
max(atol, rtol * ||rhs||) and its documented iteration budget.
Attributes:
| Name | Type | Description |
|---|---|---|
linear_options |
LinearSolveOptions
|
Explicit inner tolerance and iteration budget. |
max_backtracks |
int
|
Maximum reductions after the initial damped trial. |
backtrack_factor |
float
|
Multiplicative step-length reduction, strictly in (0,1). |
armijo |
float
|
Required fractional RMS decrease per unit step, strictly in (0,1). |
__post_init__()
¶
Validate outer, inner and globalization settings.
Raises:
| Type | Description |
|---|---|
TypeError
|
If inner options do not use the existing checked contract. |
ValueError
|
If backtracking settings are invalid. |
Source code in src/op_engine/newton_krylov.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
NewtonKrylovSolver(config=NewtonKrylovConfig(), linear_solver=ScipyGmresSolver(), preconditioner_factory=None)
dataclass
¶
Stateless eager NumPy Newton-GMRES with a per-linearization inverse factory.
The default inner solver is :class:ScipyGmresSolver (left inverse
preconditioning). A failed checked inner solve returns nonlinear
nonconvergence without applying its candidate; malformed callbacks and
arbitrary linear-solver exceptions remain fatal. The integration boundary
applies its existing fixed/adaptive/replay failure policy.
Attributes:
| Name | Type | Description |
|---|---|---|
config |
NewtonKrylovConfig
|
Outer/inner tolerances and bounded line search. |
linear_solver |
LinearSolver
|
Existing checked eager linear-solver callback. |
preconditioner_factory |
InversePreconditionerFactory | None
|
Optional factory receiving the exact current
request, operator and :class: |
__post_init__()
¶
Validate explicit configuration and callbacks.
Raises:
| Type | Description |
|---|---|
TypeError
|
If configuration or callbacks are unsupported. |
Source code in src/op_engine/newton_krylov.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
solve(problem, initial_guess)
¶
Return a root candidate and explicit eager termination evidence.
Returns:
| Type | Description |
|---|---|
NonlinearSolveResult
|
Owned candidate and residual with checked inner/outer diagnostics. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If input or callback arrays are not native real NumPy float32/float64 with matching shape/dtype/namespace. |
ValueError
|
If the state is empty or no residual JVP is supplied. |
Source code in src/op_engine/newton_krylov.py
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | |
NewtonKrylovTermination
¶
Bases: IntEnum
Eager termination codes, retained in stage/integration diagnostics.
NewtonLinearization(iteration, iterate, problem_context)
dataclass
¶
Unique per-linearization preconditioner context, with an owned iterate.
iterate is a read-only snapshot. Its full shape, dtype and coefficients,
problem_context (including SDIRK scale/time when applicable) and this
record's identity define the preparation lifetime. A factory is invoked
afresh for every linearization; a caller retaining a cache owns invalidation.
No iterate history is retained in solve diagnostics.
NonlinearStageContext(time, step_size, diagonal_step, stage_index)
dataclass
¶
Explicit SDIRK stage metadata, freshly bound on every stage and retry.