Right-Hand Side Systems

The rhs module provides adapters for wrapping user-defined right-hand side functions into dynamical systems compatible with the integrator framework.

_RHSSystem()

The _RHSSystem class provides an adapter for generic right-hand side functions. It converts arbitrary Python callables representing ODE systems dy/dt = f(t, y) into objects compatible with the dynamical systems framework. It automatically handles JIT compilation for optimal performance in numerical integrators.

class hiten.algorithms.dynamics.rhs._RHSSystem[source]

Bases: _DynamicalSystem

Provide an adapter for generic right-hand side functions.

Converts arbitrary Python callables representing ODE systems dy/dt = f(t, y) into objects compatible with the dynamical systems framework. Automatically handles JIT compilation for optimal performance in numerical integrators.

Parameters:
  • rhs_func (Callable[[float, ndarray], ndarray]) – Function implementing the ODE system dy/dt = f(t, y). Must accept time t (float) and state y (1D ndarray) and return the time derivative as a 1D ndarray of the same shape.

  • dim (int) – Dimension of the state space (length of state vector).

  • name (str, optional) – Human-readable system identifier. Default is “Generic RHS”.

dim

State space dimension (inherited from base class).

Type:

int

name

System identifier string.

Type:

str

rhs

JIT-compiled RHS function compatible with Numba nopython mode.

Type:

Callable[[float, ndarray], ndarray]

Raises:

ValueError – If dim is not positive (inherited from base class).

Parameters:

Notes

  • Uses centralized JIT compilation utility for optimal performance

  • Automatically detects pre-compiled Numba dispatchers and reuses them

  • Compiles plain Python functions with Numba JIT for performance

  • Uses global fast-math setting for numerical optimization

  • Compatible with all integrators that accept _DynamicalSystem objects

Examples

>>> import numpy as np
>>> def harmonic_oscillator(t, y):
...     return np.array([y[1], -y[0]])  # dy/dt = [v, -x]
>>> sys = _RHSSystem(harmonic_oscillator, dim=2, name="Harmonic Oscillator")
>>> derivative = sys.rhs(0.0, np.array([1.0, 0.0]))

See also

_DynamicalSystem

Base class

_compile_rhs_function()

JIT compilation method

create_rhs_system()

Factory function

create_rhs_system()

The create_rhs_system() function provides a factory function for creating RHS systems using a functional interface.

hiten.algorithms.dynamics.rhs.create_rhs_system()[source]

Create RHS system using functional interface.

Factory function that provides a functional alternative to the object-oriented _RHSSystem constructor. Useful for creating systems in a more concise, functional programming style.

Parameters:
  • rhs_func (Callable[[float, ndarray], ndarray]) – Right-hand side function implementing dy/dt = f(t, y).

  • dim (int) – State space dimension.

  • name (str, optional) – System identifier. Default is “Generic RHS”.

Returns:

Configured RHS system ready for integration.

Return type:

_RHSSystem

Examples

>>> import numpy as np
>>> def pendulum(t, y):
...     theta, omega = y
...     return np.array([omega, -np.sin(theta)])
>>> sys = create_rhs_system(pendulum, dim=2, name="Nonlinear Pendulum")
>>> # Use with any integrator that accepts _DynamicalSystem

See also

_RHSSystem

Direct constructor interface

_DynamicalSystem

Base interface