Skip to main content

MODULO (MODal mULtiscale pOd) is a software developed at the von Karman Institute to perform Multiscale Modal Analysis of numerical and experimental data.

Project description

MODULO: a python toolbox for data-driven modal decomposition

MODULO logo

MODULO is a modal decomposition package developed at the von Karman Institute for Fluid Dynamics (VKI). It offers a wide range of decomposition techniques, allowing users to choose the most appropriate method for their specific problem. MODULO can efficiently handle large datasets natively, thanks to a memory-saving feature that partitions the data and processes the decomposition in chunks (Nini et al. (2022)). Moreover, it supports non-uniform meshes through a weighted inner product formulation. Currently, MODULO heavily relies on NumPy routines and does not offer additional parallel computing capabilities beyond those naturally provided by NumPy.

While the discontinued MATLAB version of MODULO is accessible in the “Old_Matlab_Implementation” branch, it is no longer maintained. The latest decomposition techniques are exclusively available in the current Python version (Poletti et al. (2024)).

As a part of the MODULO project, we provide a series of lectures on data-driven modal decomposition, and its applications. These are available at the MODULO YouTube channel. The full package documentation can be found at: MODULO ReadTheDocs.

Release Notes

This version of MODULO includes the following updates:

  1. mPOD bug fix: the previous version of mPOD was skipping the last scale of the frequency splitting vector. Fixed in this version.

  2. SPOD parallelisation: CSD - SPOD can now be parallelized, leveraging joblib. The user needs just to pass the argument n_processes for the computation to be split between different workers.

  3. Simplified decomposition interface: the interface of the decomposition methods has been simplified to improve user experience.

  4. Enhanced POD selection: the POD function has been redesigned, allowing users to easily choose between different POD methods.

  5. Improved computational efficiency: the code of the decomposition functions has been optimised, resulting in reduced computation time. mPOD now includes two additional optional arguments to enable faster filtering and to avoid recomputing the Sigmas after QR polishing.

  6. Extended documentation: the documentation has been significantly enriched, now including theoretical foundations for all the supported modal decomposition techniques.

Documentation

The documentation of MODULO is available here. It contains a comprehensive guide on how to install and use the package, as well as a detailed description of the decompositions required inputs and outputs. A list of YouTube videos is also available to guide the introduce the user to modal decomposition and MODULO.

Installation

Installation via pip

You can access the latest update of the modulo python package on PyPI using the command line:

$ pip install modulo_vki

Installation from source

Alternatively, you can clone the repository and install the package locally:

$ git clone https://github.com/mendezVKI/MODULO.git

$ cd MODULO

$ python setup.py install

or, if you have pip installed in your environment,

$ pip install .

Example

Example 1: POD decomposition

The following example illustrates how to decompose a data set (D) using the POD decomposition.

from modulo_vki import ModuloVKI
import numpy as np

# Create a random dataset
D = np.random.rand(100, 1000)

# Initialize the ModuloVKI object
m = ModuloVKI(D)

# Compute the POD decomposition
phi_POD, Sigma_POD, psi_POD = m.POD()

which returns the spatial basis ($phi$), the temporal basis ($psi$), and the modal amplitudes ($Sigma$) of the POD decomposition.

Example 2: Memory Saving option

For the Memory Saving option, MODULO decomposes $D$ in N_partitions, defined by the user (refer to examples/ex_04_Memory_Saving.py).

import os
import numpy as np
from modulo_vki import ModuloVKI
from modulo_vki.utils.read_db import ReadData

# --- 1. User-defined settings ---
# Define the path to your data and the file naming convention.
FOLDER = 'path/to/your/snapshot_data'
FILE_ROOT_NAME = 'Res'  # The base name, e.g., 'Res' for 'Res00001.dat'
n_t = 100               # The total number of snapshots (time steps) to process.

# --- 2. Data format parameters ---
# Specify how to read your text-based snapshot files.
H = 1  # H: Number of header lines to skip
F = 0  # F: Number of footer lines to skip
C = 0  # C: Number of initial columns to skip

# --- 3. Determine data dimensions from a sample file ---
# To understand the structure, we load the first snapshot.
first_snapshot_file = os.path.join(FOLDER, f"{FILE_ROOT_NAME}00001.dat")
Dat = np.genfromtxt(first_snapshot_file, skip_header=H, skip_footer=F)

# N: Number of components per point (e.g., 2 for 2D velocity u,v)
N = Dat.shape[1]
# nxny: Number of spatial points in the mesh
nxny = Dat.shape[0]
# N_T: Total number of snapshots (aliased from n_t for clarity)
N_T = n_t

# --- 4. Process the dataset into partitions on disk ---
# The ReadData utility reads all snapshots and chunks the snapshot matrix.

D = ReadData._data_processing(
    D=None,                      # We start with no data in memory
    FOLDER_IN=FOLDER,
    filename=f'{FILE_ROOT_NAME}%05d', # File pattern for snapshot files
    N=N,                         # Number of components per point
    N_S=N * nxny,                # Total size of a single snapshot vector
    N_T=N_T,                     # Total number of snapshots
    h=H, f=F, c=C,               # Header, footer, and column skip parameters
    N_PARTITIONS=10,             # The dataset will be split into 10 chunks
    MR=False,                    # Mean-removal flag
    FOLDER_OUT=os.path.join('.', 'MODULO_tmp') # Where to save temp files
)

# --- 5. Initialize ModuloVKI and compute the POD ---
# Initialize the object, passing the number of partitions. D must be set to None
# MODULO will look for the partitions in FOLDER_OUT/MODULO_tmp
m = ModuloVKI(None, N_PARTITIONS=10, FOLDER_OUT=FOLDER_OUT)

