The SAM (Spalart-Allmaras with Machine learning) model is a modified version of the Spalart-Allmaras turbulence model that uses machine learning to improve the accuracy of flow simulations. The details about the SAM model are available in our publication: Bin et al., AIAA, 2023.
This repository provides three parts of the SAM model:
Functions
: Contains thefv1
,fv2
, andfw
functions obtained by the neural network. Users can replace these functions with linear interpolation to change SA model code to SAM model code.OpenFOAMsrc
: Contains the OpenFOAM's source code of SAM model (SplartAllmarasDNS
) and standard SA model (SplartAllmarasNASA
), which agrees with the details of the SA model documented in the NASA TMR website.OpenFOAMcases
: Contains 12 different cases that have been tested by the SAM model. We provide the setup files of OpenFOAM for these cases so that users can directly run them with OpenFOAM.
Before using the SAM model in OpenFOAM, make sure your system can run OpenFOAM and has OpenFOAM's environmental variables, such as $FOAM_SRC
and $WM_PROJECT_USER_DIR
. You can test this by typing:
echo $WM_PROJECT_USER_DIR;
echo $FOAM_SRC;
-
Copy the existing models to
$WM_PROJECT_USER_DIR
cd $WM_PROJECT_USER_DIR mkdir src cd src cp -r $FOAM_SRC/TurbulenceModels . cd TurbulenceModels
-
Modify some files before creating your own
.lib
file. Run the following commands to change the last line of theMake/files
file in theincompressible
andcompressible
folders:vi incompressible/Make/files LIB = $(FOAM_USER_LIBBIN)/libincompressibleTurbulenceModels vi compressible/Make/files LIB = $(FOAM_USER_LIBBIN)/libcompressibleTurbulenceModels vi turbulenceModels/Make/files LIB = $(FOAM_USER_LIBBIN)/libturbulenceModels
-
Compile the codes by typing:
./Allwmake
-
Add your own model. For example, to add the SpalartAllmarasDNS model, copy the code provided by this repository to
$WM_PROJECT_USER_DIR/src/TurbulenceModels/turbulenceModels/RAS
. Type the following command to check that the code has been copied correctly:ls $WM_PROJECT_USER_DIR/src/TurbulenceModels/turbulenceModels/RAS/SpalartAllmarasDNS
-
Let OpenFOAM know that you have added a new model by modifying the
incompressible/turbulentTransportModels/turbulentTransportModels.C
andcompressible/turbulentFluidThermoModels/turbulentFluidThermoModels.C
files. Add the following lines to the RAS models section of the turbulentTransportModels.C file:#include "SpalartAllmarasDNS.H" makeRASModel(SpalartAllmarasDNS);
Add the following lines to the RAS models section of the
turbulentFluidThermoModels.C
file:#include "SpalartAllmarasDNS.H" makeRASModel(SpalartAllmarasDNS);
-
Modify the
Allwmake
file byvi Allwmake
Add the code
wmakeLnInclude -u turbulenceModels
beforewmake $targetType turbulenceModels
. So it looks like:#... wmakeLnInclude -u turbulenceModels wmake $targetType turbulenceModels #...
-
Recompile by running:
./Allwmake
-
Congratulations! You can now use the new model named
SpalartAllmarasDNS
in OpenFOAM by changing the keyword inconstant/turbulenceProperties
! If you want to add more models from this repository, you need to repeat steps 5 to 8.
In summary, this repository provides the SAM model, which is an extension of the standard SA model. It includes the necessary functions and OpenFOAM source code for users to easily incorporate the SAM model into their simulations. Additionally, we provide 12 OpenFOAM cases that have been tested with the SAM model, along with setup files for users to run these cases directly.
We hope that this repository is helpful for researchers and engineers who are interested in turbulence modeling and simulation. If you have any questions or encounter any issues while using the SAM model, please feel free to contact us at [email protected]. Thank you for your interest in our work!