Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Physics-informed neural networks for data-driven fluid model #2444

Open
wants to merge 35 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
594fc94
Added option for using physics-informed neural network
EvertBunschoten Jul 17, 2024
6509e67
Added physics-informed approach to data-driven fluid model
EvertBunschoten Jul 17, 2024
e05fe40
Added PINN option
EvertBunschoten Jul 17, 2024
cd5f4a6
Merge branch 'develop' of https://github.com/su2code/SU2 into feature…
EvertBunschoten Jul 23, 2024
71c16c1
Merge branch 'develop' of https://github.com/su2code/SU2 into feature…
EvertBunschoten Aug 19, 2024
54972f2
Added ideal gas approximation when compressiblity factor gets suffici…
EvertBunschoten Nov 12, 2024
0f73683
Merge branch 'develop' of https://github.com/su2code/SU2 into feature…
EvertBunschoten Nov 12, 2024
296f49e
Added options for initial density and static energy for the data-driv…
EvertBunschoten Jan 6, 2025
cc2e6a6
Added heat capacity to output for data-driven fluid simulations
EvertBunschoten Jan 6, 2025
4a0c526
Merge branch 'develop' of https://github.com/su2code/SU2 into feature…
EvertBunschoten Jan 6, 2025
a6152c4
Merge branch 'develop' of https://github.com/su2code/SU2 into feature…
EvertBunschoten Feb 3, 2025
00db9bd
Merge branch 'develop' of https://github.com/su2code/SU2 into feature…
EvertBunschoten Feb 14, 2025
c219500
Added pressure ramp function for Riemann boundary condition
EvertBunschoten Feb 14, 2025
83e2759
Put the computation of the burnt progress variable inside the scope o…
EvertBunschoten Feb 14, 2025
6220215
Added computation of specific heat at constant pressure and at consta…
EvertBunschoten Feb 14, 2025
e80b992
Adapted data-driven fluid model test case to be compatible with physi…
EvertBunschoten Feb 14, 2025
8419fa5
Updated MLPCpp submodule
EvertBunschoten Feb 14, 2025
5325a32
fixed trailing white spaces
EvertBunschoten Feb 14, 2025
f985434
Fixed warning for unused variable in MLPCpp
EvertBunschoten Feb 14, 2025
ecf47bf
Merge branch 'develop' of https://github.com/su2code/SU2 into feature…
EvertBunschoten Feb 17, 2025
d8f0912
Changed input variables to Newton solvers to be pass-by-reference
EvertBunschoten Feb 17, 2025
5aebea8
Pass-by-reference for Newton solvers
EvertBunschoten Feb 17, 2025
a0075ba
Removed HEAT_CAPACITY from volume outputs for data-driven fluid solution
EvertBunschoten Feb 17, 2025
be78f43
Changed conductivity model such that the test case can also be ran wi…
EvertBunschoten Feb 17, 2025
88cd9e9
Set test case branch for regression tests
EvertBunschoten Feb 17, 2025
e927a02
Settings for restart in parallel regression
EvertBunschoten Feb 17, 2025
6a0be5a
Added PINN test case for data-driven fluid model
EvertBunschoten Feb 17, 2025
8b1dfee
Migrated options for data-driven fluid model and flamelet fluid model…
EvertBunschoten Feb 27, 2025
e134e0f
Const correctness for Newton solvers
EvertBunschoten Feb 27, 2025
615b7ea
Retrieve config options from options struct instead of config accesso…
EvertBunschoten Feb 27, 2025
f6d28ab
Retrieve options from flamelet solver options struct rather than conf…
EvertBunschoten Feb 27, 2025
a913d5f
Retrieve options from data-driven fluid and flamelet solver options s…
EvertBunschoten Feb 27, 2025
4b6aee0
Retrieve options for data-driven fluid simulations and flamelet simul…
EvertBunschoten Feb 27, 2025
f14361e
Added unit tests for fluid model consistency
EvertBunschoten Feb 27, 2025
101eeff
Added derived variables to PreaccOut
EvertBunschoten Feb 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ jobs:
uses: docker://ghcr.io/su2code/su2/test-su2:240320-1536
with:
# -t <Tutorials-branch> -c <Testcases-branch>
args: -b ${{github.ref}} -t develop -c develop -s ${{matrix.testscript}}
args: -b ${{github.ref}} -t develop -c feature_PINN -s ${{matrix.testscript}}
- name: Cleanup
uses: docker://ghcr.io/su2code/su2/test-su2:240320-1536
with:
Expand Down
178 changes: 29 additions & 149 deletions Common/include/CConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,15 @@ class CConfig {
Kind_TimeIntScheme_Heat, /*!< \brief Time integration for the wave equations. */
Kind_TimeStep_Heat, /*!< \brief Time stepping method for the (fvm) heat equation. */
n_Datadriven_files;
ENUM_DATADRIVEN_METHOD Kind_DataDriven_Method; /*!< \brief Method used for datset regression in data-driven fluid models. */

su2double DataDriven_Relaxation_Factor; /*!< \brief Relaxation factor for Newton solvers in data-driven fluid models. */
DataDrivenFluid_ParsedOptions datadriven_ParsedOptions;
//ENUM_DATADRIVEN_METHOD Kind_DataDriven_Method; /*!< \brief Method used for datset regression in data-driven fluid models. */

//su2double DataDriven_Relaxation_Factor; /*!< \brief Relaxation factor for Newton solvers in data-driven fluid models. */
// su2double DataDriven_rho_init{-1.0}, /*!< \brief Optional initial density value for Newton solver in data-driven fluid model.*/
// DataDriven_e_init{-1.0}; /*!< \brief Optional initial static energy value for Newton solver in data-driven fluid model.*/

//bool UsePINN = false; /*!< \brief Use physics-informed method for data-driven fluid modeling. */

STRUCT_TIME_INT Kind_TimeIntScheme_FEA; /*!< \brief Time integration for the FEA equations. */
STRUCT_SPACE_ITE Kind_SpaceIteScheme_FEA; /*!< \brief Iterative scheme for nonlinear structural analysis. */
Expand Down Expand Up @@ -821,8 +827,7 @@ class CConfig {
SurfAdjCoeff_FileName, /*!< \brief Output file with the adjoint variables on the surface. */
SurfSens_FileName, /*!< \brief Output file for the sensitivity on the surface (discrete adjoint). */
VolSens_FileName, /*!< \brief Output file for the sensitivity in the volume (discrete adjoint). */
ObjFunc_Hess_FileName, /*!< \brief Hessian approximation obtained by the Sobolev smoothing solver. */
*DataDriven_Method_FileNames; /*!< \brief Dataset information for data-driven fluid models. */
ObjFunc_Hess_FileName; /*!< \brief Hessian approximation obtained by the Sobolev smoothing solver. */

bool
Wrt_Performance, /*!< \brief Write the performance summary at the end of a calculation. */
Expand Down Expand Up @@ -1239,28 +1244,7 @@ class CConfig {
unsigned short nSpecies_Init; /*!< \brief Number of entries of SPECIES_INIT */

/*--- Additional flamelet solver options ---*/
///TODO: Add python wrapper initialization option
FLAMELET_INIT_TYPE flame_init_type = FLAMELET_INIT_TYPE::NONE; /*!< \brief Method for solution ignition for flamelet problems. */
std::array<su2double,8> flame_init; /*!< \brief Flame front initialization parameters. */
std::array<su2double,6> spark_init; /*!< \brief Spark ignition initialization parameters. */
su2double* spark_reaction_rates; /*!< \brief Source terms for flamelet spark ignition option. */
unsigned short nspark; /*!< \brief Number of source terms for spark initialization. */
bool preferential_diffusion = false; /*!< \brief Preferential diffusion physics for flamelet solver.*/

/*--- lookup table ---*/
unsigned short n_scalars = 0; /*!< \brief Number of transported scalars for flamelet LUT approach. */
unsigned short n_lookups = 0; /*!< \brief Number of lookup variables, for visualization only. */
unsigned short n_table_sources = 0; /*!< \brief Number of transported scalar source terms for LUT. */
unsigned short n_user_scalars = 0; /*!< \brief Number of user defined (auxiliary) scalar transport equations. */
unsigned short n_user_sources = 0; /*!< \brief Number of source terms for user defined (auxiliary) scalar transport equations. */
unsigned short n_control_vars = 0; /*!< \brief Number of controlling variables (independent variables) for the LUT. */

string* controlling_variable_names;
string* cv_source_names;
vector<string> table_scalar_names; /*!< \brief Names of transported scalar variables. */
string* lookup_names; /*!< \brief Names of passive look-up variables. */
string* user_scalar_names; /*!< \brief Names of the user defined (auxiliary) transported scalars .*/
string* user_source_names; /*!< \brief Names of the source terms for the user defined transported scalars. */
FluidFlamelet_ParsedOptions flamelet_ParsedOptions; /*!< \brief Additional flamelet solver options */

/*!
* \brief Set the default values of config options not set in the config file using another config object.
Expand Down Expand Up @@ -2169,106 +2153,6 @@ class CConfig {
*/
bool GetSpecies_StrongBC() const { return Species_StrongBC; }

/*!
* \brief Get the flame initialization.
* (x1,x2,x3) = flame offset/spark center location.
* (x4,x5,x6) = flame normal, separating unburnt from burnt or
* spark radius, spark start iteration, spark duration.
* (x7) = flame thickness, the length from unburnt to burnt conditions.
* (x8) = flame burnt thickness, the length to stay at burnt conditions.
* \return Ignition initialization parameters for the flamelet model.
*/
const su2double* GetFlameInit() const {
switch (flame_init_type)
{
case FLAMELET_INIT_TYPE::FLAME_FRONT:
return flame_init.data();
break;
case FLAMELET_INIT_TYPE::SPARK:
return spark_init.data();
break;
default:
return nullptr;
break;
}
}

/*!
* \brief Get species net reaction rates applied during spark ignition.
*/
const su2double* GetSpark() const {
return spark_reaction_rates;
}

/*!
* \brief Preferential diffusion combustion problem.
*/
bool GetPreferentialDiffusion() const { return preferential_diffusion; }

/*!
* \brief Define preferential diffusion combustion problem.
*/
inline void SetPreferentialDiffusion(bool input) { preferential_diffusion = input; }

/*!
* \brief Get the number of control variables for flamelet model.
*/
unsigned short GetNControlVars() const { return n_control_vars; }

/*!
* \brief Get the number of total transported scalars for flamelet model.
*/
unsigned short GetNScalars() const { return n_scalars; }

/*!
* \brief Get the number of user scalars for flamelet model.
*/
unsigned short GetNUserScalars() const { return n_user_scalars; }

/*!
* \brief Get the name of a specific controlling variable.
*/
const string& GetControllingVariableName(unsigned short i_cv) const {
return controlling_variable_names[i_cv];
}

/*!
* \brief Get the name of the source term variable for a specific controlling variable.
*/
const string& GetControllingVariableSourceName(unsigned short i_cv) const {
return cv_source_names[i_cv];
}
/*!
* \brief Get the name of the user scalar.
*/
const string& GetUserScalarName(unsigned short i_user_scalar) const {
static const std::string none = "NONE";
if (n_user_scalars > 0) return user_scalar_names[i_user_scalar]; else return none;
}

/*!
* \brief Get the name of the user scalar source term.
*/
const string& GetUserSourceName(unsigned short i_user_source) const {
static const std::string none = "NONE";
if (n_user_sources > 0) return user_source_names[i_user_source]; else return none;
}

/*!
* \brief Get the ignition method used for combustion problems.
*/
FLAMELET_INIT_TYPE GetFlameletInitType() const { return flame_init_type; }

/*!
* \brief Get the number of transported scalars for combustion.
*/
unsigned short GetNLookups() const { return n_lookups; }

/*!
* \brief Get the name of the variable that we want to retrieve from the lookup table.
*/
const string& GetLookupName(unsigned short i_lookup) const { return lookup_names[i_lookup]; }

/*!
* \brief Get the Young's modulus of elasticity.
* \return Value of the Young's modulus of elasticity.
Expand Down Expand Up @@ -3970,29 +3854,6 @@ class CConfig {
*/
unsigned short GetKind_FluidModel(void) const { return Kind_FluidModel; }

/*!
* \brief Datadriven method for EoS evaluation.
*/
ENUM_DATADRIVEN_METHOD GetKind_DataDriven_Method(void) const { return Kind_DataDriven_Method; }

/*!
* \brief Get name of the input file for the data-driven fluid model interpolation method.
* \return Name of the input file for the interpolation method.
*/
const string* GetDataDriven_FileNames(void) const { return DataDriven_Method_FileNames; }

/*!
* \brief Get number of listed look-up table or multi-layer perceptron input files.
* \return Number of listed data-driven method input files.
*/
unsigned short GetNDataDriven_Files(void) const { return n_Datadriven_files; }

/*!
* \brief Get Newton solver relaxation factor for data-driven fluid models.
* \return Newton solver relaxation factor.
*/
su2double GetRelaxation_DataDriven(void) const { return DataDriven_Relaxation_Factor; }

/*!
* \brief Returns the name of the fluid we are using in CoolProp.
*/
Expand Down Expand Up @@ -7083,6 +6944,12 @@ class CConfig {
*/
void SetGiles_Var1(su2double newVar1, const string& val_marker);

/*!
* \brief Set the var 1 for Riemann BC.
* \param[in] val_marker - Index corresponding to the Riemann BC.
*/
void SetRiemann_Var1(su2double newVar1, const string& val_marker);

/*!
* \brief Get the relax factor for the average component for the Giles BC.
* \param[in] val_marker - Index corresponding to the Giles BC.
Expand Down Expand Up @@ -9939,4 +9806,17 @@ class CConfig {
*/
LM_ParsedOptions GetLMParsedOptions() const { return lmParsedOptions; }


/*!
* \brief Get parsed option data structure for data-driven fluid model.
* \return option data structure for data-driven fluid model.
*/
DataDrivenFluid_ParsedOptions GetDataDrivenParsedOptions() const { return datadriven_ParsedOptions; }

/*!
* \brief Get parsed option data structure for the flamelet fluid model.
* \return option data structure for the flamelet fluid model.
*/
FluidFlamelet_ParsedOptions GetFlameletParsedOptions() const { return flamelet_ParsedOptions; }

};
40 changes: 40 additions & 0 deletions Common/include/option_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,20 @@ inline LM_ParsedOptions ParseLMOptions(const LM_OPTIONS *LM_Options, unsigned sh
return LMParsedOptions;
}

/*!
* \brief Structure containing parsed options for data-driven fluid model.
*/
struct DataDrivenFluid_ParsedOptions {
su2double rho_init_custom = -1; /*!< \brief Optional initial guess for density in inverse look-up operations. */
su2double e_init_custom = -1; /*!< \brief Optional initial guess for static energy in inverse look-up operations.*/
su2double Newton_relaxation = 1.0; /*!< \brief Relaxation factor for Newton solvers in data-driven fluid models. */
bool use_PINN = false; /*!< \brief Use physics-informed method for data-driven fluid modeling. */
ENUM_DATADRIVEN_METHOD interp_algorithm_type = ENUM_DATADRIVEN_METHOD::MLP; /*!< \brief Interpolation algorithm used for data-driven fluid model. */
unsigned short n_filenames = 1; /*!< \brief Number of datasets. */
std::string *datadriven_filenames; /*!< \brief Dataset information for data-driven fluid models. */
};


/*!
* \brief types of species transport models
*/
Expand Down Expand Up @@ -1391,6 +1405,32 @@ static const MapType<std::string, FLAMELET_INIT_TYPE> Flamelet_Init_Map = {
MakePair("SPARK", FLAMELET_INIT_TYPE::SPARK)
};

/*!
* \brief Structure containing parsed options for flamelet fluid model.
*/
struct FluidFlamelet_ParsedOptions {
///TODO: Add python wrapper initialization option
FLAMELET_INIT_TYPE ignition_method = FLAMELET_INIT_TYPE::NONE; /*!< \brief Method for solution ignition for flamelet problems. */
unsigned short n_scalars = 0; /*!< \brief Number of transported scalars for flamelet LUT approach. */
unsigned short n_lookups = 0; /*!< \brief Number of lookup variables, for visualization only. */
unsigned short n_table_sources = 0; /*!< \brief Number of transported scalar source terms for LUT. */
unsigned short n_user_scalars = 0; /*!< \brief Number of user defined (auxiliary) scalar transport equations. */
unsigned short n_user_sources = 0; /*!< \brief Number of source terms for user defined (auxiliary) scalar transport equations. */
unsigned short n_control_vars = 0; /*!< \brief Number of controlling variables (independent variables) for the LUT. */

std::string *controlling_variable_names; /*!< \brief Names of the independent, transported scalars. */
std::string* cv_source_names; /*!< \brief Names of the source terms of the independent, transported scalars. */
std::string* lookup_names; /*!< \brief Names of the passive look-up terms. */
std::string* user_scalar_names; /*!< \brief Names of the passive transported scalars. */
std::string* user_source_names; /*!< \brief Names of the source terms of the passive transported scalars. */

std::array<su2double,8> flame_init; /*!< \brief Flame front initialization parameters. */
std::array<su2double,6> spark_init; /*!< \brief Spark ignition initialization parameters. */
su2double* spark_reaction_rates; /*!< \brief Source terms for flamelet spark ignition option. */
unsigned short nspark; /*!< \brief Number of source terms for spark initialization. */
bool preferential_diffusion = false; /*!< \brief Preferential diffusion physics for flamelet solver.*/
};

/*!
* \brief Types of subgrid scale models
*/
Expand Down
Loading
Loading