Package: nse-nn-lpv
Convolutional Neural Networks for Semi-discrete NSEApythonmodule witha dynamic setup ofConvolutional Neural NetworksinPyTorchan interface toFEniCSto generate data from FEM simulations of flows anda numerical realization of FEM norm in the training neural networksdeveloped to design very low-dimensional LPV approximations of incompressible Navier-Stokes equations.The ModuleInstallation# package for sparse cholesky factorizations# not needed but speed up with FEM norms and PODaptinstalllibsuitesparse-dev
pipinstallscikit-sparse==0.4.5# fenics -- for the FEM partaptinstallfenics# see https://fenicsproject.org/download/# install this module and helper modulespipinstall.# if to be installed from source# pip install nse_nn_lpv  # from the pypi indexDocumentationThe underlying principles are explained in the paperBenner, Heiland, Bahmani (2022):Convolutional Neural Networks for Very Low-dimensional LPV Approximations of Incompressible Navier-Stokes Equationsthat appeared in Frontiers.This module was the backend of the presented numerical examples.Reproducing numerical resultsGenerally, the numerical procedure consists ofgenerating FEM simulation datasetting up and training the neural networksrunning simulationsStep1.is defined in the foldersimulations-training-data. See the corresponding(simulation)RUNME.mdSteps2.and3.in the foldertests. See the corresponding(training)RUNMEsh 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. Thepypidistribution only contains the core module.Data and HandlingGenerally, the data isgenerated by the simulationinterpolated tothe picturesimported to PyTorch as tensorsThe relevant formats and routines are as follows:importnse_nn_lpv.nse_data_helpersasndhtime_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':'informationofthesimulation...'}(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 twopicturesvmatx,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 viattstset: the tensor of size(batch_size, 2, width, height), where(width, height)are the dimensions of thepictureststvec: the correspondingvvecs(needed, e.g., for the loss function later)Python Machine-Learning ResourcesanoverviewTensorflow -- see belowPytorch -- see belowNeuroLabffnetScikit-Neural NetworkLasagnepyrennTensorflowwebsiteArticle for understanding NN using TensorFlowPrevious experience with building NNVisualization featureTensorBoardBased on kerasPyTorchwebsiteTutorial for simple NNRecommended by colleagues (Lessig, Richter)Scikit-Learnwebsitelooks well maintainedmany routines for data processinga few on neural network