Skip to content

Commit 2dd6d7e

Browse files
Improved formatting of documentation
1 parent d749112 commit 2dd6d7e

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

compressible_flow/NICFD_nozzle/DataDriven/README.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,29 @@ permalink: /SU2_CFD/src/fluid/CDataDrivenFluid.cpp
55
# Using Data-Driven Fluid Models in SU2
66
Modeling non-ideal fluid behavior can be difficult when limited to model equations or can be time consuming when performing large-scale simulations using the CoolProp fluid model. The data-driven fluid model class allows for the equation of state to be defined through a look-up table (LUT) or a set of multi-layer perceptrons (MLP), using an entropy-based equation of state. Given enough reference data and careful tuning of the initial conditions, it is possible to attain similar accuracies as the CoolProp library, while being compatible with the SU2 adjoint solver and a faster iteration time.
77

8-
# Data-Driven Fluid Model Class
8+
## Data-Driven Fluid Model Class
99

1010
The data-driven fluid model class allows for the use of LUT or MLP to interpolate the entropy and its partial derivatives for a given density and static energy. This type of fluid model can be used as an alternative to the CoolProp fluid model if the fluid in question is not included in the CoolProp library, adjoint capability is required, or when computational performance is important.
1111

12-
The data-driven fluid model is enabled through the config option "DATADRIVEN_FLUID". The option "INTERPOLATION_METHOD" refers to which kind of interpolator is used for thermodynamic state evaluation. The available methods here are "LUT" for a look-up table based approach, or "MLP" for the use of an MLP. Information on these two regression methods is provided in later paragraphs.
12+
The data-driven fluid model is enabled through the config option ```DATADRIVEN_FLUID```. The option ```INTERPOLATION_METHOD``` refers to which kind of interpolator is used for thermodynamic state evaluation. The available methods here are ```LUT``` for a look-up table based approach, or ```MLP``` for the use of an MLP. Information on these two regression methods is provided in later paragraphs.
1313

1414
The datadriven fluid model in SU2 uses a general, entropic equation of state to calculate the primary and secondary flow variables. The fluid entropy and its first and second partial derivatives are determined through the interpolation algorithm (LUT or MLP) given the controlling variables density and static energy. The user should therefore supply an MLP or LUT that uses inputs density and static energy and predicts the fluid entropy and its first and second partial derivatives with respect to the inputs.
15-
The input variables for the MLP should be named "Density" and "Energy". The output variables should be named:
16-
"s": fluid entropy
17-
"dsde_rho": first entropy derivative w.r.t. static energy
18-
"dsdrho_e": first entropy derivative w.r.t. density
19-
"d2sdedrho": second entropy derivative w.r.t density and static energy
20-
"d2sde2": second entropy derivative w.r.t. static energy
21-
"d2sdrho2": second entropy derivative w.r.t. density
15+
The controlling variables for the MLP should be named "Density" and "Energy". The output variables should be named:
2216

23-
Based on the values for the partial derivatives of the entropy, it is possible to calculate the temperature, pressure, enthalpy, speed of sound, and secondary flow variables. Newton solver processes are used when the thermodynamic state is defined through variable pairs other than density and static energy. The initial values for density and static energy have to be defined by the user in the config file through "DATADRIVEN_FLUID_INITIAL_DENSITY" and "DATADRIVEN_FLUID_INITIAL_ENERGY". These values thave to be chosen carefully such that the initial condition of the simulation can be attained. The option "DATADRIVEN_NEWTON_RELAXATION" determines the relaxation factor for the Newton solver processes in the data-driven fluid model. Higher values result in faster convergence of the Newton solvers in stable regions. Lower values result in more iterations, but are more likely to avoid instabilities.
17+
1. "s": fluid entropy
18+
2. "dsde_rho": first entropy derivative w.r.t. static energy
19+
3. "dsdrho_e": first entropy derivative w.r.t. density
20+
4. "d2sdedrho": second entropy derivative w.r.t density and static energy
21+
5. "d2sde2": second entropy derivative w.r.t. static energy
22+
6. "d2sdrho2": second entropy derivative w.r.t. density
2423

