Dynamical System Protocols
The protocols module provides abstract interfaces for dynamical systems using Python protocols.
_DynamicalSystemProtocol()
The _DynamicalSystemProtocol
class defines the minimal interface that any dynamical system must implement to be compatible with the integrator framework.
- class hiten.algorithms.dynamics.protocols._DynamicalSystemProtocol[source]
Bases:
Protocol
Define the protocol for the minimal interface for dynamical systems.
This protocol specifies the required attributes that any dynamical system must implement to be compatible with the integrator framework. It uses structural typing to allow duck typing while maintaining type safety.
- rhs
Right-hand side function f(t, y) that computes the time derivative dy/dt given time t and state vector y.
- Type:
Callable[[float, ndarray], ndarray]
Notes
The @runtime_checkable decorator allows isinstance() checks against this protocol at runtime, enabling flexible type validation.
_HamiltonianSystemProtocol()
The _HamiltonianSystemProtocol
class extends the base dynamical system protocol with Hamiltonian-specific methods required by symplectic integrators.
- class hiten.algorithms.dynamics.protocols._HamiltonianSystemProtocol[source]
Bases:
_DynamicalSystemProtocol
,Protocol
Define the protocol for the interface for Hamiltonian dynamical systems.
Extends the base dynamical system protocol with Hamiltonian-specific methods required by symplectic integrators. Provides access to partial derivatives and polynomial representation of the Hamiltonian.
See also
_DynamicalSystemProtocol
Base protocol
_HamiltonianSystem
Concrete implementation
- property n_dof: int
Number of degrees of freedom.
- Returns:
Degrees of freedom count. Total state dimension is 2 * n_dof.
- Return type:
- dH_dQ(Q, P)[source]
Compute partial derivatives of Hamiltonian with respect to positions.
- Parameters:
Q (ndarray, shape (n_dof,)) – Position coordinates.
P (ndarray, shape (n_dof,)) – Momentum coordinates.
- Returns:
Partial derivatives dH/dQ.
- Return type:
ndarray, shape (n_dof,)
- dH_dP(Q, P)[source]
Compute partial derivatives of Hamiltonian with respect to momenta.
- Parameters:
Q (ndarray, shape (n_dof,)) – Position coordinates.
P (ndarray, shape (n_dof,)) – Momentum coordinates.
- Returns:
Partial derivatives dH/dP.
- Return type:
ndarray, shape (n_dof,)