Integrators Base
The base module provides abstract interfaces for numerical time integration.
Base Classes
- class hiten.algorithms.integrators.base._Integrator[source]
Bases:
ABCDefine the minimal interface that every concrete integrator must satisfy.
- Parameters:
name (str) – Human-readable identifier of the method.
**options – Extra keyword arguments left untouched and stored in
optionsfor later use by subclasses.
Notes
Subclasses must implement the abstract members
order()andintegrate().Examples
Creating a dummy first-order explicit Euler scheme:
class Euler(_Integrator): @property def order(self): return 1 def integrate(self, system, y0, t_vals, **kwds): y = [y0] for t0, t1 in zip(t_vals[:-1], t_vals[1:]): dt = t1 - t0 y.append(y[-1] + dt * hiten.system.rhs(t0, y[-1])) return _Solution(np.asarray(t_vals), np.asarray(y))
- abstract property order: int | None
Return the order of accuracy of the integrator.
- Returns:
Order of the method, or
Noneif not applicable.- Return type:
int or None
- abstractmethod integrate(system, y0, t_vals, *, event_fn=None, event_cfg=None, event_options=None, **kwargs)[source]
Integrate the dynamical system from initial conditions.
- Parameters:
system (
_DynamicalSystemProtocol) – The dynamical system to integrate.y0 (numpy.ndarray) – Initial state vector of shape
(system.dim,). Units follow the providedsystem; for CR3BP components, values are typically nondimensional.t_vals (numpy.ndarray) – Strictly monotonic array of time points of shape
(N,)at which to evaluate the solution. Units follow the providedsystem; for CR3BP components, time is typically nondimensional.event_fn (Callable[[float, numpy.ndarray], float], optional) – Event function evaluated as
g(t, y). A zero crossing may be used by concrete integrators to stop or record events.event_cfg (
EventConfig, optional) – Configuration controlling event directionality and terminal behavior for event handling.event_options (
EventOptions, optional) – Runtime tuning options controlling event detection tolerances (xtol, gtol).**kwargs – Additional integration options passed to concrete implementations.
- Returns:
Integration results containing times and states (and, when available, state derivatives). Time and state units follow the provided
system.- Return type:
- Raises:
ValueError – If inputs are inconsistent (e.g., dimension mismatch or non-monotonic
t_vals) or the system is incompatible.
- validate_system(system)[source]
Check that system complies with
_DynamicalSystemProtocol.- Parameters:
system (
_DynamicalSystemProtocol) – Candidate system whose suitability is being tested.- Raises:
ValueError – If the required attribute
rhsis absent.- Return type:
None
- validate_inputs(system, y0, t_vals)[source]
Validate that the input arguments form a consistent integration task.
- Parameters:
system (
_DynamicalSystemProtocol) – System to be integrated.y0 (numpy.ndarray) – Initial state vector of length
dim.t_vals (numpy.ndarray) – Strictly monotonic array of time nodes with at least two entries.
- Raises:
ValueError – If any of the following conditions holds: -
len(y0)differs fromdim. -t_valscontains fewer than two points. -t_valsis not strictly monotonic.- Return type:
None