Skip to content

Port-Hamiltonian systems

dynax.ISPHS

Input-State port-Hamiltonian Systems (ISPHS).

Implementation of a output-less port-Hamiltonian system: $$ \dot{x} = (J(x)-R(x))\frac{\partial \mathcal{H}}{\partial x} + B(x)u $$ where: \(x(t)\) is the state vector, \(u(t)\) is the input vector, \(\mathcal{H}(x)\) is the Hamiltonian function given by hamiltonian, \(J\) is the structure matrix given by structure_matrix, \(R\) is the dissipation matrix given by dissipation_matrix, and \(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: Callable[[Array], Shaped[Array, '']]

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: Callable[[Float[Array, 'n']], Float[Array, 'n n']]

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, None can be used to indicate that the system does not have a dissipation matrix \(R\).

TYPE: Callable[[Float[Array, 'n']], Float[Array, 'n n']] | None DEFAULT: None

input_matrix

Function or submodel computing the input matrix \(G(x)\) as a function of the state vector. Alternatively, None can be used to indicate that the system does not have external inputs \(u\). Defaults to None.

TYPE: Callable[[Float[Array, 'n']], Float[Array, 'n m']] | None DEFAULT: None

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 ODESolver function signature.

TYPE: Shaped[Array, '']

x

State vector at time t. This should be a 1D array of shape (n,) where n is the number of state dimensions.

TYPE: Array

u

Input vector at time t. This should be a 1D array of shape (m,) where m is the number of input dimensions. If the system does not have inputs, this can be set to None.

TYPE: Array | None DEFAULT: None

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 (n,).