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 19 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
24 changes: 24 additions & 0 deletions Common/include/CConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,10 @@ class CConfig {
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 @@ -3993,6 +3997,20 @@ class CConfig {
*/
su2double GetRelaxation_DataDriven(void) const { return DataDriven_Relaxation_Factor; }

/*!
* \brief Get initial density value for Newton solver in data-driven fluid model.
* \return Initial density value.
*/
su2double GetInitialDensity_DataDriven(void) const { return DataDriven_rho_init; }

/*!
* \brief Get initial static value for Newton solver in data-driven fluid model.
* \return Initial static value.
*/
su2double GetInitialEnergy_DataDriven(void) const { return DataDriven_e_init; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make a dedicated struct to store the _DataDriven config options and replace all _DataDriven accessors which are becoming numerous.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've replaced the accessors for the CDataDrivenFluid fluid model now with structs. I did a similar thing for the CFluidFlamelet fluid model.


bool Use_PINN(void) const { return UsePINN; }

/*!
* \brief Returns the name of the fluid we are using in CoolProp.
*/
Expand Down Expand Up @@ -7083,6 +7101,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
15 changes: 14 additions & 1 deletion Common/src/CConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,13 @@ void CConfig::SetConfig_Options() {
/*!\brief FILENAME_INTERPOLATOR \n DESCRIPTION: Input file for the interpolation method. \n \ingroup Config*/
addStringListOption("FILENAMES_INTERPOLATOR", n_Datadriven_files, DataDriven_Method_FileNames);
/*!\brief DATADRIVEN_NEWTON_RELAXATION \n DESCRIPTION: Relaxation factor for Newton solvers in data-driven fluid model. \n \ingroup Config*/
addDoubleOption("DATADRIVEN_NEWTON_RELAXATION", DataDriven_Relaxation_Factor, 0.05);
addDoubleOption("DATADRIVEN_NEWTON_RELAXATION", DataDriven_Relaxation_Factor, 1.0);
/*!\brief DATADRIVEN_INITIAL_DENSITY \n DESCRIPTION: Optional initial value for fluid density used for the Newton solver processes in the data-driven fluid model. */
addDoubleOption("DATADRIVEN_INITIAL_DENSITY", DataDriven_rho_init, -1.0);
/*!\brief DATADRIVEN_INITIAL_ENERGY \n DESCRIPTION: Optional initial value for fluid static energy used for the Newton solver processes in the data-driven fluid model. */
addDoubleOption("DATADRIVEN_INITIAL_ENERGY", DataDriven_e_init, -1.0);
/*!\biref USE_PINN \n DESCRIPTION: Use physics-informed approach for the entropy-based fluid model. \n \ingroup Config*/
addBoolOption("USE_PINN",UsePINN, false);

/*!\brief CONFINEMENT_PARAM \n DESCRIPTION: Input Confinement Parameter for Vorticity Confinement*/
addDoubleOption("CONFINEMENT_PARAM", Confinement_Param, 0.0);
Expand Down Expand Up @@ -9124,6 +9130,13 @@ void CConfig::SetOutlet_Pressure(su2double val_pressure, const string& val_marke
Outlet_Pressure[iMarker_Outlet] = val_pressure;
}

void CConfig::SetRiemann_Var1(su2double newVar1, const string& val_marker) {
unsigned short iMarker_Riemann;
for (iMarker_Riemann = 0; iMarker_Riemann < nMarker_Riemann; iMarker_Riemann++)
if (Marker_Riemann[iMarker_Riemann] == val_marker) break;
Riemann_Var1[iMarker_Riemann] = newVar1;
}

su2double CConfig::GetRiemann_Var1(const string& val_marker) const {
unsigned short iMarker_Riemann;
for (iMarker_Riemann = 0; iMarker_Riemann < nMarker_Riemann; iMarker_Riemann++)
Expand Down
22 changes: 22 additions & 0 deletions SU2_CFD/include/fluid/CDataDrivenFluid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ class CDataDrivenFluid final : public CFluidModel {
rho_min, rho_max, /*!< \brief Minimum and maximum density values in data set. */
e_min, e_max; /*!< \brief Minimum and maximum energy values in data set. */

bool custom_init_rho{false},
custom_init_e{false};
su2double val_custom_init_rho,
val_custom_init_e,
rho_median,
e_median;
unsigned long MaxIter_Newton; /*!< \brief Maximum number of iterations for Newton solvers. */

su2double dsde_rho, /*!< \brief Entropy derivative w.r.t. density. */
Expand All @@ -77,6 +83,8 @@ class CDataDrivenFluid final : public CFluidModel {
P_middle, /*!< \brief Pressure computed from the centre of the data set. */
T_middle; /*!< \brief Temperature computed from the centre of the data set. */

su2double gas_constant_config,
gamma_config;
su2double Enthalpy, /*!< \brief Fluid enthalpy value [J kg^-1] */
dhdrho_e, /*!< \brief Enthalpy derivative w.r.t. density. */
dhde_rho; /*!< \brief Enthalpy derivative w.r.t. static energy. */
Expand All @@ -87,6 +95,10 @@ class CDataDrivenFluid final : public CFluidModel {

vector<su2double*> outputs_rhoe; /*!< \brief Pointers to output variables. */

vector<vector<su2double*>> dsdrhoe;
vector<vector<vector<su2double*>>> d2sdrhoe2;

bool use_MLP_derivatives;
/*--- Class variables for the multi-layer perceptron method ---*/
#ifdef USE_MLPCPP
MLPToolbox::CLookUp_ANN* lookup_mlp; /*!< \brief Multi-layer perceptron collection. */
Expand Down Expand Up @@ -158,6 +170,7 @@ class CDataDrivenFluid final : public CFluidModel {
void Run_Newton_Solver(su2double Y_target, su2double* Y, su2double* X, su2double* dYdX);

void ComputeIdealGasQuantities();

public:
/*!
* \brief Constructor of the class.
Expand Down Expand Up @@ -213,6 +226,15 @@ class CDataDrivenFluid final : public CFluidModel {
*/
void SetTDState_Ps(su2double P, su2double s) override;

/*!
* \brief compute some derivatives of enthalpy and entropy needed for subsonic inflow BC
* \param[in] InputSpec - Input pair for FLP calls ("Pv").
* \param[in] th1 - first thermodynamic variable (P).
* \param[in] th2 - second thermodynamic variable (v).
*
*/
void ComputeDerivativeNRBC_Prho(su2double P, su2double rho) override;

/*!
* \brief Get fluid model extrapolation instance.
* \return Query point lies outside fluid model data range.
Expand Down
11 changes: 10 additions & 1 deletion SU2_CFD/include/iteration/CFluidIteration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,23 @@ class CFluidIteration : public CIteration {
unsigned short val_iInst) override;

/*!
* \brief Monitors turbo computation (pressure and turbo ramps).
* \brief Monitors turbo computation (turbo ramp).
* \param[in] geometry_container - Geometrical definition of the problem
* \param[in] config_container - Defintion of the particular problem
* \param[in] ExtIter - The current iteration of the problem
* \param[in] iZone - The current zone
*/
void TurboMonitor(CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter, unsigned short iZone);

/*!
* \brief Update adaptive boundary condition values.
* \param[in] geometry_container - Geometrical definition of the problem
* \param[in] config_container - Defintion of the particular problem
* \param[in] ExtIter - The current iteration of the problem
* \param[in] iZone - The current zone
*/
void UpdateBoundaryConditions(CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter, unsigned short iZone);

/*!
* \brief Computes turboperformance.
*/
Expand Down
Loading
Loading