Solution¶
Every solver returns a Solution, with its counters in a SolverStats and
its outcome as a RESULT. See solutions and
output.
Warning
No solver raises on a non-convergent solve, so read sol.ok or
sol.result before trusting the arrays.
diff_soup.Solution
¶
The record every solver returns, with the saved samples, the outcome, and the statistics.
A solve never raises on non-convergence, so read ok or result before the arrays. Buffers have the size fixed at compile time, and rows past valid_count are unfilled.
Attributes:
| Name | Type | Description |
|---|---|---|
ts |
Optional[Array]
|
Save times, |
ys |
Optional[Any]
|
State at each save time, or |
lambdas |
Optional[Any]
|
Global unknowns at each save time, or |
valid_mask |
Optional[Array]
|
Boolean per row, |
valid_count |
Optional[Array]
|
Number of filled rows. |
result |
RESULT
|
The |
stats |
Optional[SolverStats]
|
The |
tolerances |
Any
|
The |
event_log |
Any
|
Record of the events fired during the solve, or |
terminal |
Any
|
State where the solve stopped, with its time and owning control epoch. |
control_state |
Any
|
Final |
control_epochs |
Optional[Array]
|
Control epoch owning each saved row, |
interpolation |
Any
|
Dense interpolant from |
outputs |
Optional[SavedOutputs]
|
Mapping from each name in |
result
class-attribute
instance-attribute
¶
result: RESULT = eqx.field(default_factory=lambda: RESULT.UNKNOWN)
evaluate
¶
evaluate(t: Any) -> Any
Evaluate the dense output, a piecewise cubic through the accepted steps, at t.
It needs SaveAt(dense=True). A time outside the solved span is clamped to its nearest end.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
Any
|
A time or a one-dimensional array of times. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The state at |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If dense output was not requested. |
trimmed
¶
trimmed(lane: Any = None) -> 'Solution'
Return a copy without the unfilled rows of the save buffers.
It runs on the host only. Inside jit or vmap, use valid_mask and valid_count instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lane
|
Any
|
Batch index to select from a batched solution, omitted for an unbatched one. |
None
|
Returns:
| Type | Description |
|---|---|
'Solution'
|
A |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If called on traced values. |
diff_soup.SolverStats
¶
Counters and settings of one solve, carried on Solution.stats.
Counters that an engine does not track stay zero.
Attributes:
| Name | Type | Description |
|---|---|---|
accepts |
Array
|
Accepted steps. |
rejects |
Array
|
Rejected step attempts. |
trial_steps |
Array
|
Step attempts, accepted or not. |
newton_iters |
Array
|
Newton iterations. |
jac_refreshes |
Array
|
Jacobian evaluations. |
factorizations |
Array
|
Factorizations of the iteration matrix. |
linear_solves |
Array
|
Linear solves. |
rhs_evals |
Array
|
Right-hand-side evaluations. |
residual_evals |
Array
|
Residual evaluations. |
active_set_iters |
Array
|
Reserved for an active-set corrector, zero on the current engines. |
active_set_changes |
Array
|
Reserved for an active-set corrector, zero on the current engines. |
ic_alg_residual_norm |
Array
|
Algebraic residual left by consistent initialization, zero when none ran. |
t_reached |
Array
|
Time the solve reached. |
status |
RESULT
|
The |
precision_promotions |
Array
|
Promotions of an adaptive solve to full precision, one counter per cause. |
newton_failures |
Array
|
Corrector failures. |
saveat_interpolations |
Array
|
Interpolant evaluations made to fill save times. |
ic_solves |
Array
|
1 when consistent initialization was requested, else 0. |
event_solves |
Array
|
Affect events applied. |
ir_refinement_steps |
Array
|
Iterative-refinement steps of the reduced-precision solves. |
fp64_fallbacks |
Array
|
Fallbacks from a float32 factor to a float64 one. |
first_step |
Array
|
Size of the first step attempt. |
last_step |
Array
|
Size of the step the next attempt would take. |
linear_backend |
Optional[str]
|
Name of the linear backend the solve ran on, |
adjoint |
Optional[str]
|
Class name of the differentiation strategy. |
adjoint_checkpoints |
Optional[int]
|
Configured checkpoint count of the strategy, or |
linear_solve_mode |
Optional[str]
|
Linear solve mode the solve ran in, |
diff_soup.RESULT
¶
The outcome of a solve, read from Solution.result.
SUCCESS and EVENT_STOP are the successful outcomes, and Solution.ok tests for either. Compare members with ==, as in sol.result == ds.RESULT.MAX_STEPS.
Attributes:
| Name | Type | Description |
|---|---|---|
SUCCESS |
The solve reached the end of the interval, or a nonlinear solve converged. |
|
EVENT_STOP |
A terminating event stopped the solve. |
|
MAX_STEPS |
The step budget ran out first. |
|
STEP_COLLAPSE |
The step size fell below its lower bound. |
|
NONLINEAR_DIVERGED |
The nonlinear corrector diverged. |
|
LINEAR_FAIL |
A linear solve failed. |
|
SINGULAR |
The operator or its factor was detected singular. |
|
INCONSISTENT_IC |
The initial state violates the algebraic constraints. |
|
ACCURACY_LIMIT |
The tolerances are tighter than double precision resolves at the solution's magnitude. |
|
UNKNOWN |
The solve did not reach a terminal status. |