Helper functions for NSE as LPV with Neural Networks
Project description
Convolutional Neural Networks for Semi-discrete NSE
A python module with
- a dynamic setup of Convolutional Neural Networks in
PyTorch - an interface to
FEniCSto generate data from FEM simulations of flows and - a numerical realization of FEM norm in the training neural networks
developed to design very low-dimensional LPV approximations of incompressible Navier-Stokes equations.
The Module
Installation
# package for sparse cholesky factorizations
# not needed but speed up with FEM norms and POD
apt install libsuitesparse-dev
pip install scikit-sparse==0.4.5
# fenics -- for the FEM part
apt install fenics # see https://fenicsproject.org/download/
# install this module and helper modules
pip install . # if to be installed from source
# pip install nse_nn_lpv # from the pypi index
Documentation
The underlying principles are explained in the paper
Benner, Heiland, Bahmani (2022): Convolutional Neural Networks for Very Low-dimensional LPV Approximations of Incompressible Navier-Stokes Equations
that appeared in Frontiers.
This module was the backend of the presented numerical examples.
Reproducing numerical results
Generally, the numerical procedure consists of
- generating FEM simulation data
- setting up and training the neural networks
- running simulations
Step 1. is defined in the folder simulations-training-data. See the corresponding (simulation) RUNME.md
Steps 2. and 3. in the folder tests. See the corresponding (training) RUNME sh for instructions.
Note: The folders and the numerical scripts are part of the complete sources in the git repository under the tag that corresponds to the paper under question or in the dedicated Zenodo repository. The pypi distribution only contains the core module.
Data and Handling
Generally, the data is
- generated by the simulation
- interpolated to the pictures
- imported to PyTorch as tensors
The relevant formats and routines are as follows:
import nse_nn_lpv.nse_data_helpers as ndh
time_dep_nse_generic.pycomputes the trajectories with snapshotsvvecand interpolates them to the two picturesvmatxandvmatyat all time instancesti. The data is stored as ajsonfile, say,data.jsonlike
{ti: {'vvec': vvec, 'vmatx': vmatx, 'vmaty': vmaty},
'femdata': 'information of the simulation ...'}
(datal, vvecl) = ndh.get_nse_img_data('data.json')takes the data filedata.jsonand returns the data as a list (of tuples) ofnumpyarrays:
datal = [(vmatx, vmaty, t_0), ..., (vmatx, vmaty, t_end)]
vvecl = [vvec_0, ..., ..., ..., ..., vvec_end]
-
trn_nse_data = ndh.NSEDataset(nsedatal, vvecl)takes the data lists and makes it available as apytorchdata set. In particular, the two picturesvmatx,vmatyare merged into a tensor. -
stst_dataloader = pytorch.DataLoader(trn_nse_data, batch_size=1, shuffle=True)then defines a way to access the data. E.g.,
(ttstset, tstvec) = next(iter(stst_dataloader))
returns a data point via
ttstset: the tensor of size(batch_size, 2, width, height), where(width, height)are the dimensions of the pictureststvec: the correspondingvvecs(needed, e.g., for the loss function later)
Python Machine-Learning Resources
- an overview
- Tensorflow -- see below
- Pytorch -- see below
- NeuroLab
- ffnet
- Scikit-Neural Network
- Lasagne
- pyrenn
Tensorflow
- website
- Article for understanding NN using TensorFlow
- Previous experience with building NN
- Visualization feature TensorBoard
- Based on keras
PyTorch
- website
- Tutorial for simple NN
- Recommended by colleagues (Lessig, Richter)
Scikit-Learn
- website
- looks well maintained
- many routines for data processing
- a few on neural network
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nse_nn_lpv-1.0.1.tar.gz.
File metadata
- Download URL: nse_nn_lpv-1.0.1.tar.gz
- Upload date:
- Size: 1.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.23.0 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
676564fbae9152953cda6bd45b7f48c99e5dabc31cd737d857ceadaafee7a9ae
|
|
| MD5 |
93d3af502bd7075c4b54e1b459f2c5d4
|
|
| BLAKE2b-256 |
a5247fa0ffcaddba148b704336d57b468789960c5d7ae522a8ac5d2278a874b1
|
File details
Details for the file nse_nn_lpv-1.0.1-py3-none-any.whl.
File metadata
- Download URL: nse_nn_lpv-1.0.1-py3-none-any.whl
- Upload date:
- Size: 13.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.23.0 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b81d81e869cf08c4b344231251b57c0ccf25d8ee951407f0b233d58135b3327
|
|
| MD5 |
ba5d81e6fbc3d562253651815bcb9e21
|
|
| BLAKE2b-256 |
faafa5acad56ac70ef9459776b3d11a94a72b10ed79db574d003c5ca7892afb1
|