Dynamic Mode Decomposition (DMD) and its variants, such as extended DMD (EDMD), are
broadly used to fit simple linear models to dynamical systems from observable data. A justification for DMD as a local, leading-order reduced model was given by Haller and Kaszás (2024) [1]. This was achieved by constructing linearizing transformations for the dynamics in attracting slow spectral submanifolds (SSMs), that have been defined by [2]. These attracting SSMs have been successfully used for nonlinear model reduction in data- and equation-driven settings by [3, 4, 5], most notably using the MATLAB
package SSMLearn.
The arguments of Haller and Kaszás (2024) [1] also lead to a new algorithm, data-driven
linearization (DDL), which is a higher-order linearization of the dynamics within slow SSMs. This package contains the numerical implementation of the algorithm using the Python
libraries Numpy
and Pytorch
.
DataDrivenLinearization depends on numpy, scipy, matplotlib, pytest, pytorch and jupyter (to run the example notebooks). Installation using pip is recommended. After cloning the repository with the command
git clone https://github.com/haller-group/DataDrivenLinearization.git
the package can be installed locally using pip
by executing
cd DataDrivenLinearization
pip install -e .
We assume that observations of trajectories of the dynamical system $$ \dot{\mathbf{x}} = \mathbf{f}(\mathbf{x}), \quad \mathbf{x}\in \mathbb{R}^n $$ are recorded and that the system possesses a low-dimensional, attracting invariant (slow) manifold. Such manifolds are guaranteed to arise as slow spectral submanifolds (SSMs) at stable hyperbolic fixed points of the system, which is illustrated by the following figure.
Denoting the parametrization of the
If the available data is sufficiently close to the slow SSM, DDL seeks a polynomial change of coordinates (to a variable denoted as
such that the dynamics becomes linear, i.e.,
This transformation is obtained via regression purely from observed data, without any knowledge of the underlying dynamical system. Therefore, DDL can be viewed as a higher-order refinement of linearization methods based on DMD.
For more information see the manuscript [1], which can be found under docs/haller_kaszas2024.pdf
.
The class DataDrivenLinearization contains the implementation of the DDL method. This class can be initialized by specifying the dimension of the slow SSM and the degree (
The transformation and the linear dynamics (.fit()
method on trajectory data restricted to the SSM (
Once the transformation and the linear dynamics are identified, the model can be used to predict unseen data, or to predict the response of the system to unseen, periodic excitation.
The data should be organized as a list of trajectories, each having a shape of (n_dimensions, n_samples)
.
from data_driven_linearization.linearization import DataDrivenLinearization
model = DataDrivenLinearization(dimension=2, degree=3)
model.fit(training_data, # training_data is a list of np.arrays with shapes (2, n_samples)
method = 'with_inverse', method_optimization = 'trf', verbose = True)
Specifying method='with_inverse'
allows DDL to fit the linearizing transformation and its inverse simultaneously. After fitting the model, we can extract these transformations to be used for further analysis as
from data_driven_linearization.differentiation_utils import differentiate_model_symbolic
inverse_transform, inverse_derivative, variables = differentiate_model_symbolic(model.poly,
model.inverse_transformation_model.coef_)
transform, derivative, variables = differentiate_model_symbolic(model.poly,
model.transformation_coefficients)
Further examples can be found in the examples/
folder.
Please consider citing the following paper, if you are using the code:
[1] G. Haller & B. Kaszás, Data-Driven Linearization of Dynamical Systems, to appear in Nonlinear Dynamics, (2024) arXiv:2407.08177
Additional references on the use of SSMs for nonlinear model reduction:
[2] G. Haller & S. Ponsioen, Exact model reduction by a slow-fast decomposition of nonlinear mechanical systems. Nonlinear Dynamics 90 (2017) 617-647
[3] M. Cenedese, J. Axås, B. Bäuerlein, K. Avila & G. Haller, Data-driven modeling and prediction of non-linearizable dynamics via spectral submanifolds Nat. Commun. 13 (2022) 872.
[4] J. Axås, M. Cenedese & G. Haller, Fast data-driven model reduction for nonlinear dynamical systems Nonlinear Dyn 111 (2023) 7941–7957.
[5] Z. Xu, B. Kaszás, M. Cenedese, G. Berti, F. Coletti, G. Haller, Data-driven modeling of the regular and chaotic dynamics of an inverted flag from experiments J. Fluid Mech. 987 (2024) R7.