• Stars
    star
    271
  • Rank 150,798 (Top 3 %)
  • Language
    Python
  • Created about 7 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This repo contains some tutorial type programs showing some basic ways machine learning can be applied to CFD.

Computational-Fluid-Dynamics-Machine-Learning-Examples

This repo contains tutorial type programs showing some basic ways Neural Networks can be applied to CFD. The purpose of this is to give those who are familiar with CFD but not Neural Networks a few very simple examples of applications. In particular, there is an example for predicting drag from the boundary conditions as well as predicting the velocity and pressure field from the boundary conditions.

The Neural Network code is written with the popular and easy to use Keras library. OpenLB is used to generate the simulation data needed for training.

Here are figures of the two networks to train.

alt tag

alt tag

Needed Install Stuff

You will need the following packages to run all the code. Mpi stuff for OpenLB and Keras for the Neural Networks. Starting from a fresh image of Ubuntu 16.04 the following should meet all dependencies.

sudo apt-get update
sudo apt-get install g++ openmpi-bin openmpi-doc libopenmpi-dev make python-vtk python-tk
sudo pip install tqdm keras tensorflow matplotlib

Note, if you want the gpu version of Tensorflow you need to install tensorflow-gpu and follow the instructions here. Also, depending how python vtk is install it can cause problems. If the above instructions are followed without a prior install of vtk then there should be no problem.

How To Generate Train Data

This repo uses OpenLB to generate the train and test set of simulation data. To setup the library run

./setup_olb.sh

This will download and compile the simulator. Now to generate the train and test set run

python make_dataset.py

This program will generate 2,000 examples of steady state flow around a cylinder at various positions and radii (simple as possible). On a i7 processor it takes about 1 hour and 2 hours on an i5. Keep in mind that it is multithreaded and runs several simulations at the same time. If you notice your machines cpu is not maxed out you can adjust the num_que parameter to make it go faster. You can also change num_runs to change how many simulations to run.

How To Train Networks

To train a network in predicting the steady state flow velocity vector field and pressure field run

keras_steady_flow_predictor.py

For the drag predicting network run

keras_drag_predictor.py

Check these scripts and the above images for more info and explanation of what is happening.

Results

Running the steady state flow predictor produces images like these.

alt tag alt tag alt tag alt tag

Once trained, the drag predicting network has an average mean squared error of 0.72. Given the boundary it is able to reasonable predict the drag. Here are 3 predictions for examples.

alt tag

true drag is : [ 10.7171] predicted drag is: [ 10.45950699]

alt tag

true drag is : [ 7.64211] predicted drag is: [ 6.81015682]

alt tag

true drag is : [ 6.08601] predicted drag is: [ 5.85990286]

Discussion

While there has been relatively little work applying Neural Networks to Computational Fluid Dynamics, there are many interesting applications. If you found these examples helpful you can check out https://github.com/loliverhennigh/Steady-State-Flow-With-Neural-Nets or https://github.com/loliverhennigh/Phy-Net for other applications. I also am compiling a comprehensive list of papers on the subject here.

More Repositories

1

Convolutional-LSTM-in-Tensorflow

An implementation of convolutional lstms in tensorflow. The code is written in the same style as the basiclstmcell function in tensorflow
Python
420
star
2

Steady-State-Flow-With-Neural-Nets

A Tensorflow re-implementation of the paper Convolutional Neural Networks for Steady Flow Approximation
Python
156
star
3

Phy-Net

compressing physics with neural networks
Python
154
star
4

Computational-Physics-and-Machine-Learning-Reading-List

A list of papers relating Computational Physics and Machine Learning
131
star
5

Lattice-Boltzmann-fluid-flow-in-Tensorflow

A Lattice Boltzmann fluid flow simulation written in Tensorflow.
Python
122
star
6

Early-Visual-Concept-Learning-Recreation-of-Some-Results

Here is an implementation of some of a few results seen in Early Visual Concept Learning with Unsupervised Deep Learning
Python
28
star
7

latnet

Neural Network Based Lattice Boltzmann solver
Python
26
star
8

All-Convnet-Autoencoder-Example

Just a simple use example of the conv2d_transpose function in TensorFlow. Its run on MNIST.
Python
22
star
9

Variational-autoencoder-tricks-and-tips

just a few trouble shooting tips I have found for training variational autoencoders. All code in tensorflow
Python
22
star
10

MinDat-Mineral-Image-Dataset

A dataset of +500,000 mineral images with labels taken from mindat.org.
Python
21
star
11

Crystal-Gems

A dataset of mineral images and labels for machine learning purposes. http://www.minerals.net/
Python
18
star
12

PhantomGaze

Simple GPU rendering of scientific data with Pytorch, Jax, CuPy, and Warp backends.
Python
15
star
13

Deep-Learning-Papers

A list of deep learning papers and notes on them
12
star
14

dynamic_rnn_conv_lstm

just a quick example of using the conv lstm in tensorflow as per https://github.com/tensorflow/tensorflow/pull/8891
Python
9
star
15

Deep-Learning-Experiment-Manager

A simple python program to queue up deep learning experiments on gpus
Python
5
star
16

DeepDesign

Automated Design Library using Deep Neural Networks
Python
5
star
17

ultrasound-nerve-segmentation-in-tensorflow

Jumping in really late to the kaggle ultrasound nerve segmentation competition. Hopefully save peoples time in writing boring data loading scripts.
Python
5
star
18

Compressing-Dynamical-Systems-Atari

This is both an implementation of the paper "Action-Conditional Video Prediction using Deep Networks in Atari Games" and an extension of some of their results
Python
4
star
19

dynamical-systems-for-machine-learning

Simple dynamical systems to test machine learning algorithms. Written with TensorFlow in mind
Python
4
star
20

Mindat

A dataset of mineral images created from mindat.org
Python
3
star
21

Flow-Sculpter

Neural Networks learning to create objects with desired flow properties.
Python
3
star
22

Quantum-Walk-Simulator

A c++ simulator for Continuous-Time Quantum Walk.
C
2
star
23

Compressing-Dynamical-Systems

A tool to compressing video based dynamical systems on to small low dimensional LSTMs or fully connected networks. This also doubles as a video generative model as seen bellow.
Python
2
star
24

Cd.jl

A simple Restricted Boltzmann machine. For use in Neural Networks and other learning needs.
Julia
2
star
25

Memory-Efficient-Autoencoder

A repo looking at autoencoders that can be applied to extremely large 2D and 3D tensors.
Python
2
star
26

resume

my resume yaya
1
star
27

The-Wedding-Project

1
star
28

All-Convnet-TensorFlow-MNIST-Tutorial

A look at using conv nets all the way through for TensorFlows MNIST Tutorial
Python
1
star
29

Ring_Net

A Neural Network for compressing dynamical systems into Markov Chains and the like
Python
1
star
30

PumpkinPulse

Dense Plasma Focus Fusion Reactor
Python
1
star