Integration Models
Integration models perform numerical integration of derivative models while supporting automatic differentiation through time.
dynax.ODESolver
ODE solver module.
Solver for continuous-time ODE systems of the form
with time \(t \in \mathbb{R}\), state \(\boldsymbol{x}(t) \in \mathbb{R}^n\), input \(\boldsymbol{u}(t) \in \mathbb{R}^m\) and optional static parameters \(\text{args}\).
The system is integrated using diffrax.diffeqsolve.
To evaluate the input \(\boldsymbol{u}(t)\) at arbitrary points in time Hermite
cubic splines with backward differences are used to interpolate the discrete
input signal \(\boldsymbol{u}_i\) given at times \(t_i\).
Notation
n: State dimension. m: Input dimension. l: Number of time steps in the simulation horizon.
__init__(func, *, solver=Tsit5(), stepsize_controller=PIDController(rtol=1e-06, atol=1e-06), max_steps=4096, dt0=None, adjoint=RecursiveCheckpointAdjoint())
Initialize the ODE solver.
| PARAMETER | DESCRIPTION |
|---|---|
func
|
Dynamics function (right hand side of the ODE)
TYPE:
|
solver
|
Diffrax ODE solver used by
TYPE:
|
stepsize_controller
|
Diffrax step-size controller.
TYPE:
|
max_steps
|
Maximum number of integration steps accepted by Diffrax.
If
TYPE:
|
dt0
|
The step size to use for the first step. If using fixed step sizes then this will also be the step size for all other steps. If set as None then the initial step size will be determined automatically.
TYPE:
|
adjoint
|
How to differentiate
TYPE:
|
__call__(ts, x0, us=None, args=None)
Solve the ODE.
| PARAMETER | DESCRIPTION |
|---|---|
ts
|
Monotonic simulation time grid.
TYPE:
|
x0
|
Initial state at
TYPE:
|
us
|
Input trajectory aligned with
TYPE:
|
args
|
Additional arguments passed to
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
PyTree
|
State trajectory sampled at |
get_diffrax_solution(ts, x0, us=None, args=None)
Integrate the dynamics and return the raw Diffrax solution object.
| PARAMETER | DESCRIPTION |
|---|---|
ts
|
Monotonic simulation time grid.
TYPE:
|
x0
|
Initial state at
TYPE:
|
us
|
Input trajectory aligned with
TYPE:
|
args
|
Additional arguments passed to
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Solution
|
Diffrax integration result ( |
Solution
|
at sampling times |
For convenience, some light wrappers around the ODESolver are
provided:
dynax.AugmentedODE
Augmented ODE module.
Extends a given initial condition with additional augmented states, then
passes it to an ODESolver. Finally, the augmentation
is removed from the solution before returning.
with time \(t \in \mathbb{R}\), state \(\boldsymbol{x}(t) \in \mathbb{R}^n\), augmented state \(\boldsymbol{z}(t) \in \mathbb{R}^{n+n_\text{aug}}\), input \(\boldsymbol{u}(t) \in \mathbb{R}^m\) and optional static parameters \(\text{args}\).
__init__(ode_solver, x0_auxiliary, concat_axes=0)
Initialize the ODE solver.
| PARAMETER | DESCRIPTION |
|---|---|
ode_solver
|
TYPE:
|
x0_auxiliary
|
The initial auxiliary state, that is concatenated to
Note Typically, your state is a 1-d array. Then
TYPE:
|
concat_axes
|
The axes along which to concatenate the state and
auxiliary state. Should be a prefix of Note
TYPE:
|
__call__(ts, x0, us=None, args=None)
Solve the augmented ODE.
| PARAMETER | DESCRIPTION |
|---|---|
ts
|
Monotonic simulation time grid.
TYPE:
|
x0
|
Initial (non-augmented) state at
TYPE:
|
us
|
Input trajectory aligned with
TYPE:
|
args
|
Additional arguments passed to
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
PyTree
|
State trajectory sampled at |
dynax.StateSpaceSystem
Module for general state-space systems.
Module for continuous-time state-space systems of the form
with time \(t \in \mathbb{R}\), state \(\boldsymbol{x}(t) \in \mathbb{R}^n\), input \(\boldsymbol{u}(t) \in \mathbb{R}^m\), output \(\boldsymbol{y}(t) \in \mathbb{R}^p\) and optional static parameters \(\text{args}\).
The state equation is integrated using the ODESolver
module.
__init__(ode_solver, output_equation)
__call__(ts, x0, us=None, args=None)
Simulate the system and return output trajectories.
| PARAMETER | DESCRIPTION |
|---|---|
ts
|
Monotonic simulation time grid.
TYPE:
|
x0
|
Initial state at
TYPE:
|
us
|
Input trajectory aligned with
TYPE:
|
args
|
Additional arguments passed to
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
PyTree
|
Output trajectory sampled at |