Integrators Types

The types module provides data structures and result containers for numerical integration.

Result Classes

class hiten.algorithms.integrators.types.EventResult[source]

Bases: object

Result container for a single event detection.

Parameters:
hit

True if an event crossing was detected and refined.

Type:

bool

t_event

Detected event time (None when hit is False).

Type:

float | None

y_event

Detected event state (None when hit is False).

Type:

numpy.ndarray | None

g_event

Event function value at the detected time/state (None when hit is False).

Type:

float | None

hit: bool
t_event: float | None
y_event: ndarray | None
g_event: float | None
class hiten.algorithms.integrators.types._Solution[source]

Bases: object

Store a discrete solution returned by an integrator.

Parameters:
  • times (numpy.ndarray, shape (n,)) – Monotonically ordered time grid.

  • states (numpy.ndarray, shape (n, d)) – State vectors corresponding to times.

  • derivatives (numpy.ndarray or None, optional, shape (n, d)) – Evaluations of f(t,y) at the stored nodes. When available a cubic Hermite interpolant is employed by interpolate(); otherwise linear interpolation is used.

Raises:

ValueError – If the lengths of times, states, or derivatives (when provided) are inconsistent.

Notes

The class is a dataclasses.dataclass and behaves like an immutable record.

times: ndarray
states: ndarray
derivatives: ndarray | None = None
__post_init__()[source]

Validate the consistency of times, states, and derivatives arrays

interpolate(t)[source]

Evaluate the trajectory at intermediate time points.

If derivatives are provided a cubic Hermite scheme of order three is employed on every step; otherwise straight linear interpolation is used.

Parameters:

t (float or array_like) – Query time or array of times contained in [times[0], times[-1]].

Returns:

Interpolated state with shape (d,) when t is scalar or (m, d) when t comprises m points.

Return type:

numpy.ndarray

Raises:

ValueError – If any entry of t lies outside the stored integration interval.

Examples

>>> sol = integrator.integrate(sys, y0, np.linspace(0, 10, 11))
>>> y_mid = sol.interpolate(5.5)