Skip to content
Specular Differentiation

specular.ode.ODEResult

ODEResult(t, u, sigma, number_of_field_evaluations)

Container for the numerical data returned by every scalar ODE method.

Attributes

Name Type Description
t NumPy float64 array, shape (n_steps + 1,) Time nodes, including both endpoints.
u NumPy float64 array, shape (n_steps + 1,) Initial value followed by the solution values at the time nodes. For Types 1/2, u[1] is the externally supplied starter.
sigma NumPy float64 array, shape (n_steps,) Scale associated with each represented time interval.
number_of_field_evaluations int Number of calls to F(t, u) made by the solver.

Notes

This is a frozen, slotted dataclass. Its attribute bindings cannot be reassigned, but the contained NumPy arrays are mutable. Results contain numerical data; plotting, event handling, and dense output are outside this API.

For all three Euler methods, sigma contains ones. In Types 1/2, this convention also covers the first interval and does not describe how u_1 was produced.

In automatic fourth-order mode, sigma records the positive E5a/E5b scale or the fallback 1.0. Only minimize_defect may use 0.0 for the zero-scale limiting method or inf for the infinite-scale Crank--Nicolson limit. These are result sentinels, not valid scales for the public scaled_mean function. See Result.

Field calls made internally by a user-provided derivatives_of_F callback are not included in number_of_field_evaluations.

Examples

import specular.ode

result = specular.ode.ellipse_scheme(
    lambda t, u: -u, 0.0, 1.0, 1.0,
    n_steps=100, sigma_n=1.0,
)
print(result.t.shape, result.u.shape, result.sigma.shape)
print(result.number_of_field_evaluations)
Source code in specular/ode/_result.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
@dataclass(frozen=True, slots=True)
class ODEResult:
    """Values produced by a scalar specular ODE method.

    ``t`` and ``u`` contain the initial value and every accepted step, while
    ``sigma`` contains the scale associated with each represented interval.
    In automatic ``minimize_defect`` mode, ``0.0`` and ``inf`` denote the
    zero- and infinite-scale limiting methods, respectively.
    ``number_of_field_evaluations`` counts calls to ``F(t, u)`` made by the
    solver.
    """

    t: FloatArray
    u: FloatArray
    sigma: FloatArray
    number_of_field_evaluations: int