You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+73-32Lines changed: 73 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,9 +47,9 @@
47
47
## Table of contents
48
48
*[Description](#description)
49
49
*[Dependencies and installation](#dependencies-and-installation)
50
-
*[Examples and Tutorials](#examples-and-tutorials)
51
-
*[Using PyDMD](#using-pydmd)
50
+
*[Quickstart guide](#quickstart-guide)
52
51
*[Awards](#awards)
52
+
*[Citing PyDMD](#citing-pydmd)
53
53
*[References](#references)
54
54
*[Developers and contributors](#developers-and-contributors)
55
55
*[Funding](#funding)
@@ -91,44 +91,78 @@ and then install the package in [development mode](https://setuptools.pypa.io/en
91
91
### Dependencies
92
92
The core features of **PyDMD** depend on `numpy` and `scipy`. In order to use the plotting functionalities you will also need `matplotlib`.
93
93
94
-
## Examples and Tutorials
95
-
You can find useful tutorials on how to use the package in the [tutorials](tutorials/README.md) folder.
94
+
## Quickstart Guide
95
+
To perform DMD, simply begin by initializing a PyDMD module that implements your DMD method of choice. Models may then be fitted by calling the `fit()` method and passing in the necessary data. This step performs the DMD algorithm, after which users may use PyDMD plotting tools in order to visualize their results.
96
96
97
-
Here we show a simple application (taken from [tutorial 2](tutorials/tutorial2/tutorial-2-adv-dmd.ipynb)): we collect few snapshots from a toy system with some noise and reconstruct the entire system evolution.
98
-
<palign="center">
99
-
<imgsrc="readme/dmd-example.png"alt>
100
-
<em>The original snapshots used as input for the dynamic mode decomposition</em>
101
-
</p>
97
+
```python3
98
+
from pydmd importDMD
99
+
from pydmd.plotter import plot_summary
102
100
103
-
<palign="center">
104
-
<imgsrc="readme/dmd-example.gif"alt></br>
105
-
<em>The system evolution reconstructed with dynamic mode decomposition</em>
106
-
</p>
101
+
# Build an exact DMD model with 12 spatiotemporal modes.
102
+
dmd = DMD(svd_rank=12)
103
+
104
+
# Fit the DMD model.
105
+
# X = (n, m) numpy array of time-varying snapshot data.
106
+
dmd.fit(X)
107
+
108
+
# Plot a summary of the key spatiotemporal modes.
109
+
plot_summary(dmd)
110
+
```
111
+
112
+
PyDMD modules can also be wrapped with data preprocessors if desired. These wrappers will preprocess the data and postprocess data reconstructions automatically.
113
+
```python3
114
+
from pydmd importDMD
115
+
from pydmd.preprocessing import zero_mean_preprocessing
116
+
117
+
# Build and fit an exact DMD model with data centering.
To perform DMD, simply begin by initializing a PyDMD module that implements your DMD method of choice. Here, we demonstrate how a user might build a customized BOP-DMD model. Models may then be fitted by calling the `fit()` method and passing in the necessary data. This step performs the DMD algorithm, after which users may use PyDMD plotting tools in order to visualize their results.
122
+
Users may also build highly complex DMD models with PyDMD. Below is an example of how one might build and fit a customized Optimized DMD model with bagging, eigenvalue constraints, and custom variable projection arguments.
110
123
```python3
111
124
from pydmd importBOPDMD
112
-
from pydmd.plotter import plot_summary
113
125
114
-
# Build a bagging, optimized DMD (BOP-DMD) model.
115
-
dmd = BOPDMD(
116
-
svd_rank=15, # rank of the DMD fit
117
-
num_trials=100, # number of bagging trials to perform
118
-
trial_size=0.5, # use 50% of the total number of snapshots per trial
119
-
eig_constraints={"imag", "conjugate_pairs"}, # constrain the eigenvalue structure
120
-
varpro_opts_dict={"tol":0.2, "verbose":True}, # set variable projection parameters
126
+
# Build a Bagging, Optimized DMD (BOP-DMD) model.
127
+
# For Optimized DMD (without bagging), use BOPDMD(svd_rank=12, num_trials=0).
128
+
bopdmd = BOPDMD(
129
+
svd_rank=12, # Rank of the DMD fit.
130
+
num_trials=100, # Number of bagging trials to perform.
131
+
trial_size=0.5, # Use 50% of the total number of snapshots per trial.
132
+
eig_constraints={"imag", "conjugate_pairs"}, # Eigenvalues must be imaginary and conjugate pairs.
133
+
varpro_opts_dict={"tol":0.2, "verbose":True}, # Set convergence tolerance and use verbose updates.
121
134
)
122
135
123
-
# Fit the DMD model.
136
+
# Fit the BOP-DMD model.
124
137
# X = (n, m) numpy array of time-varying snapshot data
125
138
# t = (m,) numpy array of times of data collection
126
-
dmd.fit(X, t)
139
+
bopdmd.fit(X, t)
140
+
```
127
141
128
-
# Display a summary of the DMD results.
129
-
plot_summary(dmd)
142
+
PyDMD modules and functions may be parameterized by a variety of inputs for added customization, so we generally recommend that new users refer to our [documentation](https://pydmd.github.io/PyDMD/code.html), as well as to our module-specific [tutorials](tutorials/README.md) for more examples and information.
143
+
144
+
Also provided below is an example call to the `plot_summary()` function when given a DMD model fitted to mean-centered flow past a cylinder data available at <ins>dmdbook.com/DATA.zip</ins>. A rank-12 exact DMD model was used to generate this figure. Eigenvalues, modes, and dynamics are color-coded to indicate associations. Eigenvalue marker sizes also indicate spatiotemporal mode amplitudes or importance.
145
+
146
+
Plotting tool documentation can be found [here](https://pydmd.github.io/PyDMD/plotter.html).
147
+
```python3
148
+
from pydmd.plotter import plot_summary
149
+
150
+
plot_summary(
151
+
dmd, # <-- Fitted PyDMD model. Can be DMD, BOPDMD, etc.
152
+
figsize=(12, 7),
153
+
index_modes=(0, 2, 4),
154
+
snapshots_shape=(449, 199),
155
+
order="F",
156
+
mode_cmap="seismic",
157
+
dynamics_color="k",
158
+
flip_continuous_axes=True,
159
+
max_sval_plot=30,
160
+
)
130
161
```
131
-
Note that modules and functions may be parameterized by a variety of inputs for added customization, so we generally recommend that new users refer to module documentation, plotting tool documentation, and to our module-specific [tutorials](tutorials/README.md) for more information.
162
+
<palign="center">
163
+
<imgsrc="readme/summary-example.png"alt></br>
164
+
<em>Sample output of the plot_summary function.</em>
165
+
</p>
132
166
133
167
For users who are unsure of which DMD method is best for them, we provide the following flow chart, which outlines how one might choose an appropriate DMD variant based on specific problem types or data sets.
134
168
@@ -140,12 +174,19 @@ For users who are unsure of which DMD method is best for them, we provide the fo
140
174
141
175
First prize winner in **DSWeb 2019 Contest**_Tutorials on Dynamical Systems Software_ (Junior Faculty Category). You can read the winner tutorial (PDF format) in the [tutorials](tutorials/tutorial_dsweb.pdf) folder.
142
176
177
+
## Citing PyDMD
178
+
When citing PyDMD, please cite both of the following references:
179
+
* Demo, Tezzele, Rozza. *PyDMD: Python Dynamic Mode Decomposition*. Journal of Open Source Software, 2018. [[DOI](https://doi.org/10.21105/joss.00530)][[bibitem](readme/refs/Demo2018)]
To implement the various versions of the DMD algorithm we follow these works:
145
184
146
185
### General DMD References
147
186
* Kutz, Brunton, Brunton, Proctor. *Dynamic Mode Decomposition: Data-Driven Modeling of Complex Systems*. SIAM Other Titles in Applied Mathematics, 2016. [[DOI](https://doi.org/10.1137/1.9781611974508)][[bibitem](readme/refs/Kutz2016_1.bib)].
148
-
* Brunton, Budišić, Kaiser, Kutz. *Modern Koopman Theory for Dynamical Systems*. SIAM Review, 2022. [[DOI](https://doi.org/10.1137/21M1401243)][[bibitem](readme/refs/Brunton2022.bib)].
187
+
* Schmid. *Dynamic mode decomposition of numerical and experimental data*. Journal of Fluid Mechanics, 2010. [[DOI](https://doi.org/10.1017/S0022112010001217)][[bibitem](readme/refs/Schmid2010)]
188
+
* Tu, Rowley, Luchtenburg, Brunton, Kutz. *On Dynamic Mode Decomposition: Theory and Applications*. Journal of Computational Dynamics, 2014. [[DOI](https://doi.org/10.3934/jcd.2014.1.391)][[bibitem](readme/refs/Tu2014.bib)]
189
+
* Schmid. *Dynamic mode decomposition and its variants*. Annual Review of Fluid Mechanics, 2022. [[DOI](https://doi.org/10.1146/annurev-fluid-030121-015835)][[bibitem](readme/refs/Schmid2022)]
149
190
150
191
### DMD Variants: Noise-robust Methods
151
192
***Forward-backward DMD:** Dawson, Hemati, Williams, Rowley. *Characterizing and correcting for the effect of sensor noise in the dynamic mode decomposition*. Experiments in Fluids, 2016. [[DOI](https://doi.org/10.1007/s00348-016-2127-7)][[bibitem](readme/refs/Dawson2016.bib)].
@@ -167,11 +208,11 @@ To implement the various versions of the DMD algorithm we follow these works:
167
208
***Parametric DMD:** Andreuzzi, Demo, Rozza. *A dynamic mode decomposition extension for the forecasting of parametric dynamical systems*. SIAM Journal on Applied Dynamical Systems, 2023. [[DOI](https://doi.org/10.1137/22M1481658)][[bibitem](readme/refs/Andreuzzi2021.bib)].
168
209
***Extended DMD:** Williams, Rowley, Kevrekidis. *A kernel-based method for data-driven koopman spectral analysis*. Journal of Computational Dynamics, 2015. [[DOI](https://doi.org/10.3934/jcd.2015005)][[bibitem](readme/refs/Williams2015.bib)].
169
210
***LANDO:** Baddoo, Herrmann, McKeon, Brunton. *Kernel learning for robust dynamic mode decomposition: linear and nonlinear disambiguation optimization*. Proceedings of the Royal Society A, 2022. [[DOI](https://doi.org/10.1098/rspa.2021.0830)][[bibitem](readme/refs/Baddoo2022.bib)].
211
+
***DMD with Centering:** Hirsh, Harris, Kutz, Brunton. *Centering data improves the dynamic mode decomposition*. SIAM Journal on Applied Dynamical Systems, 2020. [[DOI](https://doi.org/10.1137/19M1289881)][[bibitem](readme/refs/Hirsh2020.bib)]
170
212
171
-
### Implementation Tools and Preprocessing
213
+
### General Implementation Tools
172
214
* Gavish, Donoho. *The optimal hard threshold for singular values is 4/sqrt(3)*. IEEE Transactions on Information Theory, 2014. [[DOI](https://doi.org/10.1109/TIT.2014.2323359)][[bibitem](readme/refs/Gavish2014.bib)].
173
215
* Matsumoto, Indinger. *On-the-fly algorithm for dynamic mode decomposition using incremental singular value decomposition and total least squares*. 2017. [[arXiv](https://arxiv.org/abs/1703.11004)][[bibitem](readme/refs/Matsumoto2017.bib)].
174
-
* Hirsh, Harris, Kutz, Brunton. *Centering data improves the dynamic mode decomposition*. SIAM Journal on Applied Dynamical Systems, 2020. [[DOI](https://doi.org/10.1137/19M1289881)][[bibitem](readme/refs/Hirsh2020.bib)]
175
216
176
217
### Recent works using PyDMD
177
218
You can find a list of the scientific works using **PyDMD**[here](https://scholar.google.com/scholar?oi=bibs&hl=en&cites=5544023489671534143).
@@ -214,4 +255,4 @@ Beyond this, PyDMD has also been supported by some dedicated projects that have
Copy file name to clipboardExpand all lines: tutorials/developers-tutorial1/developers-help-1.ipynb
+37-5Lines changed: 37 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -23,15 +23,47 @@
23
23
"In this tutorial we will indeed create from scratch a new version of the original DMD; such extension will be totally useless from a scientific perspective, the only purpose is showing the suggested steps to implement new variants inside **PyDMD**."
24
24
]
25
25
},
26
+
{
27
+
"cell_type": "markdown",
28
+
"metadata": {},
29
+
"source": [
30
+
"## The Back-end API"
31
+
]
32
+
},
26
33
{
27
34
"cell_type": "markdown",
28
35
"metadata": {},
29
36
"source": [
30
37
"The necessary bricks for building the new DMD version are:\n",
31
38
"\n",
32
-
"- [`DMDBase`](https://mathlab.github.io/PyDMD/dmdbase.html), the actual backbone of all the different implemented versions;\n",
33
-
"- `DMDTimeDict`, the class that manages the time window;\n",
34
-
"- `DMDOperator`, the class that manages the so-called DMD operator;\n",
39
+
"- [`DMDBase`](https://pydmd.github.io/PyDMD/dmdbase.html), the actual backbone of all the different implemented versions;\n",
40
+
"- [`DMDTimeDict`](https://github.com/PyDMD/PyDMD/blob/7ac9f3fa855e9a5e7008daad9906eaa6e59ba80a/pydmd/dmdbase.py#L759), the class that manages the time window;\n",
41
+
"- [`DMDOperator`](https://pydmd.github.io/PyDMD/dmdoperator.html), the class that manages the so-called DMD operator;\n",
42
+
"\n",
43
+
"The following schematic outlines the general structure of every `DMDBase` module.\n",
44
+
"\n",
45
+
"In general, all `PyDMD` modules should be capable of the following tasks:\n",
46
+
"1) Accepting and storing DMD algorithm parameters.\n",
47
+
"2) Performing DMD given snapshot data $\\mathbf{X}$ via the `fit` method, which often does the following:\n",
48
+
" - prepares and stores the input data,\n",
49
+
" - sets the `DMDTimeDict`s,\n",
50
+
" - computes the DMD operator and its eigendecomposition, and\n",
51
+
" - (this is done by invoking the `DMDOperator`'s `compute_operator` function)\n",
52
+
" - computes the DMD amplitudes using the computed operator.\n",
53
+
"3) Fetching and utilizing DMD results, such as:\n",
54
+
" - the reduced DMD operator $\\tilde{\\mathbf{A}}$\n",
55
+
" - the spatial modes $\\mathbf{\\Phi}$ (the eigenvectors of $\\mathbf{A}$)\n",
56
+
" - the temporal frequencies $\\mathbf{\\Lambda}$ (the eigenvalues of $\\mathbf{A}$)\n",
57
+
" - the spatiotemporal mode amplitudes $\\mathbf{b}$\n",
58
+
"\n",
59
+
"Hence different modules implement different DMD variants, where any number of these steps may be performed differently."
60
+
]
61
+
},
62
+
{
63
+
"cell_type": "markdown",
64
+
"metadata": {},
65
+
"source": [
66
+
"## Building a New PyDMD Module\n",
35
67
"\n",
36
68
"We start the new module by importing all these classes and the usual math environment (`matplotlib`+`numpy`)."
0 commit comments