# The POD method will now automatically read the data from the partitioned files.
phi_POD, Sigma_POD, psi_POD = m.POD()

print("POD computation complete.")

Example 3: non-uniform grid

If you are dealing with non-uniform grid (e.g. output of a Computational Fluid Dynamic (CFD) simulation), you can use the weighted inner product formulation (refer to examples/ex_05_nonUniform_POD.py).

from modulo_vki import ModuloVKI
import numpy as np

# Create a random dataset
D = np.random.rand(100, 1000)

# Get the area of the grid
a_dataSet = gridData.compute_cell_sizes()
area = a_dataSet['Area']

# Compute weights
areaTot = np.sum(area)
weights = area/areaTot # sum should be equal to 1

# Initialize the ModuloVKI object
m = ModuloVKI(D, weights=weights)

# Compute the POD decomposition
phi_POD, Sigma_POD, psi_POD = m.POD()

Community guidelines

Contributing to MODULO

We welcome contributions to MODULO.

It is recommended to perform a shallow clone of the repository to avoid downloading the entire history of the project:

$ git clone --depth 1 https://github.com/mendezVKI/MODULO.git

This will download only the latest version of the repository, which is sufficient for contributing to the project, and will save you time and disk space.

To create a new feature, please submit a pull request, specifying the proposed changes and providing an example of how to use the new feature (that will be included in the examples/ folder).

The pull request will be reviewed by the MODULO team before being merged into the main branch, and your contribution duly acknowledged.

Report bugs

If you find a bug, or you encounter unexpected behaviour, please open an issue on the MODULO GitHub repository.

Ask for help

If you have troubles using MODULO, or you need help with a specific decomposition, please open an issue on the MODULO GitHub repository.

Citation

If you use MODULO in your research, please cite it as follows:

Poletti, R., Schena, L., Ninni, D., Mendez, M. A. (2024). MODULO: A Python toolbox for data-driven modal decomposition. Journal of Open Source Software, 9(102), 6753. https://doi.org/10.21105/joss.06753

@article{Poletti2024,
  doi = {10.21105/joss.06753},
  url = {https://doi.org/10.21105/joss.06753},
  year = {2024},
  publisher = {The Open Journal},
  volume = {9},
  number = {102},
  pages = {6753},
  author = {R. Poletti and L. Schena and D. Ninni and M. A. Mendez},
  title = {MODULO: A Python toolbox for data-driven modal decomposition},
  journal = {Journal of Open Source Software}
}

and

Ninni, D., & Mendez, M. A. (2020). MODULO: A software for Multiscale Proper Orthogonal Decomposition of data. SoftwareX, 12, 100622. https://doi.org/10.1016/j.softx.2020.100622

@article{ninni2020modulo,
    title={MODULO: A software for Multiscale Proper Orthogonal Decomposition of data},
    author={Ninni, Davide and Mendez, Miguel A},
    journal={SoftwareX},
    volume={12},
    pages={100622},
    year={2020},
    publisher={Elsevier}
}

References

  • Mendez, Miguel Alfonso. “Statistical Treatment, Fourier and Modal Decomposition.” arXiv preprint arXiv:2201.03847 (2022).

  • Mendez, M. A. (2023) “Generalized and Multiscale Modal Analysis”. In : Mendez M.A., Ianiro, A., Noack, B.R., Brunton, S. L. (Eds), “Data-Driven Fluid Mechanics: Combining First Principles and Machine Learning”. Cambridge University Press, 2023:153-181. https://doi.org/10.1017/9781108896214.013. The pre-print is available at https://arxiv.org/abs/2208.12630.

  • Ninni, Davide, and Miguel A. Mendez. “MODULO: A software for Multiscale Proper Orthogonal Decomposition of data.” SoftwareX 12 (2020): 100622.

  • Poletti, Romain, Schena, Lorenzo, Ninni, David, and Mendez, Miguel A. “Modulo: A python toolbox for data-driven modal decomposition”. Journal of Open Source Software (2024), 9(102), 6753.

  • Mendez, Miguel A. “Linear and nonlinear dimensionality reduction from fluid mechanics to machine learning.” Measurement Science and Technology 34.4 (2023): 042001.

  • 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.

  • 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.

  • Sirovich, Lawrence. “Turbulence and the dynamics of coherent structures. III. Dynamics and scaling.” Quarterly of Applied mathematics 45.3 (1987): 583-590.

  • 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.

  • Schmid, Peter J. “Dynamic mode decomposition of numerical and experimental data.” Journal of fluid mechanics 656 (2010): 5-28.

  • Sieber, Moritz, C. Oliver Paschereit, and Kilian Oberleithner. “Spectral proper orthogonal decomposition.” Journal of Fluid Mechanics 792 (2016): 798-828.

  • 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.

  • Mika, Sebastian, et al. “Kernel PCA and de-noising in feature spaces.” Advances in neural information processing systems 11 (1998).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

modulo_vki-2.1.5-py3-none-any.whl (72.9 kB view details)

Uploaded Python 3

File details

Details for the file modulo_vki-2.1.5-py3-none-any.whl.

File metadata

  • Download URL: modulo_vki-2.1.5-py3-none-any.whl
  • Upload date:
  • Size: 72.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.1

File hashes

Hashes for modulo_vki-2.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1e3fb2069e1cf89cc17dd279e9f8fce7dfa3bb732c9c0a3e74376477260df200
MD5 f6022575ae1a5dbf5e30e9098ad6b7b0
BLAKE2b-256 cb7a1a07fa259252a351831a4f516bfd06c2652fb1820a2898201236b32e320a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page