Skip to content

Commit 7d1a6bb

Browse files
Added tutorial for data-driven equation of state
1 parent ebf3eb4 commit 7d1a6bb

File tree

3 files changed

+107
-0
lines changed

3 files changed

+107
-0
lines changed

_data/tutorials.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- Unsteady_NACA0012
1818
- UQ_NACA0012
1919
- NICFD_nozzle
20+
- NICFD_nozzle_datadriven
2021
- Aachen_Turbine
2122

2223
- title: Incompressible Flow
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
---
2+
title: Non-ideal compressible flows with physics-informed neural networks
3+
permalink: /tutorials/NICFD_nozzle_datadriven/
4+
written_by: EvertBunschoten
5+
for_version: 8.3.0
6+
solver: RANS
7+
requires: SU2_CFD SU2_DataMiner
8+
complexity: advanced
9+
follows:
10+
---
11+
12+
## Goals
13+
14+
Upon completing this tutorial, the user will be familiar with performing simulations of nonideal compressible fluids through the use of physics-informed neural networks. The flow is simulated through the same supersonic convergent-divergent nozzle as in the [tutorial](NICFD_nozzle.md) for nonideal compressible fluid flows.
15+
The following capabilities of will be showcased in this tutorial:
16+
- Using [SU2 DataMiner](https://github.com/EvertBunschoten/SU2_DataMiner.git) to train physics-informed neural networks for fluid simulations.
17+
- Data-driven equation of state with multi-layer perceptrons.
18+
- Giles boundary conditions
19+
20+
The intent of this tutorial is to explain how to use the data-driven equation of state in SU2 for fluid simulations and how to train the neural network(s) required for modeling the fluid properties. The fluid used in this tutorial is Siloxane MM, but the methods explained in this tutorial can also be repeated for different fluids available within CoolProp.
21+
22+
## Background
23+
24+
The data-driven equation of state in SU2 can be used to calculate the thermodynamic state properties of the fluid during CFD calculations. The method uses an equation of state based on entropy potential, allowing for the thermodynamic state variables to be directly calculated from the density and internal energy, which can be directly obtained from the solution of the flow transport equations.
25+
26+
The thermodynamic state variables are calculated from the Jacobian and Hessian of entropy w.r.t. density and internal energy. The data-driven fluid model in SU2 uses a physics-informed neural network to calculate the entropy Jacobian and Hessian such that thermodynamic consistency is maintained.
27+
28+
The data-driven, entropy-based equation of state is discussed more in detail in [this paper](https://doi.org/10.1016/j.compfluid.2025.106932).
29+
30+
## Resources and Set-Up
31+
32+
You can find the resources for this tutorial in the folder [compressible_flow/NICFD_nozzle/PhysicsInformed](https://github.com/su2code/Tutorials/tree/master/compressible_flow/NICFD_nozzle/PhysicsInformed) in the [tutorial repository](https://github.com/su2code/Tutorials).
33+
You will need the python scripts and the [nozzle contour file](https://github.com/su2code/Tutorials/tree/master/compressible_flow/NICFD_nozzle/PhysicsInformed/nozzle_curve.csv) which describes the shape of the nozzle. The SU2 config file and mesh will be automatically generated using the scripts in this tutorial.
34+
35+
This tutorial requires [SU2 DataMiner](https://github.com/EvertBunschoten/SU2_DataMiner.git) to run. Follow the installation instructions on the repository page, and install the required python packages. To be able to use the data-driven fluid model in SU2, compile SU2 with the following command:
36+
37+
```
38+
meson.py build -Denable-mlpcpp=true
39+
```
40+
41+
which will download the [MLPCpp](https://github.com/EvertBunschoten/MLPCpp.git) submodule enabling the evaluation of deep, dense multi-layer perceptrons in SU2.
42+
43+
44+
## Tutorial
45+
46+
The following steps explain how to train physics-informed neural networks for data-driven fluid simulations in SU2.
47+
48+
### 1. Generate SU2 DataMiner Configuration
49+
Similar to SU2, SU2 DataMiner uses a configuration file to store information regarding the type of fluid, the resolution of the training data set, and the hyperparameters of the networks. Running the script [0:generate_config.py](https://github.com/su2code/Tutorials/tree/master/compressible_flow/NICFD_nozzle/PhysicsInformed/0:generate_config.py) generates the SU2 DataMiner configuration used in this tutorial and is saved as a binary file named ```SU2DataMiner_MM.cfg```.
50+
51+
### 2. Generate Training Data
52+
The thermodynamic state data used to train the network for the data-driven fluid simulation is generated using the Helmholtz equation of state evalauted through the python module for CoolProp. The thermodynamic state data are generated on a density-static energy grid for the gas and supercritical phase between the minimum and maximum density of the fluid supported by CoolProp.
53+
54+
By running the script [1:generate_fluid_data.py](https://github.com/su2code/Tutorials/tree/master/compressible_flow/NICFD_nozzle/PhysicsInformed/1:generate_fluid_data.py) will generate the thermodynamic state data used for the training of the network and generate contour plots of the temperature, pressure, and speed of sound. The complete set of thermodynamic state data is stored in the file titled *fluid_data_full.csv*. 80% of the randomly sampled fluid data is used to update the weights of the network during training, 10% is used to monitor the convergence of the training process, and the remaining 10% is used to validate the accuracy of the network upon completion of the training process. The complete data set contains approximately 2.3e5 unique data points.
55+
56+
IMAGE: training data plot
57+
### 3. Train physics-informed neural network
58+
The network used in this tutorial uses two hidden layers with 12 nodes each. The exponential function is used as the hidden layer activation function. This is an unusual choice, but is motivated by the fact that it reduces the computational cost required to calculate the network Jacobian and Hessian during the CFD solution process.
59+
The training process uses an exponential decay function for the learning rate, with an initial value of 1e-3. During each update step, the weights and biases of the network are adjusted according to the value of the loss function evaluated on a batch of 64 training data points.
60+
More details regarding the training method are presented in the [literature](https://doi.org/10.1016/j.compfluid.2025.106932).
61+
62+
The training progress can be followed from the terminal, but can also be monitored from the training convergence plots that are periodically updated under ```Worker_0/Model_0/```.
63+
64+
After training, the weights and biases of the network are stored in the SU2 DataMiner configuration.
65+
66+
IMAGE: training history plot, predicted vs training data
67+
68+
### 4. Preparation of the Simulation
69+
70+
To run data-driven fluid simulations in SU2, you need the SU2 configuration file, the mesh, and the file describing the multilayer perceptron. Running the script [3:prepare_simulation.py](https://github.com/su2code/Tutorials/tree/master/compressible_flow/NICFD_nozzle/PhysicsInformed/3:prepare_simulation.py) generates the computational mesh, writes the SU2 configuration file, and writes the ASII file containing the weights and biases of the network.
71+
72+
The mesh is generated using gmesh in which the computational domain is generated accoring to the nozzle contour. The nozzle wall is modeled as a non-slip surface and prism layer refinement is applied to resolve the boundary layer.
73+
74+
IMAGE: highlight of mesh
75+
76+
The inflow condition is modeled as a non-reflective Giles boundary condition where the pressure and temperature of the critical point of the fluid are imposed as the stagnation pressure and stagnation temperature. The outflow is also modeled as a non-reflective Giles boundary condition, where a static pressure 10 times lower than the inflow pressure is imposed.
77+
78+
The data-driven fluid model with the physics-informed entropy-based equation of state is enabled through the following options in the [SU2 configuration file](https://github.com/su2code/Tutorials/tree/master/compressible_flow/NICFD_nozzle/PhysicsInformed/config_NICFD_PINN.cfg):
79+
```
80+
FLUID_MODEL= DATADRIVEN_FLUID
81+
USE_PINN= YES
82+
INTERPOLATION_METHOD= MLP
83+
FILENAMES_INTERPOLATOR= MLP_siloxane_MM.mlp
84+
```
85+
where the ```USE_PINN= YES``` option enables the use of a physics-informed neural network for thermodynamic state calculations. The file ```MLP_siloxane_MM.mlp``` is the ASII file which describes the network architecture and the network weights and biases. At the start of the SU2 solution process, the network weigths and biases are imported into SU2 through the MLPCpp sub-module.
86+
87+
IMAGE: inflow-outflow isentrope compared to training data
88+
89+
### 5. Run SU2
90+
The simulation us run by the following command
91+
```
92+
mpirun -n <NP> SU2_CFD config_NICFD_PINN.cfg
93+
```
94+
where ```<NP>``` is the number of cores.
95+
96+
IMAGE: simulation convergence trends
97+
98+
### Results
99+
100+
IMAGE: flow field
101+
102+
IMAGE: solution w.r.t. training data
103+
104+
IMAGE: comparison to CoolProp solution

_tutorials/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ Simulation of unsteady, external, viscous flow around an airfoil.
5050
Perform uncertainty quantification of errors arising due to assumptions inherent in turbulence models.
5151
* [Non-ideal compressible flow in a supersonic nozzle](/tutorials/NICFD_nozzle/)
5252
Simulation of compressible flow in a nozzle using non-ideal thermodynamic models.
53+
* [Data-driven equation of state for non-ideal compressible fluids](/tutorials/NICFD_nozzle_datadriven/)
54+
Demonstration of data-driven equation of state using a physics-informed neural network.
5355
* [Turbomachinery: Aachen Turbine stage with mixing plane](/tutorials/Aachen_Turbine/)
5456
Simulation of compressible flow of the Aachen turbine demonstrating turbomachinery application.
5557

0 commit comments

Comments
 (0)