Skip to main content

Convolutional Neural Networks for Semi-discrete NSE

A python module with

  • a dynamic setup of Convolutional Neural Networks in PyTorch
  • an interface to FEniCS to 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

  1. generating FEM simulation data
  2. setting up and training the neural networks
  3. 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

  1. generated by the simulation
  2. interpolated to the pictures
  3. imported to PyTorch as tensors

The relevant formats and routines are as follows:

import nse_nn_lpv.nse_data_helpers as ndh
  1. time_dep_nse_generic.py computes the trajectories with snapshots vvec and interpolates them to the two pictures vmatx and vmaty at all time instances ti. The data is stored as a json file, say, data.json like
{ti: {'vvec': vvec, 'vmatx': vmatx, 'vmaty': vmaty},
 'femdata': 'information of the simulation ...'}
  1. (datal, vvecl) = ndh.get_nse_img_data('data.json') takes the data file data.json and returns the data as a list (of tuples) of numpy arrays:
datal = [(vmatx, vmaty, t_0), ..., (vmatx, vmaty, t_end)]
vvecl = [vvec_0, ..., ..., ..., ..., vvec_end]
  1. trn_nse_data = ndh.NSEDataset(nsedatal, vvecl) takes the data lists and makes it available as a pytorch data set. In particular, the two pictures vmatx, vmaty are merged into a tensor.

  2. 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 pictures
  • tstvec: the corresponding vvecs (needed, e.g., for the loss function later)

Python Machine-Learning Resources

  • an overview
    1. Tensorflow -- see below
    2. Pytorch -- see below
    3. NeuroLab
    4. ffnet
    5. Scikit-Neural Network
    6. Lasagne
    7. pyrenn

Tensorflow

PyTorch

Scikit-Learn

  • website
  • looks well maintained
  • many routines for data processing
  • a few on neural network

Release files for nse-nn-lpv 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nse-nn-lpv 1.0.1
File Size Uploaded
nse_nn_lpv-1.0.1.tar.gz 1.4 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for nse-nn-lpv 1.0.1
File Interpreter ABI Platform
nse_nn_lpv-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 1.4 MB

Release files / nse_nn_lpv-1.0.1.tar.gz

Download URL nse_nn_lpv-1.0.1.tar.gz
Size 1.4 MB
Tags Source
SHA-256 checksum
How to use checksums
676564fbae9152953cda6bd45b7f48c99e5dabc31cd737d857ceadaafee7a9ae
BLAKE2b-256 checksum
How to use checksums
a5247fa0ffcaddba148b704336d57b468789960c5d7ae522a8ac5d2278a874b1
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / nse_nn_lpv-1.0.1-py3-none-any.whl

Download URL nse_nn_lpv-1.0.1-py3-none-any.whl
Size 13.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5b81d81e869cf08c4b344231251b57c0ccf25d8ee951407f0b233d58135b3327
BLAKE2b-256 checksum
How to use checksums
faafa5acad56ac70ef9459776b3d11a94a72b10ed79db574d003c5ca7892afb1
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

0.1.1

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page