Skip to content

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, NaN in unfilled rows.

ys Optional[Any]

State at each save time, or None when SaveAt(outputs=...) leaves out "state".

lambdas Optional[Any]

Global unknowns at each save time, or None.

valid_mask Optional[Array]

Boolean per row, True where the row was filled.

valid_count Optional[Array]

Number of filled rows.

result RESULT

The RESULT of the solve.

stats Optional[SolverStats]

The SolverStats of the solve.

tolerances Any

The ResolvedTolerances of a solve given tolerances=, else None.

event_log Any

Record of the events fired during the solve, or None.

terminal Any

State where the solve stopped, with its time and owning control epoch.

control_state Any

Final ControlState of a solve whose affect events update it, else None.

control_epochs Optional[Array]

Control epoch owning each saved row, -1 in unfilled rows.

interpolation Any

Dense interpolant from SaveAt(dense=True), else None.

outputs Optional[SavedOutputs]

Mapping from each name in SaveAt(outputs=...) to its samples, else None.

ts class-attribute instance-attribute

ts: Optional[Array] = None

ys class-attribute instance-attribute

ys: Optional[Any] = None

lambdas class-attribute instance-attribute

lambdas: Optional[Any] = None

valid_mask class-attribute instance-attribute

valid_mask: Optional[Array] = None

ok property

ok: Array

Whether the solve succeeded, meaning result is SUCCESS or EVENT_STOP.

result class-attribute instance-attribute

result: RESULT = eqx.field(default_factory=lambda: RESULT.UNKNOWN)

stats class-attribute instance-attribute

stats: Optional[SolverStats] = None

tolerances class-attribute instance-attribute

tolerances: Any = None

event_log class-attribute instance-attribute

event_log: Any = None

control_state class-attribute instance-attribute

control_state: Any = None

interpolation class-attribute instance-attribute

interpolation: Any = None

outputs class-attribute instance-attribute

outputs: Optional[SavedOutputs] = None

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 t, with one row per time for an array.

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 Solution whose buffers hold valid_count rows.

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 RESULT of the solve.

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, "dense", "klu", "superlu" or "cudss", or None.

adjoint Optional[str]

Class name of the differentiation strategy.

adjoint_checkpoints Optional[int]

Configured checkpoint count of the strategy, or None.

linear_solve_mode Optional[str]

Linear solve mode the solve ran in, "fp64", "fp32_ir", "fp32_factor" (float32 factors, float64 compute), "fp32" (end-to-end float32) or "adaptive".

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.