25-
# MLP Definition
26-
Data regression using an MLP is enabled through selecting the "MLP" for the option "INTERPOLATION_METHOD" in the configuration file. In order to load an MLP architecture into SU2, an input file needs to be provided describing the network architecture, as well as the input and output variable names and ranges. An example of such an input file is provided in this folder (MLP_Air.mlp). This file can be generated from an MLP trained through Tensorflow using the "Tensorflow2SU2.py" script. Additional information regarding the translation from a Tensorflow model to an SU2 input file is provided in the python code. The script used to train the MLP is provided in "MLPTrainer.py" and the script used to generate the reference data from CoolProp in "Generate_Dataset.py".
24+
Based on the values for the partial derivatives of the entropy, it is possible to calculate the temperature, pressure, enthalpy, speed of sound, and secondary flow variables. Newton solver processes are used when the thermodynamic state is defined through variable pairs other than density and static energy. The initial values for density and static energy have to be defined by the user in the config file through ```DATADRIVEN_FLUID_INITIAL_DENSITY``` and ```DATADRIVEN_FLUID_INITIAL_ENERGY```. These values thave to be chosen carefully such that the initial condition of the simulation can be attained. The option ```DATADRIVEN_NEWTON_RELAXATION``` determines the relaxation factor for the Newton solver processes in the data-driven fluid model. Higher values result in faster convergence of the Newton solvers in stable regions. Lower values result in more iterations, but are more likely to avoid instabilities.
2725

28-
MLP regression is enabled through the MLPCpp submodule of SU2 (subprojects/MLPCpp). This submodule is enabled through the '-Denable-mlpcpp=true' meson command. The MLPCpp submodule can be used within any C++ code for MLP evaluation. Additional documentation regarding the MLPCpp module can be found on https://github.com/EvertBunschoten/MLPCpp
26+
## MLP Definition
27+
Data regression using an MLP is enabled through selecting the ```MLP``` for the option ```INTERPOLATION_METHOD``` in the configuration file. In order to load an MLP architecture into SU2, an input file needs to be provided describing the network architecture, as well as the input and output variable names and ranges. An example of such an input file is provided in this folder (```MLP_Air.mlp```). This file can be generated from an MLP trained through Tensorflow using the ```Tensorflow2SU2.py``` script. Additional information regarding the translation from a Tensorflow model to an SU2 input file is provided in the python code. The script used to train the MLP is provided in ```MLPTrainer.py``` and the script used to generate the reference data from CoolProp in "Generate_Dataset.py".
2928

30-
# LUT Definition
29+
MLP regression is enabled through the MLPCpp submodule of SU2 (subprojects/MLPCpp). This submodule is enabled through the ```-Denable-mlpcpp=true``` meson command. The MLPCpp submodule can be used within any C++ code for MLP evaluation. Additional documentation regarding the MLPCpp module can be found on https://github.com/EvertBunschoten/MLPCpp
3130

32-
In some cases it may be more convenient to use an LUT instead of an MLP for data regression. The data-driven fluid model in SU2 is also compatible with using an unstructured table (Common/src/containers/CLookUpTable.cpp) for the regression of the entropy and its partial derivatives. Data regression using an LUT is enabled through selecting the "LUT" for the option "INTERPOLATION_METHOD" in the configuration file. Examples for the .drg table format file can be found under UnitTests/Common/containers/ or can be generated using the "LUTWriter.m" MATLAB script in this tutorial folder.
31+
## LUT Definition
32+
33+
In some cases it may be more convenient to use an LUT instead of an MLP for data regression. The data-driven fluid model in SU2 is also compatible with using an unstructured table (```Common/src/containers/CLookUpTable.cpp```) for the regression of the entropy and its partial derivatives. Data regression using an LUT is enabled through selecting the ```LUT``` for the option ```INTERPOLATION_METHOD``` in the configuration file. Examples for the .drg table format file can be found under ```UnitTests/Common/containers/``` or can be generated using the ```LUTWriter.m``` MATLAB script in this tutorial folder.

compressible_flow/NICFD_nozzle/DataDriven/datadriven_nozzle.cfg

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,19 @@ REF_DIMENSIONALIZATION= DIMENSIONAL
3636
% ---- DATADRIVEN FLUID MODEL DEFINITION -------%
3737
%
3838
FLUID_MODEL = DATADRIVEN_FLUID
39+
40+
% Regression method for data set evaluation (MLP for multi-layer perceptron,
41+
% LUT for look-up table).
3942
INTERPOLATION_METHOD = MLP
43+
44+
% List of input files defining MLP architecture(s) or LUT geometry.
4045
FILENAMES_INTERPOLATOR = (MLP_Air.mlp)
4146

47+
% Newton solver relaxation factor for data-driven fluid model.
4248
DATADRIVEN_NEWTON_RELAXATION = 0.99
49+
50+
% Initial guess values for density and static energy in data-driven fluid model
51+
% Newton solver functions.
4352
DATADRIVEN_FLUID_INITIAL_DENSITY = 8.8657
4453
DATADRIVEN_FLUID_INITIAL_ENERGY = 411176.41
4554

0 commit comments

Comments
 (0)