flowTorch - a Python library for analysis and reduced-order modeling of fluid flows
flowTorch - a Python library for analysis and reduced-order modeling of fluid flows - Published in JOSS (2021)
Science Score: 59.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 3 DOI reference(s) in README -
✓Academic publication links
Links to: joss.theoj.org -
✓Committers with academic emails
4 of 6 committers (66.7%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.0%) to scientific vocabulary
Keywords
Scientific Fields
Repository
flowTorch - a Python library for analysis and reduced-order modeling of fluid flows
Basic Info
Statistics
- Stars: 157
- Watchers: 7
- Forks: 49
- Open Issues: 2
- Releases: 3
Topics
Metadata Files
README.md

flowTorch
flowTorch - a Python library for analysis and reduced order modeling of fluid flows
The development of flowTorch is primarily financed by the German Research Foundation (DFG) within the research program FOR 2895 unsteady flow and interaction phenomena at high speed stall conditions with the primary goal to investigate flow conditions that lead to buffeting at airfoils in the transonic flow regime.
https://user-images.githubusercontent.com/8482575/120886182-f2b78800-c5ec-11eb-9b93-efb9a139c431.mp4
The animation shows the shock buffet on a NACA-0012 airfoil at $Re=10^7$, $Ma=0.75$, and $\alpha=4^\circ$ angle of attack. The simulation was conducted with OpenFOAM; follow this link for more information about the setup.
Why flowTorch?
The flowTorch project was started to make the analysis and modeling of fluid data easy and accessible to everyone. The library design intends to strike a balance between usability and flexibility. Instead of a monolithic, black-box analysis tool, the library offers modular components that allow assembling custom analysis and modeling workflows with ease. flowTorch helps to fuse data from a wide range of file formats typical for fluid flow data, for example, to compare experiments simulations. The available analysis and modeling tools are rigorously tested and demonstrated on a variety of different fluid flow datasets. Moreover, one can significantly accelerate the entire process of accessing, cleaning, analyzing, and modeling fluid flow data by starting with one of the pipelines available in the flowTorch documentation.
To get a first impression of how working with flowTorch looks like, the code snippet below shows part of a pipeline for performing a dynamic mode decomposition (DMD) of a transient OpenFOAM simulation.
``` import torch as pt from flowtorch import DATASETS from flowtorch.data import FOAMDataloader, mask_box from flowtorch.analysis.dmd import DMD
path = DATASETS["ofcylinder2Dbinary"] loader = FOAMDataloader(path)
select a subset of the available snapshots
times = loader.writetimes windowtimes = [time for time in times if float(time) >= 4.0]
load vertices, discard z-coordinate, and create a mask
vertices = loader.vertices[:, :2] mask = mask_box(vertices, lower=[0.1, -1], upper=[0.75, 1])
assemble the data matrix
datamatrix = pt.zeros((mask.sum().item(), len(windowtimes)), dtype=pt.float32) for i, time in enumerate(windowtimes): # load the vorticity vector field, take the z-component [:, 2], and apply the mask datamatrix[:, i] = pt.maskedselect(loader.loadsnapshot("vorticity", time)[:, 2], mask)
perform DMD
dmd = DMD(data_matrix, rank=19)
analyze dmd.modes or dmd.eigvals
...
```
Currently, the following sub-packages are under active development. Note that some of the components are not yet available in the public release because further developments and testing are required:
| package | content | | :------ | :-------| |flowtorch.data | data loading, domain reduction (masked selection), outlier removal | | flowtorch.analysis | algorithms for dimensionality reduction and modal analysis (e.g., SVD, DMD, MSSA) | | flowtorch.rom | reduced-order modeling (CNM) |
flowTorch uses the PyTorch library as a backend for data structures, data types, and linear algebra operations on CPU and GPU. Some cool features of flowTorch include:
- data accessors return PyTorch tensors, which can be used directly within your favorite machine learning library, e.g., PyTorch, SkLearn or Tensorflow
- most algorithms run on CPU as well as on GPU
- mixed-precision operations (single/double); switching to single precision makes your life significantly easier when dealing with large datasets
- user-friendly Python library that integrates easily with popular tools and libraries like Jupyterlab, Matplotlib, Pandas, or Numpy
- a rich tutorial collection to help you getting started
- interfaces to common data formats like OpenFOAM, VTK (for Flexi and SU2), TAU, iPSP, CSV (for DaVis PIV data and raw OpenFOAM output)
flowTorch can be also used easily in combination with existing Python packages for analysis and reduced-order modeling thanks to the interoperability between PyTorch and NumPy. Great examples are (by no means a comprehensive list):
- PyDMD - Python dynamic mode decomposition
- PySINDy - sparse identification of nonlinear dynamical systems from data
- PyKoopman - data-driven approximations of the Koopman operator
Getting started
The easiest way to install flowTorch is as follows (use the development branch aweiner for access to the latest developments): ```
install via pip
pip3 install git+https://github.com/FlowModelingControl/flowtorch
or install a specific branch, e.g., aweiner
pip3 install git+https://github.com/FlowModelingControl/flowtorch.git@aweiner
to uninstall flowTorch, run
pip3 uninstall flowtorch
Alternatively, you can also clone the repository manually by running
git clone git@github.com:FlowModelingControl/flowtorch.git
and install the dependencies listed in *requirements.txt*:
pip3 install -r requirements.txt
Installing all flowTorch dependencies requires a significant amount of disk space. When using isolated subpackages, one can also install the dependencies manually (by trial-and-error). To load the library package from within a Python script file or a Jupyter notebook, add the path to the cloned repository as follows:
import sys
sys.path.insert(0, "/path/to/repository")
```
To get an overview of what flowTorch can do for you, have a look at the online documentation. The examples presented in the online documentation are also contained in this repository. In fact, the documentation is a static version of several Jupyter labs with start-to-end analyses. If you are interested in an interactive version of one particular example, navigate to ./docs/source/notebooks and run jupyter lab. Note that to execute some of the notebooks, the corresponding datasets are required. The datasets can be downloaded here (~2.6GB). If the data are only required for unit testing, a reduced dataset may be downloaded here (~411MB). Download the data into a directory of your choice and navigate into that directory. To extract the archive, run:
```
full dataset
tar xzf datasets2910_2021.tar.gz
reduced dataset
tar xzf datasetsminimal29102021.tar.gz
To tell *flowTorch* where the datasets are located, define the `FLOWTORCH_DATASETS` environment variable:
add export statement to bashrc; assumes that the extracted 'datasets' or 'datasets_minimal'
folder is located in the current directory
full dataset
echo "export FLOWTORCH_DATASETS=\"$(pwd)/datasets/\"" >> ~/.bashrc
reduced dataset
echo "export FLOWTORCHDATASETS=\"$(pwd)/datasetsminimal/\"" >> ~/.bashrc
reload bashrc
. ~/.bashrc ```
Installing ParaView
Note: the following installation of ParaView is only necessary if the TecplotDataloader is needed.
flowTorch uses the ParaView Python module for accessing Tecplot data. When installing ParaView, special attention must be paid to the installed Python and VTK versions. Therefore, the following manual installation is recommend instead of using a standard package installation of ParaView.
- Determine the version of Python:
python3 --version # example output Python 3.8.10 - Download the ParaView binaries according to your Python version from here. Note that you may have to use an older version ParaView to match your Python version.
- Install the ParaView binaries, e.g., as follows:
# optional: remove old package installation if available sudo apt remove paraview # replace the archive's name if needed in the commands below sudo mv ParaView-5.9.1-MPI-Linux-Python3.8-64bit.tar.gz /opt/ cd /opt sudo tar xf ParaView-5.9.1-MPI-Linux-Python3.8-64bit.tar.gz sudo rm ParaView-5.9.1-MPI-Linux-Python3.8-64bit.tar.gz cd ParaView-5.9.1-MPI-Linux-Python3.8-64bit/ # add path to ParaView binary and Python modules echo export PATH="\$PATH:$(pwd)/bin" >> ~/.bashrc echo export PYTHONPATH="\$PYTHONPATH:$(pwd)/lib/python3.8/site-packages" >> ~/.bashrcIn case of version conflicts between Python packages coming with ParaView and local versions of these packages, the following options exist: - go to your ParaView installation and manually delete or rename the affected packages; the packages are located at /path/to/ParaView/lib/python3.8/site-packages
- use pvpython, a modified Python interpreter shipped with ParaView and add a virtual environment containing flowTorch but not the conflicting packages (see Using pvpython and virtualenv)
Development
Documentation
To build the flowTorch documentation, the following additional packages are required:
pip3 install sphinx sphinx_rtd_theme nbsphinx recommonmark
To build the HTML version of the API documentation, navigate to ./docs and run:
make html
Unit testing
All sub-packages contain unit tests, which require the installation of PyTest:
pip3 install pytest
Moreover, the flowTorch datasets must be downloaded and referenced as described in the previous section.
To run all unit tests of all sub-packages, execute:
pytest flowtorch
You can also execute all tests in a sub-package, e.g., data
pytest flowtorch/data
or run individual test modules, e.g.,
pytest flowtorch/data/test_FOAMDataloader.py
Getting help
If you encounter any issues using flowTorch or if you have any questions regarding current and future development plans, please use the repository's issue tracker. Consider the following steps before and when opening a new issue:
- Have you searched for similar issues that may have been already reported? The issue tracker has a filter function to search for keywords in open issues.
- Click on the green New issue button in the upper right corner and describe your problem as detailed as possible. The issue should state what the problem is, what the expected behavior should be, and, maybe, suggest a solution. Note that you can also attach files or images to the issue.
- Select a suitable label from the drop-down menu called Labels.
- Click on the green Submit new issue button and wait for a reply.
Reference
If flowTorch aids your work, you may support the project by referencing the following article:
@article{Weiner2021,
doi = {10.21105/joss.03860},
url = {https://doi.org/10.21105/joss.03860},
year = {2021},
publisher = {The Open Journal},
volume = {6},
number = {68},
pages = {3860},
author = {Andre Weiner and Richard Semaan},
title = {flowTorch - a Python library for analysis and reduced-order modeling of fluid flows},
journal = {Journal of Open Source Software}
}
For a list of scientific works relying on flowTorch, refer to this list.
License
flowTorch is GPLv3-licensed; refer to the LICENSE file for more information.
Owner
- Name: Andre Weiner
- Login: AndreWeiner
- Kind: user
- Location: Dresden
- Company: Technical University of Dresden
- Website: https://www.ml-cfd.com
- Repositories: 48
- Profile: https://github.com/AndreWeiner
computational fluid dynamics, machine learning, and data science enthusiast
GitHub Events
Total
- Issues event: 1
- Watch event: 3
- Issue comment event: 1
Last Year
- Issues event: 1
- Watch event: 3
- Issue comment event: 1
Committers
Last synced: 5 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Andre Weiner | a****r@y****e | 215 |
| Jannis Anderson | y****5@t****e | 10 |
| Sebastian Spinner | s****r@d****e | 6 |
| Mehdimak | m****i@t****e | 6 |
| Dr. Richard Semaan | 5****n | 4 |
| Janis Geise | j****e@t****e | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 43
- Total pull requests: 3
- Average time to close issues: about 2 months
- Average time to close pull requests: 1 day
- Total issue authors: 11
- Total pull request authors: 2
- Average comments per issue: 2.12
- Average comments per pull request: 0.0
- Merged pull requests: 3
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 2
- Pull requests: 0
- Average time to close issues: 2 days
- Average time to close pull requests: N/A
- Issue authors: 2
- Pull request authors: 0
- Average comments per issue: 2.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- AndreWeiner (22)
- akaptano (6)
- JOEJOEJOE1231231231231 (5)
- jacktang (3)
- smallduan (1)
- Apollonaut10 (1)
- Potemkinkuliss (1)
- jiaqiwang969 (1)
- kowshiksri (1)
- yujiangsenior (1)
- JanisGeise (1)
Pull Request Authors
- Apollonaut10 (2)
- JannisAnderson (1)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- h5py *
- jupyterlab *
- matplotlib *
- netCDF4 *
- numpy *
- numpy-stl *
- pandas *
- plotly *
- scikit-learn *
- torch >=1.9
- vtk *
- h5py *
- jupyterlab *
- matplotlib *
- netCDF4 *
- numpy *
- numpy-stl *
- pandas *
- plotly *
- scikit-learn *
- torch *
- vtk *