Derivative Models
Derivative models parameterize the right hand side of an ODE in normal form: $$ \dot{\mathbf{y}} = \mathbf{f}(t, \mathbf{y}[, \mathbf{u}, \text{args}]) $$ where \(\mathbf{y}(t)\in\mathbb{R}^n\) is the systems state vector, \(t\) is time, \(\mathbf{u}(t)\in\mathbb{R}^m\) are external inputs (for example forces acting on a system), and \(\text{args}\) are arbitrary parameters of the system.
They are most often combined with a numerical solver.
Port-Hamiltonian systems
dynax.ISPHS
Input-State port-Hamiltonian Systems (ISPHS).
Implementation of the state equation of a input-state-output port-Hamiltonian system:
$$ \dot{\mathbf{x}} = (\mathbf{J}(\mathbf{x})-\mathbf{R}(\mathbf{x}))\frac{\partial\mathcal{H}(\mathbf{x})}{\partial \mathbf{x}} + \mathbf{B}(\mathbf{x})\mathbf{u} $$
where:
\(\mathbf{x}(t)\) is the state vector,
\(\mathbf{u}(t)\) is the input vector,
\(\mathcal{H}(\mathbf{x})\) is the Hamiltonian function given by hamiltonian,
\(\mathbf{J}\) is the structure matrix given by structure_matrix,
\(\mathbf{R}\) is the dissipation matrix given by dissipation_matrix,
and \(\mathbf{B}\) is the input matrix given by input_matrix.
__init__(hamiltonian, structure_matrix, dissipation_matrix=None, input_matrix=None)
Initialize the ISPHS.
| PARAMETER | DESCRIPTION |
|---|---|
hamiltonian
|
Function or submodel computing the Hamiltonian \(\mathcal{H}(x)\) as a function of the state vector.
TYPE:
|
structure_matrix
|
Function or submodel computing the structure matrix \(J(x)\) as a function of the state vector. From the port-Hamiltonian modeling view the structure matrix is required to be skew-symmetric, i.e., \(J = -J^T\).
TYPE:
|
dissipation_matrix
|
Function or submodel computing the dissipation matrix \(R(x)\)
as a function of the state vector. From the port-Hamiltonian modeling view
the dissipation matrix is required to be symmetric positive semi-definite,
i.e., \(R = R^T,\,R\succ0\). Alternatively,
TYPE:
|
input_matrix
|
Function or submodel computing the input matrix \(G(x)\) as a
function of the state vector. Alternatively,
TYPE:
|
Tipp
Consider using klax for convenient implementations of matrix valued functions.
__call__(t, x, u=None)
Return the time derivative of the state vector \(x\).
| PARAMETER | DESCRIPTION |
|---|---|
t
|
Scalar time for evaluation. This argument is unused, but required to
comply with the
TYPE:
|
x
|
State vector at time
TYPE:
|
u
|
Input vector at time
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If a input is provided but the system does not have an input matrix. |
| RETURNS | DESCRIPTION |
|---|---|
Array
|
Time derivative of the state vector \(x\) as a 1D array of shape |
Physics-agnostic systems
dynax.NeuralODE
Derivative model for a neural ODE.
This implements the following equation: $$ \dot{y} = f(t, y, u) $$ where \(f\) is a multi-layer perceptron (MLP), depending on time \(t\in\mathbb{R}\), the state vector \(y(t)\in\mathbb{R}^n\), and an input vector \(u(t)\in\mathbb{R}^m\).
__init__(state_size, input_size, *, time_dependent=False, state_dependent=True, width_sizes, weight_init=<function variance_scaling.<locals>.init>, bias_init=<function zeros>, activation=<PjitFunction of <function softplus at 0x7fdf0a78fc40>>, final_activation=<function NeuralODE.<lambda>>, use_bias=True, use_final_bias=True, weight_wrap=None, bias_wrap=None, dtype=None, key)
Create a neural ode.
| PARAMETER | DESCRIPTION |
|---|---|
state_size
|
Number of state variables.
TYPE:
|
input_size
|
Number of input variables. Can be zero to indicate no input dependence.
TYPE:
|
time_dependent
|
If true then the time is fed as an additional array entry to the MLP. Defaults to False.
TYPE:
|
state_dependent
|
If true then the state is fed as an additional array entry to the MLP. Defaults to True.
TYPE:
|
width_sizes
|
The sizes of each hidden layer in a list.
TYPE:
|
weight_init
|
The weight initializer of type
TYPE:
|
bias_init
|
The bias initializer of type
TYPE:
|
activation
|
The activation function after each hidden layer.
(Defaults to
TYPE:
|
final_activation
|
The activation function after the output layer. (Defaults to the identity.)
TYPE:
|
use_bias
|
Whether to add on a bias to internal layers.
(Defaults to
TYPE:
|
use_final_bias
|
Whether to add on a bias to the final layer.
(Defaults to
TYPE:
|
weight_wrap
|
An optional wrapper that is passed to all weights.
TYPE:
|
bias_wrap
|
An optional wrapper that is passed to all biases.
TYPE:
|
dtype
|
The dtype to use for all the weights and biases in this MLP.
Defaults to either
TYPE:
|
key
|
A
TYPE:
|