modulo-vki 2.0.4__tar.gz → 2.0.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. modulo_vki-2.0.6/PKG-INFO +304 -0
  2. modulo_vki-2.0.6/README.rst +280 -0
  3. {modulo_vki-2.0.4 → modulo_vki-2.0.6}/modulo_vki/core/_pod_space.py +6 -6
  4. {modulo_vki-2.0.4 → modulo_vki-2.0.6}/modulo_vki/modulo.py +15 -16
  5. {modulo_vki-2.0.4 → modulo_vki-2.0.6}/modulo_vki/utils/_utils.py +2 -0
  6. {modulo_vki-2.0.4 → modulo_vki-2.0.6}/modulo_vki/utils/others.py +34 -31
  7. {modulo_vki-2.0.4 → modulo_vki-2.0.6}/modulo_vki/utils/read_db.py +1 -1
  8. modulo_vki-2.0.6/modulo_vki.egg-info/PKG-INFO +304 -0
  9. {modulo_vki-2.0.4 → modulo_vki-2.0.6}/modulo_vki.egg-info/SOURCES.txt +1 -1
  10. {modulo_vki-2.0.4 → modulo_vki-2.0.6}/setup.py +2 -2
  11. modulo_vki-2.0.4/PKG-INFO +0 -96
  12. modulo_vki-2.0.4/README.md +0 -72
  13. modulo_vki-2.0.4/modulo_vki.egg-info/PKG-INFO +0 -96
  14. {modulo_vki-2.0.4 → modulo_vki-2.0.6}/LICENSE +0 -0
  15. {modulo_vki-2.0.4 → modulo_vki-2.0.6}/modulo_vki/__init__.py +0 -0
  16. {modulo_vki-2.0.4 → modulo_vki-2.0.6}/modulo_vki/core/__init__.py +0 -0
  17. {modulo_vki-2.0.4 → modulo_vki-2.0.6}/modulo_vki/core/_dft.py +0 -0
  18. {modulo_vki-2.0.4 → modulo_vki-2.0.6}/modulo_vki/core/_dmd_s.py +0 -0
  19. {modulo_vki-2.0.4 → modulo_vki-2.0.6}/modulo_vki/core/_k_matrix.py +0 -0
  20. {modulo_vki-2.0.4 → modulo_vki-2.0.6}/modulo_vki/core/_mpod_space.py +0 -0
  21. {modulo_vki-2.0.4 → modulo_vki-2.0.6}/modulo_vki/core/_mpod_time.py +0 -0
  22. {modulo_vki-2.0.4 → modulo_vki-2.0.6}/modulo_vki/core/_pod_time.py +0 -0
  23. {modulo_vki-2.0.4 → modulo_vki-2.0.6}/modulo_vki/core/_spod_s.py +0 -0
  24. {modulo_vki-2.0.4 → modulo_vki-2.0.6}/modulo_vki/core/_spod_t.py +0 -0
  25. {modulo_vki-2.0.4 → modulo_vki-2.0.6}/modulo_vki/utils/__init__.py +0 -0
  26. {modulo_vki-2.0.4 → modulo_vki-2.0.6}/modulo_vki/utils/_plots.py +0 -0
  27. {modulo_vki-2.0.4 → modulo_vki-2.0.6}/modulo_vki.egg-info/dependency_links.txt +0 -0
  28. {modulo_vki-2.0.4 → modulo_vki-2.0.6}/modulo_vki.egg-info/requires.txt +0 -0
  29. {modulo_vki-2.0.4 → modulo_vki-2.0.6}/modulo_vki.egg-info/top_level.txt +0 -0
  30. {modulo_vki-2.0.4 → modulo_vki-2.0.6}/setup.cfg +0 -0
@@ -0,0 +1,304 @@
1
+ Metadata-Version: 2.1
2
+ Name: modulo_vki
3
+ Version: 2.0.6
4
+ Summary: MODULO (MODal mULtiscale pOd) is a software developed at the von Karman Institute to perform Multiscale Modal Analysis of numerical and experimental data.
5
+ Home-page: https://github.com/mendezVKI/MODULO/tree/master/modulo_python_package/
6
+ Author: ['R. Poletti', 'L. Schena', 'D. Ninni', 'M. A. Mendez']
7
+ Author-email: mendez@vki.ac.be
8
+ License: BSD (3-clause)
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Natural Language :: English
11
+ Classifier: Programming Language :: Python :: 3
12
+ Requires-Python: >=3.6
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: tqdm
16
+ Requires-Dist: numpy
17
+ Requires-Dist: scipy
18
+ Requires-Dist: scikit-learn
19
+ Requires-Dist: ipykernel
20
+ Requires-Dist: ipython
21
+ Requires-Dist: ipython-genutils
22
+ Requires-Dist: ipywidgets
23
+ Requires-Dist: matplotlib
24
+
25
+
26
+
27
+ MODULO: a python toolbox for data-driven modal decomposition
28
+ -----------------------------------------------------------
29
+
30
+ .. image:: https://readthedocs.org/projects/modulo/badge/?version=latest
31
+ :target: https://modulo.readthedocs.io/en/latest/?badge=latest
32
+ :alt: Documentation Status
33
+
34
+ .. raw:: html
35
+
36
+ <div style="text-align: center;">
37
+ <img src="https://modulo.readthedocs.io/en/latest/_images/modulo_logo.png" alt="Modulo Logo" width="500"/>
38
+ </div>
39
+
40
+ **MODULO** is a modal decomposition package developed at the von Karman Institute for Fluid Dynamics (VKI).
41
+ It offers a wide range of decomposition techniques, enabling users to select the most suitable method based
42
+ on the specific physics of their problem and their desired outcomes. MODULO can natively handle large
43
+ datasets efficiently, featuring a memory-saving option that partitions the data and computes the decomposition in
44
+ chunks (ninni2020modulo). Additionally, it supports non-uniform meshes through its weighted inner product formulation.
45
+
46
+ While the discontinued MATLAB version of MODULO (ninni2020modulo) is accessible in the “Old_Matlab_Implementation” branch,
47
+ it is no longer maintained. The latest decomposition techniques are exclusively available in the current Python version.
48
+
49
+ As a part of the MODULO project, we provide a series of lectures on data-driven modal decomposition, and its applications.
50
+ These are available at the `MODULO YouTube channel <https://www.youtube.com/@modulompod5682>`_.
51
+
52
+
53
+ .. contents:: Table of contents
54
+
55
+ Modal decompositions
56
+ --------------------
57
+ Modal decompositions aim to describe the data as a linear combination of *modes*, obtained by projecting the data
58
+ onto a suitable set of basis. For instance, consider a matrix $D(x, t)$, where $x$ and $t$ are the spatial and temporal
59
+ coordinates, respectively, the modal decomposition can be written as:
60
+
61
+ $D(x_i, t_k) = \\phi(x_i) \\Sigma \\psi(t_k)^T$
62
+
63
+ where $\\phi(x_i)$ is the spatial basis, $\\psi(t_k)$ is the temporal basis, and $\\Sigma$ is the modal coefficients.
64
+ Different decompositions employ different basis, such as prescribed Fourier basis ($\\psi_\\mathcal{F}$) for
65
+ the Discrete Fourier Transform (DFT), or data-driven basis, i.e. tailored on the dataset at hand,
66
+ for the Proper Orthogonal Decomposition (POD).
67
+
68
+ We refer to (mendez2022statistical, mendez2022generalizedmultiscalemodalanalysis, Mendez_2023) for an introduction to the topic.
69
+
70
+ MODULO currently features the following decompositions:
71
+ - Discrete Fourier Transform (DFT) (briggs1995dft)
72
+ - Proper Orthogonal Decomposition (POD) (sirovich1987turbulence, berkooz1993proper)
73
+ - Multi-Scale Proper Orthogonal Decomposition (mPOD) (mendez2019multi)
74
+ - Dynamic Mode Decomposition (DMD) (schmid2010dynamic)
75
+ - Spectral Proper Orthogonal Decomposition (SPOD) (csieber2016spectral, towne2018spectral), note that the two are
76
+ different formulations, and both are available in MODULO.
77
+ - Kernel Proper Orthogonal Decomposition (KPOD) (mika1998kernel)
78
+
79
+ We remind the curious reader to the respective references for a detailed description of each decomposition, and to the
80
+ documentation for a practical guide on how to use them in MODULO.
81
+
82
+
83
+ Release Notes
84
+ -------------
85
+ The latest version of MODULO (v2.0) includes the following updates:
86
+
87
+ 1. **Faster EIG/SVD algorithms**, using powerful randomized svd solvers from scikit_learn
88
+ (see `here<https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.TruncatedSVD.html>`_
89
+ and `here <https://scikit-learn.org/stable/modules/generated/sklearn.utils.extmath.randomized_svd.html>`_.)
90
+ It is now possible to select various options as "eig_solver" and "svd_solver",
91
+ offering different trade-offs in terms of accuracy vs computational time.
92
+
93
+ 2. **Computation the POD directly via SVD**, using any of the four "svd_solver" options.
94
+ This is generally faster but requires more memory.
95
+
96
+ 1. **Faster subscale estimators for the mPOD:** the previous version used the rank of the correlation matrix in each scale to define
97
+ the number of modes to be computed in each portion of the splitting vector before assembling the full basis.
98
+ This is computationally very demanding. This estimation has been replaced by a
99
+ frequency-based threshold (i.e. based on the frequency bins within each portion) since one can show that the
100
+ frequency-based estimator is always more "conservative" than the rank-based estimator.
101
+
102
+ 1. **Major improvement on the memory saving option**: the previous version of modulo always required in input the matrix D.
103
+ Then, if the memory saving option was active, the matrix was partitioned and stored locally to free the RAM before computing the
104
+ correlation matrix (see [this tutorial by D. Ninni](https://www.youtube.com/watch?v=LclxO1WTuao)).
105
+ In the new version, it is possible to initialize a modulo object *without* the matrix D (see exercise 5 in the examples).
106
+ Instead, one can create the partitions without loading the matrix D.
107
+
108
+ 1. **Implementation of Dynamic Mode Decomposition (DMD)** from (Schmid, P.J 2010)
109
+
110
+ 2. **Implementation of the two Spectral POD formulations**, namely the one from (Sieber et al 2016),
111
+ and the one from (Towne et al 2018).
112
+
113
+ 3. **Implementation of a kernel version of the POD**, in which the correlation matrix is replaced by a kernel matrix.
114
+ This is described in Lecture 15 of the course `Hands on Machine Learning for Fluid dynamics 2023 <https://www.vki.ac.be/index.php/events-ls/events/eventdetail/552/-/online-on-site-hands-on-machine-learning-for-fluid-dynamics-2023>`_.
115
+ We refer also to: `https://arxiv.org/abs/2208.07746`.
116
+
117
+ 1. **Implementation of a formulation for non-uniform meshes**, using a weighted matrix for all the relevant inner products.
118
+ This is currently available only for POD and mPOD but allows for handling data produced from CFD simulation without resampling on a uniform grid (see exercise 4).
119
+ It can be used both with and without the memory-saving option.
120
+
121
+
122
+ Installation
123
+ -------------
124
+
125
+ Installation via pip
126
+ ^^^^^^^^^^^^^^^^^^^^
127
+
128
+ You can access the latest update of the modulo python package on PyPI using the command line:
129
+
130
+ .. code-block:: bash
131
+
132
+ $ pip install modulo_vki
133
+
134
+ Installation from source
135
+ ^^^^^^^^^^^^^^^^^^^^^^^^
136
+
137
+ Alternatively, you can clone the repository and install the package locally:
138
+
139
+ .. code-block:: bash
140
+
141
+ $ git clone https://github.com/mendezVKI/MODULO.git
142
+
143
+ $ cd MODULO
144
+
145
+ $ python setup.py install
146
+
147
+ or, if you have pip installed in your environment,
148
+
149
+ .. code-block:: bash
150
+
151
+ $ pip install .
152
+
153
+
154
+ Documentation
155
+ -------------
156
+
157
+ The documentation of MODULO is available `here <https://modulo.readthedocs.io/en/latest/intro.html>`_. It
158
+ contains a comprehensive guide on how to install and use the package, as well as a detailed description of the
159
+ decompositions required inputs and outputs. A `list of YouTube videos<https://www.youtube.com/@modulompod5682>`_
160
+ is also available to guide the introduce the user to modal decomposition and MODULO.
161
+
162
+ Example
163
+ -------------
164
+
165
+ Example 1: POD decomposition
166
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
167
+
168
+ The following example illustrates how to decompose a data set (D) using the POD decomposition.
169
+
170
+ .. code-block:: python
171
+
172
+ from modulo_vki import ModuloVKI
173
+ import numpy as np
174
+
175
+ # Create a random dataset
176
+ D = np.random.rand(100, 1000)
177
+
178
+ # Initialize the ModuloVKI object
179
+ m = ModuloVKI(D)
180
+
181
+ # Compute the POD decomposition
182
+ phi_POD, Sigma_POD, psi_POD = m.Compute_POD_K()
183
+
184
+ which returns the spatial basis ($\phi$), the temporal basis ($\psi$), and the modal
185
+ amplitudes ($\Sigma$) of the POD decomposition.
186
+
187
+ Example 2: Memory Saving option
188
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
189
+
190
+ For the Memory Saving option, MODULO decomposes $D$ in `N_partitions`, defined
191
+ by the user (refer to `examples/ex_04_Memory_Saving.py`).
192
+
193
+ .. code-block:: python
194
+
195
+ from modulo_vki import ModuloVKI
196
+ import numpy as np
197
+
198
+ # Create a random dataset
199
+ D = np.random.rand(100, 1000)
200
+
201
+ # Initialize the ModuloVKI object
202
+ m = ModuloVKI(D, N_PARTITIONS=10)
203
+
204
+ # Compute the POD decomposition
205
+ phi_POD, Sigma_POD, psi_POD = m.Compute_POD_K()
206
+
207
+ Example 3: non-uniform grid
208
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
209
+
210
+ If you are dealing with non-uniform grid (e.g. output of a Computational Fluid Dynamic (CFD) simulation),
211
+ you can use the weighted inner product formulation (refer to `examples/ex_05_nonUniform_POD.py`).
212
+
213
+ .. code-block:: python
214
+
215
+ from modulo_vki import ModuloVKI
216
+ import numpy as np
217
+
218
+ # Create a random dataset
219
+ D = np.random.rand(100, 1000)
220
+
221
+ # Get the area of the grid
222
+ a_dataSet = gridData.compute_cell_sizes()
223
+ area = a_dataSet['Area']
224
+
225
+ # Compute weights
226
+ areaTot = np.sum(area)
227
+ weights = area/areaTot # sum should be equal to 1
228
+
229
+ # Initialize the ModuloVKI object
230
+ m = ModuloVKI(D, weights=weights)
231
+
232
+ # Compute the POD decomposition
233
+ phi_POD, Sigma_POD, psi_POD = m.Compute_POD_K()
234
+
235
+
236
+
237
+ Community guidelines
238
+ ---------------------
239
+
240
+ Contributing to MODULO
241
+ ^^^^^^^^^^^^^^^^^^^^^^^
242
+ We welcome contributions to MODULO. To create a new feature, please submit a pull request, specifying the proposed changes and
243
+ providing an example of how to use the new feature (that will be included in the `examples/` folder).
244
+
245
+ The pull request will be reviewed by the MODULO team before being merged into the main branch, and your contribution duly acknowledged.
246
+
247
+ Report bugs
248
+ ^^^^^^^^^^^^
249
+ If you find a bug, or you encounter unexpected behaviour, please open an issue on the MODULO GitHub repository.
250
+
251
+ Ask for help
252
+ ^^^^^^^^^^^^
253
+
254
+ Citation
255
+ ---------
256
+ If you use MODULO in your research, please cite it as follows:
257
+
258
+ ``Ninni, D., & Mendez, M. A. (2020). MODULO: A software for Multiscale Proper Orthogonal Decomposition of data. SoftwareX, 12, 100622.``
259
+
260
+ .. code-block:: text
261
+
262
+ @article{ninni2020modulo,
263
+ title={MODULO: A software for Multiscale Proper Orthogonal Decomposition of data},
264
+ author={Ninni, Davide and Mendez, Miguel A},
265
+ journal={SoftwareX},
266
+ volume={12},
267
+ pages={100622},
268
+ year={2020},
269
+ publisher={Elsevier}
270
+ }
271
+
272
+ We are currently working on a Journal of Open Source article that will be available soon.
273
+
274
+ References
275
+ ----------
276
+
277
+ - Mendez, Miguel Alfonso. "Statistical Treatment, Fourier and Modal Decomposition." arXiv preprint arXiv:2201.03847 (2022).
278
+ - Mendez, M. A. (2023) "Generalized and Multiscale Modal Analysis". In : Mendez M.A., Ianiro, A., Noack, B.R., Brunton, S. L. (Eds),
279
+ "Data-Driven Fluid Mechanics: Combining First Principles and Machine Learning". Cambridge University Press, 2023:153-181.
280
+ https://doi.org/10.1017/9781108896214.013. The pre-print is available at https://arxiv.org/abs/2208.12630.
281
+ - Ninni, Davide, and Miguel A. Mendez. "MODULO: A software for Multiscale Proper Orthogonal Decomposition of data." SoftwareX 12 (2020): 100622.
282
+ - Mendez, Miguel A. "Linear and nonlinear dimensionality reduction from fluid mechanics to machine learning." Measurement Science and Technology 34.4 (2023): 042001.
283
+ - Briggs, William L., and Van Emden Henson. The DFT: an owner's manual for the discrete Fourier transform. Society for Industrial and Applied Mathematics, 1995.
284
+ - Berkooz, Gal, Philip Holmes, and John L. Lumley. "The proper orthogonal decomposition in the analysis of turbulent flows." Annual review of fluid mechanics 25.1 (1993): 539-575.
285
+ - Sirovich, Lawrence. "Turbulence and the dynamics of coherent structures. III. Dynamics and scaling." Quarterly of Applied mathematics 45.3 (1987): 583-590.
286
+ - Mendez, M. A., M. Balabane, and J-M. Buchlin. "Multi-scale proper orthogonal decomposition of complex fluid flows." Journal of Fluid Mechanics 870 (2019): 988-1036.
287
+ - Schmid, Peter J. "Dynamic mode decomposition of numerical and experimental data." Journal of fluid mechanics 656 (2010): 5-28.
288
+ - Sieber, Moritz, C. Oliver Paschereit, and Kilian Oberleithner. "Spectral proper orthogonal decomposition." Journal of Fluid Mechanics 792 (2016): 798-828.
289
+ - Towne, Aaron, Oliver T. Schmidt, and Tim Colonius. "Spectral proper orthogonal decomposition and its relationship to dynamic mode decomposition and resolvent analysis." Journal of Fluid Mechanics 847 (2018): 821-867.
290
+ - Mika, Sebastian, et al. "Kernel PCA and de-noising in feature spaces." Advances in neural information processing systems 11 (1998).
291
+
292
+ Related projects
293
+ ----------------
294
+ MODULO encapsulates a wide range of decomposition techniques, but not all of them. We refer to the project below for an additional set of decomposition techniques:
295
+
296
+ - ModRed, https://github.com/belson17/modred
297
+
298
+ There are also decomposition-specific projects, some of which are listed below:
299
+
300
+ - Rogowski, Marcin, Brandon CY Yeung, Oliver T. Schmidt, Romit Maulik, Lisandro Dalcin, Matteo Parsani, and Gianmarco Mengaldo. "Unlocking massively parallel spectral proper orthogonal decompositions in the PySPOD package." Computer Physics Communications 302 (2024): 109246.
301
+ - Lario, A., Maulik, R., Schmidt, O.T., Rozza, G. and Mengaldo, G., 2022. Neural-network learning of SPOD latent dynamics. Journal of Computational Physics, 468, p.111475.
302
+ - Ichinaga, Andreuzzi, Demo, Tezzele, Lapo, Rozza, Brunton, Kutz. PyDMD: A Python package for robust dynamic mode decomposition. arXiv preprint, 2024.
303
+ - Rogowski, Marcin, et al. "Unlocking massively parallel spectral proper orthogonal decompositions in the PySPOD package." Computer Physics Communications 302 (2024): 109246.
304
+
@@ -0,0 +1,280 @@
1
+
2
+
3
+ MODULO: a python toolbox for data-driven modal decomposition
4
+ -----------------------------------------------------------
5
+
6
+ .. image:: https://readthedocs.org/projects/modulo/badge/?version=latest
7
+ :target: https://modulo.readthedocs.io/en/latest/?badge=latest
8
+ :alt: Documentation Status
9
+
10
+ .. raw:: html
11
+
12
+ <div style="text-align: center;">
13
+ <img src="https://modulo.readthedocs.io/en/latest/_images/modulo_logo.png" alt="Modulo Logo" width="500"/>
14
+ </div>
15
+
16
+ **MODULO** is a modal decomposition package developed at the von Karman Institute for Fluid Dynamics (VKI).
17
+ It offers a wide range of decomposition techniques, enabling users to select the most suitable method based
18
+ on the specific physics of their problem and their desired outcomes. MODULO can natively handle large
19
+ datasets efficiently, featuring a memory-saving option that partitions the data and computes the decomposition in
20
+ chunks (ninni2020modulo). Additionally, it supports non-uniform meshes through its weighted inner product formulation.
21
+
22
+ While the discontinued MATLAB version of MODULO (ninni2020modulo) is accessible in the “Old_Matlab_Implementation” branch,
23
+ it is no longer maintained. The latest decomposition techniques are exclusively available in the current Python version.
24
+
25
+ As a part of the MODULO project, we provide a series of lectures on data-driven modal decomposition, and its applications.
26
+ These are available at the `MODULO YouTube channel <https://www.youtube.com/@modulompod5682>`_.
27
+
28
+
29
+ .. contents:: Table of contents
30
+
31
+ Modal decompositions
32
+ --------------------
33
+ Modal decompositions aim to describe the data as a linear combination of *modes*, obtained by projecting the data
34
+ onto a suitable set of basis. For instance, consider a matrix $D(x, t)$, where $x$ and $t$ are the spatial and temporal
35
+ coordinates, respectively, the modal decomposition can be written as:
36
+
37
+ $D(x_i, t_k) = \\phi(x_i) \\Sigma \\psi(t_k)^T$
38
+
39
+ where $\\phi(x_i)$ is the spatial basis, $\\psi(t_k)$ is the temporal basis, and $\\Sigma$ is the modal coefficients.
40
+ Different decompositions employ different basis, such as prescribed Fourier basis ($\\psi_\\mathcal{F}$) for
41
+ the Discrete Fourier Transform (DFT), or data-driven basis, i.e. tailored on the dataset at hand,
42
+ for the Proper Orthogonal Decomposition (POD).
43
+
44
+ We refer to (mendez2022statistical, mendez2022generalizedmultiscalemodalanalysis, Mendez_2023) for an introduction to the topic.
45
+
46
+ MODULO currently features the following decompositions:
47
+ - Discrete Fourier Transform (DFT) (briggs1995dft)
48
+ - Proper Orthogonal Decomposition (POD) (sirovich1987turbulence, berkooz1993proper)
49
+ - Multi-Scale Proper Orthogonal Decomposition (mPOD) (mendez2019multi)
50
+ - Dynamic Mode Decomposition (DMD) (schmid2010dynamic)
51
+ - Spectral Proper Orthogonal Decomposition (SPOD) (csieber2016spectral, towne2018spectral), note that the two are
52
+ different formulations, and both are available in MODULO.
53
+ - Kernel Proper Orthogonal Decomposition (KPOD) (mika1998kernel)
54
+
55
+ We remind the curious reader to the respective references for a detailed description of each decomposition, and to the
56
+ documentation for a practical guide on how to use them in MODULO.
57
+
58
+
59
+ Release Notes
60
+ -------------
61
+ The latest version of MODULO (v2.0) includes the following updates:
62
+
63
+ 1. **Faster EIG/SVD algorithms**, using powerful randomized svd solvers from scikit_learn
64
+ (see `here<https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.TruncatedSVD.html>`_
65
+ and `here <https://scikit-learn.org/stable/modules/generated/sklearn.utils.extmath.randomized_svd.html>`_.)
66
+ It is now possible to select various options as "eig_solver" and "svd_solver",
67
+ offering different trade-offs in terms of accuracy vs computational time.
68
+
69
+ 2. **Computation the POD directly via SVD**, using any of the four "svd_solver" options.
70
+ This is generally faster but requires more memory.
71
+
72
+ 1. **Faster subscale estimators for the mPOD:** the previous version used the rank of the correlation matrix in each scale to define
73
+ the number of modes to be computed in each portion of the splitting vector before assembling the full basis.
74
+ This is computationally very demanding. This estimation has been replaced by a
75
+ frequency-based threshold (i.e. based on the frequency bins within each portion) since one can show that the
76
+ frequency-based estimator is always more "conservative" than the rank-based estimator.
77
+
78
+ 1. **Major improvement on the memory saving option**: the previous version of modulo always required in input the matrix D.
79
+ Then, if the memory saving option was active, the matrix was partitioned and stored locally to free the RAM before computing the
80
+ correlation matrix (see [this tutorial by D. Ninni](https://www.youtube.com/watch?v=LclxO1WTuao)).
81
+ In the new version, it is possible to initialize a modulo object *without* the matrix D (see exercise 5 in the examples).
82
+ Instead, one can create the partitions without loading the matrix D.
83
+
84
+ 1. **Implementation of Dynamic Mode Decomposition (DMD)** from (Schmid, P.J 2010)
85
+
86
+ 2. **Implementation of the two Spectral POD formulations**, namely the one from (Sieber et al 2016),
87
+ and the one from (Towne et al 2018).
88
+
89
+ 3. **Implementation of a kernel version of the POD**, in which the correlation matrix is replaced by a kernel matrix.
90
+ This is described in Lecture 15 of the course `Hands on Machine Learning for Fluid dynamics 2023 <https://www.vki.ac.be/index.php/events-ls/events/eventdetail/552/-/online-on-site-hands-on-machine-learning-for-fluid-dynamics-2023>`_.
91
+ We refer also to: `https://arxiv.org/abs/2208.07746`.
92
+
93
+ 1. **Implementation of a formulation for non-uniform meshes**, using a weighted matrix for all the relevant inner products.
94
+ This is currently available only for POD and mPOD but allows for handling data produced from CFD simulation without resampling on a uniform grid (see exercise 4).
95
+ It can be used both with and without the memory-saving option.
96
+
97
+
98
+ Installation
99
+ -------------
100
+
101
+ Installation via pip
102
+ ^^^^^^^^^^^^^^^^^^^^
103
+
104
+ You can access the latest update of the modulo python package on PyPI using the command line:
105
+
106
+ .. code-block:: bash
107
+
108
+ $ pip install modulo_vki
109
+
110
+ Installation from source
111
+ ^^^^^^^^^^^^^^^^^^^^^^^^
112
+
113
+ Alternatively, you can clone the repository and install the package locally:
114
+
115
+ .. code-block:: bash
116
+
117
+ $ git clone https://github.com/mendezVKI/MODULO.git
118
+
119
+ $ cd MODULO
120
+
121
+ $ python setup.py install
122
+
123
+ or, if you have pip installed in your environment,
124
+
125
+ .. code-block:: bash
126
+
127
+ $ pip install .
128
+
129
+
130
+ Documentation
131
+ -------------
132
+
133
+ The documentation of MODULO is available `here <https://modulo.readthedocs.io/en/latest/intro.html>`_. It
134
+ contains a comprehensive guide on how to install and use the package, as well as a detailed description of the
135
+ decompositions required inputs and outputs. A `list of YouTube videos<https://www.youtube.com/@modulompod5682>`_
136
+ is also available to guide the introduce the user to modal decomposition and MODULO.
137
+
138
+ Example
139
+ -------------
140
+
141
+ Example 1: POD decomposition
142
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
143
+
144
+ The following example illustrates how to decompose a data set (D) using the POD decomposition.
145
+
146
+ .. code-block:: python
147
+
148
+ from modulo_vki import ModuloVKI
149
+ import numpy as np
150
+
151
+ # Create a random dataset
152
+ D = np.random.rand(100, 1000)
153
+
154
+ # Initialize the ModuloVKI object
155
+ m = ModuloVKI(D)
156
+
157
+ # Compute the POD decomposition
158
+ phi_POD, Sigma_POD, psi_POD = m.Compute_POD_K()
159
+
160
+ which returns the spatial basis ($\phi$), the temporal basis ($\psi$), and the modal
161
+ amplitudes ($\Sigma$) of the POD decomposition.
162
+
163
+ Example 2: Memory Saving option
164
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
165
+
166
+ For the Memory Saving option, MODULO decomposes $D$ in `N_partitions`, defined
167
+ by the user (refer to `examples/ex_04_Memory_Saving.py`).
168
+
169
+ .. code-block:: python
170
+
171
+ from modulo_vki import ModuloVKI
172
+ import numpy as np
173
+
174
+ # Create a random dataset
175
+ D = np.random.rand(100, 1000)
176
+
177
+ # Initialize the ModuloVKI object
178
+ m = ModuloVKI(D, N_PARTITIONS=10)
179
+
180
+ # Compute the POD decomposition
181
+ phi_POD, Sigma_POD, psi_POD = m.Compute_POD_K()
182
+
183
+ Example 3: non-uniform grid
184
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
185
+
186
+ If you are dealing with non-uniform grid (e.g. output of a Computational Fluid Dynamic (CFD) simulation),
187
+ you can use the weighted inner product formulation (refer to `examples/ex_05_nonUniform_POD.py`).
188
+
189
+ .. code-block:: python
190
+
191
+ from modulo_vki import ModuloVKI
192
+ import numpy as np
193
+
194
+ # Create a random dataset
195
+ D = np.random.rand(100, 1000)
196
+
197
+ # Get the area of the grid
198
+ a_dataSet = gridData.compute_cell_sizes()
199
+ area = a_dataSet['Area']
200
+
201
+ # Compute weights
202
+ areaTot = np.sum(area)
203
+ weights = area/areaTot # sum should be equal to 1
204
+
205
+ # Initialize the ModuloVKI object
206
+ m = ModuloVKI(D, weights=weights)
207
+
208
+ # Compute the POD decomposition
209
+ phi_POD, Sigma_POD, psi_POD = m.Compute_POD_K()
210
+
211
+
212
+
213
+ Community guidelines
214
+ ---------------------
215
+
216
+ Contributing to MODULO
217
+ ^^^^^^^^^^^^^^^^^^^^^^^
218
+ We welcome contributions to MODULO. To create a new feature, please submit a pull request, specifying the proposed changes and
219
+ providing an example of how to use the new feature (that will be included in the `examples/` folder).
220
+
221
+ The pull request will be reviewed by the MODULO team before being merged into the main branch, and your contribution duly acknowledged.
222
+
223
+ Report bugs
224
+ ^^^^^^^^^^^^
225
+ If you find a bug, or you encounter unexpected behaviour, please open an issue on the MODULO GitHub repository.
226
+
227
+ Ask for help
228
+ ^^^^^^^^^^^^
229
+
230
+ Citation
231
+ ---------
232
+ If you use MODULO in your research, please cite it as follows:
233
+
234
+ ``Ninni, D., & Mendez, M. A. (2020). MODULO: A software for Multiscale Proper Orthogonal Decomposition of data. SoftwareX, 12, 100622.``
235
+
236
+ .. code-block:: text
237
+
238
+ @article{ninni2020modulo,
239
+ title={MODULO: A software for Multiscale Proper Orthogonal Decomposition of data},
240
+ author={Ninni, Davide and Mendez, Miguel A},
241
+ journal={SoftwareX},
242
+ volume={12},
243
+ pages={100622},
244
+ year={2020},
245
+ publisher={Elsevier}
246
+ }
247
+
248
+ We are currently working on a Journal of Open Source article that will be available soon.
249
+
250
+ References
251
+ ----------
252
+
253
+ - Mendez, Miguel Alfonso. "Statistical Treatment, Fourier and Modal Decomposition." arXiv preprint arXiv:2201.03847 (2022).
254
+ - Mendez, M. A. (2023) "Generalized and Multiscale Modal Analysis". In : Mendez M.A., Ianiro, A., Noack, B.R., Brunton, S. L. (Eds),
255
+ "Data-Driven Fluid Mechanics: Combining First Principles and Machine Learning". Cambridge University Press, 2023:153-181.
256
+ https://doi.org/10.1017/9781108896214.013. The pre-print is available at https://arxiv.org/abs/2208.12630.
257
+ - Ninni, Davide, and Miguel A. Mendez. "MODULO: A software for Multiscale Proper Orthogonal Decomposition of data." SoftwareX 12 (2020): 100622.
258
+ - Mendez, Miguel A. "Linear and nonlinear dimensionality reduction from fluid mechanics to machine learning." Measurement Science and Technology 34.4 (2023): 042001.
259
+ - Briggs, William L., and Van Emden Henson. The DFT: an owner's manual for the discrete Fourier transform. Society for Industrial and Applied Mathematics, 1995.
260
+ - Berkooz, Gal, Philip Holmes, and John L. Lumley. "The proper orthogonal decomposition in the analysis of turbulent flows." Annual review of fluid mechanics 25.1 (1993): 539-575.
261
+ - Sirovich, Lawrence. "Turbulence and the dynamics of coherent structures. III. Dynamics and scaling." Quarterly of Applied mathematics 45.3 (1987): 583-590.
262
+ - Mendez, M. A., M. Balabane, and J-M. Buchlin. "Multi-scale proper orthogonal decomposition of complex fluid flows." Journal of Fluid Mechanics 870 (2019): 988-1036.
263
+ - Schmid, Peter J. "Dynamic mode decomposition of numerical and experimental data." Journal of fluid mechanics 656 (2010): 5-28.
264
+ - Sieber, Moritz, C. Oliver Paschereit, and Kilian Oberleithner. "Spectral proper orthogonal decomposition." Journal of Fluid Mechanics 792 (2016): 798-828.
265
+ - Towne, Aaron, Oliver T. Schmidt, and Tim Colonius. "Spectral proper orthogonal decomposition and its relationship to dynamic mode decomposition and resolvent analysis." Journal of Fluid Mechanics 847 (2018): 821-867.
266
+ - Mika, Sebastian, et al. "Kernel PCA and de-noising in feature spaces." Advances in neural information processing systems 11 (1998).
267
+
268
+ Related projects
269
+ ----------------
270
+ MODULO encapsulates a wide range of decomposition techniques, but not all of them. We refer to the project below for an additional set of decomposition techniques:
271
+
272
+ - ModRed, https://github.com/belson17/modred
273
+
274
+ There are also decomposition-specific projects, some of which are listed below:
275
+
276
+ - Rogowski, Marcin, Brandon CY Yeung, Oliver T. Schmidt, Romit Maulik, Lisandro Dalcin, Matteo Parsani, and Gianmarco Mengaldo. "Unlocking massively parallel spectral proper orthogonal decompositions in the PySPOD package." Computer Physics Communications 302 (2024): 109246.
277
+ - Lario, A., Maulik, R., Schmidt, O.T., Rozza, G. and Mengaldo, G., 2022. Neural-network learning of SPOD latent dynamics. Journal of Computational Physics, 468, p.111475.
278
+ - Ichinaga, Andreuzzi, Demo, Tezzele, Lapo, Rozza, Brunton, Kutz. PyDMD: A Python package for robust dynamic mode decomposition. arXiv preprint, 2024.
279
+ - Rogowski, Marcin, et al. "Unlocking massively parallel spectral proper orthogonal decompositions in the PySPOD package." Computer Physics Communications 302 (2024): 109246.
280
+
@@ -120,7 +120,7 @@ def Spatial_basis_POD(D, PSI_P, Sigma_P, MEMORY_SAVING, N_T, FOLDER_OUT='./', N_
120
120
  np.copyto(dr[:, C1:C2], di[R1:R2, :])
121
121
 
122
122
  PHI_SIGMA_BLOCK = np.dot(dr, PSI_P)
123
- np.savez(FOLDER_OUT + f"/POD/PHI_SIGMA_{i}",
123
+ np.savez(FOLDER_OUT + f"/PHI_SIGMA_{i}",
124
124
  phi_sigma=PHI_SIGMA_BLOCK)
125
125
 
126
126
  # 3 - Converting partitions R to partitions C and get Sigmas
@@ -144,7 +144,7 @@ def Spatial_basis_POD(D, PSI_P, Sigma_P, MEMORY_SAVING, N_T, FOLDER_OUT='./', N_
144
144
 
145
145
  for b in range(1, tot_blocks_row + 1):
146
146
 
147
- PHI_SIGMA_BLOCK = np.load(FOLDER_OUT + f"/POD/PHI_SIGMA_{b}.npz")['phi_sigma']
147
+ PHI_SIGMA_BLOCK = np.load(FOLDER_OUT + f"/PHI_SIGMA_{b}.npz")['phi_sigma']
148
148
 
149
149
  if (i == tot_blocks_col) and (R - dim_col * N_PARTITIONS > 0) and fixed == 0:
150
150
  R1 = R2
@@ -154,7 +154,7 @@ def Spatial_basis_POD(D, PSI_P, Sigma_P, MEMORY_SAVING, N_T, FOLDER_OUT='./', N_
154
154
  R1 = (i - 1) * dim_col
155
155
  R2 = i * dim_col
156
156
 
157
- if (b == tot_blocks_col) and (N_S - dim_row * N_PARTITIONS > 0):
157
+ if (b == tot_blocks_row) and (N_S - dim_row * N_PARTITIONS > 0): # Change here !!!
158
158
  C1 = C2
159
159
  C2 = C1 + (N_S - dim_row * N_PARTITIONS)
160
160
  else:
@@ -169,16 +169,16 @@ def Spatial_basis_POD(D, PSI_P, Sigma_P, MEMORY_SAVING, N_T, FOLDER_OUT='./', N_
169
169
  jj = j - R1
170
170
  Sigma_P[jj] = np.linalg.norm(dps[:, jj])
171
171
  Phi_P = dps[:, jj] / Sigma_P[jj]
172
- np.savez(FOLDER_OUT + f"/POD/phi_{j + 1}", phi_p=Phi_P)
172
+ np.savez(FOLDER_OUT + f"/phi_{j + 1}", phi_p=Phi_P)
173
173
  else:
174
174
  for j in range(R1, R2):
175
175
  jj = j - R1
176
176
  Phi_P = dps[:, jj] / Sigma_P[jj]
177
- np.savez(FOLDER_OUT + f"/POD/phi_{j + 1}", phi_p=Phi_P)
177
+ np.savez(FOLDER_OUT + f"/phi_{j + 1}", phi_p=Phi_P)
178
178
 
179
179
  Phi_P_M = np.zeros((N_S, R))
180
180
  for j in range(R):
181
- Phi_P_V = np.load(FOLDER_OUT + f"/POD/phi_{j + 1}.npz")['phi_p']
181
+ Phi_P_V = np.load(FOLDER_OUT + f"/phi_{j + 1}.npz")['phi_p']
182
182
  Phi_P_M[:, j] = Phi_P_V
183
183
 
184
184
  return Phi_P_M
@@ -429,7 +429,7 @@ class ModuloVKI:
429
429
  POD Phis
430
430
  """
431
431
 
432
- print('Computing correlation matrix D matrix...')
432
+ print('Computing correlation matrix...')
433
433
  self.K = CorrelationMatrix(self.N_T, self.N_PARTITIONS,
434
434
  self.MEMORY_SAVING,
435
435
  self.FOLDER_OUT, self.SAVE_K, D=self.Dstar, weights=self.weights)
@@ -443,24 +443,23 @@ class ModuloVKI:
443
443
  print("Done.")
444
444
  print("Computing Spatial Basis...")
445
445
 
446
- if hasattr(self, 'D'): # if self.D is available:
447
- print('Computing Phi from D...')
448
- Phi_P = Spatial_basis_POD(self.D, N_T=self.N_T,
449
- PSI_P=Psi_P,
450
- Sigma_P=Sigma_P,
451
- MEMORY_SAVING=self.MEMORY_SAVING,
452
- FOLDER_OUT=self.FOLDER_OUT,
453
- N_PARTITIONS=self.N_PARTITIONS)
454
-
455
- else: # if not, the memory saving is on and D will not be used. We pass a dummy D
446
+ if self.MEMORY_SAVING: # if self.D is available:
456
447
  print('Computing Phi from partitions...')
457
448
  Phi_P = Spatial_basis_POD(np.array([1]), N_T=self.N_T,
458
- PSI_P=Psi_P,
459
- Sigma_P=Sigma_P,
460
- MEMORY_SAVING=self.MEMORY_SAVING,
461
- FOLDER_OUT=self.FOLDER_OUT,
462
- N_PARTITIONS=self.N_PARTITIONS)
449
+ PSI_P=Psi_P,
450
+ Sigma_P=Sigma_P,
451
+ MEMORY_SAVING=self.MEMORY_SAVING,
452
+ FOLDER_OUT=self.FOLDER_OUT,
453
+ N_PARTITIONS=self.N_PARTITIONS)
463
454
 
455
+ else: # if not, the memory saving is on and D will not be used. We pass a dummy D
456
+ print('Computing Phi from D...')
457
+ Phi_P = Spatial_basis_POD(self.D, N_T=self.N_T,
458
+ PSI_P=Psi_P,
459
+ Sigma_P=Sigma_P,
460
+ MEMORY_SAVING=self.MEMORY_SAVING,
461
+ FOLDER_OUT=self.FOLDER_OUT,
462
+ N_PARTITIONS=self.N_PARTITIONS)
464
463
  print("Done.")
465
464
 
466
465
  return Phi_P, Psi_P, Sigma_P