From 594fc94f8717033e135780e200da44b08bf77ac0 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Wed, 17 Jul 2024 10:26:33 +0200 Subject: [PATCH 01/57] Added option for using physics-informed neural network --- Common/include/CConfig.hpp | 3 +++ Common/src/CConfig.cpp | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index bc32b5407b18..213c66ccf750 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -533,6 +533,7 @@ 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. */ + 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. */ @@ -3935,6 +3936,8 @@ class CConfig { */ su2double GetRelaxation_DataDriven(void) const { return DataDriven_Relaxation_Factor; } + bool Use_PINN(void) const { return UsePINN; } + /*! * \brief Returns the name of the fluid we are using in CoolProp. */ diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 63810ab3e03b..239cc2883729 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1192,7 +1192,9 @@ void CConfig::SetConfig_Options() { 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); - + /*!\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); From 6509e67371331f4295271e6ea7fe5e0bc2902ebc Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Wed, 17 Jul 2024 10:30:33 +0200 Subject: [PATCH 02/57] Added physics-informed approach to data-driven fluid model --- SU2_CFD/include/fluid/CDataDrivenFluid.hpp | 13 ++++ SU2_CFD/src/fluid/CDataDrivenFluid.cpp | 80 +++++++++++++++++----- 2 files changed, 75 insertions(+), 18 deletions(-) diff --git a/SU2_CFD/include/fluid/CDataDrivenFluid.hpp b/SU2_CFD/include/fluid/CDataDrivenFluid.hpp index 1a524326c8a1..b2a3d4dcf9ad 100644 --- a/SU2_CFD/include/fluid/CDataDrivenFluid.hpp +++ b/SU2_CFD/include/fluid/CDataDrivenFluid.hpp @@ -87,6 +87,10 @@ class CDataDrivenFluid final : public CFluidModel { vector outputs_rhoe; /*!< \brief Pointers to output variables. */ + vector> dsdrhoe; + vector>> 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. */ @@ -213,6 +217,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. diff --git a/SU2_CFD/src/fluid/CDataDrivenFluid.cpp b/SU2_CFD/src/fluid/CDataDrivenFluid.cpp index 09f187f2d1d2..5858017946b0 100644 --- a/SU2_CFD/src/fluid/CDataDrivenFluid.cpp +++ b/SU2_CFD/src/fluid/CDataDrivenFluid.cpp @@ -38,6 +38,7 @@ CDataDrivenFluid::CDataDrivenFluid(const CConfig* config, bool display) : CFluid varname_rho = "Density"; varname_e = "Energy"; + use_MLP_derivatives = config->Use_PINN(); /*--- Set up interpolation algorithm according to data-driven method. Currently only MLP's are supported. ---*/ switch (Kind_DataDriven_Method) { case ENUM_DATADRIVEN_METHOD::MLP: @@ -92,23 +93,50 @@ void CDataDrivenFluid::MapInputs_to_Outputs() { /*--- Required outputs for the interpolation method are entropy and its partial derivatives with respect to energy and * density. ---*/ - size_t n_outputs = 6; - size_t idx_s = 0, idx_dsde_rho = 1, idx_dsdrho_e = 2, idx_d2sde2 = 3, idx_d2sdedrho = 4, idx_d2sdrho2 = 5; - - outputs_rhoe.resize(n_outputs); - output_names_rhoe.resize(n_outputs); - output_names_rhoe[idx_s] = "s"; - outputs_rhoe[idx_s] = &Entropy; - output_names_rhoe[idx_dsde_rho] = "dsde_rho"; - outputs_rhoe[idx_dsde_rho] = &dsde_rho; - output_names_rhoe[idx_dsdrho_e] = "dsdrho_e"; - outputs_rhoe[idx_dsdrho_e] = &dsdrho_e; - output_names_rhoe[idx_d2sde2] = "d2sde2"; - outputs_rhoe[idx_d2sde2] = &d2sde2; - output_names_rhoe[idx_d2sdedrho] = "d2sdedrho"; - outputs_rhoe[idx_d2sdedrho] = &d2sdedrho; - output_names_rhoe[idx_d2sdrho2] = "d2sdrho2"; - outputs_rhoe[idx_d2sdrho2] = &d2sdrho2; + size_t n_outputs, idx_s,idx_dsde_rho = 1, idx_dsdrho_e = 2, idx_d2sde2 = 3, idx_d2sdedrho = 4, idx_d2sdrho2 = 5; + if (use_MLP_derivatives) { + n_outputs = 1; + idx_s = 0; + + outputs_rhoe.resize(n_outputs); + output_names_rhoe.resize(n_outputs); + output_names_rhoe[idx_s] = "s"; + outputs_rhoe[idx_s] = &Entropy; + + dsdrhoe.resize(n_outputs); + d2sdrhoe2.resize(n_outputs); + dsdrhoe[0].resize(2); + dsdrhoe[0][idx_rho] = &dsdrho_e; + dsdrhoe[0][idx_e] = &dsde_rho; + + d2sdrhoe2[0].resize(2); + d2sdrhoe2[0][idx_rho].resize(2); + d2sdrhoe2[0][idx_e].resize(2); + d2sdrhoe2[0][idx_rho][idx_rho] = &d2sdrho2; + d2sdrhoe2[0][idx_rho][idx_e] = &d2sdedrho; + d2sdrhoe2[0][idx_e][idx_rho] = &d2sdedrho; + d2sdrhoe2[0][idx_e][idx_e] = &d2sde2; + } else { + n_outputs = 6; + idx_s = 0; + idx_dsde_rho = 1, idx_dsdrho_e = 2, idx_d2sde2 = 3, idx_d2sdedrho = 4, idx_d2sdrho2 = 5; + + outputs_rhoe.resize(n_outputs); + output_names_rhoe.resize(n_outputs); + output_names_rhoe[idx_s] = "s"; + outputs_rhoe[idx_s] = &Entropy; + output_names_rhoe[idx_dsde_rho] = "dsde_rho"; + outputs_rhoe[idx_dsde_rho] = &dsde_rho; + output_names_rhoe[idx_dsdrho_e] = "dsdrho_e"; + outputs_rhoe[idx_dsdrho_e] = &dsdrho_e; + output_names_rhoe[idx_d2sde2] = "d2sde2"; + outputs_rhoe[idx_d2sde2] = &d2sde2; + output_names_rhoe[idx_d2sdedrho] = "d2sdedrho"; + outputs_rhoe[idx_d2sdedrho] = &d2sdedrho; + output_names_rhoe[idx_d2sdrho2] = "d2sdrho2"; + outputs_rhoe[idx_d2sdrho2] = &d2sdrho2; + } + /*--- Further preprocessing of input and output variables. ---*/ if (Kind_DataDriven_Method == ENUM_DATADRIVEN_METHOD::MLP) { @@ -236,14 +264,30 @@ void CDataDrivenFluid::SetTDState_Ps(su2double P, su2double s) { Run_Newton_Solver(P, s, &Pressure, &Entropy, &dPdrho_e, &dPde_rho, &dsdrho_e, &dsde_rho); } + +void CDataDrivenFluid::ComputeDerivativeNRBC_Prho(su2double P, su2double rho) { + SetTDState_Prho(P, rho); +} + + unsigned long CDataDrivenFluid::Predict_MLP(su2double rho, su2double e) { unsigned long exit_code = 0; /*--- Evaluate MLP collection for the given values for density and energy. ---*/ #ifdef USE_MLPCPP MLP_inputs[idx_rho] = rho; MLP_inputs[idx_e] = e; - exit_code = lookup_mlp->PredictANN(iomap_rhoe, MLP_inputs, outputs_rhoe); + if (use_MLP_derivatives){ + exit_code = lookup_mlp->PredictANN(iomap_rhoe, MLP_inputs, outputs_rhoe, &dsdrhoe, &d2sdrhoe2); + } else { + exit_code = lookup_mlp->PredictANN(iomap_rhoe, MLP_inputs, outputs_rhoe); + } + #endif + if (!use_MLP_derivatives){ + dsdrho_e = -exp(dsdrho_e); + d2sdrho2 = exp(d2sdrho2); + } + return exit_code; } From e05fe40ac0ddf38f296d71317f1360da820d0639 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Wed, 17 Jul 2024 14:01:19 +0200 Subject: [PATCH 03/57] Added PINN option --- SU2_CFD/src/fluid/CDataDrivenFluid.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/SU2_CFD/src/fluid/CDataDrivenFluid.cpp b/SU2_CFD/src/fluid/CDataDrivenFluid.cpp index 5858017946b0..b48f45ca275d 100644 --- a/SU2_CFD/src/fluid/CDataDrivenFluid.cpp +++ b/SU2_CFD/src/fluid/CDataDrivenFluid.cpp @@ -38,7 +38,9 @@ CDataDrivenFluid::CDataDrivenFluid(const CConfig* config, bool display) : CFluid varname_rho = "Density"; varname_e = "Energy"; + /*--- Use physics-informed approach ---*/ use_MLP_derivatives = config->Use_PINN(); + /*--- Set up interpolation algorithm according to data-driven method. Currently only MLP's are supported. ---*/ switch (Kind_DataDriven_Method) { case ENUM_DATADRIVEN_METHOD::MLP: @@ -50,6 +52,9 @@ CDataDrivenFluid::CDataDrivenFluid(const CConfig* config, bool display) : CFluid #endif break; case ENUM_DATADRIVEN_METHOD::LUT: + if (use_MLP_derivatives && (rank == MASTER_NODE) && display) + cout << "Physics-informed approach currently only works with MLP-based tabulation." << endl; + lookup_table = new CLookUpTable(config->GetDataDriven_FileNames()[0], varname_rho, varname_e); break; default: From 54972f2c432bcea630aaeba6014e185d5bd4c98c Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Tue, 12 Nov 2024 13:29:33 +0100 Subject: [PATCH 04/57] Added ideal gas approximation when compressiblity factor gets sufficiently high --- SU2_CFD/include/fluid/CDataDrivenFluid.hpp | 7 ++ SU2_CFD/src/fluid/CDataDrivenFluid.cpp | 91 +++++++++++++++------- 2 files changed, 71 insertions(+), 27 deletions(-) diff --git a/SU2_CFD/include/fluid/CDataDrivenFluid.hpp b/SU2_CFD/include/fluid/CDataDrivenFluid.hpp index b2a3d4dcf9ad..d8044959bea4 100644 --- a/SU2_CFD/include/fluid/CDataDrivenFluid.hpp +++ b/SU2_CFD/include/fluid/CDataDrivenFluid.hpp @@ -77,6 +77,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. */ @@ -162,6 +164,11 @@ class CDataDrivenFluid final : public CFluidModel { void Run_Newton_Solver(su2double Y_target, su2double* Y, su2double* X, su2double* dYdX); void ComputeIdealGasQuantities(); + + void SetTDState_entropicEOS(su2double rho, su2double e); + + void SetTDState_idealgas(su2double rho, su2double e); + public: /*! * \brief Constructor of the class. diff --git a/SU2_CFD/src/fluid/CDataDrivenFluid.cpp b/SU2_CFD/src/fluid/CDataDrivenFluid.cpp index b48f45ca275d..dd1ccf7ea506 100644 --- a/SU2_CFD/src/fluid/CDataDrivenFluid.cpp +++ b/SU2_CFD/src/fluid/CDataDrivenFluid.cpp @@ -40,6 +40,8 @@ CDataDrivenFluid::CDataDrivenFluid(const CConfig* config, bool display) : CFluid /*--- Use physics-informed approach ---*/ use_MLP_derivatives = config->Use_PINN(); + gas_constant_config = config->GetGas_Constant(); + gamma_config = config->GetGamma(); /*--- Set up interpolation algorithm according to data-driven method. Currently only MLP's are supported. ---*/ switch (Kind_DataDriven_Method) { @@ -71,6 +73,13 @@ CDataDrivenFluid::CDataDrivenFluid(const CConfig* config, bool display) : CFluid /*--- Compute approximate ideal gas properties ---*/ ComputeIdealGasQuantities(); + + SetTDState_rhoe(100, 3e5); + cout << scientific << Density << ", " + << scientific << StaticEnergy << ", " + << scientific << Temperature << ", " + << scientific << Pressure << ", " + << scientific << SoundSpeed2 << endl; } CDataDrivenFluid::~CDataDrivenFluid() { @@ -171,43 +180,66 @@ void CDataDrivenFluid::MapInputs_to_Outputs() { void CDataDrivenFluid::SetTDState_rhoe(su2double rho, su2double e) { /*--- Compute thermodynamic state based on density and energy. ---*/ - Density = rho; - StaticEnergy = e; - - /*--- Clip density and energy values to prevent extrapolation. ---*/ - Density = min(rho_max, max(rho_min, Density)); - StaticEnergy = min(e_max, max(e_min, StaticEnergy)); + + Density = max(min(rho, rho_max), rho_min); + StaticEnergy = max(min(e, e_max), e_min); Evaluate_Dataset(Density, StaticEnergy); - /*--- Compute speed of sound. ---*/ - auto blue_term = (dsdrho_e * (2 - rho * pow(dsde_rho, -1) * d2sdedrho) + rho * d2sdrho2); - auto green_term = (-pow(dsde_rho, -1) * d2sde2 * dsdrho_e + d2sdedrho); - - SoundSpeed2 = -rho * pow(dsde_rho, -1) * (blue_term - rho * green_term * (dsdrho_e / dsde_rho)); - + su2double rho_2 = Density * Density; /*--- Compute primary flow variables. ---*/ - Temperature = 1.0 / dsde_rho; - Pressure = -pow(rho, 2) * Temperature * dsdrho_e; - Density = rho; - StaticEnergy = e; - Enthalpy = e + Pressure / rho; + Temperature = pow(dsde_rho, -1); + Pressure = -Density*Density * Temperature * dsdrho_e; + Enthalpy = StaticEnergy + Pressure / Density; + + su2double Compressbility_factor = Pressure / (Temperature * Density * gas_constant_config); + // cout << scientific << rho << ", " + // << scientific << e << ", " + // << scientific << Compressbility_factor << endl; + if (Compressbility_factor > 0.695079) { + SetTDState_idealgas(Density, StaticEnergy); + } else { + SetTDState_entropicEOS(Density, StaticEnergy); + } +} +void CDataDrivenFluid::SetTDState_entropicEOS(su2double rho, su2double e){ /*--- Compute secondary flow variables ---*/ - dTde_rho = -pow(dsde_rho, -2) * d2sde2; - dTdrho_e = -pow(dsde_rho, -2) * d2sdedrho; + dTde_rho = -Temperature * Temperature * d2sde2; + dTdrho_e = -Temperature * Temperature * d2sdedrho; + + /*--- Compute speed of sound. ---*/ + su2double blue_term = (dsdrho_e * (2 - Density * Temperature * d2sdedrho) + Density * d2sdrho2); + su2double green_term = (-Temperature * d2sde2 * dsdrho_e + d2sdedrho); - dPde_rho = -pow(rho, 2) * (dTde_rho * dsdrho_e + Temperature * d2sdedrho); - dPdrho_e = -2 * rho * Temperature * dsdrho_e - pow(rho, 2) * (dTdrho_e * dsdrho_e + Temperature * d2sdrho2); + SoundSpeed2 = -Density * Temperature * (blue_term - Density * green_term * (dsdrho_e / dsde_rho)); + //dPde_rho = -pow(Density, 2) * (dTde_rho * dsdrho_e + Temperature * d2sdedrho); + //dPdrho_e = -2 * Density * Temperature * dsdrho_e - pow(Density, 2) * (dTdrho_e * dsdrho_e + Temperature * d2sdrho2); + su2double rho_2 = Density*Density; + dPde_rho = -rho_2 * Temperature * (-Temperature * (d2sde2 * dsdrho_e) + d2sdedrho); + dPdrho_e = - Density * Temperature * (dsdrho_e * (2 - Density * Temperature * d2sdedrho) + Density * d2sdrho2); /*--- Compute enthalpy and entropy derivatives required for Giles boundary conditions. ---*/ - dhdrho_e = -Pressure * pow(rho, -2) + dPdrho_e / rho; - dhde_rho = 1 + dPde_rho / rho; + dhdrho_e = -Pressure * (1 / rho_2) + dPdrho_e / Density; + dhde_rho = 1 + dPde_rho / Density; - dhdrho_P = dhdrho_e - dhde_rho * (1 / dPde_rho) * dPdrho_e; - dhdP_rho = dhde_rho * (1 / dPde_rho); - dsdrho_P = dsdrho_e - dPdrho_e * (1 / dPde_rho) * dsde_rho; - dsdP_rho = dsde_rho / dPde_rho; + // dhdrho_P = dhdrho_e - dhde_rho * (1 / dPde_rho) * dPdrho_e; + // dhdP_rho = dhde_rho * (1 / dPde_rho); + // dsdrho_P = dsdrho_e - dPdrho_e * (1 / dPde_rho) * dsde_rho; + // dsdP_rho = dsde_rho / dPde_rho; +} + +void CDataDrivenFluid::SetTDState_idealgas(su2double rho, su2double e) { + //Pressure = (gamma_config - 1) * Density * StaticEnergy; + //Temperature = (gamma_config - 1) * StaticEnergy / gas_constant_config; + SoundSpeed2 = gamma_config * Pressure / Density; + dPdrho_e = (gamma_config - 1) * StaticEnergy; + dPde_rho = (gamma_config - 1) * Density; + dTdrho_e = 0.0; + dTde_rho = (gamma_config - 1) / gas_constant_config; + dhdrho_e = -Pressure * (1 / (Density * Density)) + dPdrho_e / Density; + dhde_rho = 1 + dPde_rho / Density; + //Entropy = (1.0 / (gamma_config - 1) * log(Temperature) + log(1.0 / Density)) * gas_constant_config; } void CDataDrivenFluid::SetTDState_PT(su2double P, su2double T) { @@ -272,6 +304,11 @@ void CDataDrivenFluid::SetTDState_Ps(su2double P, su2double s) { void CDataDrivenFluid::ComputeDerivativeNRBC_Prho(su2double P, su2double rho) { SetTDState_Prho(P, rho); + + dhdrho_P = dhdrho_e - dhde_rho * (1 / dPde_rho) * dPdrho_e; + dhdP_rho = dhde_rho * (1 / dPde_rho); + dsdrho_P = dsdrho_e - dPdrho_e * (1 / dPde_rho) * dsde_rho; + dsdP_rho = dsde_rho / dPde_rho; } From 296f49e849e1b36717885909d5a3f1b1204d7418 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Mon, 6 Jan 2025 10:36:56 +0100 Subject: [PATCH 05/57] Added options for initial density and static energy for the data-driven fluid model --- Common/include/CConfig.hpp | 15 +++++++++++++++ Common/src/CConfig.cpp | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 166005531220..11841eaf7ca1 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -539,6 +539,9 @@ 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. */ @@ -3980,6 +3983,18 @@ 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; } + bool Use_PINN(void) const { return UsePINN; } /*! diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index b001bf8c8c5c..19ba9009f561 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1193,6 +1193,10 @@ void CConfig::SetConfig_Options() { 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); + /*!\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); From cc2e6a6123ece057aba3a1392607ea9d0a07f994 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Mon, 6 Jan 2025 10:37:41 +0100 Subject: [PATCH 06/57] Added heat capacity to output for data-driven fluid simulations --- SU2_CFD/src/output/CFlowCompOutput.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index e460109c8b52..e8f2ae91b3d9 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -250,6 +250,7 @@ void CFlowCompOutput::SetVolumeOutputFields(CConfig *config){ AddVolumeOutput("EXTRAPOLATION", "Extrapolation", "PRIMITIVE", "Density, energy outside data range"); AddVolumeOutput("FLUIDMODEL_NEWTONITER", "nIter_Newton", "PRIMITIVE", "Number of iterations evaluated by the Newton solver"); AddVolumeOutput("ENTROPY", "Entropy", "PRIMITIVE", "Fluid entropy value"); + AddVolumeOutput("HEAT_CAPACITY", "Heat_Capacity", "PRIMITIVE", "Heat capacity"); } if (config->GetViscous()) { @@ -347,6 +348,7 @@ void CFlowCompOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolv SetVolumeOutputValue("EXTRAPOLATION", iPoint, Node_Flow->GetDataExtrapolation(iPoint)); SetVolumeOutputValue("FLUIDMODEL_NEWTONITER", iPoint, Node_Flow->GetNewtonSolverIterations(iPoint)); SetVolumeOutputValue("ENTROPY", iPoint, Node_Flow->GetEntropy(iPoint)); + SetVolumeOutputValue("HEAT_CAPACITY", iPoint, Node_Flow->GetSpecificHeatCp(iPoint)); } if (config->GetKind_Solver() == MAIN_SOLVER::RANS || config->GetKind_Solver() == MAIN_SOLVER::NAVIER_STOKES){ From c2195001e4035dd06d103c361e1fc21d21685969 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Fri, 14 Feb 2025 14:56:24 +0100 Subject: [PATCH 07/57] Added pressure ramp function for Riemann boundary condition --- Common/include/CConfig.hpp | 6 ++++++ Common/src/CConfig.cpp | 9 ++++++++- SU2_CFD/include/iteration/CFluidIteration.hpp | 11 ++++++++++- SU2_CFD/src/iteration/CFluidIteration.cpp | 10 ++++++++-- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 325ce056fb5e..a30db2c3029a 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -7101,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. diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 94d1a39d50c8..a38cefbfea32 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1197,7 +1197,7 @@ 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. */ @@ -9130,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++) diff --git a/SU2_CFD/include/iteration/CFluidIteration.hpp b/SU2_CFD/include/iteration/CFluidIteration.hpp index 346f763581cf..61cbc66a986b 100644 --- a/SU2_CFD/include/iteration/CFluidIteration.hpp +++ b/SU2_CFD/include/iteration/CFluidIteration.hpp @@ -108,7 +108,7 @@ 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 @@ -116,6 +116,15 @@ class CFluidIteration : public CIteration { */ 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. */ diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index 4ca6c45a1724..e77b0d7c2ca3 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -235,6 +235,10 @@ bool CFluidIteration::Monitor(COutput* output, CIntegration**** integration, CGe TurboMonitor(geometry, config, config[val_iZone]->GetInnerIter(), val_iZone); } + + /*--- Update the values of any adaptive boundary conditions ---*/ + UpdateBoundaryConditions(geometry, config, config[val_iZone]->GetInnerIter(), val_iZone); + output->SetHistoryOutput(geometry[val_iZone][val_iInst][MESH_0], solver[val_iZone][val_iInst][MESH_0], config[val_iZone], config[val_iZone]->GetTimeIter(), config[val_iZone]->GetOuterIter(), config[val_iZone]->GetInnerIter()); @@ -286,7 +290,9 @@ void CFluidIteration::TurboMonitor(CGeometry**** geometry_container, CConfig** c } } } - +} +void CFluidIteration::UpdateBoundaryConditions(CGeometry**** geometry_container, CConfig** config_container, unsigned long iter, unsigned short iZone) { + auto* config = config_container[iZone]; /*--- Outlet Pressure Ramp: Compute the updated pressure. ---*/ if (config->GetRampOutletPressure()) { const unsigned long rampFreq = SU2_TYPE::Int(config->GetRampOutletPressure_Coeff(1)); @@ -306,7 +312,7 @@ void CFluidIteration::TurboMonitor(CGeometry**** geometry_container, CConfig** c case RIEMANN_BOUNDARY: KindBCOption = config->GetKind_Data_Riemann(Marker_Tag); if (KindBCOption == STATIC_PRESSURE || KindBCOption == RADIAL_EQUILIBRIUM) { - SU2_MPI::Error("Outlet pressure ramp only implemented for NRBC", CURRENT_FUNCTION); + config->SetRiemann_Var1(outPres, Marker_Tag); } break; case GILES_BOUNDARY: From 83e275951ea782e0818349c7b1ce9f9d542457d9 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Fri, 14 Feb 2025 14:57:44 +0100 Subject: [PATCH 08/57] Put the computation of the burnt progress variable inside the scope of flame front initialization --- SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp index 33ad74b3f38a..f2f14d051797 100644 --- a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp @@ -214,12 +214,14 @@ void CSpeciesFlameletSolver::SetInitialCondition(CGeometry** geometry, CSolver** scalar_init[I_ENTH] = enth_inlet; prog_unburnt = config->GetSpecies_Init()[I_PROGVAR]; - prog_burnt = GetBurntProgressVariable(fluid_model_local, scalar_init); SU2_OMP_FOR_STAT(omp_chunk_size) for (unsigned long i_point = 0; i_point < nPoint; i_point++) { auto coords = geometry[i_mesh]->nodes->GetCoord(i_point); if (flame_front_ignition) { + + prog_burnt = GetBurntProgressVariable(fluid_model_local, scalar_init); + /*--- Determine if point is above or below the plane, assuming the normal is pointing towards the burned region. ---*/ point_loc = 0.0; From 6220215d77ae5b8236fd056d13fad67a6d8a82c5 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Fri, 14 Feb 2025 14:59:23 +0100 Subject: [PATCH 09/57] Added computation of specific heat at constant pressure and at constant volume --- SU2_CFD/include/fluid/CDataDrivenFluid.hpp | 10 +- SU2_CFD/src/fluid/CDataDrivenFluid.cpp | 125 ++++++++++----------- 2 files changed, 63 insertions(+), 72 deletions(-) diff --git a/SU2_CFD/include/fluid/CDataDrivenFluid.hpp b/SU2_CFD/include/fluid/CDataDrivenFluid.hpp index 446f02ef93cc..2e70f3d569fa 100644 --- a/SU2_CFD/include/fluid/CDataDrivenFluid.hpp +++ b/SU2_CFD/include/fluid/CDataDrivenFluid.hpp @@ -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. */ @@ -165,10 +171,6 @@ class CDataDrivenFluid final : public CFluidModel { void ComputeIdealGasQuantities(); - void SetTDState_entropicEOS(su2double rho, su2double e); - - void SetTDState_idealgas(su2double rho, su2double e); - public: /*! * \brief Constructor of the class. diff --git a/SU2_CFD/src/fluid/CDataDrivenFluid.cpp b/SU2_CFD/src/fluid/CDataDrivenFluid.cpp index eed1446b14cf..57d905155a6f 100644 --- a/SU2_CFD/src/fluid/CDataDrivenFluid.cpp +++ b/SU2_CFD/src/fluid/CDataDrivenFluid.cpp @@ -41,7 +41,13 @@ CDataDrivenFluid::CDataDrivenFluid(const CConfig* config, bool display) : CFluid /*--- Use physics-informed approach ---*/ use_MLP_derivatives = config->Use_PINN(); gas_constant_config = config->GetGas_Constant(); - gamma_config = config->GetGamma(); + + /*--- Retrieve initial density and static energy values from config ---*/ + val_custom_init_e = config->GetInitialEnergy_DataDriven(); + val_custom_init_rho = config->GetInitialDensity_DataDriven(); + custom_init_e = (val_custom_init_e != -1.0); + custom_init_rho = (val_custom_init_rho != -1.0); + /*--- Set up interpolation algorithm according to data-driven method. Currently only MLP's are supported. ---*/ switch (Kind_DataDriven_Method) { @@ -73,13 +79,6 @@ CDataDrivenFluid::CDataDrivenFluid(const CConfig* config, bool display) : CFluid /*--- Compute approximate ideal gas properties ---*/ ComputeIdealGasQuantities(); - - SetTDState_rhoe(100, 3e5); - cout << scientific << Density << ", " - << scientific << StaticEnergy << ", " - << scientific << Temperature << ", " - << scientific << Pressure << ", " - << scientific << SoundSpeed2 << endl; } CDataDrivenFluid::~CDataDrivenFluid() { @@ -179,6 +178,11 @@ void CDataDrivenFluid::MapInputs_to_Outputs() { } void CDataDrivenFluid::SetTDState_rhoe(su2double rho, su2double e) { + + AD::StartPreacc(); + AD::SetPreaccIn(rho); + AD::SetPreaccIn(e); + /*--- Compute thermodynamic state based on density and energy. ---*/ Density = max(min(rho, rho_max), rho_min); @@ -189,21 +193,9 @@ void CDataDrivenFluid::SetTDState_rhoe(su2double rho, su2double e) { su2double rho_2 = Density * Density; /*--- Compute primary flow variables. ---*/ Temperature = pow(dsde_rho, -1); - Pressure = -Density*Density * Temperature * dsdrho_e; + Pressure = -rho_2 * Temperature * dsdrho_e; Enthalpy = StaticEnergy + Pressure / Density; - su2double Compressbility_factor = Pressure / (Temperature * Density * gas_constant_config); - // cout << scientific << rho << ", " - // << scientific << e << ", " - // << scientific << Compressbility_factor << endl; - if (Compressbility_factor > 0.695079) { - SetTDState_idealgas(Density, StaticEnergy); - } else { - SetTDState_entropicEOS(Density, StaticEnergy); - } -} - -void CDataDrivenFluid::SetTDState_entropicEOS(su2double rho, su2double e){ /*--- Compute secondary flow variables ---*/ dTde_rho = -Temperature * Temperature * d2sde2; dTdrho_e = -Temperature * Temperature * d2sdedrho; @@ -214,32 +206,33 @@ void CDataDrivenFluid::SetTDState_entropicEOS(su2double rho, su2double e){ SoundSpeed2 = -Density * Temperature * (blue_term - Density * green_term * (dsdrho_e / dsde_rho)); - //dPde_rho = -pow(Density, 2) * (dTde_rho * dsdrho_e + Temperature * d2sdedrho); - //dPdrho_e = -2 * Density * Temperature * dsdrho_e - pow(Density, 2) * (dTdrho_e * dsdrho_e + Temperature * d2sdrho2); - su2double rho_2 = Density*Density; dPde_rho = -rho_2 * Temperature * (-Temperature * (d2sde2 * dsdrho_e) + d2sdedrho); dPdrho_e = - Density * Temperature * (dsdrho_e * (2 - Density * Temperature * d2sdedrho) + Density * d2sdrho2); + /*--- Compute enthalpy and entropy derivatives required for Giles boundary conditions. ---*/ dhdrho_e = -Pressure * (1 / rho_2) + dPdrho_e / Density; dhde_rho = 1 + dPde_rho / Density; - // dhdrho_P = dhdrho_e - dhde_rho * (1 / dPde_rho) * dPdrho_e; - // dhdP_rho = dhde_rho * (1 / dPde_rho); - // dsdrho_P = dsdrho_e - dPdrho_e * (1 / dPde_rho) * dsde_rho; - // dsdP_rho = dsde_rho / dPde_rho; -} + /*--- Compute specific heat at constant volume and specific heat at constant pressure. ---*/ + Cv = 1 / dTde_rho; + dhdrho_P = dhdrho_e - dhde_rho * (1 / dPde_rho) * dPdrho_e; + dhdP_rho = dhde_rho * (1 / dPde_rho); + dsdrho_P = dsdrho_e - dPdrho_e * (1 / dPde_rho) * dsde_rho; + dsdP_rho = dsde_rho / dPde_rho; -void CDataDrivenFluid::SetTDState_idealgas(su2double rho, su2double e) { - //Pressure = (gamma_config - 1) * Density * StaticEnergy; - //Temperature = (gamma_config - 1) * StaticEnergy / gas_constant_config; - SoundSpeed2 = gamma_config * Pressure / Density; - dPdrho_e = (gamma_config - 1) * StaticEnergy; - dPde_rho = (gamma_config - 1) * Density; - dTdrho_e = 0.0; - dTde_rho = (gamma_config - 1) / gas_constant_config; - dhdrho_e = -Pressure * (1 / (Density * Density)) + dPdrho_e / Density; - dhde_rho = 1 + dPde_rho / Density; - //Entropy = (1.0 / (gamma_config - 1) * log(Temperature) + log(1.0 / Density)) * gas_constant_config; + su2double drhode_p = -dPde_rho/dPdrho_e; + su2double dTde_p = dTde_rho + dTdrho_e*drhode_p; + su2double dhde_p = dhde_rho + drhode_p*dhdrho_e; + Cp = dhde_p / dTde_p; + + AD::SetPreaccOut(Temperature); + AD::SetPreaccOut(SoundSpeed2); + AD::SetPreaccOut(dPde_rho); + AD::SetPreaccOut(dPdrho_e); + AD::SetPreaccOut(dTde_rho); + AD::SetPreaccOut(Pressure); + AD::SetPreaccOut(Entropy); + AD::EndPreacc(); } void CDataDrivenFluid::SetTDState_PT(su2double P, su2double T) { @@ -262,8 +255,7 @@ void CDataDrivenFluid::SetEnergy_Prho(su2double P, su2double rho) { Density = rho; /*--- Approximate static energy through ideal gas law. ---*/ - su2double e_idealgas = Cv_idealgas * (P / (R_idealgas * rho)); - StaticEnergy = min(e_max, max(e_idealgas, e_min)); + StaticEnergy = Cv_idealgas * (P / (R_idealgas * rho)); Run_Newton_Solver(P, &Pressure, &StaticEnergy, &dPde_rho); } @@ -281,23 +273,16 @@ void CDataDrivenFluid::SetTDState_rhoT(su2double rho, su2double T) { void CDataDrivenFluid::SetTDState_hs(su2double h, su2double s) { /*--- Run 2D Newton solver for enthalpy and entropy. ---*/ - /*--- Approximate density and static energy through ideal gas law under isentropic assumption. ---*/ - su2double T_init = h / Cp_idealgas; - su2double P_init = P_middle * pow(T_init / T_middle, gamma_idealgas/(gamma_idealgas - 1)); - - e_start = h * Cv_idealgas / Cp_idealgas; - rho_start = P_init / (R_idealgas * T_init); + e_start = StaticEnergy; + rho_start = Density; Run_Newton_Solver(h, s, &Enthalpy, &Entropy, &dhdrho_e, &dhde_rho, &dsdrho_e, &dsde_rho); } void CDataDrivenFluid::SetTDState_Ps(su2double P, su2double s) { /*--- Run 2D Newton solver for pressure and entropy ---*/ - /*--- Approximate initial state through isentropic assumption and ideal gas law. ---*/ - su2double T_init = T_middle * pow(P / P_middle, (gamma_idealgas - 1)/gamma_idealgas); - e_start = Cv_idealgas * T_init; - rho_start = P / (R_idealgas * T_init); - + e_start = StaticEnergy; + rho_start = Density; Run_Newton_Solver(P, s, &Pressure, &Entropy, &dPdrho_e, &dPde_rho, &dsdrho_e, &dsde_rho); } @@ -323,12 +308,7 @@ unsigned long CDataDrivenFluid::Predict_MLP(su2double rho, su2double e) { } else { exit_code = lookup_mlp->PredictANN(iomap_rhoe, MLP_inputs, outputs_rhoe); } - #endif - if (!use_MLP_derivatives){ - dsdrho_e = -exp(dsdrho_e); - d2sdrho2 = exp(d2sdrho2); - } return exit_code; } @@ -359,6 +339,9 @@ void CDataDrivenFluid::Run_Newton_Solver(su2double Y1_target, su2double Y2_targe /*--- 2D Newton solver, computing the density and internal energy values corresponding to Y1_target and Y2_target. * ---*/ + AD::StartPreacc(); + AD::SetPreaccIn(*Y1); + AD::SetPreaccIn(*Y2); /*--- Setting initial values for density and energy. ---*/ su2double rho = rho_start, e = e_start; @@ -393,7 +376,9 @@ void CDataDrivenFluid::Run_Newton_Solver(su2double Y1_target, su2double Y2_targe Iter++; } nIter_Newton = Iter; - + AD::SetPreaccOut(rho); + AD::SetPreaccOut(e); + AD::EndPreacc(); /*--- Evaluation of final state. ---*/ SetTDState_rhoe(rho, e); } @@ -403,7 +388,6 @@ void CDataDrivenFluid::Run_Newton_Solver(su2double Y_target, su2double* Y, su2do bool converged = false; unsigned long Iter = 0; - su2double delta_Y, delta_X; /*--- Initiating Newton solver. ---*/ @@ -425,7 +409,6 @@ void CDataDrivenFluid::Run_Newton_Solver(su2double Y_target, su2double* Y, su2do } Iter++; } - /*--- Calculate thermodynamic state based on converged values for density and energy. ---*/ SetTDState_rhoe(Density, StaticEnergy); @@ -453,21 +436,27 @@ void CDataDrivenFluid::ComputeIdealGasQuantities() { e_min = lookup_mlp->GetInputNorm(iomap_rhoe, idx_e).first; rho_max = lookup_mlp->GetInputNorm(iomap_rhoe, idx_rho).second; e_max = lookup_mlp->GetInputNorm(iomap_rhoe, idx_e).second; - rho_average = 0.5*(lookup_mlp->GetInputNorm(iomap_rhoe, idx_rho).first + lookup_mlp->GetInputNorm(iomap_rhoe, idx_rho).second); - e_average = 0.5*(lookup_mlp->GetInputNorm(iomap_rhoe, idx_e).first + lookup_mlp->GetInputNorm(iomap_rhoe, idx_e).second); + rho_average = lookup_mlp->GetInputOffset(iomap_rhoe, idx_rho); + e_average = lookup_mlp->GetInputOffset(iomap_rhoe, idx_e); #endif break; default: break; } - /*--- Compute thermodynamic state from middle of data set. ---*/ - SetTDState_rhoe(rho_average, e_average); + + su2double rho_init = custom_init_rho ? val_custom_init_rho : rho_average; + su2double e_init = custom_init_e ? val_custom_init_e : e_average; + + SetTDState_rhoe(rho_init, e_init); + rho_median = rho_init; + e_median = e_init; P_middle = Pressure; T_middle = Temperature; - R_idealgas = P_middle / (rho_average * T_middle); - Cv_idealgas = e_average / T_middle; - Cp_idealgas = Enthalpy / T_middle; + R_idealgas = P_middle / (rho_init * T_middle); + Cv_idealgas = Cv; + Cp_idealgas = Cp; + gamma_idealgas = (R_idealgas / Cv_idealgas) + 1; } \ No newline at end of file From e80b992cd8410d1ac9571e06c7f19b9276297301 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Fri, 14 Feb 2025 15:00:29 +0100 Subject: [PATCH 10/57] Adapted data-driven fluid model test case to be compatible with physics-informed neural networks --- .../nicf/datadriven/datadriven_nozzle.cfg | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/TestCases/nicf/datadriven/datadriven_nozzle.cfg b/TestCases/nicf/datadriven/datadriven_nozzle.cfg index 0e5326609f48..33a1085c6b61 100644 --- a/TestCases/nicf/datadriven/datadriven_nozzle.cfg +++ b/TestCases/nicf/datadriven/datadriven_nozzle.cfg @@ -26,10 +26,10 @@ AOA= 0.0 SIDESLIP_ANGLE= 0.0 INIT_OPTION= TD_CONDITIONS FREESTREAM_OPTION= TEMPERATURE_FS -FREESTREAM_PRESSURE= 250000.0 +FREESTREAM_PRESSURE= 904388 % % Free-stream temperature (288.15 K, 518.67 R by default) -FREESTREAM_TEMPERATURE= 400.0 +FREESTREAM_TEMPERATURE= 542.13 FREESTREAM_DENSITY= 2.0 REF_DIMENSIONALIZATION= DIMENSIONAL @@ -37,8 +37,8 @@ REF_DIMENSIONALIZATION= DIMENSIONAL % FLUID_MODEL = DATADRIVEN_FLUID INTERPOLATION_METHOD = MLP -FILENAMES_INTERPOLATOR = (MLP_air.mlp) -DATADRIVEN_NEWTON_RELAXATION = 0.8 +FILENAMES_INTERPOLATOR = (MLP_MM.mlp) +USE_PINN= YES % --------------------------- VISCOSITY MODEL ---------------------------------% VISCOSITY_MODEL= CONSTANT_VISCOSITY @@ -49,9 +49,13 @@ CONDUCTIVITY_MODEL= CONSTANT_CONDUCTIVITY THERMAL_CONDUCTIVITY_CONSTANT= 0.030542828 % -------------------- BOUNDARY CONDITION DEFINITION --------------------------% -MARKER_SYM= ( SYMMETRY, WALL ) +MARKER_SYM= ( SYMMETRY ) +MARKER_HEATFLUX= (WALL, 0.0) MARKER_RIEMANN= ( INFLOW, TOTAL_CONDITIONS_PT, 904388, 542.13, 1.0, 0.0, 0.0, OUTFLOW, STATIC_PRESSURE, 200000.0, 0.0, 0.0, 0.0, 0.0 ) +RAMP_OUTLET_PRESSURE= YES +RAMP_OUTLET_PRESSURE_COEFF= (904388, 10, 200) + % ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% NUM_METHOD_GRAD= GREEN_GAUSS CFL_NUMBER= 10.0 @@ -89,7 +93,7 @@ CFL_REDUCTION_TURB= 1.0 % --------------------------- CONVERGENCE PARAMETERS --------------------------% % % Number of total iterations -ITER= 10 +ITER= 1000 CONV_RESIDUAL_MINVAL= -24 CONV_STARTITER= 10 @@ -116,6 +120,7 @@ RESTART_FILENAME= restart_flow.dat % % Output file flow (w/o extension) variables VOLUME_FILENAME= flow +VOLUME_OUTPUT=(PRIMITIVE, SOLUTION,RESIDUAL) % % Output file surface flow coefficient (w/o extension) SURFACE_FILENAME= surface_flow @@ -124,4 +129,4 @@ SURFACE_FILENAME= surface_flow OUTPUT_WRT_FREQ= 500 % % Screen output -SCREEN_OUTPUT= (INNER_ITER, RMS_DENSITY, RMS_TKE, RMS_DISSIPATION, LIFT, DRAG) +SCREEN_OUTPUT= (INNER_ITER, RMS_DENSITY, RMS_TKE) From 8419fa5ac5c76ec1a03123ec320dbfeb3f7975c5 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Fri, 14 Feb 2025 15:01:55 +0100 Subject: [PATCH 11/57] Updated MLPCpp submodule --- meson_scripts/init.py | 2 +- subprojects/MLPCpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/meson_scripts/init.py b/meson_scripts/init.py index 67a2e41a2ecc..be99908e7ea5 100755 --- a/meson_scripts/init.py +++ b/meson_scripts/init.py @@ -74,7 +74,7 @@ def init_submodules( github_repo_mel = "https://github.com/pcarruscag/MEL" sha_version_fado = "ce7ee018e4e699af5028d69baa1939fea290e18a" github_repo_fado = "https://github.com/pcarruscag/FADO" - sha_version_mlpcpp = "6865a58b22f21a92977839d9c93eae9522402f55" + sha_version_mlpcpp = "c4c5612d3f368493aeae1039044beb4c10765f69" github_repo_mlpcpp = "https://github.com/EvertBunschoten/MLPCpp" medi_name = "MeDiPack" diff --git a/subprojects/MLPCpp b/subprojects/MLPCpp index 6865a58b22f2..c4c5612d3f36 160000 --- a/subprojects/MLPCpp +++ b/subprojects/MLPCpp @@ -1 +1 @@ -Subproject commit 6865a58b22f21a92977839d9c93eae9522402f55 +Subproject commit c4c5612d3f368493aeae1039044beb4c10765f69 From 5325a327b9ee94c5c2b3eca19dd71dc443d564f3 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Fri, 14 Feb 2025 15:04:06 +0100 Subject: [PATCH 12/57] fixed trailing white spaces --- Common/include/CConfig.hpp | 8 ++++---- Common/src/CConfig.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index a30db2c3029a..195840a4fdac 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -540,7 +540,7 @@ class CConfig { 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. */ @@ -4008,9 +4008,9 @@ class CConfig { * \return Initial static value. */ su2double GetInitialEnergy_DataDriven(void) const { return DataDriven_e_init; } - + bool Use_PINN(void) const { return UsePINN; } - + /*! * \brief Returns the name of the fluid we are using in CoolProp. */ @@ -7106,7 +7106,7 @@ class CConfig { * \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. diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index a38cefbfea32..ec3f23c1ee64 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1204,7 +1204,7 @@ void CConfig::SetConfig_Options() { 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); From f985434523f70717ca298bb736ecef93e520d9a7 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Fri, 14 Feb 2025 15:38:55 +0100 Subject: [PATCH 13/57] Fixed warning for unused variable in MLPCpp --- meson_scripts/init.py | 2 +- subprojects/MLPCpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/meson_scripts/init.py b/meson_scripts/init.py index be99908e7ea5..f8f2cdecc9dd 100755 --- a/meson_scripts/init.py +++ b/meson_scripts/init.py @@ -74,7 +74,7 @@ def init_submodules( github_repo_mel = "https://github.com/pcarruscag/MEL" sha_version_fado = "ce7ee018e4e699af5028d69baa1939fea290e18a" github_repo_fado = "https://github.com/pcarruscag/FADO" - sha_version_mlpcpp = "c4c5612d3f368493aeae1039044beb4c10765f69" + sha_version_mlpcpp = "e19ca0cafb28c4b7ba5b8cffef42883259b00dc0" github_repo_mlpcpp = "https://github.com/EvertBunschoten/MLPCpp" medi_name = "MeDiPack" diff --git a/subprojects/MLPCpp b/subprojects/MLPCpp index c4c5612d3f36..e19ca0cafb28 160000 --- a/subprojects/MLPCpp +++ b/subprojects/MLPCpp @@ -1 +1 @@ -Subproject commit c4c5612d3f368493aeae1039044beb4c10765f69 +Subproject commit e19ca0cafb28c4b7ba5b8cffef42883259b00dc0 From d8f09128509a53c7f09551f838788f370faf1880 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Mon, 17 Feb 2025 13:45:19 +0100 Subject: [PATCH 14/57] Changed input variables to Newton solvers to be pass-by-reference --- SU2_CFD/include/fluid/CDataDrivenFluid.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SU2_CFD/include/fluid/CDataDrivenFluid.hpp b/SU2_CFD/include/fluid/CDataDrivenFluid.hpp index 2e70f3d569fa..ba7ef76317bc 100644 --- a/SU2_CFD/include/fluid/CDataDrivenFluid.hpp +++ b/SU2_CFD/include/fluid/CDataDrivenFluid.hpp @@ -157,8 +157,8 @@ class CDataDrivenFluid final : public CFluidModel { * \param[in] dY2drho - Pointer to the partial derivative of quantity 2 w.r.t. density at constant energy. * \param[in] dY2de - Pointer to the partial derivative of quantity 2 w.r.t. energy at constant density. */ - void Run_Newton_Solver(su2double Y1_target, su2double Y2_target, su2double* Y1, su2double* Y2, su2double* dY1drho, - su2double* dY1de, su2double* dY2drho, su2double* dY2de); + void Run_Newton_Solver(su2double Y1_target, su2double Y2_target, su2double& Y1, su2double& Y2, su2double& dY1drho, + su2double& dY1de, su2double& dY2drho, su2double& dY2de); /*! * \brief 1D Newton solver for computing the density or energy corresponding to Y_target. @@ -167,7 +167,7 @@ class CDataDrivenFluid final : public CFluidModel { * \param[in] X - Pointer to controlling variable (density or energy). * \param[in] dYdX - Pointer to the partial derivative of target quantity w.r.t. controlling variable. */ - void Run_Newton_Solver(su2double Y_target, su2double* Y, su2double* X, su2double* dYdX); + void Run_Newton_Solver(su2double Y_target, su2double& Y, su2double& X, su2double& dYdX); void ComputeIdealGasQuantities(); From 5aebea895c83fe5fee381e76ae03a31319da9c15 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Mon, 17 Feb 2025 13:45:47 +0100 Subject: [PATCH 15/57] Pass-by-reference for Newton solvers --- SU2_CFD/src/fluid/CDataDrivenFluid.cpp | 46 +++++++++++++------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/SU2_CFD/src/fluid/CDataDrivenFluid.cpp b/SU2_CFD/src/fluid/CDataDrivenFluid.cpp index 57d905155a6f..5555576bddbd 100644 --- a/SU2_CFD/src/fluid/CDataDrivenFluid.cpp +++ b/SU2_CFD/src/fluid/CDataDrivenFluid.cpp @@ -242,7 +242,7 @@ void CDataDrivenFluid::SetTDState_PT(su2double P, su2double T) { e_start = Cv_idealgas * T; /*--- Run 2D Newton solver for pressure and temperature ---*/ - Run_Newton_Solver(P, T, &Pressure, &Temperature, &dPdrho_e, &dPde_rho, &dTdrho_e, &dTde_rho); + Run_Newton_Solver(P, T, Pressure, Temperature, dPdrho_e, dPde_rho, dTdrho_e, dTde_rho); } void CDataDrivenFluid::SetTDState_Prho(su2double P, su2double rho) { @@ -257,7 +257,7 @@ void CDataDrivenFluid::SetEnergy_Prho(su2double P, su2double rho) { /*--- Approximate static energy through ideal gas law. ---*/ StaticEnergy = Cv_idealgas * (P / (R_idealgas * rho)); - Run_Newton_Solver(P, &Pressure, &StaticEnergy, &dPde_rho); + Run_Newton_Solver(P, Pressure, StaticEnergy, dPde_rho); } void CDataDrivenFluid::SetTDState_rhoT(su2double rho, su2double T) { @@ -267,7 +267,7 @@ void CDataDrivenFluid::SetTDState_rhoT(su2double rho, su2double T) { /*--- Approximate static energy through ideal gas law. ---*/ StaticEnergy = Cv_idealgas * T; - Run_Newton_Solver(T, &Temperature, &StaticEnergy, &dTde_rho); + Run_Newton_Solver(T, Temperature, StaticEnergy, dTde_rho); } void CDataDrivenFluid::SetTDState_hs(su2double h, su2double s) { @@ -275,7 +275,7 @@ void CDataDrivenFluid::SetTDState_hs(su2double h, su2double s) { e_start = StaticEnergy; rho_start = Density; - Run_Newton_Solver(h, s, &Enthalpy, &Entropy, &dhdrho_e, &dhde_rho, &dsdrho_e, &dsde_rho); + Run_Newton_Solver(h, s, Enthalpy, Entropy, dhdrho_e, dhde_rho, dsdrho_e, dsde_rho); } void CDataDrivenFluid::SetTDState_Ps(su2double P, su2double s) { @@ -283,7 +283,7 @@ void CDataDrivenFluid::SetTDState_Ps(su2double P, su2double s) { e_start = StaticEnergy; rho_start = Density; - Run_Newton_Solver(P, s, &Pressure, &Entropy, &dPdrho_e, &dPde_rho, &dsdrho_e, &dsde_rho); + Run_Newton_Solver(P, s, Pressure, Entropy, dPdrho_e, dPde_rho, dsdrho_e, dsde_rho); } @@ -334,14 +334,14 @@ void CDataDrivenFluid::Evaluate_Dataset(su2double rho, su2double e) { } } -void CDataDrivenFluid::Run_Newton_Solver(su2double Y1_target, su2double Y2_target, su2double* Y1, su2double* Y2, - su2double* dY1drho, su2double* dY1de, su2double* dY2drho, su2double* dY2de) { +void CDataDrivenFluid::Run_Newton_Solver(su2double Y1_target, su2double Y2_target, su2double& Y1, su2double& Y2, + su2double& dY1drho, su2double& dY1de, su2double& dY2drho, su2double& dY2de) { /*--- 2D Newton solver, computing the density and internal energy values corresponding to Y1_target and Y2_target. * ---*/ AD::StartPreacc(); - AD::SetPreaccIn(*Y1); - AD::SetPreaccIn(*Y2); + AD::SetPreaccIn(Y1); + AD::SetPreaccIn(Y2); /*--- Setting initial values for density and energy. ---*/ su2double rho = rho_start, e = e_start; @@ -356,18 +356,18 @@ void CDataDrivenFluid::Run_Newton_Solver(su2double Y1_target, su2double Y2_targe SetTDState_rhoe(rho, e); /*--- Determine residuals. ---*/ - delta_Y1 = *Y1 - Y1_target; - delta_Y2 = *Y2 - Y2_target; + delta_Y1 = Y1 - Y1_target; + delta_Y2 = Y2 - Y2_target; /*--- Continue iterative process if residuals are outside tolerances. ---*/ - if ((abs(delta_Y1 / *Y1) < Newton_Tolerance) && (abs(delta_Y2 / *Y2) < Newton_Tolerance)) { + if ((abs(delta_Y1 / Y1) < Newton_Tolerance) && (abs(delta_Y2 / Y2) < Newton_Tolerance)) { converged = true; } else { /*--- Compute step size for density and energy. ---*/ - determinant = (*dY1drho) * (*dY2de) - (*dY1de) * (*dY2drho); + determinant = (dY1drho) * (dY2de) - (dY1de) * (dY2drho); - delta_rho = (*dY2de * delta_Y1 - *dY1de * delta_Y2) / determinant; - delta_e = (-*dY2drho * delta_Y1 + *dY1drho * delta_Y2) / determinant; + delta_rho = (dY2de * delta_Y1 - dY1de * delta_Y2) / determinant; + delta_e = (-dY2drho * delta_Y1 + dY1drho * delta_Y2) / determinant; /*--- Update density and energy values. ---*/ rho -= Newton_Relaxation * delta_rho; @@ -376,14 +376,14 @@ void CDataDrivenFluid::Run_Newton_Solver(su2double Y1_target, su2double Y2_targe Iter++; } nIter_Newton = Iter; - AD::SetPreaccOut(rho); - AD::SetPreaccOut(e); + AD::SetPreaccOut(Density); + AD::SetPreaccOut(StaticEnergy); AD::EndPreacc(); /*--- Evaluation of final state. ---*/ - SetTDState_rhoe(rho, e); + SetTDState_rhoe(Density, StaticEnergy); } -void CDataDrivenFluid::Run_Newton_Solver(su2double Y_target, su2double* Y, su2double* X, su2double* dYdX) { +void CDataDrivenFluid::Run_Newton_Solver(su2double Y_target, su2double& Y, su2double& X, su2double& dYdX) { /*--- 1D Newton solver, computing the density or internal energy value corresponding to Y_target. ---*/ bool converged = false; @@ -396,16 +396,16 @@ void CDataDrivenFluid::Run_Newton_Solver(su2double Y_target, su2double* Y, su2do SetTDState_rhoe(Density, StaticEnergy); /*--- Determine residual ---*/ - delta_Y = Y_target - *Y; + delta_Y = Y_target - Y; /*--- Continue iterative process if residuals are outside tolerances. ---*/ - if (abs(delta_Y / *Y) < Newton_Tolerance) { + if (abs(delta_Y / Y) < Newton_Tolerance) { converged = true; } else { - delta_X = delta_Y / *dYdX; + delta_X = delta_Y / dYdX; /*--- Update energy value ---*/ - *X += Newton_Relaxation * delta_X; + X += Newton_Relaxation * delta_X; } Iter++; } From a0075bac28948c6c32057926c95ab8436d0852a4 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Mon, 17 Feb 2025 13:46:39 +0100 Subject: [PATCH 16/57] Removed HEAT_CAPACITY from volume outputs for data-driven fluid solution --- SU2_CFD/src/output/CFlowCompOutput.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index b375dee92089..d3c76e75a361 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -250,7 +250,6 @@ void CFlowCompOutput::SetVolumeOutputFields(CConfig *config){ AddVolumeOutput("EXTRAPOLATION", "Extrapolation", "PRIMITIVE", "Density, energy outside data range"); AddVolumeOutput("FLUIDMODEL_NEWTONITER", "nIter_Newton", "PRIMITIVE", "Number of iterations evaluated by the Newton solver"); AddVolumeOutput("ENTROPY", "Entropy", "PRIMITIVE", "Fluid entropy value"); - AddVolumeOutput("HEAT_CAPACITY", "Heat_Capacity", "PRIMITIVE", "Heat capacity"); } if (config->GetViscous()) { @@ -348,7 +347,6 @@ void CFlowCompOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolv SetVolumeOutputValue("EXTRAPOLATION", iPoint, Node_Flow->GetDataExtrapolation(iPoint)); SetVolumeOutputValue("FLUIDMODEL_NEWTONITER", iPoint, Node_Flow->GetNewtonSolverIterations(iPoint)); SetVolumeOutputValue("ENTROPY", iPoint, Node_Flow->GetEntropy(iPoint)); - SetVolumeOutputValue("HEAT_CAPACITY", iPoint, Node_Flow->GetSpecificHeatCp(iPoint)); } if (config->GetKind_Solver() == MAIN_SOLVER::RANS || config->GetKind_Solver() == MAIN_SOLVER::NAVIER_STOKES){ From be78f43d46c0664593dc48ffd99128c496cd05a8 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Mon, 17 Feb 2025 13:49:38 +0100 Subject: [PATCH 17/57] Changed conductivity model such that the test case can also be ran with ideal gas --- TestCases/nicf/datadriven/datadriven_nozzle.cfg | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/TestCases/nicf/datadriven/datadriven_nozzle.cfg b/TestCases/nicf/datadriven/datadriven_nozzle.cfg index 33a1085c6b61..1d8dc4646b7a 100644 --- a/TestCases/nicf/datadriven/datadriven_nozzle.cfg +++ b/TestCases/nicf/datadriven/datadriven_nozzle.cfg @@ -37,16 +37,17 @@ REF_DIMENSIONALIZATION= DIMENSIONAL % FLUID_MODEL = DATADRIVEN_FLUID INTERPOLATION_METHOD = MLP -FILENAMES_INTERPOLATOR = (MLP_MM.mlp) +FILENAMES_INTERPOLATOR = (MLP_nitrogen.mlp) USE_PINN= YES +CONDUCTIVITY_MODEL=CONSTANT_PRANDTL +PRANDTL_LAM=0.7071413764001355 +PRANDTL_TURB=0.7071413764001355 + % --------------------------- VISCOSITY MODEL ---------------------------------% VISCOSITY_MODEL= CONSTANT_VISCOSITY -MU_CONSTANT= 1.21409E-05 +MU_CONSTANT= 2.395531900375651e-05 -% --------------------------- THERMAL CONDUCTIVITY MODEL ----------------------% -CONDUCTIVITY_MODEL= CONSTANT_CONDUCTIVITY -THERMAL_CONDUCTIVITY_CONSTANT= 0.030542828 % -------------------- BOUNDARY CONDITION DEFINITION --------------------------% MARKER_SYM= ( SYMMETRY ) @@ -93,7 +94,7 @@ CFL_REDUCTION_TURB= 1.0 % --------------------------- CONVERGENCE PARAMETERS --------------------------% % % Number of total iterations -ITER= 1000 +ITER= 10000 CONV_RESIDUAL_MINVAL= -24 CONV_STARTITER= 10 @@ -113,13 +114,13 @@ SOLUTION_FILENAME= solution_flow.dat TABULAR_FORMAT= CSV % % Output file convergence history (w/o extension) -CONV_FILENAME= history +CONV_FILENAME= history_nitrogen_DD % % Output file restart flow RESTART_FILENAME= restart_flow.dat % % Output file flow (w/o extension) variables -VOLUME_FILENAME= flow +VOLUME_FILENAME= flow_nitrogen_DD VOLUME_OUTPUT=(PRIMITIVE, SOLUTION,RESIDUAL) % % Output file surface flow coefficient (w/o extension) From 88cd9e94a4e883bde53b67210de26527fcfcaf8d Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Mon, 17 Feb 2025 15:14:38 +0100 Subject: [PATCH 18/57] Set test case branch for regression tests --- .github/workflows/regression.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 2502204b64c4..91fe553df80c 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -209,7 +209,7 @@ jobs: uses: docker://ghcr.io/su2code/su2/test-su2:240320-1536 with: # -t -c - 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: From e927a02bb0e0c1fe9c3efa08f692fc911b0c3c95 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Mon, 17 Feb 2025 15:15:07 +0100 Subject: [PATCH 19/57] Settings for restart in parallel regression --- .../nicf/datadriven/datadriven_nozzle.cfg | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/TestCases/nicf/datadriven/datadriven_nozzle.cfg b/TestCases/nicf/datadriven/datadriven_nozzle.cfg index 1d8dc4646b7a..fb7c93c7ace0 100644 --- a/TestCases/nicf/datadriven/datadriven_nozzle.cfg +++ b/TestCases/nicf/datadriven/datadriven_nozzle.cfg @@ -15,7 +15,7 @@ SOLVER= RANS KIND_TURB_MODEL= SST MATH_PROBLEM= DIRECT -RESTART_SOL= NO +RESTART_SOL= YES SYSTEM_MEASUREMENTS= SI % % -------------------- COMPRESSIBLE FREE-STREAM DEFINITION --------------------% @@ -26,36 +26,36 @@ AOA= 0.0 SIDESLIP_ANGLE= 0.0 INIT_OPTION= TD_CONDITIONS FREESTREAM_OPTION= TEMPERATURE_FS -FREESTREAM_PRESSURE= 904388 +FREESTREAM_PRESSURE= 3361842.0 % -% Free-stream temperature (288.15 K, 518.67 R by default) -FREESTREAM_TEMPERATURE= 542.13 +FREESTREAM_TEMPERATURE= 189.288 FREESTREAM_DENSITY= 2.0 REF_DIMENSIONALIZATION= DIMENSIONAL % ---- DATADRIVEN FLUID MODEL DEFINITION -------% -% +% Use physics-informed neural network method. FLUID_MODEL = DATADRIVEN_FLUID INTERPOLATION_METHOD = MLP FILENAMES_INTERPOLATOR = (MLP_nitrogen.mlp) USE_PINN= YES CONDUCTIVITY_MODEL=CONSTANT_PRANDTL -PRANDTL_LAM=0.7071413764001355 -PRANDTL_TURB=0.7071413764001355 +PRANDTL_LAM=0.8426621478074403 +PRANDTL_TURB=0.8426621478074403 % --------------------------- VISCOSITY MODEL ---------------------------------% VISCOSITY_MODEL= CONSTANT_VISCOSITY -MU_CONSTANT= 2.395531900375651e-05 +MU_CONSTANT= 1.0998841148727364e-05 % -------------------- BOUNDARY CONDITION DEFINITION --------------------------% MARKER_SYM= ( SYMMETRY ) MARKER_HEATFLUX= (WALL, 0.0) -MARKER_RIEMANN= ( INFLOW, TOTAL_CONDITIONS_PT, 904388, 542.13, 1.0, 0.0, 0.0, OUTFLOW, STATIC_PRESSURE, 200000.0, 0.0, 0.0, 0.0, 0.0 ) +MARKER_RIEMANN= ( INFLOW, TOTAL_CONDITIONS_PT, 3361842.0, 189.288, 1.0, 0.0, 0.0, \ + OUTFLOW, STATIC_PRESSURE, 747076.0, 0.0, 0.0, 0.0, 0.0 ) -RAMP_OUTLET_PRESSURE= YES -RAMP_OUTLET_PRESSURE_COEFF= (904388, 10, 200) +RAMP_OUTLET_PRESSURE= NO +RAMP_OUTLET_PRESSURE_COEFF= (3361842.0, 1, 20) % ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% NUM_METHOD_GRAD= GREEN_GAUSS @@ -78,8 +78,6 @@ LINEAR_SOLVER_ITER= 10 % -------------------------- MULTIGRID PARAMETERS -----------------------------% % -% Multi-grid levels (0 = no multi-grid) -MGLEVEL= 0 % -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------% CONV_NUM_METHOD_FLOW= ROE @@ -94,7 +92,7 @@ CFL_REDUCTION_TURB= 1.0 % --------------------------- CONVERGENCE PARAMETERS --------------------------% % % Number of total iterations -ITER= 10000 +ITER= 500 CONV_RESIDUAL_MINVAL= -24 CONV_STARTITER= 10 @@ -114,20 +112,19 @@ SOLUTION_FILENAME= solution_flow.dat TABULAR_FORMAT= CSV % % Output file convergence history (w/o extension) -CONV_FILENAME= history_nitrogen_DD % % Output file restart flow RESTART_FILENAME= restart_flow.dat % % Output file flow (w/o extension) variables -VOLUME_FILENAME= flow_nitrogen_DD -VOLUME_OUTPUT=(PRIMITIVE, SOLUTION,RESIDUAL) +VOLUME_OUTPUT=(SOLUTION) % % Output file surface flow coefficient (w/o extension) SURFACE_FILENAME= surface_flow % % Writing solution file frequency OUTPUT_WRT_FREQ= 500 +OUTPUT_FILES=RESTART % % Screen output -SCREEN_OUTPUT= (INNER_ITER, RMS_DENSITY, RMS_TKE) +SCREEN_OUTPUT= (INNER_ITER, RMS_RES) From 6a0be5ab8c44162a6e48ce5733568696dc7f092e Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Mon, 17 Feb 2025 15:15:28 +0100 Subject: [PATCH 20/57] Added PINN test case for data-driven fluid model --- TestCases/parallel_regression.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 530328b52a64..23260a04f8ec 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1066,7 +1066,7 @@ def main(): datadriven_fluidModel.cfg_dir = "nicf/datadriven" datadriven_fluidModel.cfg_file = "datadriven_nozzle.cfg" datadriven_fluidModel.test_iter = 50 - datadriven_fluidModel.test_vals = [-2.632817, 0.155922, 4.690917, 0.000000, 0.000000] + datadriven_fluidModel.test_vals = [-5.506499, -3.447247, -3.859876, -1.251899, -2.140268, 1.267121] test_list.append(datadriven_fluidModel) ###################################### From 8b1dfee60c734c40282c01712672821fd9fe30df Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Thu, 27 Feb 2025 14:01:04 +0100 Subject: [PATCH 21/57] Migrated options for data-driven fluid model and flamelet fluid model to separate structs --- Common/include/CConfig.hpp | 188 ++++------------------------ Common/include/option_structure.hpp | 40 ++++++ Common/src/CConfig.cpp | 45 ++++--- 3 files changed, 84 insertions(+), 189 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 195840a4fdac..1bdee5d9ef98 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -535,13 +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. */ - 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.*/ + DataDrivenFluid_ParsedOptions datadriven_ParsedOptions; + //ENUM_DATADRIVEN_METHOD Kind_DataDriven_Method; /*!< \brief Method used for datset regression in data-driven fluid models. */ - bool UsePINN = false; /*!< \brief Use physics-informed method for data-driven fluid modeling. */ + //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. */ @@ -825,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. */ @@ -1243,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 flame_init; /*!< \brief Flame front initialization parameters. */ - std::array 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 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. @@ -2173,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. @@ -3974,43 +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 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; } - - bool Use_PINN(void) const { return UsePINN; } - /*! * \brief Returns the name of the fluid we are using in CoolProp. */ @@ -9963,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; } + }; diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index ddf570ab6978..f116547aadf9 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -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 */ @@ -1391,6 +1405,32 @@ static const MapType 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 flame_init; /*!< \brief Flame front initialization parameters. */ + std::array 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 */ diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 325dbcd7bf52..2ac04c963917 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -991,7 +991,6 @@ void CConfig::SetPointersNull() { Species_Init = nullptr; Species_Clipping_Min = nullptr; Species_Clipping_Max = nullptr; - spark_reaction_rates = nullptr; /*--- Moving mesh pointers ---*/ @@ -1194,17 +1193,17 @@ void CConfig::SetConfig_Options() { /*!\par CONFIG_CATEGORY: Data-driven fluid model parameters \ingroup Config*/ /*!\brief INTERPOLATION_METHOD \n DESCRIPTION: Interpolation method used to determine the thermodynamic state of the fluid. \n OPTIONS: See \link DataDrivenMethod_Map \endlink DEFAULT: MLP \ingroup Config*/ - addEnumOption("INTERPOLATION_METHOD",Kind_DataDriven_Method, DataDrivenMethod_Map, ENUM_DATADRIVEN_METHOD::LUT); + addEnumOption("INTERPOLATION_METHOD",datadriven_ParsedOptions.interp_algorithm_type, DataDrivenMethod_Map, ENUM_DATADRIVEN_METHOD::LUT); /*!\brief FILENAME_INTERPOLATOR \n DESCRIPTION: Input file for the interpolation method. \n \ingroup Config*/ - addStringListOption("FILENAMES_INTERPOLATOR", n_Datadriven_files, DataDriven_Method_FileNames); + addStringListOption("FILENAMES_INTERPOLATOR", datadriven_ParsedOptions.n_filenames, datadriven_ParsedOptions.datadriven_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, 1.0); + addDoubleOption("DATADRIVEN_NEWTON_RELAXATION", datadriven_ParsedOptions.Newton_relaxation, 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); + addDoubleOption("DATADRIVEN_INITIAL_DENSITY", datadriven_ParsedOptions.rho_init_custom, -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); + addDoubleOption("DATADRIVEN_INITIAL_ENERGY", datadriven_ParsedOptions.e_init_custom, -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); + addBoolOption("USE_PINN",datadriven_ParsedOptions.use_PINN, false); /*!\brief CONFINEMENT_PARAM \n DESCRIPTION: Input Confinement Parameter for Vorticity Confinement*/ addDoubleOption("CONFINEMENT_PARAM", Confinement_Param, 0.0); @@ -1391,22 +1390,22 @@ void CConfig::SetConfig_Options() { addDoubleListOption("SPECIES_CLIPPING_MIN", nSpecies_Clipping_Min, Species_Clipping_Min); /*!\brief FLAME_INIT_METHOD \n DESCRIPTION: Ignition method for flamelet solver \n DEFAULT: no ignition; cold flow only. */ - addEnumOption("FLAME_INIT_METHOD", flame_init_type, Flamelet_Init_Map, FLAMELET_INIT_TYPE::NONE); + addEnumOption("FLAME_INIT_METHOD", flamelet_ParsedOptions.ignition_method, Flamelet_Init_Map, FLAMELET_INIT_TYPE::NONE); /*!\brief FLAME_INIT \n DESCRIPTION: flame front initialization using the flamelet model \ingroup Config*/ /*--- flame offset (x,y,z) ---*/ - flame_init[0] = 0.0; flame_init[1] = 0.0; flame_init[2] = 0.0; + flamelet_ParsedOptions.flame_init[0] = 0.0; flamelet_ParsedOptions.flame_init[1] = 0.0; flamelet_ParsedOptions.flame_init[2] = 0.0; /*--- flame normal (nx, ny, nz) ---*/ - flame_init[3] = 1.0; flame_init[4] = 0.0; flame_init[5] = 0.0; + flamelet_ParsedOptions.flame_init[3] = 1.0; flamelet_ParsedOptions.flame_init[4] = 0.0; flamelet_ParsedOptions.flame_init[5] = 0.0; /*--- flame thickness (x) and flame burnt thickness (after this thickness, we have unburnt conditions again) ---*/ - flame_init[6] = 0.5e-3; flame_init[7] = 1.0; - addDoubleArrayOption("FLAME_INIT", 8,flame_init.begin()); + flamelet_ParsedOptions.flame_init[6] = 0.5e-3; flamelet_ParsedOptions.flame_init[7] = 1.0; + addDoubleArrayOption("FLAME_INIT", 8,flamelet_ParsedOptions.flame_init.begin()); /*!\brief SPARK_INIT \n DESCRIPTION: spark initialization using the flamelet model \ingroup Config*/ - for (auto iSpark=0u; iSpark<6; ++iSpark) spark_init[iSpark]=0; - addDoubleArrayOption("SPARK_INIT", 6, spark_init.begin()); + for (auto iSpark=0u; iSpark<6; ++iSpark) flamelet_ParsedOptions.spark_init[iSpark]=0; + addDoubleArrayOption("SPARK_INIT", 6, flamelet_ParsedOptions.spark_init.begin()); /*!\brief SPARK_REACTION_RATES \n DESCRIPTION: Net source term values applied to species within spark area during spark ignition. \ingroup Config*/ - addDoubleListOption("SPARK_REACTION_RATES", nspark, spark_reaction_rates); + addDoubleListOption("SPARK_REACTION_RATES", flamelet_ParsedOptions.nspark, flamelet_ParsedOptions.spark_reaction_rates); /*--- Options related to mass diffusivity and thereby the species solver. ---*/ @@ -2161,22 +2160,22 @@ void CConfig::SetConfig_Options() { addBoolOption("MULTIZONE_RESIDUAL", Multizone_Residual, false); /* !\brief CONTROLLING_VARIABLE_NAMES \n DESCRIPTION: Names of the variables used as inputs for the data regression method in flamelet or data-driven fluid models. */ - addStringListOption("CONTROLLING_VARIABLE_NAMES", n_control_vars, controlling_variable_names); + addStringListOption("CONTROLLING_VARIABLE_NAMES", flamelet_ParsedOptions.n_control_vars, flamelet_ParsedOptions.controlling_variable_names); /* !\brief CONTROLLING_VARIABLE_SOURCE_NAMES \n DESCRIPTION: Names of the variables in the flamelet manifold corresponding to the source terms of the controlling variables. */ - addStringListOption("CONTROLLING_VARIABLE_SOURCE_NAMES", n_control_vars, cv_source_names); + addStringListOption("CONTROLLING_VARIABLE_SOURCE_NAMES", flamelet_ParsedOptions.n_control_vars, flamelet_ParsedOptions.cv_source_names); /* DESCRIPTION: Names of the passive lookup variables for flamelet LUT */ - addStringListOption("LOOKUP_NAMES", n_lookups, lookup_names); + addStringListOption("LOOKUP_NAMES", flamelet_ParsedOptions.n_lookups, flamelet_ParsedOptions.lookup_names); /* DESCRIPTION: Names of the user transport equations solved in the flamelet problem. */ - addStringListOption("USER_SCALAR_NAMES", n_user_scalars, user_scalar_names); + addStringListOption("USER_SCALAR_NAMES", flamelet_ParsedOptions.n_user_scalars, flamelet_ParsedOptions.user_scalar_names); /* DESCRIPTION: Names of the user scalar source terms. */ - addStringListOption("USER_SOURCE_NAMES", n_user_sources, user_source_names); + addStringListOption("USER_SOURCE_NAMES", flamelet_ParsedOptions.n_user_sources, flamelet_ParsedOptions.user_source_names); /* DESCRIPTION: Enable preferential diffusion for FGM simulations. \n DEFAULT: false */ - addBoolOption("PREFERENTIAL_DIFFUSION", preferential_diffusion, false); + addBoolOption("PREFERENTIAL_DIFFUSION", flamelet_ParsedOptions.preferential_diffusion, false); /*!\brief CONV_FILENAME \n DESCRIPTION: Output file convergence history (w/o extension) \n DEFAULT: history \ingroup Config*/ addStringOption("CONV_FILENAME", Conv_FileName, string("history")); @@ -5634,10 +5633,10 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i /*--- Define some variables for flamelet model. ---*/ if (Kind_Species_Model == SPECIES_MODEL::FLAMELET) { /*--- The controlling variables are progress variable, total enthalpy, and optionally mixture fraction ---*/ - if (n_control_vars != (nSpecies - n_user_scalars)) + if (flamelet_ParsedOptions.n_control_vars != (nSpecies - flamelet_ParsedOptions.n_user_scalars)) SU2_MPI::Error("Number of initial species incompatible with number of controlling variables and user scalars.", CURRENT_FUNCTION); /*--- We can have additional user defined transported scalars ---*/ - n_scalars = n_control_vars + n_user_scalars; + flamelet_ParsedOptions.n_scalars = flamelet_ParsedOptions.n_control_vars + flamelet_ParsedOptions.n_user_scalars; } if (Kind_Regime == ENUM_REGIME::COMPRESSIBLE && GetBounded_Scalar()) { From e134e0f080fa64b2bd76850a959aaa871e738962 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Thu, 27 Feb 2025 14:02:03 +0100 Subject: [PATCH 22/57] Const correctness for Newton solvers --- SU2_CFD/include/fluid/CDataDrivenFluid.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SU2_CFD/include/fluid/CDataDrivenFluid.hpp b/SU2_CFD/include/fluid/CDataDrivenFluid.hpp index ba7ef76317bc..aba771f4932e 100644 --- a/SU2_CFD/include/fluid/CDataDrivenFluid.hpp +++ b/SU2_CFD/include/fluid/CDataDrivenFluid.hpp @@ -157,8 +157,8 @@ class CDataDrivenFluid final : public CFluidModel { * \param[in] dY2drho - Pointer to the partial derivative of quantity 2 w.r.t. density at constant energy. * \param[in] dY2de - Pointer to the partial derivative of quantity 2 w.r.t. energy at constant density. */ - void Run_Newton_Solver(su2double Y1_target, su2double Y2_target, su2double& Y1, su2double& Y2, su2double& dY1drho, - su2double& dY1de, su2double& dY2drho, su2double& dY2de); + void Run_Newton_Solver(const su2double Y1_target, const su2double Y2_target, su2double const & Y1, su2double const & Y2, su2double const & dY1drho, + su2double const & dY1de, su2double const & dY2drho, su2double const & dY2de); /*! * \brief 1D Newton solver for computing the density or energy corresponding to Y_target. @@ -167,7 +167,7 @@ class CDataDrivenFluid final : public CFluidModel { * \param[in] X - Pointer to controlling variable (density or energy). * \param[in] dYdX - Pointer to the partial derivative of target quantity w.r.t. controlling variable. */ - void Run_Newton_Solver(su2double Y_target, su2double& Y, su2double& X, su2double& dYdX); + void Run_Newton_Solver(const su2double Y_target, su2double const & Y, su2double & X, su2double const & dYdX); void ComputeIdealGasQuantities(); From 615b7eab3ff516b4326df81112e00e2a5de6cd24 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Thu, 27 Feb 2025 14:03:00 +0100 Subject: [PATCH 23/57] Retrieve config options from options struct instead of config accessor functions. --- SU2_CFD/src/fluid/CDataDrivenFluid.cpp | 62 +++++++++++++------------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/SU2_CFD/src/fluid/CDataDrivenFluid.cpp b/SU2_CFD/src/fluid/CDataDrivenFluid.cpp index 5555576bddbd..9fc77f66c1a5 100644 --- a/SU2_CFD/src/fluid/CDataDrivenFluid.cpp +++ b/SU2_CFD/src/fluid/CDataDrivenFluid.cpp @@ -33,18 +33,19 @@ CDataDrivenFluid::CDataDrivenFluid(const CConfig* config, bool display) : CFluidModel() { rank = SU2_MPI::GetRank(); - Kind_DataDriven_Method = config->GetKind_DataDriven_Method(); + DataDrivenFluid_ParsedOptions datadriven_fluid_options = config->GetDataDrivenParsedOptions(); + + Kind_DataDriven_Method = datadriven_fluid_options.interp_algorithm_type; varname_rho = "Density"; varname_e = "Energy"; /*--- Use physics-informed approach ---*/ - use_MLP_derivatives = config->Use_PINN(); - gas_constant_config = config->GetGas_Constant(); + use_MLP_derivatives = datadriven_fluid_options.use_PINN; /*--- Retrieve initial density and static energy values from config ---*/ - val_custom_init_e = config->GetInitialEnergy_DataDriven(); - val_custom_init_rho = config->GetInitialDensity_DataDriven(); + val_custom_init_e = datadriven_fluid_options.rho_init_custom; + val_custom_init_rho = datadriven_fluid_options.e_init_custom; custom_init_e = (val_custom_init_e != -1.0); custom_init_rho = (val_custom_init_rho != -1.0); @@ -53,7 +54,7 @@ CDataDrivenFluid::CDataDrivenFluid(const CConfig* config, bool display) : CFluid switch (Kind_DataDriven_Method) { case ENUM_DATADRIVEN_METHOD::MLP: #ifdef USE_MLPCPP - lookup_mlp = new MLPToolbox::CLookUp_ANN(config->GetNDataDriven_Files(), config->GetDataDriven_FileNames()); + lookup_mlp = new MLPToolbox::CLookUp_ANN(datadriven_fluid_options.n_filenames, datadriven_fluid_options.datadriven_filenames); if ((rank == MASTER_NODE) && display) lookup_mlp->DisplayNetworkInfo(); #else SU2_MPI::Error("SU2 was not compiled with MLPCpp enabled (-Denable-mlpcpp=true).", CURRENT_FUNCTION); @@ -63,14 +64,14 @@ CDataDrivenFluid::CDataDrivenFluid(const CConfig* config, bool display) : CFluid if (use_MLP_derivatives && (rank == MASTER_NODE) && display) cout << "Physics-informed approach currently only works with MLP-based tabulation." << endl; - lookup_table = new CLookUpTable(config->GetDataDriven_FileNames()[0], varname_rho, varname_e); + lookup_table = new CLookUpTable(datadriven_fluid_options.datadriven_filenames[0], varname_rho, varname_e); break; default: break; } /*--- Relaxation factor and tolerance for Newton solvers. ---*/ - Newton_Relaxation = config->GetRelaxation_DataDriven(); + Newton_Relaxation = datadriven_fluid_options.Newton_relaxation; Newton_Tolerance = 1e-10; MaxIter_Newton = 50; @@ -190,7 +191,7 @@ void CDataDrivenFluid::SetTDState_rhoe(su2double rho, su2double e) { Evaluate_Dataset(Density, StaticEnergy); - su2double rho_2 = Density * Density; + const su2double rho_2 = Density * Density; /*--- Compute primary flow variables. ---*/ Temperature = pow(dsde_rho, -1); Pressure = -rho_2 * Temperature * dsdrho_e; @@ -201,8 +202,8 @@ void CDataDrivenFluid::SetTDState_rhoe(su2double rho, su2double e) { dTdrho_e = -Temperature * Temperature * d2sdedrho; /*--- Compute speed of sound. ---*/ - su2double blue_term = (dsdrho_e * (2 - Density * Temperature * d2sdedrho) + Density * d2sdrho2); - su2double green_term = (-Temperature * d2sde2 * dsdrho_e + d2sdedrho); + const su2double blue_term = (dsdrho_e * (2 - Density * Temperature * d2sdedrho) + Density * d2sdrho2); + const su2double green_term = (-Temperature * d2sde2 * dsdrho_e + d2sdedrho); SoundSpeed2 = -Density * Temperature * (blue_term - Density * green_term * (dsdrho_e / dsde_rho)); @@ -220,9 +221,9 @@ void CDataDrivenFluid::SetTDState_rhoe(su2double rho, su2double e) { dsdrho_P = dsdrho_e - dPdrho_e * (1 / dPde_rho) * dsde_rho; dsdP_rho = dsde_rho / dPde_rho; - su2double drhode_p = -dPde_rho/dPdrho_e; - su2double dTde_p = dTde_rho + dTdrho_e*drhode_p; - su2double dhde_p = dhde_rho + drhode_p*dhdrho_e; + const su2double drhode_p = -dPde_rho/dPdrho_e; + const su2double dTde_p = dTde_rho + dTdrho_e*drhode_p; + const su2double dhde_p = dhde_rho + drhode_p*dhdrho_e; Cp = dhde_p / dTde_p; AD::SetPreaccOut(Temperature); @@ -334,40 +335,37 @@ void CDataDrivenFluid::Evaluate_Dataset(su2double rho, su2double e) { } } -void CDataDrivenFluid::Run_Newton_Solver(su2double Y1_target, su2double Y2_target, su2double& Y1, su2double& Y2, - su2double& dY1drho, su2double& dY1de, su2double& dY2drho, su2double& dY2de) { +void CDataDrivenFluid::Run_Newton_Solver(const su2double Y1_target, const su2double Y2_target, su2double const & Y1, su2double const & Y2, + su2double const & dY1drho, su2double const & dY1de, su2double const & dY2drho, su2double const & dY2de) { /*--- 2D Newton solver, computing the density and internal energy values corresponding to Y1_target and Y2_target. * ---*/ AD::StartPreacc(); - AD::SetPreaccIn(Y1); - AD::SetPreaccIn(Y2); + AD::SetPreaccIn(Y1_target); + AD::SetPreaccIn(Y2_target); /*--- Setting initial values for density and energy. ---*/ su2double rho = rho_start, e = e_start; bool converged = false; unsigned long Iter = 0; - su2double delta_Y1, delta_Y2, delta_rho, delta_e, determinant; - /*--- Initiating Newton solver ---*/ while (!converged && (Iter < MaxIter_Newton)) { /*--- Determine thermodynamic state based on current density and energy. ---*/ SetTDState_rhoe(rho, e); /*--- Determine residuals. ---*/ - delta_Y1 = Y1 - Y1_target; - delta_Y2 = Y2 - Y2_target; + const su2double delta_Y1 = Y1 - Y1_target; + const su2double delta_Y2 = Y2 - Y2_target; /*--- Continue iterative process if residuals are outside tolerances. ---*/ if ((abs(delta_Y1 / Y1) < Newton_Tolerance) && (abs(delta_Y2 / Y2) < Newton_Tolerance)) { converged = true; } else { /*--- Compute step size for density and energy. ---*/ - determinant = (dY1drho) * (dY2de) - (dY1de) * (dY2drho); - - delta_rho = (dY2de * delta_Y1 - dY1de * delta_Y2) / determinant; - delta_e = (-dY2drho * delta_Y1 + dY1drho * delta_Y2) / determinant; + const su2double determinant = (dY1drho) * (dY2de) - (dY1de) * (dY2drho); + const su2double delta_rho = (dY2de * delta_Y1 - dY1de * delta_Y2) / determinant; + const su2double delta_e = (-dY2drho * delta_Y1 + dY1drho * delta_Y2) / determinant; /*--- Update density and energy values. ---*/ rho -= Newton_Relaxation * delta_rho; @@ -383,32 +381,36 @@ void CDataDrivenFluid::Run_Newton_Solver(su2double Y1_target, su2double Y2_targe SetTDState_rhoe(Density, StaticEnergy); } -void CDataDrivenFluid::Run_Newton_Solver(su2double Y_target, su2double& Y, su2double& X, su2double& dYdX) { +void CDataDrivenFluid::Run_Newton_Solver(const su2double Y_target, su2double const & Y, su2double &X, su2double const & dYdX) { /*--- 1D Newton solver, computing the density or internal energy value corresponding to Y_target. ---*/ bool converged = false; unsigned long Iter = 0; - su2double delta_Y, delta_X; + AD::StartPreacc(); + AD::SetPreaccIn(Y_target); /*--- Initiating Newton solver. ---*/ while (!converged && (Iter < MaxIter_Newton)) { /*--- Determine thermodynamic state based on current density and energy. ---*/ SetTDState_rhoe(Density, StaticEnergy); /*--- Determine residual ---*/ - delta_Y = Y_target - Y; + const su2double delta_Y = Y_target - Y; /*--- Continue iterative process if residuals are outside tolerances. ---*/ if (abs(delta_Y / Y) < Newton_Tolerance) { converged = true; } else { - delta_X = delta_Y / dYdX; + const su2double delta_X = delta_Y / dYdX; /*--- Update energy value ---*/ X += Newton_Relaxation * delta_X; } Iter++; } + AD::SetPreaccOut(X); + AD::EndPreacc(); + /*--- Calculate thermodynamic state based on converged values for density and energy. ---*/ SetTDState_rhoe(Density, StaticEnergy); From f6d28abfc32fc27c1a45b528009872b3147df8bd Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Thu, 27 Feb 2025 14:04:24 +0100 Subject: [PATCH 24/57] Retrieve options from flamelet solver options struct rather than config accessor functions. --- .../solvers/CSpeciesFlameletSolver.hpp | 7 +- .../src/solvers/CSpeciesFlameletSolver.cpp | 69 ++++++++++--------- 2 files changed, 39 insertions(+), 37 deletions(-) diff --git a/SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp b/SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp index cf336b7f4584..1d3b137e59c8 100644 --- a/SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp +++ b/SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp @@ -37,6 +37,7 @@ */ class CSpeciesFlameletSolver final : public CSpeciesSolver { private: + FluidFlamelet_ParsedOptions flamelet_config_options; bool include_mixture_fraction = false; /*!< \brief include mixture fraction as a controlling variable. */ /*! * \brief Compute the preconditioner for low-Mach flows. @@ -87,24 +88,22 @@ class CSpeciesFlameletSolver final : public CSpeciesSolver { /*! * \brief Retrieve passive look-up data from manifold. - * \param[in] config - definition of particular problem. * \param[in] fluid_model_local - pointer to flamelet fluid model. * \param[in] iPoint - node ID. * \param[in] scalars - local scalar solution. * \return - within manifold bounds (0) or outside manifold bounds (1). */ - unsigned long SetScalarLookUps(const CConfig* config, CFluidModel* fluid_model_local, unsigned long iPoint, + unsigned long SetScalarLookUps(CFluidModel* fluid_model_local, unsigned long iPoint, const vector& scalars); /*! * \brief Retrieve the preferential diffusion scalar values from manifold. - * \param[in] config - definition of particular problem. * \param[in] fluid_model_local - pointer to flamelet fluid model. * \param[in] iPoint - node ID. * \param[in] scalars - local scalar solution. * \return - within manifold bounds (0) or outside manifold bounds (1). */ - unsigned long SetPreferentialDiffusionScalars(const CConfig* config, CFluidModel* fluid_model_local, + unsigned long SetPreferentialDiffusionScalars(CFluidModel* fluid_model_local, unsigned long iPoint, const vector& scalars); public: diff --git a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp index f2f14d051797..e57fd11a5f80 100644 --- a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp @@ -36,9 +36,13 @@ CSpeciesFlameletSolver::CSpeciesFlameletSolver(CGeometry* geometry, CConfig* config, unsigned short iMesh) : CSpeciesSolver(geometry, config, true) { + + /*--- Retrieve options from config. ---*/ + flamelet_config_options = config->GetFlameletParsedOptions(); + /*--- Dimension of the problem. ---*/ - nVar = config->GetNScalars(); - include_mixture_fraction = (config->GetNControlVars() == 3); + nVar = flamelet_config_options.n_scalars; + include_mixture_fraction = (flamelet_config_options.n_control_vars == 3); Initialize(geometry, config, iMesh, nVar); @@ -73,8 +77,8 @@ void CSpeciesFlameletSolver::Preprocessing(CGeometry* geometry, CSolver** solver auto* flowNodes = su2staticcast_p(solver_container[FLOW_SOL]->GetNodes()); /*--- Retrieve spark ignition parameters for spark-type ignition. ---*/ - if ((config->GetFlameletInitType() == FLAMELET_INIT_TYPE::SPARK) && !config->GetRestart()) { - auto spark_init = config->GetFlameInit(); + if ((flamelet_config_options.ignition_method == FLAMELET_INIT_TYPE::SPARK) && !config->GetRestart()) { + auto spark_init = flamelet_config_options.spark_init; spark_iter_start = ceil(spark_init[4]); spark_duration = ceil(spark_init[5]); unsigned long iter = config->GetMultizone_Problem() ? config->GetOuterIter() : config->GetInnerIter(); @@ -95,18 +99,18 @@ void CSpeciesFlameletSolver::Preprocessing(CGeometry* geometry, CSolver** solver if (ignition) { /*--- Apply source terms within spark radius. ---*/ su2double dist_from_center = 0, - spark_radius = config->GetFlameInit()[3]; - dist_from_center = GeometryToolbox::SquaredDistance(nDim, geometry->nodes->GetCoord(i_point), config->GetFlameInit()); + spark_radius = flamelet_config_options.spark_init[3]; + dist_from_center = GeometryToolbox::SquaredDistance(nDim, geometry->nodes->GetCoord(i_point), flamelet_config_options.flame_init.data()); if (dist_from_center < pow(spark_radius,2)) { for (auto iVar = 0u; iVar < nVar; iVar++) - nodes->SetScalarSource(i_point, iVar, nodes->GetScalarSources(i_point)[iVar] + config->GetSpark()[iVar]); + nodes->SetScalarSource(i_point, iVar, nodes->GetScalarSources(i_point)[iVar] + flamelet_config_options.spark_reaction_rates[iVar]); } } nodes->SetTableMisses(i_point, misses); n_not_in_domain_local += misses; /*--- Obtain passive look-up scalars. ---*/ - SetScalarLookUps(config, fluid_model_local, i_point, scalars_vector); + SetScalarLookUps(fluid_model_local, i_point, scalars_vector); /*--- Set mass diffusivity based on thermodynamic state. ---*/ auto T = flowNodes->GetTemperature(i_point); @@ -117,8 +121,8 @@ void CSpeciesFlameletSolver::Preprocessing(CGeometry* geometry, CSolver** solver } /*--- Obtain preferential diffusion scalar values. ---*/ - if (config->GetPreferentialDiffusion()) - SetPreferentialDiffusionScalars(config, fluid_model_local, i_point, scalars_vector); + if (flamelet_config_options.preferential_diffusion) + SetPreferentialDiffusionScalars(fluid_model_local, i_point, scalars_vector); if (!Output) LinSysRes.SetBlock_Zero(i_point); } @@ -130,7 +134,7 @@ void CSpeciesFlameletSolver::Preprocessing(CGeometry* geometry, CSolver** solver cout << "Number of points outside manifold domain: " << n_not_in_domain_global << endl; /*--- Compute preferential diffusion scalar gradients. ---*/ - if (config->GetPreferentialDiffusion()) { + if (flamelet_config_options.preferential_diffusion) { switch (config->GetKind_Gradient_Method()) { case GREEN_GAUSS: SetAuxVar_Gradient_GG(geometry, config); @@ -157,11 +161,11 @@ void CSpeciesFlameletSolver::SetInitialCondition(CGeometry** geometry, CSolver** su2double flame_offset[3] = {0, 0, 0}, flame_normal[3] = {0, 0, 0}, flame_thickness = 0, flame_burnt_thickness = 0, flamenorm = 0; - bool flame_front_ignition = (config->GetFlameletInitType() == FLAMELET_INIT_TYPE::FLAME_FRONT); + bool flame_front_ignition = (flamelet_config_options.ignition_method == FLAMELET_INIT_TYPE::FLAME_FRONT); if (flame_front_ignition) { /*--- Collect flame front ignition parameters. ---*/ - auto flame_init = config->GetFlameInit(); + auto flame_init = flamelet_config_options.flame_init; for (auto iDim = 0u; iDim < 3; ++iDim) { flame_offset[iDim] = flame_init[iDim]; flame_normal[iDim] = flame_init[3 + iDim]; @@ -179,11 +183,11 @@ void CSpeciesFlameletSolver::SetInitialCondition(CGeometry** geometry, CSolver** if (rank == MASTER_NODE) { cout << "initial condition: T = " << temp_inlet << endl; - for (auto iCV = 0u; iCV < config->GetNControlVars(); iCV++) { - const auto& cv_name = config->GetControllingVariableName(iCV); + for (auto iCV = 0u; iCV < flamelet_config_options.n_control_vars; iCV++) { + const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; cout << "initial condition: " << cv_name << " = " << config->GetSpecies_Init()[iCV] << endl; } - switch (config->GetFlameletInitType()) { + switch (flamelet_config_options.ignition_method) { case FLAMELET_INIT_TYPE::FLAME_FRONT: cout << "Ignition with a straight flame front" << endl; break; @@ -260,7 +264,7 @@ void CSpeciesFlameletSolver::SetInitialCondition(CGeometry** geometry, CSolver** n_not_in_domain_local += fluid_model_local->GetExtrapolation(); /* --- Initialize the auxiliary transported scalars (not controlling variables). --- */ - for (int i_scalar = config->GetNControlVars(); i_scalar < config->GetNScalars(); ++i_scalar) { + for (int i_scalar = flamelet_config_options.n_control_vars; i_scalar < flamelet_config_options.n_scalars; ++i_scalar) { scalar_init[i_scalar] = config->GetSpecies_Init()[i_scalar]; } @@ -508,40 +512,40 @@ unsigned long CSpeciesFlameletSolver::SetScalarSources(const CConfig* config, CF unsigned long iPoint, const vector& scalars) { /*--- Compute total source terms from the production and consumption. ---*/ - vector table_sources(config->GetNControlVars() + 2 * config->GetNUserScalars()); + vector table_sources(flamelet_config_options.n_control_vars + 2 * flamelet_config_options.n_user_scalars); unsigned long misses = fluid_model_local->EvaluateDataSet(scalars, FLAMELET_LOOKUP_OPS::SOURCES, table_sources); table_sources[I_PROGVAR] = fmax(0, table_sources[I_PROGVAR]); nodes->SetTableMisses(iPoint, misses); /*--- The source term for progress variable is always positive, we clip from below to makes sure. --- */ - vector source_scalar(config->GetNScalars()); - for (auto iCV = 0u; iCV < config->GetNControlVars(); iCV++) source_scalar[iCV] = table_sources[iCV]; + vector source_scalar(flamelet_config_options.n_control_vars); + for (auto iCV = 0u; iCV < flamelet_config_options.n_control_vars; iCV++) source_scalar[iCV] = table_sources[iCV]; /*--- Source term for the auxiliary species transport equations. ---*/ - for (size_t i_aux = 0; i_aux < config->GetNUserScalars(); i_aux++) { + for (size_t i_aux = 0; i_aux < flamelet_config_options.n_user_scalars; i_aux++) { /*--- The source term for the auxiliary equations consists of a production term and a consumption term: S_TOT = S_PROD + S_CONS * Y ---*/ - su2double y_aux = scalars[config->GetNControlVars() + i_aux]; - su2double source_prod = table_sources[config->GetNControlVars() + 2 * i_aux]; - su2double source_cons = table_sources[config->GetNControlVars() + 2 * i_aux + 1]; - source_scalar[config->GetNControlVars() + i_aux] = source_prod + source_cons * y_aux; + su2double y_aux = scalars[flamelet_config_options.n_control_vars + i_aux]; + su2double source_prod = table_sources[flamelet_config_options.n_control_vars + 2 * i_aux]; + su2double source_cons = table_sources[flamelet_config_options.n_control_vars + 2 * i_aux + 1]; + source_scalar[flamelet_config_options.n_control_vars + i_aux] = source_prod + source_cons * y_aux; } for (auto i_scalar = 0u; i_scalar < nVar; i_scalar++) nodes->SetScalarSource(iPoint, i_scalar, source_scalar[i_scalar]); return misses; } -unsigned long CSpeciesFlameletSolver::SetScalarLookUps(const CConfig* config, CFluidModel* fluid_model_local, +unsigned long CSpeciesFlameletSolver::SetScalarLookUps(CFluidModel* fluid_model_local, unsigned long iPoint, const vector& scalars) { /*--- Retrieve the passive look-up variables from the manifold. ---*/ unsigned long misses{0}; /*--- Skip if no passive look-ups are listed ---*/ - if (config->GetNLookups() > 0) { - vector lookup_scalar(config->GetNLookups()); + if (flamelet_config_options.n_lookups > 0) { + vector lookup_scalar(flamelet_config_options.n_lookups); misses = fluid_model_local->EvaluateDataSet(scalars, FLAMELET_LOOKUP_OPS::LOOKUP, lookup_scalar); - for (auto i_lookup = 0u; i_lookup < config->GetNLookups(); i_lookup++) { + for (auto i_lookup = 0u; i_lookup < flamelet_config_options.n_lookups; i_lookup++) { nodes->SetLookupScalar(iPoint, lookup_scalar[i_lookup], i_lookup); } } @@ -549,8 +553,7 @@ unsigned long CSpeciesFlameletSolver::SetScalarLookUps(const CConfig* config, CF return misses; } -unsigned long CSpeciesFlameletSolver::SetPreferentialDiffusionScalars(const CConfig* config, - CFluidModel* fluid_model_local, +unsigned long CSpeciesFlameletSolver::SetPreferentialDiffusionScalars(CFluidModel* fluid_model_local, unsigned long iPoint, const vector& scalars) { /*--- Retrieve the preferential diffusion scalar values from the manifold. ---*/ @@ -568,7 +571,7 @@ void CSpeciesFlameletSolver::Viscous_Residual(const unsigned long iEdge, const C CNumerics* numerics, const CConfig* config) { /*--- Overloaded viscous residual method which accounts for preferential diffusion. ---*/ const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT), - PreferentialDiffusion = config->GetPreferentialDiffusion(); + PreferentialDiffusion = flamelet_config_options.preferential_diffusion; /*--- Points in edge ---*/ auto iPoint = geometry->edges->GetNode(iEdge, 0); @@ -594,7 +597,7 @@ void CSpeciesFlameletSolver::Viscous_Residual(const unsigned long iEdge, const C diff_coeff_beta_j[MAXNVAR] = {0}; // Number of active transport scalars - const auto n_CV = config->GetNControlVars(); + const auto n_CV = flamelet_config_options.n_control_vars; su2activematrix scalar_grad_i(MAXNVAR, MAXNDIM), scalar_grad_j(MAXNVAR, MAXNDIM); /*--- Looping over spatial dimensions to fill in the diffusion scalar gradients. ---*/ From a913d5f4a8da13892df59bfd6d5ee1073981857a Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Thu, 27 Feb 2025 14:05:05 +0100 Subject: [PATCH 25/57] Retrieve options from data-driven fluid and flamelet solver options structs rather than config accessor functions. --- SU2_CFD/include/fluid/CFluidFlamelet.hpp | 3 ++ SU2_CFD/src/fluid/CFluidFlamelet.cpp | 39 +++++++++++++----------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/SU2_CFD/include/fluid/CFluidFlamelet.hpp b/SU2_CFD/include/fluid/CFluidFlamelet.hpp index f95072f30ce1..c933c8650cb6 100644 --- a/SU2_CFD/include/fluid/CFluidFlamelet.hpp +++ b/SU2_CFD/include/fluid/CFluidFlamelet.hpp @@ -37,6 +37,9 @@ class CFluidFlamelet final : public CFluidModel { private: + DataDrivenFluid_ParsedOptions datadriven_fluid_options; + FluidFlamelet_ParsedOptions flamelet_options; + ENUM_DATADRIVEN_METHOD Kind_DataDriven_Method = ENUM_DATADRIVEN_METHOD::LUT; /*!< \brief Interpolation method for data set evaluation. */ diff --git a/SU2_CFD/src/fluid/CFluidFlamelet.cpp b/SU2_CFD/src/fluid/CFluidFlamelet.cpp index a458a3fd97c1..d9920d3fa47f 100644 --- a/SU2_CFD/src/fluid/CFluidFlamelet.cpp +++ b/SU2_CFD/src/fluid/CFluidFlamelet.cpp @@ -36,13 +36,16 @@ CFluidFlamelet::CFluidFlamelet(CConfig* config, su2double value_pressure_operating) : CFluidModel() { rank = SU2_MPI::GetRank(); - Kind_DataDriven_Method = config->GetKind_DataDriven_Method(); + datadriven_fluid_options = config->GetDataDrivenParsedOptions(); + flamelet_options = config->GetFlameletParsedOptions(); + + Kind_DataDriven_Method = datadriven_fluid_options.interp_algorithm_type; /* -- number of auxiliary species transport equations, e.g. 1=CO, 2=NOx --- */ - n_user_scalars = config->GetNUserScalars(); - n_control_vars = config->GetNControlVars(); + n_user_scalars = flamelet_options.n_user_scalars; + n_control_vars = flamelet_options.n_control_vars; include_mixture_fraction = (n_control_vars == 3); - n_scalars = config->GetNScalars(); + n_scalars = flamelet_options.n_scalars; if (rank == MASTER_NODE) { cout << "Number of scalars: " << n_scalars << endl; @@ -52,19 +55,19 @@ CFluidFlamelet::CFluidFlamelet(CConfig* config, su2double value_pressure_operati scalars_vector.resize(n_scalars); table_scalar_names.resize(n_scalars); - for (auto iCV = 0u; iCV < n_control_vars; iCV++) table_scalar_names[iCV] = config->GetControllingVariableName(iCV); + for (auto iCV = 0u; iCV < n_control_vars; iCV++) table_scalar_names[iCV] = flamelet_options.controlling_variable_names[iCV];//->GetControllingVariableName(iCV); /*--- auxiliary species transport equations---*/ for (auto i_aux = 0u; i_aux < n_user_scalars; i_aux++) { - table_scalar_names[n_control_vars + i_aux] = config->GetUserScalarName(i_aux); + table_scalar_names[n_control_vars + i_aux] = flamelet_options.user_scalar_names[i_aux]; } controlling_variable_names.resize(n_control_vars); for (auto iCV = 0u; iCV < n_control_vars; iCV++) - controlling_variable_names[iCV] = config->GetControllingVariableName(iCV); + controlling_variable_names[iCV] =flamelet_options.controlling_variable_names[iCV]; passive_specie_names.resize(n_user_scalars); - for (auto i_aux = 0u; i_aux < n_user_scalars; i_aux++) passive_specie_names[i_aux] = config->GetUserScalarName(i_aux); + for (auto i_aux = 0u; i_aux < n_user_scalars; i_aux++) passive_specie_names[i_aux] = flamelet_options.user_scalar_names[i_aux];//config->GetUserScalarName(i_aux); switch (Kind_DataDriven_Method) { case ENUM_DATADRIVEN_METHOD::LUT: @@ -73,7 +76,7 @@ CFluidFlamelet::CFluidFlamelet(CConfig* config, su2double value_pressure_operati cout << "*** initializing the lookup table ***" << endl; cout << "*****************************************" << endl; } - look_up_table = new CLookUpTable(config->GetDataDriven_FileNames()[0], table_scalar_names[I_PROGVAR], + look_up_table = new CLookUpTable(datadriven_fluid_options.datadriven_filenames[0], table_scalar_names[I_PROGVAR], table_scalar_names[I_ENTH]); break; default: @@ -83,7 +86,7 @@ CFluidFlamelet::CFluidFlamelet(CConfig* config, su2double value_pressure_operati cout << "***********************************************" << endl; } #ifdef USE_MLPCPP - lookup_mlp = new MLPToolbox::CLookUp_ANN(config->GetNDataDriven_Files(), config->GetDataDriven_FileNames()); + lookup_mlp = new MLPToolbox::CLookUp_ANN(datadriven_fluid_options.n_filenames, datadriven_fluid_options.datadriven_filenames); if ((rank == MASTER_NODE)) lookup_mlp->DisplayNetworkInfo(); #else SU2_MPI::Error("SU2 was not compiled with MLPCpp enabled (-Denable-mlpcpp=true).", CURRENT_FUNCTION); @@ -170,7 +173,7 @@ void CFluidFlamelet::PreprocessLookUp(CConfig* config) { varnames_Sources.resize(n_sources); val_vars_Sources.resize(n_sources); for (auto iCV = 0u; iCV < n_control_vars; iCV++) - varnames_Sources[iCV] = config->GetControllingVariableSourceName(iCV); + varnames_Sources[iCV] = flamelet_options.cv_source_names[iCV];//->GetControllingVariableSourceName(iCV); /*--- No source term for enthalpy ---*/ /*--- For the auxiliary equations, we use a positive (production) and a negative (consumption) term: @@ -178,12 +181,12 @@ void CFluidFlamelet::PreprocessLookUp(CConfig* config) { for (size_t i_aux = 0; i_aux < n_user_scalars; i_aux++) { /*--- Order of the source terms: S_prod_1, S_cons_1, S_prod_2, S_cons_2, ...---*/ - varnames_Sources[n_control_vars + 2 * i_aux] = config->GetUserSourceName(2 * i_aux); - varnames_Sources[n_control_vars + 2 * i_aux + 1] = config->GetUserSourceName(2 * i_aux + 1); + varnames_Sources[n_control_vars + 2 * i_aux] = flamelet_options.user_source_names[2 * i_aux];//>GetUserSourceName(2 * i_aux); + varnames_Sources[n_control_vars + 2 * i_aux + 1] = flamelet_options.user_source_names[2 * i_aux + 1];//config->GetUserSourceName(2 * i_aux + 1); } /*--- Passive look-up terms ---*/ - size_t n_lookups = config->GetNLookups(); + size_t n_lookups = flamelet_options.n_lookups;//>GetNLookups(); if (n_lookups == 0) { varnames_LookUp.resize(1); val_vars_LookUp.resize(1); @@ -191,7 +194,7 @@ void CFluidFlamelet::PreprocessLookUp(CConfig* config) { } else { varnames_LookUp.resize(n_lookups); val_vars_LookUp.resize(n_lookups); - for (auto iLookup = 0u; iLookup < n_lookups; iLookup++) varnames_LookUp[iLookup] = config->GetLookupName(iLookup); + for (auto iLookup = 0u; iLookup < n_lookups; iLookup++) varnames_LookUp[iLookup] = flamelet_options.lookup_names[iLookup];//>GetLookupName(iLookup); } /*--- Preferential diffusion scalars ---*/ @@ -208,7 +211,7 @@ void CFluidFlamelet::PreprocessLookUp(CConfig* config) { val_vars_PD[FLAMELET_PREF_DIFF_SCALARS::I_BETA_ENTH] = beta_enth; val_vars_PD[FLAMELET_PREF_DIFF_SCALARS::I_BETA_MIXFRAC] = beta_mixfrac; - preferential_diffusion = config->GetPreferentialDiffusion(); + preferential_diffusion = flamelet_options.preferential_diffusion;//>GetPreferentialDiffusion(); switch (Kind_DataDriven_Method) { case ENUM_DATADRIVEN_METHOD::LUT: preferential_diffusion = look_up_table->CheckForVariables(varnames_PD); @@ -216,7 +219,7 @@ void CFluidFlamelet::PreprocessLookUp(CConfig* config) { case ENUM_DATADRIVEN_METHOD::MLP: #ifdef USE_MLPCPP n_betas = 0; - for (auto iMLP = 0u; iMLP < config->GetNDataDriven_Files(); iMLP++) { + for (auto iMLP = 0u; iMLP < datadriven_fluid_options.n_filenames; iMLP++) { auto outputMap = lookup_mlp->FindVariableIndices(iMLP, varnames_PD, false); n_betas += outputMap.size(); } @@ -227,7 +230,7 @@ void CFluidFlamelet::PreprocessLookUp(CConfig* config) { break; } - if (!preferential_diffusion && config->GetPreferentialDiffusion()) + if (!preferential_diffusion && flamelet_options.preferential_diffusion) SU2_MPI::Error("Preferential diffusion scalars not included in flamelet manifold.", CURRENT_FUNCTION); if (Kind_DataDriven_Method == ENUM_DATADRIVEN_METHOD::MLP) { From 4b6aee01822abff053138628f94091c25cbab312 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Thu, 27 Feb 2025 14:05:59 +0100 Subject: [PATCH 26/57] Retrieve options for data-driven fluid simulations and flamelet simulations from structs rather than config accessor functions. --- SU2_CFD/src/output/CAdjFlowOutput.cpp | 78 +++++---- SU2_CFD/src/output/CFlowOutput.cpp | 158 +++++++++--------- SU2_CFD/src/solvers/CSolver.cpp | 7 +- .../variables/CSpeciesFlameletVariable.cpp | 8 +- 4 files changed, 133 insertions(+), 118 deletions(-) diff --git a/SU2_CFD/src/output/CAdjFlowOutput.cpp b/SU2_CFD/src/output/CAdjFlowOutput.cpp index 481b63f6fb49..c50c08b10a6d 100644 --- a/SU2_CFD/src/output/CAdjFlowOutput.cpp +++ b/SU2_CFD/src/output/CAdjFlowOutput.cpp @@ -62,12 +62,13 @@ void CAdjFlowOutput::AddHistoryOutputFields_AdjScalarRMS_RES(const CConfig* conf } if (config->GetKind_Species_Model() == SPECIES_MODEL::FLAMELET) { - for (auto iCV=0u; iCV < config->GetNControlVars(); iCV++) { - const auto& cv_name = config->GetControllingVariableName(iCV); + const auto flamelet_config_options = config->GetFlameletParsedOptions(); + for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { + const auto& cv_name = config->GetFlameletParsedOptions().controlling_variable_names[iCV]; AddHistoryOutput("RMS_ADJ_"+cv_name, "rms[" + cv_name + "]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of the adjoint " + cv_name, HistoryFieldType::RESIDUAL); } - for (unsigned short i_scalar = 0; i_scalar < config->GetNUserScalars(); i_scalar++) { - const auto& scalar_name = config->GetUserScalarName(i_scalar); + for (unsigned short i_scalar = 0; i_scalar < flamelet_config_options.n_user_scalars; i_scalar++) { + const auto& scalar_name = config->GetFlameletParsedOptions().user_scalar_names[i_scalar];//config->GetUserScalarName(i_scalar); AddHistoryOutput("RMS_ADJ_" + scalar_name, "rms[" + scalar_name + "]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of the adjoint of " + scalar_name + " .", HistoryFieldType::RESIDUAL); } } @@ -98,12 +99,13 @@ void CAdjFlowOutput::AddHistoryOutputFields_AdjScalarMAX_RES(const CConfig* conf } if (config->GetKind_Species_Model() == SPECIES_MODEL::FLAMELET) { - for (auto iCV=0u; iCV < config->GetNControlVars(); iCV++) { - const auto& cv_name = config->GetControllingVariableName(iCV); + const auto flamelet_config_options = config->GetFlameletParsedOptions(); + for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { + const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; AddHistoryOutput("MAX_ADJ_" + cv_name, "max["+cv_name +"]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the adjoint " + cv_name, HistoryFieldType::RESIDUAL); } - for (unsigned short i_scalar = 0; i_scalar < config->GetNUserScalars(); i_scalar++) { - const auto& scalar_name = config->GetUserScalarName(i_scalar); + for (unsigned short i_scalar = 0; i_scalar < flamelet_config_options.n_user_scalars; i_scalar++) { + const auto& scalar_name = flamelet_config_options.user_scalar_names[i_scalar]; AddHistoryOutput("MAX_ADJ_" + scalar_name, "max[scalar_" + scalar_name + "]",ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the adjoint of " + scalar_name + " .", HistoryFieldType::RESIDUAL); } } @@ -136,13 +138,14 @@ void CAdjFlowOutput::AddHistoryOutputFields_AdjScalarBGS_RES(const CConfig* conf } if (config->GetKind_Species_Model() == SPECIES_MODEL::FLAMELET) { - for (auto iCV=0u; iCV < config->GetNControlVars(); iCV++) { - const auto& cv_name = config->GetControllingVariableName(iCV); + const auto flamelet_config_options = config->GetFlameletParsedOptions(); + for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { + const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; AddHistoryOutput("BGS_ADJ_" + cv_name, "bgs[" + cv_name + "]", ScreenOutputFormat::FIXED, "BGS_RES", "BGS residual of the adjoint " + cv_name, HistoryFieldType::RESIDUAL); } - for (unsigned short i_scalar = 0; i_scalar < config->GetNUserScalars(); i_scalar++) { - const auto& scalar_name = config->GetUserScalarName(i_scalar); + for (unsigned short i_scalar = 0; i_scalar < flamelet_config_options.n_user_scalars; i_scalar++) { + const auto& scalar_name = flamelet_config_options.user_scalar_names[i_scalar]; AddHistoryOutput("BGS_ADJ_" + scalar_name, "bgs[" + scalar_name + "]", ScreenOutputFormat::FIXED, "BGS_RES", "BGS residual of the adjoint of " + scalar_name + " .", HistoryFieldType::RESIDUAL); } } @@ -213,16 +216,17 @@ void CAdjFlowOutput::LoadHistoryDataAdjScalar(const CConfig* config, const CSolv } if (config->GetKind_Species_Model() == SPECIES_MODEL::FLAMELET) { - for (auto iCV=0u; iCV < config->GetNControlVars(); iCV++) { - const auto& cv_name = config->GetControllingVariableName(iCV); - SetHistoryOutputValue("RMS_ADJ_"+cv_name, log10(adjspecies_solver->GetRes_RMS(iCV))); - SetHistoryOutputValue("MAX_ADJ_"+cv_name, log10(adjspecies_solver->GetRes_Max(iCV))); - if (multiZone) - SetHistoryOutputValue("BGS_ADJ_" + cv_name, log10(adjspecies_solver->GetRes_BGS(iCV))); - } + const auto flamelet_config_options = config->GetFlameletParsedOptions(); + for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { + const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; + SetHistoryOutputValue("RMS_ADJ_"+cv_name, log10(adjspecies_solver->GetRes_RMS(iCV))); + SetHistoryOutputValue("MAX_ADJ_"+cv_name, log10(adjspecies_solver->GetRes_Max(iCV))); + if (multiZone) + SetHistoryOutputValue("BGS_ADJ_" + cv_name, log10(adjspecies_solver->GetRes_BGS(iCV))); + } - for (unsigned short i_scalar = 0; i_scalar < config->GetNUserScalars(); i_scalar++) { - const auto& scalar_name = config->GetUserScalarName(i_scalar); + for (unsigned short i_scalar = 0; i_scalar < flamelet_config_options.n_user_scalars; i_scalar++) { + const auto& scalar_name = flamelet_config_options.user_scalar_names[i_scalar]; SetHistoryOutputValue("RMS_ADJ_" + scalar_name, log10(adjspecies_solver->GetRes_RMS(2 + i_scalar))); SetHistoryOutputValue("MAX_ADJ_" + scalar_name, log10(adjspecies_solver->GetRes_Max(2 + i_scalar))); if (multiZone) { @@ -263,13 +267,14 @@ void CAdjFlowOutput::SetVolumeOutputFieldsAdjScalarSolution(const CConfig* confi } if (config->GetKind_Species_Model() == SPECIES_MODEL::FLAMELET) { - for (auto iCV=0u; iCV < config->GetNControlVars(); iCV++) { - const auto& cv_name = config->GetControllingVariableName(iCV); + const auto flamelet_config_options = config->GetFlameletParsedOptions(); + for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { + const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; AddVolumeOutput("ADJ_" + cv_name, "Adjoint_" + cv_name, "SOLUTION", "Adjoint of the " + cv_name + " controlling variable."); } - for (unsigned short i_scalar = 0; i_scalar < config->GetNUserScalars(); i_scalar++) { - const auto& scalar_name = config->GetUserScalarName(i_scalar); + for (unsigned short i_scalar = 0; i_scalar < flamelet_config_options.n_user_scalars; i_scalar++) { + const auto& scalar_name = flamelet_config_options.user_scalar_names[i_scalar]; AddVolumeOutput("ADJ_" + scalar_name, "Adjoint_" + scalar_name, "SOLUTION", "Adjoint of " + scalar_name); } } @@ -304,12 +309,13 @@ void CAdjFlowOutput::SetVolumeOutputFieldsAdjScalarResidual(const CConfig* confi } if (config->GetKind_Species_Model() == SPECIES_MODEL::FLAMELET) { - for(auto iCV=0u; iCV < config->GetNControlVars(); iCV++) { - const auto& cv_name = config->GetControllingVariableName(iCV); + const auto flamelet_config_options = config->GetFlameletParsedOptions(); + for(auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { + const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; AddVolumeOutput("RES_ADJ_" + cv_name, "Residual_Adjoint_" + cv_name, "RESIDUAL", "Residual of the adjoint of " + cv_name); } - for (unsigned short i_scalar = 0; i_scalar < config->GetNUserScalars(); i_scalar++) { - const auto& scalar_name = config->GetUserScalarName(i_scalar); + for (unsigned short i_scalar = 0; i_scalar < flamelet_config_options.n_user_scalars; i_scalar++) { + const auto& scalar_name = flamelet_config_options.user_scalar_names[i_scalar]; AddVolumeOutput("RES_ADJ_" + scalar_name, "Residual_Adjoint_" + scalar_name, "RESIDUAL", "Residual of the adjoint of " + scalar_name); } } @@ -351,16 +357,16 @@ void CAdjFlowOutput::LoadVolumeDataAdjScalar(const CConfig* config, const CSolve } if (config->GetKind_Species_Model() == SPECIES_MODEL::FLAMELET) { - - for (auto iCV=0u; iCV < config->GetNControlVars(); iCV++) { - const auto& cv_name = config->GetControllingVariableName(iCV); + const auto flamelet_config_options = config->GetFlameletParsedOptions(); + for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { + const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; SetVolumeOutputValue("ADJ_" + cv_name, iPoint, Node_AdjSpecies->GetSolution(iPoint, iCV)); SetVolumeOutputValue("RES_ADJ_" + cv_name, iPoint, Node_AdjSpecies->GetSolution(iPoint, iCV) - Node_AdjSpecies->GetSolution_Old(iPoint, iCV)); } - for (unsigned short i_scalar = 0; i_scalar < config->GetNUserScalars(); i_scalar++) { - const auto& scalar_name = config->GetUserScalarName(i_scalar); - SetVolumeOutputValue("ADJ_" + scalar_name, iPoint, Node_AdjSpecies->GetSolution(iPoint, config->GetNControlVars() + i_scalar)); - SetVolumeOutputValue("RES_ADJ_" + scalar_name, iPoint, Node_AdjSpecies->GetSolution(iPoint, config->GetNControlVars() + i_scalar) - Node_AdjSpecies->GetSolution_Old(iPoint, config->GetNControlVars() + i_scalar)); + for (unsigned short i_scalar = 0; i_scalar < flamelet_config_options.n_user_scalars; i_scalar++) { + const auto& scalar_name = flamelet_config_options.user_scalar_names[i_scalar]; + SetVolumeOutputValue("ADJ_" + scalar_name, iPoint, Node_AdjSpecies->GetSolution(iPoint, flamelet_config_options.n_control_vars + i_scalar)); + SetVolumeOutputValue("RES_ADJ_" + scalar_name, iPoint, Node_AdjSpecies->GetSolution(iPoint, flamelet_config_options.n_control_vars + i_scalar) - Node_AdjSpecies->GetSolution_Old(iPoint, flamelet_config_options.n_control_vars + i_scalar)); } } diff --git a/SU2_CFD/src/output/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index 3c651269b02e..ac1bd8f92d95 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -995,15 +995,16 @@ void CFlowOutput::AddHistoryOutputFields_ScalarRMS_RES(const CConfig* config) { break; } case SPECIES_MODEL::FLAMELET: { + const auto flamelet_config_options = config->GetFlameletParsedOptions(); /*--- Controlling variable transport. ---*/ - for (auto iCV = 0u; iCV < config->GetNControlVars(); iCV++){ - const auto& CV_name = config->GetControllingVariableName(iCV); + for (auto iCV = 0u; iCV < flamelet_config_options.n_control_vars; iCV++){ + const auto& CV_name = flamelet_config_options.controlling_variable_names[iCV]; AddHistoryOutput("RMS_"+CV_name, "rms["+CV_name+"]",ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean squared residual of " + CV_name + " controlling variable equation.", HistoryFieldType::RESIDUAL); } /*--- auxiliary species transport ---*/ - for (auto i_scalar = 0u; i_scalar < config->GetNUserScalars(); i_scalar++){ - const auto& scalar_name = config->GetUserScalarName(i_scalar); + for (auto i_scalar = 0u; i_scalar < flamelet_config_options.n_user_scalars; i_scalar++){ + const auto& scalar_name = flamelet_config_options.user_scalar_names[i_scalar]; AddHistoryOutput("RMS_"+scalar_name, "rms["+scalar_name+"]", ScreenOutputFormat::FIXED , "RMS_RES", "Root-mean squared residual of the "+scalar_name+" mass fraction equation." , HistoryFieldType::RESIDUAL); } break; @@ -1052,15 +1053,16 @@ void CFlowOutput::AddHistoryOutputFields_ScalarMAX_RES(const CConfig* config) { break; } case SPECIES_MODEL::FLAMELET: { + const auto flamelet_config_options = config->GetFlameletParsedOptions(); /*--- Controlling variable transport. ---*/ - for (auto iCV=0u; iCV < config->GetNControlVars(); iCV++){ - const auto& cv_name = config->GetControllingVariableName(iCV); + for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++){ + const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; AddHistoryOutput("MAX_" + cv_name, "max[" + cv_name + "]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the " + cv_name + " equation.", HistoryFieldType::RESIDUAL); } /*--- auxiliary species transport ---*/ - for (auto i_scalar = 0u; i_scalar < config->GetNUserScalars(); i_scalar++){ - const auto& scalar_name = config->GetUserScalarName(i_scalar); + for (auto i_scalar = 0u; i_scalar < flamelet_config_options.n_user_scalars; i_scalar++){ + const auto& scalar_name = flamelet_config_options.user_scalar_names[i_scalar]; AddHistoryOutput("MAX_" + scalar_name, "max[" + scalar_name + "]", ScreenOutputFormat::FIXED , "MAX_RES", "Maximum residual of the " + scalar_name + " mass fraction equation." , HistoryFieldType::RESIDUAL); } break; @@ -1107,15 +1109,16 @@ void CFlowOutput::AddHistoryOutputFields_ScalarBGS_RES(const CConfig* config) { break; } case SPECIES_MODEL::FLAMELET: { + const auto flamelet_config_options = config->GetFlameletParsedOptions(); /*--- Controlling variable transport. ---*/ - for (auto iCV=0u; iCV < config->GetNControlVars(); iCV++){ - const auto& cv_name = config->GetControllingVariableName(iCV); + for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++){ + const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; AddHistoryOutput("BGS_" + cv_name, "bgs[" + cv_name + "]", ScreenOutputFormat::FIXED, "BGS_RES", "BGS residual of the " + cv_name + " controlling variable equation.", HistoryFieldType::RESIDUAL); } /*--- auxiliary species transport ---*/ - for (auto i_scalar = 0u; i_scalar < config->GetNUserScalars(); i_scalar++){ - const auto& scalar_name = config->GetUserScalarName(i_scalar); + for (auto i_scalar = 0u; i_scalar < flamelet_config_options.n_user_scalars; i_scalar++){ + const auto& scalar_name = flamelet_config_options.user_scalar_names[i_scalar]; AddHistoryOutput("BGS_"+scalar_name, "bgs["+scalar_name+"]", ScreenOutputFormat::FIXED , "BGS_RES", "BGS residual of the "+scalar_name+" mass fraction equation." , HistoryFieldType::RESIDUAL); } break; @@ -1213,9 +1216,10 @@ void CFlowOutput::LoadHistoryDataScalar(const CConfig* config, const CSolver* co } case SPECIES_MODEL::FLAMELET: { + const auto flamelet_config_options = config->GetFlameletParsedOptions(); /*--- Controlling variable transport. ---*/ - for (auto iCV=0u; iCV < config->GetNControlVars(); iCV++){ - const auto& cv_name = config->GetControllingVariableName(iCV); + for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++){ + const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; SetHistoryOutputValue("RMS_" + cv_name, log10(solver[SPECIES_SOL]->GetRes_RMS(iCV))); SetHistoryOutputValue("MAX_" + cv_name, log10(solver[SPECIES_SOL]->GetRes_Max(iCV))); if (multiZone) { @@ -1223,19 +1227,19 @@ void CFlowOutput::LoadHistoryDataScalar(const CConfig* config, const CSolver* co } } /*--- auxiliary species transport ---*/ - for (unsigned short iReactant=0; iReactantGetNUserScalars(); iReactant++){ - const auto& species_name = config->GetUserScalarName(iReactant); - SetHistoryOutputValue("RMS_" + species_name, log10(solver[SPECIES_SOL]->GetRes_RMS(config->GetNControlVars() + iReactant))); - SetHistoryOutputValue("MAX_" + species_name, log10(solver[SPECIES_SOL]->GetRes_Max(config->GetNControlVars() + iReactant))); + for (unsigned short iReactant=0; iReactantGetRes_RMS(flamelet_config_options.n_control_vars + iReactant))); + SetHistoryOutputValue("MAX_" + species_name, log10(solver[SPECIES_SOL]->GetRes_Max(flamelet_config_options.n_control_vars + iReactant))); if (multiZone) { - SetHistoryOutputValue("BGS_" + species_name, log10(solver[SPECIES_SOL]->GetRes_BGS(config->GetNControlVars() + iReactant))); + SetHistoryOutputValue("BGS_" + species_name, log10(solver[SPECIES_SOL]->GetRes_BGS(flamelet_config_options.n_control_vars + iReactant))); } } SetHistoryOutputValue("LINSOL_ITER_FLAMELET", solver[SPECIES_SOL]->GetIterLinSolver()); SetHistoryOutputValue("LINSOL_RESIDUAL_FLAMELET", log10(solver[SPECIES_SOL]->GetResLinSolver())); - break; } + break; case SPECIES_MODEL::NONE: break; } @@ -1274,18 +1278,19 @@ void CFlowOutput::SetVolumeOutputFieldsScalarSolution(const CConfig* config){ AddVolumeOutput("SPECIES_" + std::to_string(iVar), "Species_" + std::to_string(iVar), "SOLUTION", "Species_" + std::to_string(iVar) + " mass fraction"); } break; - case SPECIES_MODEL::FLAMELET: - /*--- Controlling variables. ---*/ - for (auto iCV=0u; iCVGetNControlVars(); iCV++) { - const auto& cv_name = config->GetControllingVariableName(iCV); - AddVolumeOutput(cv_name, cv_name, "SOLUTION", cv_name + " solution."); - } - /*--- auxiliary species ---*/ - for (auto iReactant=0u; iReactantGetNUserScalars(); iReactant++) { - const auto& species_name = config->GetUserScalarName(iReactant); - AddVolumeOutput(species_name, species_name, "SOLUTION", species_name + "Mass fraction solution"); + case SPECIES_MODEL::FLAMELET: { + const auto flamelet_config_options = config->GetFlameletParsedOptions(); + /*--- Controlling variables. ---*/ + for (auto iCV=0u; iCVGetFlameletParsedOptions(); /*--- Residuals for controlling variable transport equations. ---*/ - for (auto iCV=0u; iCVGetNControlVars(); iCV++) { - const auto& cv_name = config->GetControllingVariableName(iCV); + for (auto iCV=0u; iCVGetNUserScalars(); iReactant++){ - const auto& species_name = config->GetUserScalarName(iReactant); + for (unsigned short iReactant=0; iReactantGetnSpecies(); iVar++) AddVolumeOutput("LIMITER_SPECIES_" + std::to_string(iVar), "Limiter_Species_" + std::to_string(iVar), "LIMITER", "Limiter value of the transported species " + std::to_string(iVar)); break; - case SPECIES_MODEL::FLAMELET: + case SPECIES_MODEL::FLAMELET: { + const auto flamelet_config_options = config->GetFlameletParsedOptions(); /*--- Limiter for controlling variables transport. ---*/ - for (auto iCV=0u; iCV < config->GetNControlVars(); iCV++) { - const auto& cv_name = config->GetControllingVariableName(iCV); + for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { + const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; AddVolumeOutput("LIMITER_" + cv_name, "Limiter_" + cv_name, "LIMITER", "Limiter of " + cv_name + " controlling variable."); } /*--- limiter for auxiliary species transport ---*/ - for (unsigned short iReactant=0; iReactant < config->GetNUserScalars(); iReactant++) { - const auto& species_name = config->GetUserScalarName(iReactant); + for (unsigned short iReactant=0; iReactant < flamelet_config_options.n_user_scalars; iReactant++) { + const auto& species_name = flamelet_config_options.user_scalar_names[iReactant]; AddVolumeOutput("LIMITER_" + species_name, "LIMITER_" + species_name, "LIMITER", "Limiter value for the " + species_name + " equation"); } + } break; default: break; @@ -1421,19 +1430,21 @@ void CFlowOutput::SetVolumeOutputFieldsScalarSource(const CConfig* config) { /*--- Only place outputs of the "SOURCE" group for scalar transport here. ---*/ switch (config->GetKind_Species_Model()) { - case SPECIES_MODEL::FLAMELET: - for (auto iCV=0u; iCV < config->GetNControlVars(); iCV++) { - const auto& cv_source_name = config->GetControllingVariableSourceName(iCV); - const auto& cv_name = config->GetControllingVariableName(iCV); + case SPECIES_MODEL::FLAMELET: { + const auto flamelet_config_options = config->GetFlameletParsedOptions(); + for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { + const auto& cv_source_name = flamelet_config_options.cv_source_names[iCV]; + const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; if (cv_source_name.compare("NULL") != 0) AddVolumeOutput("SOURCE_"+cv_name, "Source_" + cv_name, "SOURCE", "Source " + cv_name); } /*--- no source term for enthalpy ---*/ /*--- auxiliary species source terms ---*/ - for (auto iReactant=0u; iReactantGetNUserScalars(); iReactant++) { - const auto& species_name = config->GetUserScalarName(iReactant); + for (auto iReactant=0u; iReactantGetKind_Species_Model()) { - case SPECIES_MODEL::FLAMELET: - for (auto i_lookup = 0u; i_lookup < config->GetNLookups(); ++i_lookup) { - string strname1 = "lookup_" + config->GetLookupName(i_lookup); - AddVolumeOutput(config->GetLookupName(i_lookup), strname1,"LOOKUP", config->GetLookupName(i_lookup)); - } - AddVolumeOutput("TABLE_MISSES" , "Table_misses" , "LOOKUP", "Lookup table misses"); - break; - default: - break; + if (config->GetKind_Species_Model() == SPECIES_MODEL::FLAMELET) { + const auto flamelet_config_options = config->GetFlameletParsedOptions(); + for (auto i_lookup = 0u; i_lookup < flamelet_config_options.n_lookups; ++i_lookup) { + string strname1 = "lookup_" + flamelet_config_options.lookup_names[i_lookup]; + AddVolumeOutput(flamelet_config_options.lookup_names[i_lookup], strname1,"LOOKUP", flamelet_config_options.lookup_names[i_lookup]); + } + AddVolumeOutput("TABLE_MISSES" , "Table_misses" , "LOOKUP", "Lookup table misses"); } } @@ -1585,47 +1593,47 @@ void CFlowOutput::LoadVolumeDataScalar(const CConfig* config, const CSolver* con case SPECIES_MODEL::FLAMELET: { const auto Node_Species = solver[SPECIES_SOL]->GetNodes(); - + const auto flamelet_config_options = config->GetFlameletParsedOptions(); /*--- Controlling variables transport equations. ---*/ - for (auto iCV=0u; iCV < config->GetNControlVars(); iCV++) { - const auto& cv_name = config->GetControllingVariableName(iCV); + for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { + const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; SetVolumeOutputValue(cv_name, iPoint, Node_Species->GetSolution(iPoint, iCV)); SetVolumeOutputValue("RES_" + cv_name, iPoint, solver[SPECIES_SOL]->LinSysRes(iPoint, iCV)); - const auto& source_name = config->GetControllingVariableSourceName(iCV); + const auto& source_name = flamelet_config_options.cv_source_names[iCV]; if (source_name.compare("NULL") != 0) SetVolumeOutputValue("SOURCE_" + cv_name, iPoint, Node_Species->GetScalarSources(iPoint)[iCV]); } /*--- auxiliary species transport equations ---*/ - for (unsigned short i_scalar=0; i_scalarGetNUserScalars(); i_scalar++) { - const auto& scalar_name = config->GetUserScalarName(i_scalar); - SetVolumeOutputValue(scalar_name, iPoint, Node_Species->GetSolution(iPoint, config->GetNControlVars() + i_scalar)); - SetVolumeOutputValue("SOURCE_" + scalar_name, iPoint, Node_Species->GetScalarSources(iPoint)[config->GetNControlVars() + i_scalar]); - SetVolumeOutputValue("RES_" + scalar_name, iPoint, solver[SPECIES_SOL]->LinSysRes(iPoint, config->GetNControlVars() + i_scalar)); + for (unsigned short i_scalar=0; i_scalarGetSolution(iPoint, flamelet_config_options.n_control_vars + i_scalar)); + SetVolumeOutputValue("SOURCE_" + scalar_name, iPoint, Node_Species->GetScalarSources(iPoint)[flamelet_config_options.n_control_vars + i_scalar]); + SetVolumeOutputValue("RES_" + scalar_name, iPoint, solver[SPECIES_SOL]->LinSysRes(iPoint, flamelet_config_options.n_control_vars + i_scalar)); } if (config->GetKind_SlopeLimit_Species() != LIMITER::NONE) { /*--- Limiter for controlling variable transport equations. ---*/ - for (auto iCV=0u; iCVGetNControlVars(); iCV++) { - const auto& cv_name = config->GetControllingVariableName(iCV); + for (auto iCV=0u; iCVGetLimiter(iPoint, iCV)); } /*--- limiter for auxiliary species transport equations ---*/ - for (unsigned short i_scalar=0; i_scalarGetNUserScalars(); i_scalar++) { - const auto& scalar_name = config->GetUserScalarName(i_scalar); - SetVolumeOutputValue("LIMITER_" + scalar_name, iPoint, Node_Species->GetLimiter(iPoint, config->GetNControlVars() + i_scalar)); + for (unsigned short i_scalar=0; i_scalarGetLimiter(iPoint, flamelet_config_options.n_control_vars + i_scalar)); } } /*--- variables that we look up from the LUT ---*/ - for (int i_lookup = 0; i_lookup < config->GetNLookups(); ++i_lookup) { - if (config->GetLookupName(i_lookup)!="NULL") - SetVolumeOutputValue(config->GetLookupName(i_lookup), iPoint, Node_Species->GetScalarLookups(iPoint)[i_lookup]); + for (int i_lookup = 0; i_lookup < flamelet_config_options.n_lookups; ++i_lookup) { + if (flamelet_config_options.lookup_names[i_lookup] !="NULL") + SetVolumeOutputValue(flamelet_config_options.lookup_names[i_lookup], iPoint, Node_Species->GetScalarLookups(iPoint)[i_lookup]); } SetVolumeOutputValue("TABLE_MISSES", iPoint, Node_Species->GetTableMisses(iPoint)); - break; } + break; case SPECIES_MODEL::NONE: break; } } diff --git a/SU2_CFD/src/solvers/CSolver.cpp b/SU2_CFD/src/solvers/CSolver.cpp index 2c6322392c72..2263b2c94f3c 100644 --- a/SU2_CFD/src/solvers/CSolver.cpp +++ b/SU2_CFD/src/solvers/CSolver.cpp @@ -3697,13 +3697,14 @@ void CSolver::LoadInletProfile(CGeometry **geometry, } break; case SPECIES_MODEL::FLAMELET: + const auto flamelet_config_options = config->GetFlameletParsedOptions(); /*--- 2-equation flamelet model ---*/ columnName << "PROGRESSVAR" << setw(24) << "ENTHALPYTOT" << setw(24); columnValue << config->GetInlet_SpeciesVal(Marker_Tag)[0] << "\t" << config->GetInlet_SpeciesVal(Marker_Tag)[1]<<"\t"; /*--- auxiliary species transport equations ---*/ - for (unsigned short iReactant = 0; iReactant < config->GetNUserScalars(); iReactant++) { - columnName << config->GetUserScalarName(iReactant) << setw(24); - columnValue << config->GetInlet_SpeciesVal(Marker_Tag)[config->GetNControlVars() + iReactant] << "\t"; + for (unsigned short iReactant = 0; iReactant < flamelet_config_options.n_user_scalars; iReactant++) { + columnName << flamelet_config_options.user_scalar_names[iReactant] << setw(24); + columnValue << config->GetInlet_SpeciesVal(Marker_Tag)[flamelet_config_options.n_control_vars + iReactant] << "\t"; } break; } diff --git a/SU2_CFD/src/variables/CSpeciesFlameletVariable.cpp b/SU2_CFD/src/variables/CSpeciesFlameletVariable.cpp index 9b8d9b562126..d6d444ec934f 100644 --- a/SU2_CFD/src/variables/CSpeciesFlameletVariable.cpp +++ b/SU2_CFD/src/variables/CSpeciesFlameletVariable.cpp @@ -49,12 +49,12 @@ CSpeciesFlameletVariable::CSpeciesFlameletVariable(const su2double* species_inf, Res_TruncError.resize(nPoint, nVar) = su2double(0.0); /* Allocate space for the source and scalars for visualization */ - - source_scalar.resize(nPoint, config->GetNScalars()) = su2double(0.0); - lookup_scalar.resize(nPoint, config->GetNLookups()) = su2double(0.0); + const auto flamelet_config_options = config->GetFlameletParsedOptions(); + source_scalar.resize(nPoint, flamelet_config_options.n_scalars) = su2double(0.0); + lookup_scalar.resize(nPoint, flamelet_config_options.n_lookups) = su2double(0.0); table_misses.resize(nPoint) = 0; - if (config->GetPreferentialDiffusion()) { + if (flamelet_config_options.preferential_diffusion) { AuxVar.resize(nPoint, FLAMELET_PREF_DIFF_SCALARS::N_BETA_TERMS) = su2double(0.0); Grad_AuxVar.resize(nPoint, FLAMELET_PREF_DIFF_SCALARS::N_BETA_TERMS, nDim, 0.0); } From f14361e4ee0d8386534652f45af3285259949e22 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Thu, 27 Feb 2025 16:52:27 +0100 Subject: [PATCH 27/57] Added unit tests for fluid model consistency --- UnitTests/SU2_CFD/fluid/CFluidModel_tests.cpp | 125 ++++++++++++++++++ UnitTests/SU2_CFD/fluid/MLP_PINN.mlp | 78 +++++++++++ 2 files changed, 203 insertions(+) create mode 100644 UnitTests/SU2_CFD/fluid/CFluidModel_tests.cpp create mode 100644 UnitTests/SU2_CFD/fluid/MLP_PINN.mlp diff --git a/UnitTests/SU2_CFD/fluid/CFluidModel_tests.cpp b/UnitTests/SU2_CFD/fluid/CFluidModel_tests.cpp new file mode 100644 index 000000000000..c0d18f54a1c0 --- /dev/null +++ b/UnitTests/SU2_CFD/fluid/CFluidModel_tests.cpp @@ -0,0 +1,125 @@ +/*! + * \file CFluidModel_tests.cpp + * \brief Unit tests for the fluid model classes. + * \author E.Bunschoten + * \version 8.1.0 "Harrier" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2024, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "catch.hpp" +#include +#include "../../../SU2_CFD/include/fluid/CFluidModel.hpp" +#include "../../../SU2_CFD/include/fluid/CIdealGas.hpp" +#include "../../../SU2_CFD/include/fluid/CDataDrivenFluid.hpp" + +void FluidModelChecks(CFluidModel * fluid_model, const su2double val_p, const su2double val_T) { + + /*--- Check consistency of reverse look-up ---*/ + { + fluid_model->SetTDState_PT(val_p, val_T); + + const su2double val_rho_fluidmodel = fluid_model->GetDensity(); + const su2double val_e_fluidmodel = fluid_model->GetStaticEnergy(); + + fluid_model->SetTDState_rhoe(val_rho_fluidmodel, val_e_fluidmodel); + CHECK(Approx(fluid_model->GetPressure()) == val_p); + CHECK(Approx(fluid_model->GetTemperature()) == val_T); + } + /*--- Check internal consistency between primary and derived fluid properties ---*/ + fluid_model->SetTDState_PT(val_p, val_T); + const su2double val_rho = fluid_model->GetDensity(); + const su2double val_e = fluid_model->GetStaticEnergy(); + + const su2double dTdrho_e = fluid_model->GetdTdrho_e(); + const su2double dPdrho_e = fluid_model->GetdPdrho_e(); + const su2double dTde_rho = fluid_model->GetdTde_rho(); + const su2double dPde_rho= fluid_model->GetdPde_rho(); + + su2double delta_rho = 1e-2, delta_e = 100.0; + { + fluid_model->SetTDState_rhoe(val_rho+delta_rho, val_e); + const su2double T_plus = fluid_model->GetTemperature(); + const su2double p_plus = fluid_model->GetPressure(); + + fluid_model->SetTDState_rhoe(val_rho-delta_rho, val_e); + const su2double T_minus = fluid_model->GetTemperature(); + const su2double p_minus = fluid_model->GetPressure(); + const su2double dTdrho_e_FD = (T_plus - T_minus)/(2*delta_rho); + const su2double dPdrho_e_FD = (p_plus - p_minus)/(2*delta_rho); + + CHECK(dTdrho_e == Approx(dTdrho_e_FD)); + CHECK(dPdrho_e == Approx(dPdrho_e_FD)); + } + { + fluid_model->SetTDState_rhoe(val_rho, val_e + delta_e); + const su2double T_plus = fluid_model->GetTemperature(); + const su2double p_plus = fluid_model->GetPressure(); + + fluid_model->SetTDState_rhoe(val_rho, val_e - delta_e); + const su2double T_minus = fluid_model->GetTemperature(); + const su2double p_minus = fluid_model->GetPressure(); + const su2double dTde_rho_FD = (T_plus - T_minus)/(2*delta_e); + const su2double dPde_rho_FD = (p_plus - p_minus)/(2*delta_e); + + CHECK(dTde_rho == Approx(dTde_rho_FD)); + CHECK(dPde_rho == Approx(dPde_rho_FD)); + } +} + +TEST_CASE("Test case for ideal gas fluid model") { + + CIdealGas * fluid_model = new CIdealGas(1.4, 287.0); + + FluidModelChecks(fluid_model, 101325, 300.0); + FluidModelChecks(fluid_model, 1e6, 600.0); + + delete fluid_model; +} + +TEST_CASE("Test case for data-driven fluid model") { + std::stringstream config_options; + + config_options << "SOLVER=RANS" << std::endl; + config_options<<"KIND_TURB_MODEL=SA"< + +[number of layers] +4 + +[neurons per layer] +2 +12 +12 +1 + +[activation function] +linear +exponential +exponential +linear + +[input names] +Density +Energy + +[input regularization method] +minmax + +[input normalization] ++1.0000000000002272e-01 +3.6000000000001620e+02 ++2.4999999999999913e+05 +5.5000000000000407e+05 + +[output names] +s + +[output regularization method] +minmax + +[output normalization] ++6.5239076364026619e+02 +1.5203988895015702e+03 + + + +[weights per layer] + +-2.2636230520308294e+00 -1.4376163759051570e+02 -1.8210265085365642e+00 -1.9392431999968291e+01 +7.7998972848161929e-01 -4.4451402056377132e-01 +1.1480586943782076e+00 +7.3911541657373481e-01 +6.6848364842168884e-01 -1.8271554443848029e+01 +1.2261285194926941e+00 -1.4498105832610020e+00 +-3.5792276167311754e-01 -4.6660012868153460e-02 +8.6960980388545261e-01 -3.3067252427727123e-01 +7.2901181049513930e-01 -4.5132436983111057e-01 -1.6721101091715045e+00 +1.6381708561036443e-01 -9.9953810361650641e-01 -1.6660397867362475e+00 -3.6845287976534608e-01 +3.2679042214120246e-01 + + ++5.9993107069789275e-01 -3.7968611358916876e-01 -9.1784196873856094e-01 +3.7697075096981791e-01 -2.4514594732936050e+00 -2.9404244326707329e-01 -9.4877021231483852e-02 -3.3980372028224931e-02 +4.2421189400580528e-01 +7.7781137867976824e-01 +7.8391084779202980e-02 -1.8389416804610961e+00 +-2.5408281524798354e-01 +9.0756663051344069e-03 +1.1584753496996323e+00 +2.3534308868577432e-03 +2.4490086543179976e+00 +5.5043198360778117e-02 +7.1243387886788068e-01 -1.3472356985325758e-02 -1.6022336815491792e-01 +7.9384957177751261e-03 -8.3913484678289282e-02 -5.0208325332694126e-01 +-1.3231543644220687e+00 +2.3890465005266312e-01 -2.7829788154280122e+00 -4.1684736117099767e-02 -1.7289853140913009e-01 -2.7452124285237439e-01 +1.9057689172006617e-01 -4.8499148958861135e-02 -1.5998171284591250e-01 -3.8444057771255657e-01 -1.7591798029573689e+00 -3.1998700856829099e-01 +-3.4460543761346853e+00 +2.8269088892223054e-01 -1.8007009126606924e-01 -1.8194428084477665e-01 -9.8097976562849054e-01 +2.2343131530917884e+00 -9.3480765212571959e-01 -2.1820922470878051e-01 +2.4998489167470859e+00 -9.2764413588769656e-01 +4.2116280346986166e+00 +5.7430289000882420e+00 +-1.3779943339666223e-01 +5.1527341679864391e-01 -2.0684081713014844e+00 -4.6713867186704139e-01 -1.6656574393452730e+00 +8.2916484143979841e-02 -6.2985392912561127e-03 -8.0554067455084744e-01 +1.5050572815527488e-01 -3.0403633272013114e-01 +9.3661086475363739e-02 -1.7366620874413785e-01 ++1.2102271004943301e+00 -1.4795362440831727e-01 -7.7934495467562570e-01 -5.9581359297919689e-01 -2.5799123516309956e+00 -4.2086823260415152e-01 -6.1754592301131395e-01 +5.3496586769756471e-01 -1.1988742301845021e+00 -1.1825507727456516e-01 -1.2989806049860451e+00 -1.5082167140110778e+00 +-1.5832999264655581e+00 -5.0541334265413407e-01 -1.2224436375090135e+00 +9.4464382557138807e-02 -7.7094226591729909e-01 -1.3308898524504738e+00 -5.6071570095690060e-01 -1.1808627032633583e-01 -6.8406003004295413e-01 -1.0851498125792971e+00 -1.6619882623877327e+00 +3.3905033683843949e-01 +-1.6613583604241693e+00 -4.7389354240091253e-01 -1.6404302611149377e+00 +5.6328884449292083e-01 -2.3886973163682126e+00 +6.3182847097032660e-02 -1.1988633757241718e+00 -1.0449760622285645e-01 -5.0007576677205112e-01 -5.7953124309145942e-01 +1.3744226228525147e-01 -5.2406676771136440e-01 +-5.2321502793378249e-01 -5.3150359391312596e-01 -8.2608918128172837e-01 -1.5179873908573804e+00 -1.3741534704444816e+00 -1.1396125599060034e+00 -2.4669798409655488e-01 +3.5463486969786873e-01 -1.4557579529418466e-01 +3.9772638519145487e-01 -7.3761409583500159e-01 +4.3638838398439539e-01 ++1.1339107378860229e+00 +1.7594521224843396e-01 -2.3113519941138065e+00 -1.6298684024567350e-01 +2.1654392231781072e+00 +1.1946181086317720e+00 +6.1504990167411666e-01 +3.5812470374750952e-02 +4.7359603213749768e-01 -1.3926908147980210e-01 +1.5092490082960155e+00 +6.2527693075989743e-01 +-1.8730091080176507e+00 +6.0253144933079306e-01 -8.4799895628536026e-01 -4.9738323769072662e-01 -2.7954591059886620e+00 -6.0772894919752340e-01 -1.6669559186193763e+00 +3.2575755465661199e-01 -6.3810153137096781e-01 -1.5742470796026808e+00 +4.0723523279497037e-01 -2.6629855030791610e-01 ++9.5260226581936475e-02 +1.3178352071446142e-01 -8.2706051782881629e-01 +4.3476689449955158e-01 -1.9510329069314138e+00 -6.1816074212742961e-02 -8.8250388388085288e-01 -3.9491669828062620e-01 -1.5457029407527009e-01 -8.1118953547083511e-02 -9.3695252718016830e-01 -7.2928015955932368e-01 + + +-1.1729556416685407e+00 ++6.5203789113121413e-01 +-1.8734538612518090e-01 ++2.1621137726863668e-01 ++5.6641315509463920e-03 ++2.0302117964378608e-01 ++8.4775779057667755e-02 +-3.0580176253474467e-01 ++3.0269028189313296e-01 ++5.6045172511572938e-01 +-1.2871102614766081e-01 +-1.2950131608167472e+00 + + +[biases per layer] ++0.0000000000000000e+00 +0.0000000000000000e+00 ++1.1016481462000773e+00 +2.3664012769409184e+00 -9.4722828005676618e-01 +2.9514075029104910e-02 -7.7331761508748165e-01 +7.3249514271738470e-01 +2.5926140499409794e-01 +8.9008692454169913e-01 +5.0307216362067246e-02 +5.9255316881972364e-01 -2.0202744615666726e-01 -4.3866869529767016e-01 ++3.7843782710203738e-01 +1.6775822623352205e-01 -6.9759335447123827e-01 -4.0155126735738134e-01 -2.5582386039767488e+00 -4.7188519950683777e-01 -7.9682095244914830e-01 -7.9066710997409528e-02 -6.3882846975992846e-01 -4.3560525651855958e-01 -1.3131160733413525e+00 -8.0222167363936081e-01 ++3.4454053855686528e-01 From 101eeff56a39740a079fe925287246ab100072aa Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Thu, 27 Feb 2025 16:52:54 +0100 Subject: [PATCH 28/57] Added derived variables to PreaccOut --- SU2_CFD/src/fluid/CDataDrivenFluid.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SU2_CFD/src/fluid/CDataDrivenFluid.cpp b/SU2_CFD/src/fluid/CDataDrivenFluid.cpp index 9fc77f66c1a5..d25b5c2135c9 100644 --- a/SU2_CFD/src/fluid/CDataDrivenFluid.cpp +++ b/SU2_CFD/src/fluid/CDataDrivenFluid.cpp @@ -231,8 +231,11 @@ void CDataDrivenFluid::SetTDState_rhoe(su2double rho, su2double e) { AD::SetPreaccOut(dPde_rho); AD::SetPreaccOut(dPdrho_e); AD::SetPreaccOut(dTde_rho); + AD::SetPreaccOut(dTdrho_e); AD::SetPreaccOut(Pressure); AD::SetPreaccOut(Entropy); + AD::SetPreaccOut(Cp); + AD::SetPreaccOut(Cv); AD::EndPreacc(); } From 0ee4c38bd5ef63ce5aaa7e73064a932c1eb3977c Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Fri, 28 Feb 2025 11:46:00 +0100 Subject: [PATCH 29/57] Changes from develop --- Common/include/CConfig.hpp | 102 ++++++++++-------- Common/include/geometry/CGeometry.hpp | 13 +++ Common/include/option_structure.hpp | 14 +++ Common/src/CConfig.cpp | 80 ++++++++++---- SU2_CFD/include/iteration/CFluidIteration.hpp | 14 +-- SU2_CFD/src/iteration/CFluidIteration.cpp | 90 ++++++++-------- 6 files changed, 193 insertions(+), 120 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 1bdee5d9ef98..3f7fe8869e0c 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -1072,12 +1072,19 @@ class CConfig { unsigned short *nSpan_iZones; /*!< \brief number of span-wise sections for each zones */ bool turbMixingPlane; /*!< \brief option for turbulent mixingplane */ bool SpatialFourier; /*!< \brief option for computing the fourier transforms for subsonic non-reflecting BC. */ - bool RampRotatingFrame; /*!< \brief option for ramping up or down the Rotating Frame values */ - bool RampOutletPressure; /*!< \brief option for ramping up or down the outlet pressure */ + bool RampMotionFrame; /*!< \brief option for ramping up or down the motion Frame values */ + bool RampOutlet; /*!< \brief option for ramping up or down the outlet values */ + bool RampRotatingFrame; /*!< \brief option for ramping up or down the motion Frame values */ + bool RampTranslationFrame; /*!< \brief option for ramping up or down the outlet values */ + bool RampOutletMassFlow; /*!< \brief option for ramping up or down the motion Frame values */ + bool RampOutletPressure; /*!< \brief option for ramping up or down the outlet values */ su2double AverageMachLimit; /*!< \brief option for turbulent mixingplane */ su2double FinalRotation_Rate_Z; /*!< \brief Final rotation rate Z if Ramp rotating frame is activated. */ + su2double FinalTranslation_Rate_Y; /*!< \brief Final translation rate Y if Ramp translation frame is activated. */ su2double FinalOutletPressure; /*!< \brief Final outlet pressure if Ramp outlet pressure is activated. */ + su2double FinalOutletMassFlow; /*!< \brief Final outlet mass flow rate if Ramp outlet mass flow rate is activated */ su2double MonitorOutletPressure; /*!< \brief Monitor outlet pressure if Ramp outlet pressure is activated. */ + su2double MonitorOutletMassFlow; /*!< \brief Monitor outlet mass flow rate if ramp outlet mass flow rate is activated. */ array cp_polycoeffs{{0.0}}; /*!< \brief Array for specific heat polynomial coefficients. */ array mu_polycoeffs{{0.0}}; /*!< \brief Array for viscosity polynomial coefficients. */ array kt_polycoeffs{{0.0}}; /*!< \brief Array for thermal conductivity polynomial coefficients. */ @@ -1126,8 +1133,8 @@ class CConfig { jst_coeff[2], /*!< \brief artificial dissipation (flow) array for the COption class. */ ffd_coeff[3], /*!< \brief artificial dissipation (flow) array for the COption class. */ mixedout_coeff[3], /*!< \brief default mixedout algorithm coefficients for the COption class. */ - rampRotFrame_coeff[3], /*!< \brief ramp rotating frame coefficients for the COption class. */ - rampOutPres_coeff[3], /*!< \brief ramp outlet pressure coefficients for the COption class. */ + rampMotionFrame_coeff[3], /*!< \brief ramp motion frame coefficients for the COption class. */ + rampOutlet_coeff[3], /*!< \brief ramp outlet value coefficients for the COption class. */ jst_adj_coeff[2], /*!< \brief artificial dissipation (adjoint) array for the COption class. */ mesh_box_length[3], /*!< \brief mesh box length for the COption class. */ mesh_box_offset[3], /*!< \brief mesh box offset for the COption class. */ @@ -5019,45 +5026,46 @@ class CConfig { void SetKind_PerformanceAverageProcess(unsigned short new_AverageProcess) { Kind_PerformanceAverageProcess = new_AverageProcess; } /*! - * \brief Get coeff for Rotating Frame Ramp. - * \return coeff Ramp Rotating Frame. + * \brief Get Motion Frame Ramp option. + * \return Ramp Motion Frame option. */ - su2double GetRampRotatingFrame_Coeff(unsigned short iCoeff) const { return rampRotFrame_coeff[iCoeff];} + bool GetRampMotionFrame(void) const { return RampMotionFrame; } /*! - * \brief Get Rotating Frame Ramp option. - * \return Ramp Rotating Frame option. - */ - bool GetRampRotatingFrame(void) const { return RampRotatingFrame;} - - /*! - * \brief Get coeff for Outlet Pressure Ramp. - * \return coeff Ramp Outlet Pressure. - */ - su2double GetRampOutletPressure_Coeff(unsigned short iCoeff) const { return rampOutPres_coeff[iCoeff];} + * \brief Get coeff for ramping the frame of motion (translation/rotation) [TURBO ONLY] + * \return coeff Ramp for frame of motion + */ + su2double GetRampMotionFrame_Coeff(unsigned short iCoeff) const { return rampMotionFrame_coeff[iCoeff];} /*! - * \brief Get final Outlet Pressure value for the ramp. - * \return final Outlet Pressure value. + * \brief Get outflow ramp option. + * \return Ramp outflow option. */ - su2double GetFinalOutletPressure(void) const { return FinalOutletPressure; } + bool GetRampOutflow(void) const { return RampOutlet; } /*! - * \brief Get final Outlet Pressure value for the ramp. - * \return Monitor Outlet Pressure value. - */ - su2double GetMonitorOutletPressure(void) const { return MonitorOutletPressure; } + * \brief Get coeff for ramping the Giles boundary outflow (pressure/mass flow) [TURBO ONLY] + * \return coeff Ramp for Giles outflow + */ + su2double GetRampOutflow_Coeff(unsigned short iCoeff) const { return rampOutlet_coeff[iCoeff]; } /*! - * \brief Set Monitor Outlet Pressure value for the ramp. - */ - void SetMonitorOutletPressure(su2double newMonPres) { MonitorOutletPressure = newMonPres;} + * \brief General interface for accessing ramp coefficient information + * \return coeff for ramps + */ + su2double GetRamp_Coeff(RAMP_TYPE ramp_flag, RAMP_COEFF val_coeff) { + if (ramp_flag == RAMP_TYPE::GRID) return rampMotionFrame_coeff[val_coeff]; + else if (ramp_flag == RAMP_TYPE::BOUNDARY) return rampOutlet_coeff[val_coeff]; + else return 0; + }; /*! - * \brief Get Outlet Pressure Ramp option. - * \return Ramp Outlet pressure option. + * \brief Generic interface for setting monitor outlet values for the ramp. */ - bool GetRampOutletPressure(void) const { return RampOutletPressure;} + void SetMonitorValue(su2double newMon_val) { + if (RampOutletPressure) MonitorOutletPressure = newMon_val; + else if (RampOutletMassFlow) MonitorOutletMassFlow = newMon_val; + } /*! * \brief Get mixedout coefficients. @@ -5916,6 +5924,16 @@ class CConfig { */ void SetRotation_Rate(unsigned short iDim, su2double val) { Rotation_Rate[iDim] = val;} + /*! + * \brief General interface for setting the rate of motion in grid ramps + * \param[in] ramp_flag - flag for type of ramp + * \param[in] val - new value of rate of motion + */ + void SetRate(su2double val) { + if (RampRotatingFrame) Rotation_Rate[2] = val; + else if (RampTranslationFrame) Translation_Rate[1] = val; + }; + /*! * \brief Get the rotation rate of the marker. * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) @@ -6010,16 +6028,16 @@ class CConfig { su2double GetMarkerPlunging_Ampl(unsigned short iMarkerMoving, unsigned short iDim) const { return MarkerPlunging_Ampl[3*iMarkerMoving + iDim];} /*! - * \brief Get the angular velocity of the mesh about the z-axis. - * \return Angular velocity of the mesh about the z-axis. + * \brief Generic interface for retrieving final value of a turbomachinery ramp + * \return Final value of a specified ramp */ - su2double GetFinalRotation_Rate_Z() const { return FinalRotation_Rate_Z;} - - /*! - * \brief Set the angular velocity of the mesh about the z-axis. - * \param[in] newRotation_Rate_Z - new rotation rate after computing the ramp value. - */ - void SetRotation_Rate_Z(su2double newRotation_Rate_Z); + su2double GetFinalValue(RAMP_TYPE ramp_flag) { + if (ramp_flag == RAMP_TYPE::GRID && RampRotatingFrame) return FinalRotation_Rate_Z; + else if (ramp_flag == RAMP_TYPE::GRID && RampTranslationFrame) return FinalTranslation_Rate_Y; + else if (ramp_flag == RAMP_TYPE::BOUNDARY && RampOutletPressure) return FinalOutletPressure; + else if (ramp_flag == RAMP_TYPE::BOUNDARY && RampOutletMassFlow) return FinalOutletMassFlow; + else return 0.0; + }; /*! * \brief Get the Harmonic Balance frequency pointer. @@ -6944,12 +6962,6 @@ 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. diff --git a/Common/include/geometry/CGeometry.hpp b/Common/include/geometry/CGeometry.hpp index 3a05f446e09f..470147b70760 100644 --- a/Common/include/geometry/CGeometry.hpp +++ b/Common/include/geometry/CGeometry.hpp @@ -952,6 +952,19 @@ class CGeometry { */ void SetCustomBoundary(CConfig* config); + /*! + * \brief General interface for setting the velocity in the geometry during motion ramps + * \param[in] config - config class + * \param[in] ramp_flag - flag for type of ramp + * \param[in] print - bool to print update to screen + */ + void SetVelocity(CConfig* config, bool print) { + if (config->GetKind_GridMovement() == ENUM_GRIDMOVEMENT::ROTATING_FRAME) + SetRotationalVelocity(config, print); + else if (config->GetKind_GridMovement() == ENUM_GRIDMOVEMENT::STEADY_TRANSLATION) + SetTranslationalVelocity(config, print); + }; + /*! * \brief Set cartesian grid velocity based on rotational speed and axis. * \param[in] config - Definition of the particular problem. diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index f116547aadf9..5516c1be7976 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -1926,6 +1926,20 @@ enum TURBO_MARKER_TYPE{ OUTFLOW = 2 /*!< \brief flag for outflow marker for compute turboperformance. */ }; +enum class RAMP_TYPE{ + GRID, /*!< \brief flag for rotational/translational ramps */ + BOUNDARY /*!< \brief flag for pressure/mass flow ramps*/ +}; + +/*! + * \brief Coefficients of the ramp specified in the config, ordered by index in the config + */ +enum RAMP_COEFF{ + INITIAL_VALUE = 0, /*!< \brief intial value of the ramp */ + UPDATE_FREQ = 1, /* 0.0){ - Rotation_Rate[2] = rampRotFrame_coeff[0]; + Rotation_Rate[2] = rampMotionFrame_coeff[RAMP_COEFF::INITIAL_VALUE]; + } + } + + if(GetGrid_Movement() && RampTranslationFrame && !DiscreteAdjoint){ + FinalTranslation_Rate_Y = Translation_Rate[1]; + if(abs(FinalTranslation_Rate_Y) > 0.0){ + Translation_Rate[1] = rampMotionFrame_coeff[RAMP_COEFF::INITIAL_VALUE]; } } @@ -4373,13 +4407,22 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i for (iMarker = 0; iMarker < nMarker_Giles; iMarker++){ if (Kind_Data_Giles[iMarker] == STATIC_PRESSURE || Kind_Data_Giles[iMarker] == STATIC_PRESSURE_1D || Kind_Data_Giles[iMarker] == RADIAL_EQUILIBRIUM ){ FinalOutletPressure = Giles_Var1[iMarker]; - Giles_Var1[iMarker] = rampOutPres_coeff[0]; + Giles_Var1[iMarker] = rampOutlet_coeff[RAMP_COEFF::INITIAL_VALUE]; } } for (iMarker = 0; iMarker < nMarker_Riemann; iMarker++){ if (Kind_Data_Riemann[iMarker] == STATIC_PRESSURE || Kind_Data_Riemann[iMarker] == RADIAL_EQUILIBRIUM){ FinalOutletPressure = Riemann_Var1[iMarker]; - Riemann_Var1[iMarker] = rampOutPres_coeff[0]; + Riemann_Var1[iMarker] = rampOutlet_coeff[RAMP_COEFF::INITIAL_VALUE]; + } + } + } + + if(RampOutletMassFlow && !DiscreteAdjoint){ + for (iMarker = 0; iMarker < nMarker_Giles; iMarker++){ + if (Kind_Data_Giles[iMarker] == MASS_FLOW_OUTLET){ + FinalOutletMassFlow = Giles_Var1[iMarker]; + Giles_Var1[iMarker] = rampOutlet_coeff[RAMP_COEFF::INITIAL_VALUE]; } } } @@ -5424,7 +5467,9 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i } RampOutletPressure = false; + RampOutletMassFlow = false; RampRotatingFrame = false; + RampTranslationFrame = false; } /* 2nd-order MUSCL is not possible for the continuous adjoint @@ -9130,13 +9175,6 @@ 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++) diff --git a/SU2_CFD/include/iteration/CFluidIteration.hpp b/SU2_CFD/include/iteration/CFluidIteration.hpp index 61cbc66a986b..fc196419a9b4 100644 --- a/SU2_CFD/include/iteration/CFluidIteration.hpp +++ b/SU2_CFD/include/iteration/CFluidIteration.hpp @@ -108,22 +108,14 @@ class CFluidIteration : public CIteration { unsigned short val_iInst) override; /*! - * \brief Monitors turbo computation (turbo ramp). + * \brief Monitors and updates ramps * \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 + * \param[in] ramp_flag - Flag indicating type of ramp (grid or boundary) */ - 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); + void UpdateRamp(CGeometry**** geometry_container, CConfig** config_container, unsigned long iter, unsigned short iZone, RAMP_TYPE ramp_flag); /*! * \brief Computes turboperformance. diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index e77b0d7c2ca3..2e60d087b7de 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -232,12 +232,14 @@ bool CFluidIteration::Monitor(COutput* output, CIntegration**** integration, CGe config, TurbomachineryStagePerformance, TurbomachineryPerformance, val_iZone, config[val_iZone]->GetTimeIter(), config[val_iZone]->GetOuterIter(), config[val_iZone]->GetInnerIter(), val_iInst); } - - TurboMonitor(geometry, config, config[val_iZone]->GetInnerIter(), val_iZone); + /*--- Update ramps, grid first then outlet boundary ---*/ + if (config[val_iZone]->GetRampMotionFrame()) + UpdateRamp(geometry, config, config[val_iZone]->GetInnerIter(), val_iZone, RAMP_TYPE::GRID); } - /*--- Update the values of any adaptive boundary conditions ---*/ - UpdateBoundaryConditions(geometry, config, config[val_iZone]->GetInnerIter(), val_iZone); + // Outside turbo scope as Riemann boundaries can be ramped (pressure only) + if (config[val_iZone]->GetRampOutflow()) + UpdateRamp(geometry, config, config[val_iZone]->GetInnerIter(), val_iZone, RAMP_TYPE::BOUNDARY); output->SetHistoryOutput(geometry[val_iZone][val_iInst][MESH_0], solver[val_iZone][val_iInst][MESH_0], config[val_iZone], config[val_iZone]->GetTimeIter(), config[val_iZone]->GetOuterIter(), @@ -255,54 +257,56 @@ bool CFluidIteration::Monitor(COutput* output, CIntegration**** integration, CGe return StopCalc; } -void CFluidIteration::TurboMonitor(CGeometry**** geometry_container, CConfig** config_container, unsigned long iter, unsigned short iZone) { +void CFluidIteration::UpdateRamp(CGeometry**** geometry_container, CConfig** config_container, unsigned long iter, unsigned short iZone, RAMP_TYPE ramp_flag) { + /*--- Generic function for handling ramps ---*/ + // Grid updates (i.e. rotation/translation) handled seperately to boundary (i.e. pressure/mass flow) updates auto* config = config_container[iZone]; + auto* geometry = geometry_container[iZone][INST_0][ZONE_0]; + + std::string msg = "\nUpdated rotating frame grid velocities for zone "; + if (ramp_flag == RAMP_TYPE::GRID && config->GetKind_GridMovement() == ENUM_GRIDMOVEMENT::STEADY_TRANSLATION) + msg = "\nUpdated translation frame grid velocities for zone "; if (config_container[ZONE_0]->GetMultizone_Problem()) iter = config_container[ZONE_0]->GetOuterIter(); - /*--- ROTATING FRAME Ramp: Compute the updated rotational velocity. ---*/ - if (config->GetGrid_Movement() && config->GetRampRotatingFrame()) { - const unsigned long rampFreq = SU2_TYPE::Int(config->GetRampRotatingFrame_Coeff(1)); - const unsigned long finalRamp_Iter = SU2_TYPE::Int(config->GetRampRotatingFrame_Coeff(2)); - const su2double rot_z_ini = config->GetRampRotatingFrame_Coeff(0); - const bool print = (config->GetComm_Level() == COMM_FULL); - - if(iter % rampFreq == 0 && iter <= finalRamp_Iter){ - - const su2double rot_z_final = config->GetFinalRotation_Rate_Z(); - - if (fabs(rot_z_final) > 0.0) { - const su2double rot_z = rot_z_ini + iter * ( rot_z_final - rot_z_ini) / finalRamp_Iter; - config->SetRotation_Rate(2, rot_z); - if (rank == MASTER_NODE && iter > 0) { - cout << "\nUpdated rotating frame grid velocities for zone " << iZone << ".\n"; - } - geometry_container[iZone][INST_0][MESH_0]->SetRotationalVelocity(config, print); - geometry_container[iZone][INST_0][MESH_0]->SetShroudVelocity(config); - } - geometry_container[iZone][INST_0][MESH_0]->SetAvgTurboValue(config, iZone, INFLOW, false); - geometry_container[iZone][INST_0][MESH_0]->SetAvgTurboValue(config, iZone, OUTFLOW, false); - geometry_container[iZone][INST_0][MESH_0]->GatherInOutAverageValues(config, false); + /*-- Update grid velocities (ROTATING_FRAME, STEADY_TRANSLATION)*/ + if (ramp_flag == RAMP_TYPE::GRID && config->GetGrid_Movement()) { + const auto ini_vel = config->GetRamp_Coeff(ramp_flag, RAMP_COEFF::INITIAL_VALUE); + const long unsigned rampFreq = SU2_TYPE::Int(config->GetRamp_Coeff(ramp_flag, RAMP_COEFF::UPDATE_FREQ)); + const long unsigned finalRamp_Iter = SU2_TYPE::Int(config->GetRamp_Coeff(ramp_flag, RAMP_COEFF::FINAL_ITER)); + + // Two options needed as if finalRamp_Iter % rampFreq != 0 final value is not set correctly + if((iter % rampFreq == 0 && iter < finalRamp_Iter) || (iter == finalRamp_Iter)){ + const auto final_vel = config->GetFinalValue(ramp_flag); + if(fabs(final_vel) > 0.0) { + const auto vel = ini_vel + iter * (final_vel - ini_vel)/finalRamp_Iter; + config->SetRate(vel); + if (rank == MASTER_NODE && iter > 0) cout << msg << iZone << ".\n"; + geometry->SetVelocity(config, true); + geometry->SetShroudVelocity(config); + } + // Update average turbo values + geometry->SetAvgTurboValue(config, iZone, INFLOW, false); + geometry->SetAvgTurboValue(config, iZone, OUTFLOW, false); + geometry->GatherInOutAverageValues(config, false); if (iZone < nZone - 1) { geometry_container[nZone-1][INST_0][MESH_0]->SetAvgTurboGeoValues(config ,geometry_container[iZone][INST_0][MESH_0], iZone); } } } -} -void CFluidIteration::UpdateBoundaryConditions(CGeometry**** geometry_container, CConfig** config_container, unsigned long iter, unsigned short iZone) { - auto* config = config_container[iZone]; - /*--- Outlet Pressure Ramp: Compute the updated pressure. ---*/ - if (config->GetRampOutletPressure()) { - const unsigned long rampFreq = SU2_TYPE::Int(config->GetRampOutletPressure_Coeff(1)); - const unsigned long finalRamp_Iter = SU2_TYPE::Int(config->GetRampOutletPressure_Coeff(2)); - const su2double outPres_ini = config->GetRampOutletPressure_Coeff(0); - const su2double outPres_final = config->GetFinalOutletPressure(); - if (iter % rampFreq == 0 && iter <= finalRamp_Iter) { - const su2double outPres = outPres_ini + iter * (outPres_final - outPres_ini) / finalRamp_Iter; - if (rank == MASTER_NODE) config->SetMonitorOutletPressure(outPres); + // Boundary ramps (pressure/mass flow) + if (ramp_flag == RAMP_TYPE::BOUNDARY){ + const auto outVal_ini = config->GetRamp_Coeff(ramp_flag, RAMP_COEFF::INITIAL_VALUE); + const long unsigned rampFreq = SU2_TYPE::Int(config->GetRamp_Coeff(ramp_flag, RAMP_COEFF::UPDATE_FREQ)); + const long unsigned finalRamp_Iter = SU2_TYPE::Int(config->GetRamp_Coeff(ramp_flag, RAMP_COEFF::FINAL_ITER)); + const auto outVal_final = config->GetFinalValue(ramp_flag); + + if ((iter % rampFreq == 0 && iter < finalRamp_Iter) || (iter == finalRamp_Iter)) { + const su2double outVal = outVal_ini + iter * (outVal_final - outVal_ini) / finalRamp_Iter; + if (rank == MASTER_NODE) config->SetMonitorValue(outVal); for (auto iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { const auto KindBC = config->GetMarker_All_KindBC(iMarker); @@ -312,14 +316,14 @@ void CFluidIteration::UpdateBoundaryConditions(CGeometry**** geometry_container, case RIEMANN_BOUNDARY: KindBCOption = config->GetKind_Data_Riemann(Marker_Tag); if (KindBCOption == STATIC_PRESSURE || KindBCOption == RADIAL_EQUILIBRIUM) { - config->SetRiemann_Var1(outPres, Marker_Tag); + SU2_MPI::Error("Outlet pressure ramp only implemented for NRBC", CURRENT_FUNCTION); } break; case GILES_BOUNDARY: KindBCOption = config->GetKind_Data_Giles(Marker_Tag); if (KindBCOption == STATIC_PRESSURE || KindBCOption == STATIC_PRESSURE_1D || - KindBCOption == RADIAL_EQUILIBRIUM ) { - config->SetGiles_Var1(outPres, Marker_Tag); + KindBCOption == RADIAL_EQUILIBRIUM || KindBCOption == MASS_FLOW_OUTLET) { + config->SetGiles_Var1(outVal, Marker_Tag); } break; } From b8837703527fe8d3ef9e3f1d950e7180e3262e25 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Fri, 28 Feb 2025 11:46:19 +0100 Subject: [PATCH 30/57] Fixed segmentation fault for test cases --- SU2_CFD/src/solvers/CSolver.cpp | 3 ++- SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/src/solvers/CSolver.cpp b/SU2_CFD/src/solvers/CSolver.cpp index 2263b2c94f3c..90c4a0aaa74f 100644 --- a/SU2_CFD/src/solvers/CSolver.cpp +++ b/SU2_CFD/src/solvers/CSolver.cpp @@ -3696,7 +3696,7 @@ void CSolver::LoadInletProfile(CGeometry **geometry, columnValue << config->GetInlet_SpeciesVal(Marker_Tag)[iVar] << "\t"; } break; - case SPECIES_MODEL::FLAMELET: + case SPECIES_MODEL::FLAMELET: { const auto flamelet_config_options = config->GetFlameletParsedOptions(); /*--- 2-equation flamelet model ---*/ columnName << "PROGRESSVAR" << setw(24) << "ENTHALPYTOT" << setw(24); @@ -3706,6 +3706,7 @@ void CSolver::LoadInletProfile(CGeometry **geometry, columnName << flamelet_config_options.user_scalar_names[iReactant] << setw(24); columnValue << config->GetInlet_SpeciesVal(Marker_Tag)[flamelet_config_options.n_control_vars + iReactant] << "\t"; } + } break; } diff --git a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp index e57fd11a5f80..440145b5102a 100644 --- a/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp @@ -519,7 +519,7 @@ unsigned long CSpeciesFlameletSolver::SetScalarSources(const CConfig* config, CF /*--- The source term for progress variable is always positive, we clip from below to makes sure. --- */ - vector source_scalar(flamelet_config_options.n_control_vars); + vector source_scalar(flamelet_config_options.n_scalars); for (auto iCV = 0u; iCV < flamelet_config_options.n_control_vars; iCV++) source_scalar[iCV] = table_sources[iCV]; /*--- Source term for the auxiliary species transport equations. ---*/ From 53c5e6958999da3801a73d3bdd026cee00fe78ee Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Fri, 28 Feb 2025 11:47:01 +0100 Subject: [PATCH 31/57] clang format --- UnitTests/SU2_CFD/fluid/CFluidModel_tests.cpp | 47 +++++++++---------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/UnitTests/SU2_CFD/fluid/CFluidModel_tests.cpp b/UnitTests/SU2_CFD/fluid/CFluidModel_tests.cpp index c0d18f54a1c0..639d15a7b739 100644 --- a/UnitTests/SU2_CFD/fluid/CFluidModel_tests.cpp +++ b/UnitTests/SU2_CFD/fluid/CFluidModel_tests.cpp @@ -31,15 +31,14 @@ #include "../../../SU2_CFD/include/fluid/CIdealGas.hpp" #include "../../../SU2_CFD/include/fluid/CDataDrivenFluid.hpp" -void FluidModelChecks(CFluidModel * fluid_model, const su2double val_p, const su2double val_T) { - +void FluidModelChecks(CFluidModel* fluid_model, const su2double val_p, const su2double val_T) { /*--- Check consistency of reverse look-up ---*/ { fluid_model->SetTDState_PT(val_p, val_T); const su2double val_rho_fluidmodel = fluid_model->GetDensity(); const su2double val_e_fluidmodel = fluid_model->GetStaticEnergy(); - + fluid_model->SetTDState_rhoe(val_rho_fluidmodel, val_e_fluidmodel); CHECK(Approx(fluid_model->GetPressure()) == val_p); CHECK(Approx(fluid_model->GetTemperature()) == val_T); @@ -48,23 +47,23 @@ void FluidModelChecks(CFluidModel * fluid_model, const su2double val_p, const su fluid_model->SetTDState_PT(val_p, val_T); const su2double val_rho = fluid_model->GetDensity(); const su2double val_e = fluid_model->GetStaticEnergy(); - + const su2double dTdrho_e = fluid_model->GetdTdrho_e(); const su2double dPdrho_e = fluid_model->GetdPdrho_e(); const su2double dTde_rho = fluid_model->GetdTde_rho(); - const su2double dPde_rho= fluid_model->GetdPde_rho(); + const su2double dPde_rho = fluid_model->GetdPde_rho(); su2double delta_rho = 1e-2, delta_e = 100.0; { - fluid_model->SetTDState_rhoe(val_rho+delta_rho, val_e); + fluid_model->SetTDState_rhoe(val_rho + delta_rho, val_e); const su2double T_plus = fluid_model->GetTemperature(); const su2double p_plus = fluid_model->GetPressure(); - fluid_model->SetTDState_rhoe(val_rho-delta_rho, val_e); + fluid_model->SetTDState_rhoe(val_rho - delta_rho, val_e); const su2double T_minus = fluid_model->GetTemperature(); const su2double p_minus = fluid_model->GetPressure(); - const su2double dTdrho_e_FD = (T_plus - T_minus)/(2*delta_rho); - const su2double dPdrho_e_FD = (p_plus - p_minus)/(2*delta_rho); + const su2double dTdrho_e_FD = (T_plus - T_minus) / (2 * delta_rho); + const su2double dPdrho_e_FD = (p_plus - p_minus) / (2 * delta_rho); CHECK(dTdrho_e == Approx(dTdrho_e_FD)); CHECK(dPdrho_e == Approx(dPdrho_e_FD)); @@ -77,8 +76,8 @@ void FluidModelChecks(CFluidModel * fluid_model, const su2double val_p, const su fluid_model->SetTDState_rhoe(val_rho, val_e - delta_e); const su2double T_minus = fluid_model->GetTemperature(); const su2double p_minus = fluid_model->GetPressure(); - const su2double dTde_rho_FD = (T_plus - T_minus)/(2*delta_e); - const su2double dPde_rho_FD = (p_plus - p_minus)/(2*delta_e); + const su2double dTde_rho_FD = (T_plus - T_minus) / (2 * delta_e); + const su2double dPde_rho_FD = (p_plus - p_minus) / (2 * delta_e); CHECK(dTde_rho == Approx(dTde_rho_FD)); CHECK(dPde_rho == Approx(dPde_rho_FD)); @@ -86,35 +85,34 @@ void FluidModelChecks(CFluidModel * fluid_model, const su2double val_p, const su } TEST_CASE("Test case for ideal gas fluid model") { + CIdealGas* fluid_model = new CIdealGas(1.4, 287.0); - CIdealGas * fluid_model = new CIdealGas(1.4, 287.0); + FluidModelChecks(fluid_model, 101325, 300.0); + FluidModelChecks(fluid_model, 1e6, 600.0); - FluidModelChecks(fluid_model, 101325, 300.0); - FluidModelChecks(fluid_model, 1e6, 600.0); - - delete fluid_model; + delete fluid_model; } TEST_CASE("Test case for data-driven fluid model") { std::stringstream config_options; config_options << "SOLVER=RANS" << std::endl; - config_options<<"KIND_TURB_MODEL=SA"< Date: Fri, 28 Feb 2025 12:15:23 +0100 Subject: [PATCH 32/57] Fixed initialization of flame and spark parameters --- Common/include/option_structure.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 5516c1be7976..db9e50b0e600 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -1424,8 +1424,10 @@ struct FluidFlamelet_ParsedOptions { 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 flame_init; /*!< \brief Flame front initialization parameters. */ - std::array spark_init; /*!< \brief Spark ignition initialization parameters. */ + std::array flame_init{{0,0,0, /* flame offset (x,y,z) */ + 1,0,0, /* flame normal (nx, ny, nz) */ + 5e-3,1}}; /*!< \brief Flame front initialization parameters. */ + std::array spark_init{{0,0,0,0,0,0}}; /*!< \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.*/ From a645b123cd2615d0fd08704408e9ceab931d50a5 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Fri, 28 Feb 2025 12:19:49 +0100 Subject: [PATCH 33/57] Removed initialization of flame and spark parameters --- Common/src/CConfig.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 2fb000e65c74..e8bb064963a8 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1392,17 +1392,10 @@ void CConfig::SetConfig_Options() { /*!\brief FLAME_INIT_METHOD \n DESCRIPTION: Ignition method for flamelet solver \n DEFAULT: no ignition; cold flow only. */ addEnumOption("FLAME_INIT_METHOD", flamelet_ParsedOptions.ignition_method, Flamelet_Init_Map, FLAMELET_INIT_TYPE::NONE); /*!\brief FLAME_INIT \n DESCRIPTION: flame front initialization using the flamelet model \ingroup Config*/ - /*--- flame offset (x,y,z) ---*/ - flamelet_ParsedOptions.flame_init[0] = 0.0; flamelet_ParsedOptions.flame_init[1] = 0.0; flamelet_ParsedOptions.flame_init[2] = 0.0; - /*--- flame normal (nx, ny, nz) ---*/ - flamelet_ParsedOptions.flame_init[3] = 1.0; flamelet_ParsedOptions.flame_init[4] = 0.0; flamelet_ParsedOptions.flame_init[5] = 0.0; - /*--- flame thickness (x) and flame burnt thickness (after this thickness, we have unburnt conditions again) ---*/ - flamelet_ParsedOptions.flame_init[6] = 0.5e-3; flamelet_ParsedOptions.flame_init[7] = 1.0; - addDoubleArrayOption("FLAME_INIT", 8,flamelet_ParsedOptions.flame_init.begin()); + addDoubleArrayOption("FLAME_INIT", flamelet_ParsedOptions.flame_init.size(),flamelet_ParsedOptions.flame_init.begin()); /*!\brief SPARK_INIT \n DESCRIPTION: spark initialization using the flamelet model \ingroup Config*/ - for (auto iSpark=0u; iSpark<6; ++iSpark) flamelet_ParsedOptions.spark_init[iSpark]=0; - addDoubleArrayOption("SPARK_INIT", 6, flamelet_ParsedOptions.spark_init.begin()); + addDoubleArrayOption("SPARK_INIT", flamelet_ParsedOptions.spark_init.size(), flamelet_ParsedOptions.spark_init.begin()); /*!\brief SPARK_REACTION_RATES \n DESCRIPTION: Net source term values applied to species within spark area during spark ignition. \ingroup Config*/ addDoubleListOption("SPARK_REACTION_RATES", flamelet_ParsedOptions.nspark, flamelet_ParsedOptions.spark_reaction_rates); From 4da22341b0d23fd2e071dd90625ccef144fd37b5 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Fri, 28 Feb 2025 12:20:30 +0100 Subject: [PATCH 34/57] Updated options from develop --- TestCases/turbomachinery/APU_turbocharger/Jones_restart.cfg | 4 ++-- TestCases/turbomachinery/APU_turbocharger/rotor.cfg | 4 ++-- TestCases/turbomachinery/APU_turbocharger/rotor_restart.cfg | 4 ++-- .../turbomachinery/Aachen_turbine/aachen_3D_MP_restart.cfg | 4 ++-- TestCases/turbomachinery/Aachen_turbine/rotor.cfg | 4 ++-- TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg | 4 ++-- .../turbomachinery/multi_interface/multi_interface_rst.cfg | 2 +- .../transonic_stator_2D/transonic_stator_restart.cfg | 4 ++-- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/TestCases/turbomachinery/APU_turbocharger/Jones_restart.cfg b/TestCases/turbomachinery/APU_turbocharger/Jones_restart.cfg index 405bea3ae75e..52223cd96504 100755 --- a/TestCases/turbomachinery/APU_turbocharger/Jones_restart.cfg +++ b/TestCases/turbomachinery/APU_turbocharger/Jones_restart.cfg @@ -79,8 +79,8 @@ TURBOMACHINERY_KIND= CENTRIPETAL CENTRIPETAL_AXIAL TURBO_PERF_KIND = TURBINE TURBINE MIXINGPLANE_INTERFACE_KIND= LINEAR_INTERPOLATION TURBULENT_MIXINGPLANE= YES -RAMP_OUTLET_PRESSURE= NO -RAMP_OUTLET_PRESSURE_COEFF= (400000.0, 10.0, 500) +RAMP_OUTLET= NO +RAMP_OUTLET_COEFF= (400000.0, 10.0, 500) AVERAGE_PROCESS_KIND= MIXEDOUT PERFORMANCE_AVERAGE_PROCESS_KIND= MIXEDOUT MIXEDOUT_COEFF= (1.0, 1.0E-05, 15) diff --git a/TestCases/turbomachinery/APU_turbocharger/rotor.cfg b/TestCases/turbomachinery/APU_turbocharger/rotor.cfg index e1b64c618bf4..8558690af39c 100644 --- a/TestCases/turbomachinery/APU_turbocharger/rotor.cfg +++ b/TestCases/turbomachinery/APU_turbocharger/rotor.cfg @@ -3,5 +3,5 @@ GRID_MOVEMENT= ROTATING_FRAME MACH_MOTION= 0.35 ROTATION_RATE= 0.0 0.0 7508.3 -RAMP_ROTATING_FRAME= YES -RAMP_ROTATING_FRAME_COEFF= (0.0, 39.0, 500) +RAMP_MOTION_FRAME= YES +RAMP_MOTION_FRAME_COEFF= (0.0, 39.0, 500) diff --git a/TestCases/turbomachinery/APU_turbocharger/rotor_restart.cfg b/TestCases/turbomachinery/APU_turbocharger/rotor_restart.cfg index df0cc2365455..09194a8eb4bc 100644 --- a/TestCases/turbomachinery/APU_turbocharger/rotor_restart.cfg +++ b/TestCases/turbomachinery/APU_turbocharger/rotor_restart.cfg @@ -3,5 +3,5 @@ GRID_MOVEMENT= ROTATING_FRAME MACH_MOTION= 0.35 ROTATION_RATE= 0.0 0.0 7508.3 -RAMP_ROTATING_FRAME= NO -RAMP_ROTATING_FRAME_COEFF= (0.0, 39.0, 500) +RAMP_MOTION_FRAME= NO +RAMP_MOTION_FRAME_COEFF= (0.0, 39.0, 500) diff --git a/TestCases/turbomachinery/Aachen_turbine/aachen_3D_MP_restart.cfg b/TestCases/turbomachinery/Aachen_turbine/aachen_3D_MP_restart.cfg index 05c383114b8b..8a8b23c08024 100755 --- a/TestCases/turbomachinery/Aachen_turbine/aachen_3D_MP_restart.cfg +++ b/TestCases/turbomachinery/Aachen_turbine/aachen_3D_MP_restart.cfg @@ -173,10 +173,10 @@ MIXINGPLANE_INTERFACE_KIND= LINEAR_INTERPOLATION TURBULENT_MIXINGPLANE= YES % % Specify ramp option for Outlet pressure (YES, NO) default NO -RAMP_OUTLET_PRESSURE= NO +RAMP_OUTLET= NO % % Parameters of the outlet pressure ramp (starting outlet pressure, updating-iteration-frequency, total number of iteration for the ramp) -RAMP_OUTLET_PRESSURE_COEFF= (140000.0, 150.0, 2000) +RAMP_OUTLET_COEFF= (140000.0, 150.0, 2000) % % Specify Kind of average process for linearizing the Navier-Stokes equation at inflow and outflow BC included mixing-plane % (ALGEBRAIC, AREA, MASSSFLUX, MIXEDOUT) default AREA diff --git a/TestCases/turbomachinery/Aachen_turbine/rotor.cfg b/TestCases/turbomachinery/Aachen_turbine/rotor.cfg index ed7d886a96bd..2478ffd8e3e6 100644 --- a/TestCases/turbomachinery/Aachen_turbine/rotor.cfg +++ b/TestCases/turbomachinery/Aachen_turbine/rotor.cfg @@ -13,7 +13,7 @@ MOTION_ORIGIN= 0.0 0.0 0.0 ROTATION_RATE= 0.0 0.0 -366.52 % Specify ramp option fr rotating frame (YES, NO) default NO -RAMP_ROTATING_FRAME= NO +RAMP_MOTION_FRAME= NO % % Parameters of the rotating frame ramp (starting rotational speed, updating-iteration-frequency, total number of iteration for the ramp) -RAMP_ROTATING_FRAME_COEFF= (0.0, 39.0, 500) +RAMP_MOTION_FRAME_COEFF= (0.0, 39.0, 500) diff --git a/TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg b/TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg index f53bdcf2baa4..49cffd50b731 100755 --- a/TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg +++ b/TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg @@ -81,8 +81,8 @@ SPATIAL_FOURIER= NO TURBOMACHINERY_KIND= AXIAL AXIAL TURBO_PERF_KIND = TURBINE TURBINE TURBULENT_MIXINGPLANE= YES -RAMP_OUTLET_PRESSURE= NO -RAMP_OUTLET_PRESSURE_COEFF= (140000.0, 10.0, 2000) +RAMP_OUTLET= NO +RAMP_OUTLET_COEFF= (140000.0, 10.0, 2000) AVERAGE_PROCESS_KIND= MIXEDOUT PERFORMANCE_AVERAGE_PROCESS_KIND= MIXEDOUT MIXEDOUT_COEFF= (1.0, 1.0E-05, 15) diff --git a/TestCases/turbomachinery/multi_interface/multi_interface_rst.cfg b/TestCases/turbomachinery/multi_interface/multi_interface_rst.cfg index 8d5c456d2a0e..b9d9220257f2 100644 --- a/TestCases/turbomachinery/multi_interface/multi_interface_rst.cfg +++ b/TestCases/turbomachinery/multi_interface/multi_interface_rst.cfg @@ -78,7 +78,7 @@ TURBOMACHINERY_KIND= AXIAL, AXIAL, AXIAL TURBO_PERF_KIND= (TURBINE, TURBINE, TURBINE) MIXINGPLANE_INTERFACE_KIND= LINEAR_INTERPOLATION TURBULENT_MIXINGPLANE= YES -RAMP_OUTLET_PRESSURE= NO +RAMP_OUTLET= NO AVERAGE_PROCESS_KIND= MIXEDOUT PERFORMANCE_AVERAGE_PROCESS_KIND= MIXEDOUT MIXEDOUT_COEFF= (1.0, 1.0E-05, 100) diff --git a/TestCases/turbomachinery/transonic_stator_2D/transonic_stator_restart.cfg b/TestCases/turbomachinery/transonic_stator_2D/transonic_stator_restart.cfg index 9ae4300d381b..46f007f1267c 100644 --- a/TestCases/turbomachinery/transonic_stator_2D/transonic_stator_restart.cfg +++ b/TestCases/turbomachinery/transonic_stator_2D/transonic_stator_restart.cfg @@ -76,8 +76,8 @@ SPATIAL_FOURIER= YES % TURBOMACHINERY_KIND = AXIAL TURBO_PERF_KIND = TURBINE -RAMP_OUTLET_PRESSURE= NO -RAMP_OUTLET_PRESSURE_COEFF= (700000.0, 10.0, 500) +RAMP_OUTLET= NO +RAMP_OUTLET_COEFF= (700000.0, 10.0, 500) AVERAGE_PROCESS_KIND= MIXEDOUT PERFORMANCE_AVERAGE_PROCESS_KIND= MIXEDOUT MIXEDOUT_COEFF= (1.0, 1.0E-05, 15) From 6924ec76c51d2f9c078f9fde07ad621226019724 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Fri, 28 Feb 2025 13:32:13 +0100 Subject: [PATCH 35/57] include array package --- Common/include/option_structure.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index db9e50b0e600..2bc268970883 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include From cc31e6bedcca89cab111b2de4f9bb7006e19a217 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Fri, 28 Feb 2025 13:32:31 +0100 Subject: [PATCH 36/57] Removed pressure ramp options --- .../transonic_stator_2D/transonic_stator.cfg | 4 ++-- TestCases/nicf/datadriven/datadriven_nozzle.cfg | 2 -- config_template.cfg | 17 +++++++++-------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/TestCases/disc_adj_turbomachinery/transonic_stator_2D/transonic_stator.cfg b/TestCases/disc_adj_turbomachinery/transonic_stator_2D/transonic_stator.cfg index 479586fc59ff..989aa9bd00c6 100644 --- a/TestCases/disc_adj_turbomachinery/transonic_stator_2D/transonic_stator.cfg +++ b/TestCases/disc_adj_turbomachinery/transonic_stator_2D/transonic_stator.cfg @@ -76,8 +76,8 @@ SPATIAL_FOURIER= YES % TURBOMACHINERY_KIND = AXIAL TURBO_PERF_KIND = TURBINE -RAMP_OUTLET_PRESSURE= NO -RAMP_OUTLET_PRESSURE_COEFF= (700000.0, 10.0, 500) +RAMP_OUTLET= NO +RAMP_OUTLET_COEFF= (700000.0, 10.0, 500) AVERAGE_PROCESS_KIND= MIXEDOUT PERFORMANCE_AVERAGE_PROCESS_KIND= MIXEDOUT MIXEDOUT_COEFF= (1.0, 1.0E-05, 15) diff --git a/TestCases/nicf/datadriven/datadriven_nozzle.cfg b/TestCases/nicf/datadriven/datadriven_nozzle.cfg index fb7c93c7ace0..38dfd82a5197 100644 --- a/TestCases/nicf/datadriven/datadriven_nozzle.cfg +++ b/TestCases/nicf/datadriven/datadriven_nozzle.cfg @@ -54,8 +54,6 @@ MARKER_HEATFLUX= (WALL, 0.0) MARKER_RIEMANN= ( INFLOW, TOTAL_CONDITIONS_PT, 3361842.0, 189.288, 1.0, 0.0, 0.0, \ OUTFLOW, STATIC_PRESSURE, 747076.0, 0.0, 0.0, 0.0, 0.0 ) -RAMP_OUTLET_PRESSURE= NO -RAMP_OUTLET_PRESSURE_COEFF= (3361842.0, 1, 20) % ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% NUM_METHOD_GRAD= GREEN_GAUSS diff --git a/config_template.cfg b/config_template.cfg index 0acf538f8562..246395cd10f6 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -735,19 +735,20 @@ MIXINGPLANE_INTERFACE_KIND= LINEAR_INTERPOLATION % Specify option for turbulent mixing-plane (YES, NO) default NO TURBULENT_MIXINGPLANE= YES % -% Specify ramp option for Outlet pressure (YES, NO) default NO -RAMP_OUTLET_PRESSURE= NO +% Specify ramp option for Outlet Giles value (YES, NO) default NO +RAMP_OUTLET= NO % -% Parameters of the outlet pressure ramp (starting outlet pressure, +% Parameters of the outlet Giles ramp (starting outlet value, % updating-iteration-frequency, total number of iteration for the ramp) -RAMP_OUTLET_PRESSURE_COEFF= (400000.0, 10.0, 500) +RAMP_OUTLET_COEFF= (400000.0, 10.0, 500) % -% Specify ramp option for rotating frame (YES, NO) default NO -RAMP_ROTATING_FRAME= YES +% Specify ramp option for frame of motion (YES, NO) default NO +RAMP_MOTION_FRAME= YES % -% Parameters of the rotating frame ramp (starting rotational speed, +% Parameters of the frame of motion ramp (starting frame of motion speed, % updating-iteration-frequency, total number of iteration for the ramp) -RAMP_ROTATING_FRAME_COEFF= (0.0, 39.0, 500) +RAMP_MOTION_FRAME_COEFF= (0.0, 39.0, 500) +% % % Specify Kind of average process for linearizing the Navier-Stokes % equation at inflow and outflow BCs included at the mixing-plane interface From 3e6586664700d4badb454f01ae4f14c7c6c8cf01 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Mon, 3 Mar 2025 13:48:09 +0100 Subject: [PATCH 37/57] Reverted changes from PR#2419 and pass fluid flamelet and data-driven fluid options through const reference --- Common/include/CConfig.hpp | 100 +++++++----------- Common/src/CConfig.cpp | 73 +++---------- SU2_CFD/include/iteration/CFluidIteration.hpp | 5 +- SU2_CFD/src/iteration/CFluidIteration.cpp | 84 +++++++-------- 4 files changed, 94 insertions(+), 168 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 3f7fe8869e0c..e81cd11b1acc 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -1072,19 +1072,12 @@ class CConfig { unsigned short *nSpan_iZones; /*!< \brief number of span-wise sections for each zones */ bool turbMixingPlane; /*!< \brief option for turbulent mixingplane */ bool SpatialFourier; /*!< \brief option for computing the fourier transforms for subsonic non-reflecting BC. */ - bool RampMotionFrame; /*!< \brief option for ramping up or down the motion Frame values */ - bool RampOutlet; /*!< \brief option for ramping up or down the outlet values */ - bool RampRotatingFrame; /*!< \brief option for ramping up or down the motion Frame values */ - bool RampTranslationFrame; /*!< \brief option for ramping up or down the outlet values */ - bool RampOutletMassFlow; /*!< \brief option for ramping up or down the motion Frame values */ - bool RampOutletPressure; /*!< \brief option for ramping up or down the outlet values */ + bool RampRotatingFrame; /*!< \brief option for ramping up or down the Rotating Frame values */ + bool RampOutletPressure; /*!< \brief option for ramping up or down the outlet pressure */ su2double AverageMachLimit; /*!< \brief option for turbulent mixingplane */ su2double FinalRotation_Rate_Z; /*!< \brief Final rotation rate Z if Ramp rotating frame is activated. */ - su2double FinalTranslation_Rate_Y; /*!< \brief Final translation rate Y if Ramp translation frame is activated. */ su2double FinalOutletPressure; /*!< \brief Final outlet pressure if Ramp outlet pressure is activated. */ - su2double FinalOutletMassFlow; /*!< \brief Final outlet mass flow rate if Ramp outlet mass flow rate is activated */ su2double MonitorOutletPressure; /*!< \brief Monitor outlet pressure if Ramp outlet pressure is activated. */ - su2double MonitorOutletMassFlow; /*!< \brief Monitor outlet mass flow rate if ramp outlet mass flow rate is activated. */ array cp_polycoeffs{{0.0}}; /*!< \brief Array for specific heat polynomial coefficients. */ array mu_polycoeffs{{0.0}}; /*!< \brief Array for viscosity polynomial coefficients. */ array kt_polycoeffs{{0.0}}; /*!< \brief Array for thermal conductivity polynomial coefficients. */ @@ -1133,8 +1126,8 @@ class CConfig { jst_coeff[2], /*!< \brief artificial dissipation (flow) array for the COption class. */ ffd_coeff[3], /*!< \brief artificial dissipation (flow) array for the COption class. */ mixedout_coeff[3], /*!< \brief default mixedout algorithm coefficients for the COption class. */ - rampMotionFrame_coeff[3], /*!< \brief ramp motion frame coefficients for the COption class. */ - rampOutlet_coeff[3], /*!< \brief ramp outlet value coefficients for the COption class. */ + rampRotFrame_coeff[3], /*!< \brief ramp rotating frame coefficients for the COption class. */ + rampOutPres_coeff[3], /*!< \brief ramp outlet pressure coefficients for the COption class. */ jst_adj_coeff[2], /*!< \brief artificial dissipation (adjoint) array for the COption class. */ mesh_box_length[3], /*!< \brief mesh box length for the COption class. */ mesh_box_offset[3], /*!< \brief mesh box offset for the COption class. */ @@ -5026,46 +5019,45 @@ class CConfig { void SetKind_PerformanceAverageProcess(unsigned short new_AverageProcess) { Kind_PerformanceAverageProcess = new_AverageProcess; } /*! - * \brief Get Motion Frame Ramp option. - * \return Ramp Motion Frame option. + * \brief Get coeff for Rotating Frame Ramp. + * \return coeff Ramp Rotating Frame. */ - bool GetRampMotionFrame(void) const { return RampMotionFrame; } + su2double GetRampRotatingFrame_Coeff(unsigned short iCoeff) const { return rampRotFrame_coeff[iCoeff];} /*! - * \brief Get coeff for ramping the frame of motion (translation/rotation) [TURBO ONLY] - * \return coeff Ramp for frame of motion - */ - su2double GetRampMotionFrame_Coeff(unsigned short iCoeff) const { return rampMotionFrame_coeff[iCoeff];} + * \brief Get Rotating Frame Ramp option. + * \return Ramp Rotating Frame option. + */ + bool GetRampRotatingFrame(void) const { return RampRotatingFrame;} /*! - * \brief Get outflow ramp option. - * \return Ramp outflow option. + * \brief Get coeff for Outlet Pressure Ramp. + * \return coeff Ramp Outlet Pressure. */ - bool GetRampOutflow(void) const { return RampOutlet; } + su2double GetRampOutletPressure_Coeff(unsigned short iCoeff) const { return rampOutPres_coeff[iCoeff];} /*! - * \brief Get coeff for ramping the Giles boundary outflow (pressure/mass flow) [TURBO ONLY] - * \return coeff Ramp for Giles outflow - */ - su2double GetRampOutflow_Coeff(unsigned short iCoeff) const { return rampOutlet_coeff[iCoeff]; } + * \brief Get final Outlet Pressure value for the ramp. + * \return final Outlet Pressure value. + */ + su2double GetFinalOutletPressure(void) const { return FinalOutletPressure; } /*! - * \brief General interface for accessing ramp coefficient information - * \return coeff for ramps - */ - su2double GetRamp_Coeff(RAMP_TYPE ramp_flag, RAMP_COEFF val_coeff) { - if (ramp_flag == RAMP_TYPE::GRID) return rampMotionFrame_coeff[val_coeff]; - else if (ramp_flag == RAMP_TYPE::BOUNDARY) return rampOutlet_coeff[val_coeff]; - else return 0; - }; + * \brief Get final Outlet Pressure value for the ramp. + * \return Monitor Outlet Pressure value. + */ + su2double GetMonitorOutletPressure(void) const { return MonitorOutletPressure; } /*! - * \brief Generic interface for setting monitor outlet values for the ramp. + * \brief Set Monitor Outlet Pressure value for the ramp. */ - void SetMonitorValue(su2double newMon_val) { - if (RampOutletPressure) MonitorOutletPressure = newMon_val; - else if (RampOutletMassFlow) MonitorOutletMassFlow = newMon_val; - } + void SetMonitorOutletPressure(su2double newMonPres) { MonitorOutletPressure = newMonPres;} + + /*! + * \brief Get Outlet Pressure Ramp option. + * \return Ramp Outlet pressure option. + */ + bool GetRampOutletPressure(void) const { return RampOutletPressure;} /*! * \brief Get mixedout coefficients. @@ -5924,16 +5916,6 @@ class CConfig { */ void SetRotation_Rate(unsigned short iDim, su2double val) { Rotation_Rate[iDim] = val;} - /*! - * \brief General interface for setting the rate of motion in grid ramps - * \param[in] ramp_flag - flag for type of ramp - * \param[in] val - new value of rate of motion - */ - void SetRate(su2double val) { - if (RampRotatingFrame) Rotation_Rate[2] = val; - else if (RampTranslationFrame) Translation_Rate[1] = val; - }; - /*! * \brief Get the rotation rate of the marker. * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) @@ -6028,16 +6010,16 @@ class CConfig { su2double GetMarkerPlunging_Ampl(unsigned short iMarkerMoving, unsigned short iDim) const { return MarkerPlunging_Ampl[3*iMarkerMoving + iDim];} /*! - * \brief Generic interface for retrieving final value of a turbomachinery ramp - * \return Final value of a specified ramp + * \brief Get the angular velocity of the mesh about the z-axis. + * \return Angular velocity of the mesh about the z-axis. + */ + su2double GetFinalRotation_Rate_Z() const { return FinalRotation_Rate_Z;} + + /*! + * \brief Set the angular velocity of the mesh about the z-axis. + * \param[in] newRotation_Rate_Z - new rotation rate after computing the ramp value. */ - su2double GetFinalValue(RAMP_TYPE ramp_flag) { - if (ramp_flag == RAMP_TYPE::GRID && RampRotatingFrame) return FinalRotation_Rate_Z; - else if (ramp_flag == RAMP_TYPE::GRID && RampTranslationFrame) return FinalTranslation_Rate_Y; - else if (ramp_flag == RAMP_TYPE::BOUNDARY && RampOutletPressure) return FinalOutletPressure; - else if (ramp_flag == RAMP_TYPE::BOUNDARY && RampOutletMassFlow) return FinalOutletMassFlow; - else return 0.0; - }; + void SetRotation_Rate_Z(su2double newRotation_Rate_Z); /*! * \brief Get the Harmonic Balance frequency pointer. @@ -9823,12 +9805,12 @@ class CConfig { * \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; } + const 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; } + const FluidFlamelet_ParsedOptions& GetFlameletParsedOptions() const { return flamelet_ParsedOptions; } }; diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index e8bb064963a8..a18129ed5517 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1620,20 +1620,20 @@ void CConfig::SetConfig_Options() { * the 2nd coefficient is the tolerance for the Newton method, 3rd coefficient is the maximum number of * iteration for the Newton Method.*/ addDoubleArrayOption("MIXEDOUT_COEFF", 3, mixedout_coeff); - /*!\brief RAMP_MOTION_FRAME\n DESCRIPTION: option to ramp up or down the frame of motion velocity value*/ - addBoolOption("RAMP_MOTION_FRAME", RampMotionFrame, false); - rampMotionFrame_coeff[0] = 100.0; rampMotionFrame_coeff[1] = 1.0; rampMotionFrame_coeff[2] = 1000.0; - /*!\brief RAMP_MOTION_FRAME_COEFF \n DESCRIPTION: the 1st coeff is the staring outlet value, - * the 2nd coeff is the number of iterations for the update, 3rd is the number of total iteration till reaching the final outlet pressure value */ - addDoubleArrayOption("RAMP_MOTION_FRAME_COEFF", 3, rampMotionFrame_coeff); + /*!\brief RAMP_ROTATING_FRAME\n DESCRIPTION: option to ramp up or down the rotating frame velocity value*/ + addBoolOption("RAMP_ROTATING_FRAME", RampRotatingFrame, false); + rampRotFrame_coeff[0] = 0; rampRotFrame_coeff[1] = 1.0; rampRotFrame_coeff[2] = 1000.0; + /*!\brief RAMP_ROTATING_FRAME_COEFF \n DESCRIPTION: the 1st coeff is the staring velocity, + * the 2nd coeff is the number of iterations for the update, 3rd is the number of iteration */ + addDoubleArrayOption("RAMP_ROTATING_FRAME_COEFF", 3, rampRotFrame_coeff); /* DESCRIPTION: AVERAGE_MACH_LIMIT is a limit value for average procedure based on the mass flux. */ addDoubleOption("AVERAGE_MACH_LIMIT", AverageMachLimit, 0.03); - /*!\brief RAMP_OUTLET\n DESCRIPTION: option to ramp up or down the Giles outlet value*/ - addBoolOption("RAMP_OUTLET", RampOutlet, false); - rampOutlet_coeff[0] = 100000.0; rampOutlet_coeff[1] = 1.0; rampOutlet_coeff[2] = 1000.0; - /*!\brief RAMP_OUTLET_COEFF \n DESCRIPTION: the 1st coeff is the staring outlet value, + /*!\brief RAMP_OUTLET_PRESSURE\n DESCRIPTION: option to ramp up or down the rotating frame velocity value*/ + addBoolOption("RAMP_OUTLET_PRESSURE", RampOutletPressure, false); + rampOutPres_coeff[0] = 100000.0; rampOutPres_coeff[1] = 1.0; rampOutPres_coeff[2] = 1000.0; + /*!\brief RAMP_OUTLET_PRESSURE_COEFF \n DESCRIPTION: the 1st coeff is the staring outlet pressure, * the 2nd coeff is the number of iterations for the update, 3rd is the number of total iteration till reaching the final outlet pressure value */ - addDoubleArrayOption("RAMP_OUTLET_COEFF", 3, rampOutlet_coeff); + addDoubleArrayOption("RAMP_OUTLET_PRESSURE_COEFF", 3, rampOutPres_coeff); /*!\brief MARKER_MIXINGPLANE \n DESCRIPTION: Identify the boundaries in which the mixing plane is applied. \ingroup Config*/ addStringListOption("MARKER_MIXINGPLANE_INTERFACE", nMarker_MixingPlaneInterface, Marker_MixingPlaneInterface); /*!\brief TURBULENT_MIXINGPLANE \n DESCRIPTION: Activate mixing plane also for turbulent quantities \ingroup Config*/ @@ -3073,14 +3073,6 @@ void CConfig::SetConfig_Parsing(istream& config_buffer){ newString.append("SPECIES_USE_STRONG_BC is deprecated. Use MARKER_SPECIES_STRONG_BC= (marker1, ...) instead.\n\n"); else if (!option_name.compare("DEAD_LOAD")) newString.append("DEAD_LOAD is deprecated. Use GRAVITY_FORCE or BODY_FORCE instead.\n\n"); - else if (!option_name.compare("RAMP_OUTLET_PRESSURE")) - newString.append("RAMP_OUTLET_PRESSURE is deprectaed. Use RAMP_OUTLET instead"); - else if (!option_name.compare("RAMP_OUTLET_PRESSURE_COEFF")) - newString.append("RAMP_OUTLET_PRESSURE_COEFF is deprectaed. Use RAMP_OUTLET_COEFF instead"); - else if (!option_name.compare("RAMP_ROTATION_FRAME")) - newString.append("RAMP_ROTATION_FRAME is deprectaed. Use RAMP_MOTION_FRAME instead"); - else if (!option_name.compare("RAMP_ROTATION_FRAME_COEFF")) - newString.append("RAMP_ROTATION_FRAME_COEFF is deprectaed. Use RAMP_MOTION_FRAME_COEFF instead"); else { /*--- Find the most likely candidate for the unrecognized option, based on the length of start and end character sequences shared by candidates and the option. ---*/ @@ -4362,37 +4354,11 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i nSpan_iZones = new unsigned short[nZone]; } - /*--- Interface for handling turbo ramps ---*/ - if (GetGrid_Movement() && RampMotionFrame && !DiscreteAdjoint) { - if (Kind_GridMovement == ENUM_GRIDMOVEMENT::ROTATING_FRAME) RampRotatingFrame = true; - else if (Kind_GridMovement == ENUM_GRIDMOVEMENT::STEADY_TRANSLATION) RampTranslationFrame = true; - } - - if(RampOutlet && !DiscreteAdjoint) { - for (iMarker = 0; iMarker < nMarker_Giles; iMarker++){ - switch (Kind_Data_Giles[iMarker]) { - case STATIC_PRESSURE: case STATIC_PRESSURE_1D: case RADIAL_EQUILIBRIUM: - RampOutletPressure = true; - break; - case MASS_FLOW_OUTLET: - RampOutletMassFlow = true; - break; - } - } - } - /*--- Set number of TurboPerformance markers ---*/ if(GetGrid_Movement() && RampRotatingFrame && !DiscreteAdjoint){ FinalRotation_Rate_Z = Rotation_Rate[2]; if(abs(FinalRotation_Rate_Z) > 0.0){ - Rotation_Rate[2] = rampMotionFrame_coeff[RAMP_COEFF::INITIAL_VALUE]; - } - } - - if(GetGrid_Movement() && RampTranslationFrame && !DiscreteAdjoint){ - FinalTranslation_Rate_Y = Translation_Rate[1]; - if(abs(FinalTranslation_Rate_Y) > 0.0){ - Translation_Rate[1] = rampMotionFrame_coeff[RAMP_COEFF::INITIAL_VALUE]; + Rotation_Rate[2] = rampRotFrame_coeff[0]; } } @@ -4400,22 +4366,13 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i for (iMarker = 0; iMarker < nMarker_Giles; iMarker++){ if (Kind_Data_Giles[iMarker] == STATIC_PRESSURE || Kind_Data_Giles[iMarker] == STATIC_PRESSURE_1D || Kind_Data_Giles[iMarker] == RADIAL_EQUILIBRIUM ){ FinalOutletPressure = Giles_Var1[iMarker]; - Giles_Var1[iMarker] = rampOutlet_coeff[RAMP_COEFF::INITIAL_VALUE]; + Giles_Var1[iMarker] = rampOutPres_coeff[0]; } } for (iMarker = 0; iMarker < nMarker_Riemann; iMarker++){ if (Kind_Data_Riemann[iMarker] == STATIC_PRESSURE || Kind_Data_Riemann[iMarker] == RADIAL_EQUILIBRIUM){ FinalOutletPressure = Riemann_Var1[iMarker]; - Riemann_Var1[iMarker] = rampOutlet_coeff[RAMP_COEFF::INITIAL_VALUE]; - } - } - } - - if(RampOutletMassFlow && !DiscreteAdjoint){ - for (iMarker = 0; iMarker < nMarker_Giles; iMarker++){ - if (Kind_Data_Giles[iMarker] == MASS_FLOW_OUTLET){ - FinalOutletMassFlow = Giles_Var1[iMarker]; - Giles_Var1[iMarker] = rampOutlet_coeff[RAMP_COEFF::INITIAL_VALUE]; + Riemann_Var1[iMarker] = rampOutPres_coeff[0]; } } } @@ -5460,9 +5417,7 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i } RampOutletPressure = false; - RampOutletMassFlow = false; RampRotatingFrame = false; - RampTranslationFrame = false; } /* 2nd-order MUSCL is not possible for the continuous adjoint diff --git a/SU2_CFD/include/iteration/CFluidIteration.hpp b/SU2_CFD/include/iteration/CFluidIteration.hpp index fc196419a9b4..346f763581cf 100644 --- a/SU2_CFD/include/iteration/CFluidIteration.hpp +++ b/SU2_CFD/include/iteration/CFluidIteration.hpp @@ -108,14 +108,13 @@ class CFluidIteration : public CIteration { unsigned short val_iInst) override; /*! - * \brief Monitors and updates ramps + * \brief Monitors turbo computation (pressure and turbo ramps). * \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 - * \param[in] ramp_flag - Flag indicating type of ramp (grid or boundary) */ - void UpdateRamp(CGeometry**** geometry_container, CConfig** config_container, unsigned long iter, unsigned short iZone, RAMP_TYPE ramp_flag); + void TurboMonitor(CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter, unsigned short iZone); /*! * \brief Computes turboperformance. diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index 2e60d087b7de..4ca6c45a1724 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -232,15 +232,9 @@ bool CFluidIteration::Monitor(COutput* output, CIntegration**** integration, CGe config, TurbomachineryStagePerformance, TurbomachineryPerformance, val_iZone, config[val_iZone]->GetTimeIter(), config[val_iZone]->GetOuterIter(), config[val_iZone]->GetInnerIter(), val_iInst); } - /*--- Update ramps, grid first then outlet boundary ---*/ - if (config[val_iZone]->GetRampMotionFrame()) - UpdateRamp(geometry, config, config[val_iZone]->GetInnerIter(), val_iZone, RAMP_TYPE::GRID); - } - - // Outside turbo scope as Riemann boundaries can be ramped (pressure only) - if (config[val_iZone]->GetRampOutflow()) - UpdateRamp(geometry, config, config[val_iZone]->GetInnerIter(), val_iZone, RAMP_TYPE::BOUNDARY); + TurboMonitor(geometry, config, config[val_iZone]->GetInnerIter(), val_iZone); + } output->SetHistoryOutput(geometry[val_iZone][val_iInst][MESH_0], solver[val_iZone][val_iInst][MESH_0], config[val_iZone], config[val_iZone]->GetTimeIter(), config[val_iZone]->GetOuterIter(), config[val_iZone]->GetInnerIter()); @@ -257,39 +251,35 @@ bool CFluidIteration::Monitor(COutput* output, CIntegration**** integration, CGe return StopCalc; } -void CFluidIteration::UpdateRamp(CGeometry**** geometry_container, CConfig** config_container, unsigned long iter, unsigned short iZone, RAMP_TYPE ramp_flag) { - /*--- Generic function for handling ramps ---*/ - // Grid updates (i.e. rotation/translation) handled seperately to boundary (i.e. pressure/mass flow) updates +void CFluidIteration::TurboMonitor(CGeometry**** geometry_container, CConfig** config_container, unsigned long iter, unsigned short iZone) { auto* config = config_container[iZone]; - auto* geometry = geometry_container[iZone][INST_0][ZONE_0]; - - std::string msg = "\nUpdated rotating frame grid velocities for zone "; - if (ramp_flag == RAMP_TYPE::GRID && config->GetKind_GridMovement() == ENUM_GRIDMOVEMENT::STEADY_TRANSLATION) - msg = "\nUpdated translation frame grid velocities for zone "; if (config_container[ZONE_0]->GetMultizone_Problem()) iter = config_container[ZONE_0]->GetOuterIter(); - - /*-- Update grid velocities (ROTATING_FRAME, STEADY_TRANSLATION)*/ - if (ramp_flag == RAMP_TYPE::GRID && config->GetGrid_Movement()) { - const auto ini_vel = config->GetRamp_Coeff(ramp_flag, RAMP_COEFF::INITIAL_VALUE); - const long unsigned rampFreq = SU2_TYPE::Int(config->GetRamp_Coeff(ramp_flag, RAMP_COEFF::UPDATE_FREQ)); - const long unsigned finalRamp_Iter = SU2_TYPE::Int(config->GetRamp_Coeff(ramp_flag, RAMP_COEFF::FINAL_ITER)); - - // Two options needed as if finalRamp_Iter % rampFreq != 0 final value is not set correctly - if((iter % rampFreq == 0 && iter < finalRamp_Iter) || (iter == finalRamp_Iter)){ - const auto final_vel = config->GetFinalValue(ramp_flag); - if(fabs(final_vel) > 0.0) { - const auto vel = ini_vel + iter * (final_vel - ini_vel)/finalRamp_Iter; - config->SetRate(vel); - if (rank == MASTER_NODE && iter > 0) cout << msg << iZone << ".\n"; - geometry->SetVelocity(config, true); - geometry->SetShroudVelocity(config); + /*--- ROTATING FRAME Ramp: Compute the updated rotational velocity. ---*/ + if (config->GetGrid_Movement() && config->GetRampRotatingFrame()) { + const unsigned long rampFreq = SU2_TYPE::Int(config->GetRampRotatingFrame_Coeff(1)); + const unsigned long finalRamp_Iter = SU2_TYPE::Int(config->GetRampRotatingFrame_Coeff(2)); + const su2double rot_z_ini = config->GetRampRotatingFrame_Coeff(0); + const bool print = (config->GetComm_Level() == COMM_FULL); + + if(iter % rampFreq == 0 && iter <= finalRamp_Iter){ + + const su2double rot_z_final = config->GetFinalRotation_Rate_Z(); + + if (fabs(rot_z_final) > 0.0) { + const su2double rot_z = rot_z_ini + iter * ( rot_z_final - rot_z_ini) / finalRamp_Iter; + config->SetRotation_Rate(2, rot_z); + if (rank == MASTER_NODE && iter > 0) { + cout << "\nUpdated rotating frame grid velocities for zone " << iZone << ".\n"; + } + geometry_container[iZone][INST_0][MESH_0]->SetRotationalVelocity(config, print); + geometry_container[iZone][INST_0][MESH_0]->SetShroudVelocity(config); } - // Update average turbo values - geometry->SetAvgTurboValue(config, iZone, INFLOW, false); - geometry->SetAvgTurboValue(config, iZone, OUTFLOW, false); - geometry->GatherInOutAverageValues(config, false); + + geometry_container[iZone][INST_0][MESH_0]->SetAvgTurboValue(config, iZone, INFLOW, false); + geometry_container[iZone][INST_0][MESH_0]->SetAvgTurboValue(config, iZone, OUTFLOW, false); + geometry_container[iZone][INST_0][MESH_0]->GatherInOutAverageValues(config, false); if (iZone < nZone - 1) { geometry_container[nZone-1][INST_0][MESH_0]->SetAvgTurboGeoValues(config ,geometry_container[iZone][INST_0][MESH_0], iZone); @@ -297,16 +287,16 @@ void CFluidIteration::UpdateRamp(CGeometry**** geometry_container, CConfig** con } } - // Boundary ramps (pressure/mass flow) - if (ramp_flag == RAMP_TYPE::BOUNDARY){ - const auto outVal_ini = config->GetRamp_Coeff(ramp_flag, RAMP_COEFF::INITIAL_VALUE); - const long unsigned rampFreq = SU2_TYPE::Int(config->GetRamp_Coeff(ramp_flag, RAMP_COEFF::UPDATE_FREQ)); - const long unsigned finalRamp_Iter = SU2_TYPE::Int(config->GetRamp_Coeff(ramp_flag, RAMP_COEFF::FINAL_ITER)); - const auto outVal_final = config->GetFinalValue(ramp_flag); + /*--- Outlet Pressure Ramp: Compute the updated pressure. ---*/ + if (config->GetRampOutletPressure()) { + const unsigned long rampFreq = SU2_TYPE::Int(config->GetRampOutletPressure_Coeff(1)); + const unsigned long finalRamp_Iter = SU2_TYPE::Int(config->GetRampOutletPressure_Coeff(2)); + const su2double outPres_ini = config->GetRampOutletPressure_Coeff(0); + const su2double outPres_final = config->GetFinalOutletPressure(); - if ((iter % rampFreq == 0 && iter < finalRamp_Iter) || (iter == finalRamp_Iter)) { - const su2double outVal = outVal_ini + iter * (outVal_final - outVal_ini) / finalRamp_Iter; - if (rank == MASTER_NODE) config->SetMonitorValue(outVal); + if (iter % rampFreq == 0 && iter <= finalRamp_Iter) { + const su2double outPres = outPres_ini + iter * (outPres_final - outPres_ini) / finalRamp_Iter; + if (rank == MASTER_NODE) config->SetMonitorOutletPressure(outPres); for (auto iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { const auto KindBC = config->GetMarker_All_KindBC(iMarker); @@ -322,8 +312,8 @@ void CFluidIteration::UpdateRamp(CGeometry**** geometry_container, CConfig** con case GILES_BOUNDARY: KindBCOption = config->GetKind_Data_Giles(Marker_Tag); if (KindBCOption == STATIC_PRESSURE || KindBCOption == STATIC_PRESSURE_1D || - KindBCOption == RADIAL_EQUILIBRIUM || KindBCOption == MASS_FLOW_OUTLET) { - config->SetGiles_Var1(outVal, Marker_Tag); + KindBCOption == RADIAL_EQUILIBRIUM ) { + config->SetGiles_Var1(outPres, Marker_Tag); } break; } From 6f3ff33f49a461efc3da23b66aba8cf222a84466 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Mon, 3 Mar 2025 13:52:25 +0100 Subject: [PATCH 38/57] Removed commented out code --- SU2_CFD/src/fluid/CFluidFlamelet.cpp | 16 +++++++-------- SU2_CFD/src/output/CAdjFlowOutput.cpp | 18 ++++++++--------- SU2_CFD/src/output/CFlowOutput.cpp | 20 +++++++++---------- SU2_CFD/src/solvers/CSolver.cpp | 2 +- .../variables/CSpeciesFlameletVariable.cpp | 2 +- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/SU2_CFD/src/fluid/CFluidFlamelet.cpp b/SU2_CFD/src/fluid/CFluidFlamelet.cpp index d9920d3fa47f..ad70a85011d7 100644 --- a/SU2_CFD/src/fluid/CFluidFlamelet.cpp +++ b/SU2_CFD/src/fluid/CFluidFlamelet.cpp @@ -55,7 +55,7 @@ CFluidFlamelet::CFluidFlamelet(CConfig* config, su2double value_pressure_operati scalars_vector.resize(n_scalars); table_scalar_names.resize(n_scalars); - for (auto iCV = 0u; iCV < n_control_vars; iCV++) table_scalar_names[iCV] = flamelet_options.controlling_variable_names[iCV];//->GetControllingVariableName(iCV); + for (auto iCV = 0u; iCV < n_control_vars; iCV++) table_scalar_names[iCV] = flamelet_options.controlling_variable_names[iCV]; /*--- auxiliary species transport equations---*/ for (auto i_aux = 0u; i_aux < n_user_scalars; i_aux++) { @@ -67,7 +67,7 @@ CFluidFlamelet::CFluidFlamelet(CConfig* config, su2double value_pressure_operati controlling_variable_names[iCV] =flamelet_options.controlling_variable_names[iCV]; passive_specie_names.resize(n_user_scalars); - for (auto i_aux = 0u; i_aux < n_user_scalars; i_aux++) passive_specie_names[i_aux] = flamelet_options.user_scalar_names[i_aux];//config->GetUserScalarName(i_aux); + for (auto i_aux = 0u; i_aux < n_user_scalars; i_aux++) passive_specie_names[i_aux] = flamelet_options.user_scalar_names[i_aux]; switch (Kind_DataDriven_Method) { case ENUM_DATADRIVEN_METHOD::LUT: @@ -173,7 +173,7 @@ void CFluidFlamelet::PreprocessLookUp(CConfig* config) { varnames_Sources.resize(n_sources); val_vars_Sources.resize(n_sources); for (auto iCV = 0u; iCV < n_control_vars; iCV++) - varnames_Sources[iCV] = flamelet_options.cv_source_names[iCV];//->GetControllingVariableSourceName(iCV); + varnames_Sources[iCV] = flamelet_options.cv_source_names[iCV]; /*--- No source term for enthalpy ---*/ /*--- For the auxiliary equations, we use a positive (production) and a negative (consumption) term: @@ -181,12 +181,12 @@ void CFluidFlamelet::PreprocessLookUp(CConfig* config) { for (size_t i_aux = 0; i_aux < n_user_scalars; i_aux++) { /*--- Order of the source terms: S_prod_1, S_cons_1, S_prod_2, S_cons_2, ...---*/ - varnames_Sources[n_control_vars + 2 * i_aux] = flamelet_options.user_source_names[2 * i_aux];//>GetUserSourceName(2 * i_aux); - varnames_Sources[n_control_vars + 2 * i_aux + 1] = flamelet_options.user_source_names[2 * i_aux + 1];//config->GetUserSourceName(2 * i_aux + 1); + varnames_Sources[n_control_vars + 2 * i_aux] = flamelet_options.user_source_names[2 * i_aux]; + varnames_Sources[n_control_vars + 2 * i_aux + 1] = flamelet_options.user_source_names[2 * i_aux + 1]; } /*--- Passive look-up terms ---*/ - size_t n_lookups = flamelet_options.n_lookups;//>GetNLookups(); + size_t n_lookups = flamelet_options.n_lookups; if (n_lookups == 0) { varnames_LookUp.resize(1); val_vars_LookUp.resize(1); @@ -194,7 +194,7 @@ void CFluidFlamelet::PreprocessLookUp(CConfig* config) { } else { varnames_LookUp.resize(n_lookups); val_vars_LookUp.resize(n_lookups); - for (auto iLookup = 0u; iLookup < n_lookups; iLookup++) varnames_LookUp[iLookup] = flamelet_options.lookup_names[iLookup];//>GetLookupName(iLookup); + for (auto iLookup = 0u; iLookup < n_lookups; iLookup++) varnames_LookUp[iLookup] = flamelet_options.lookup_names[iLookup]; } /*--- Preferential diffusion scalars ---*/ @@ -211,7 +211,7 @@ void CFluidFlamelet::PreprocessLookUp(CConfig* config) { val_vars_PD[FLAMELET_PREF_DIFF_SCALARS::I_BETA_ENTH] = beta_enth; val_vars_PD[FLAMELET_PREF_DIFF_SCALARS::I_BETA_MIXFRAC] = beta_mixfrac; - preferential_diffusion = flamelet_options.preferential_diffusion;//>GetPreferentialDiffusion(); + preferential_diffusion = flamelet_options.preferential_diffusion; switch (Kind_DataDriven_Method) { case ENUM_DATADRIVEN_METHOD::LUT: preferential_diffusion = look_up_table->CheckForVariables(varnames_PD); diff --git a/SU2_CFD/src/output/CAdjFlowOutput.cpp b/SU2_CFD/src/output/CAdjFlowOutput.cpp index c50c08b10a6d..2e64e674baf6 100644 --- a/SU2_CFD/src/output/CAdjFlowOutput.cpp +++ b/SU2_CFD/src/output/CAdjFlowOutput.cpp @@ -62,13 +62,13 @@ void CAdjFlowOutput::AddHistoryOutputFields_AdjScalarRMS_RES(const CConfig* conf } if (config->GetKind_Species_Model() == SPECIES_MODEL::FLAMELET) { - const auto flamelet_config_options = config->GetFlameletParsedOptions(); + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { - const auto& cv_name = config->GetFlameletParsedOptions().controlling_variable_names[iCV]; + const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; AddHistoryOutput("RMS_ADJ_"+cv_name, "rms[" + cv_name + "]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of the adjoint " + cv_name, HistoryFieldType::RESIDUAL); } for (unsigned short i_scalar = 0; i_scalar < flamelet_config_options.n_user_scalars; i_scalar++) { - const auto& scalar_name = config->GetFlameletParsedOptions().user_scalar_names[i_scalar];//config->GetUserScalarName(i_scalar); + const auto& scalar_name = flamelet_config_options.user_scalar_names[i_scalar]; AddHistoryOutput("RMS_ADJ_" + scalar_name, "rms[" + scalar_name + "]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of the adjoint of " + scalar_name + " .", HistoryFieldType::RESIDUAL); } } @@ -99,7 +99,7 @@ void CAdjFlowOutput::AddHistoryOutputFields_AdjScalarMAX_RES(const CConfig* conf } if (config->GetKind_Species_Model() == SPECIES_MODEL::FLAMELET) { - const auto flamelet_config_options = config->GetFlameletParsedOptions(); + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; AddHistoryOutput("MAX_ADJ_" + cv_name, "max["+cv_name +"]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the adjoint " + cv_name, HistoryFieldType::RESIDUAL); @@ -138,7 +138,7 @@ void CAdjFlowOutput::AddHistoryOutputFields_AdjScalarBGS_RES(const CConfig* conf } if (config->GetKind_Species_Model() == SPECIES_MODEL::FLAMELET) { - const auto flamelet_config_options = config->GetFlameletParsedOptions(); + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; AddHistoryOutput("BGS_ADJ_" + cv_name, "bgs[" + cv_name + "]", ScreenOutputFormat::FIXED, "BGS_RES", "BGS residual of the adjoint " + cv_name, HistoryFieldType::RESIDUAL); @@ -216,7 +216,7 @@ void CAdjFlowOutput::LoadHistoryDataAdjScalar(const CConfig* config, const CSolv } if (config->GetKind_Species_Model() == SPECIES_MODEL::FLAMELET) { - const auto flamelet_config_options = config->GetFlameletParsedOptions(); + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; SetHistoryOutputValue("RMS_ADJ_"+cv_name, log10(adjspecies_solver->GetRes_RMS(iCV))); @@ -267,7 +267,7 @@ void CAdjFlowOutput::SetVolumeOutputFieldsAdjScalarSolution(const CConfig* confi } if (config->GetKind_Species_Model() == SPECIES_MODEL::FLAMELET) { - const auto flamelet_config_options = config->GetFlameletParsedOptions(); + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; AddVolumeOutput("ADJ_" + cv_name, "Adjoint_" + cv_name, "SOLUTION", "Adjoint of the " + cv_name + " controlling variable."); @@ -309,7 +309,7 @@ void CAdjFlowOutput::SetVolumeOutputFieldsAdjScalarResidual(const CConfig* confi } if (config->GetKind_Species_Model() == SPECIES_MODEL::FLAMELET) { - const auto flamelet_config_options = config->GetFlameletParsedOptions(); + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); for(auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; AddVolumeOutput("RES_ADJ_" + cv_name, "Residual_Adjoint_" + cv_name, "RESIDUAL", "Residual of the adjoint of " + cv_name); @@ -357,7 +357,7 @@ void CAdjFlowOutput::LoadVolumeDataAdjScalar(const CConfig* config, const CSolve } if (config->GetKind_Species_Model() == SPECIES_MODEL::FLAMELET) { - const auto flamelet_config_options = config->GetFlameletParsedOptions(); + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; SetVolumeOutputValue("ADJ_" + cv_name, iPoint, Node_AdjSpecies->GetSolution(iPoint, iCV)); diff --git a/SU2_CFD/src/output/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index ac1bd8f92d95..94344a26c06e 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -995,7 +995,7 @@ void CFlowOutput::AddHistoryOutputFields_ScalarRMS_RES(const CConfig* config) { break; } case SPECIES_MODEL::FLAMELET: { - const auto flamelet_config_options = config->GetFlameletParsedOptions(); + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); /*--- Controlling variable transport. ---*/ for (auto iCV = 0u; iCV < flamelet_config_options.n_control_vars; iCV++){ const auto& CV_name = flamelet_config_options.controlling_variable_names[iCV]; @@ -1053,7 +1053,7 @@ void CFlowOutput::AddHistoryOutputFields_ScalarMAX_RES(const CConfig* config) { break; } case SPECIES_MODEL::FLAMELET: { - const auto flamelet_config_options = config->GetFlameletParsedOptions(); + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); /*--- Controlling variable transport. ---*/ for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++){ const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; @@ -1109,7 +1109,7 @@ void CFlowOutput::AddHistoryOutputFields_ScalarBGS_RES(const CConfig* config) { break; } case SPECIES_MODEL::FLAMELET: { - const auto flamelet_config_options = config->GetFlameletParsedOptions(); + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); /*--- Controlling variable transport. ---*/ for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++){ const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; @@ -1216,7 +1216,7 @@ void CFlowOutput::LoadHistoryDataScalar(const CConfig* config, const CSolver* co } case SPECIES_MODEL::FLAMELET: { - const auto flamelet_config_options = config->GetFlameletParsedOptions(); + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); /*--- Controlling variable transport. ---*/ for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++){ const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; @@ -1279,7 +1279,7 @@ void CFlowOutput::SetVolumeOutputFieldsScalarSolution(const CConfig* config){ } break; case SPECIES_MODEL::FLAMELET: { - const auto flamelet_config_options = config->GetFlameletParsedOptions(); + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); /*--- Controlling variables. ---*/ for (auto iCV=0u; iCVGetFlameletParsedOptions(); + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); /*--- Residuals for controlling variable transport equations. ---*/ for (auto iCV=0u; iCVGetFlameletParsedOptions(); + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); /*--- Limiter for controlling variables transport. ---*/ for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; @@ -1431,7 +1431,7 @@ void CFlowOutput::SetVolumeOutputFieldsScalarSource(const CConfig* config) { switch (config->GetKind_Species_Model()) { case SPECIES_MODEL::FLAMELET: { - const auto flamelet_config_options = config->GetFlameletParsedOptions(); + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { const auto& cv_source_name = flamelet_config_options.cv_source_names[iCV]; const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; @@ -1456,7 +1456,7 @@ void CFlowOutput::SetVolumeOutputFieldsScalarLookup(const CConfig* config) { /*--- Only place outputs of the "LOOKUP" group for scalar transport here. ---*/ if (config->GetKind_Species_Model() == SPECIES_MODEL::FLAMELET) { - const auto flamelet_config_options = config->GetFlameletParsedOptions(); + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); for (auto i_lookup = 0u; i_lookup < flamelet_config_options.n_lookups; ++i_lookup) { string strname1 = "lookup_" + flamelet_config_options.lookup_names[i_lookup]; AddVolumeOutput(flamelet_config_options.lookup_names[i_lookup], strname1,"LOOKUP", flamelet_config_options.lookup_names[i_lookup]); @@ -1593,7 +1593,7 @@ void CFlowOutput::LoadVolumeDataScalar(const CConfig* config, const CSolver* con case SPECIES_MODEL::FLAMELET: { const auto Node_Species = solver[SPECIES_SOL]->GetNodes(); - const auto flamelet_config_options = config->GetFlameletParsedOptions(); + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); /*--- Controlling variables transport equations. ---*/ for (auto iCV=0u; iCV < flamelet_config_options.n_control_vars; iCV++) { const auto& cv_name = flamelet_config_options.controlling_variable_names[iCV]; diff --git a/SU2_CFD/src/solvers/CSolver.cpp b/SU2_CFD/src/solvers/CSolver.cpp index 90c4a0aaa74f..009910e91a2a 100644 --- a/SU2_CFD/src/solvers/CSolver.cpp +++ b/SU2_CFD/src/solvers/CSolver.cpp @@ -3697,7 +3697,7 @@ void CSolver::LoadInletProfile(CGeometry **geometry, } break; case SPECIES_MODEL::FLAMELET: { - const auto flamelet_config_options = config->GetFlameletParsedOptions(); + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); /*--- 2-equation flamelet model ---*/ columnName << "PROGRESSVAR" << setw(24) << "ENTHALPYTOT" << setw(24); columnValue << config->GetInlet_SpeciesVal(Marker_Tag)[0] << "\t" << config->GetInlet_SpeciesVal(Marker_Tag)[1]<<"\t"; diff --git a/SU2_CFD/src/variables/CSpeciesFlameletVariable.cpp b/SU2_CFD/src/variables/CSpeciesFlameletVariable.cpp index d6d444ec934f..f9e38b971773 100644 --- a/SU2_CFD/src/variables/CSpeciesFlameletVariable.cpp +++ b/SU2_CFD/src/variables/CSpeciesFlameletVariable.cpp @@ -49,7 +49,7 @@ CSpeciesFlameletVariable::CSpeciesFlameletVariable(const su2double* species_inf, Res_TruncError.resize(nPoint, nVar) = su2double(0.0); /* Allocate space for the source and scalars for visualization */ - const auto flamelet_config_options = config->GetFlameletParsedOptions(); + const auto& flamelet_config_options = config->GetFlameletParsedOptions(); source_scalar.resize(nPoint, flamelet_config_options.n_scalars) = su2double(0.0); lookup_scalar.resize(nPoint, flamelet_config_options.n_lookups) = su2double(0.0); table_misses.resize(nPoint) = 0; From 670f008a14c349e0ce0c383cf376a39e47f5d62d Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Mon, 3 Mar 2025 13:53:22 +0100 Subject: [PATCH 39/57] Reverted changes from merging with PR#2419 --- TestCases/turbomachinery/APU_turbocharger/Jones_restart.cfg | 4 ++-- TestCases/turbomachinery/APU_turbocharger/rotor.cfg | 4 ++-- TestCases/turbomachinery/APU_turbocharger/rotor_restart.cfg | 4 ++-- .../turbomachinery/Aachen_turbine/aachen_3D_MP_restart.cfg | 4 ++-- TestCases/turbomachinery/Aachen_turbine/rotor.cfg | 4 ++-- TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg | 4 ++-- .../turbomachinery/multi_interface/multi_interface_rst.cfg | 2 +- .../transonic_stator_2D/transonic_stator_restart.cfg | 4 ++-- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/TestCases/turbomachinery/APU_turbocharger/Jones_restart.cfg b/TestCases/turbomachinery/APU_turbocharger/Jones_restart.cfg index 52223cd96504..405bea3ae75e 100755 --- a/TestCases/turbomachinery/APU_turbocharger/Jones_restart.cfg +++ b/TestCases/turbomachinery/APU_turbocharger/Jones_restart.cfg @@ -79,8 +79,8 @@ TURBOMACHINERY_KIND= CENTRIPETAL CENTRIPETAL_AXIAL TURBO_PERF_KIND = TURBINE TURBINE MIXINGPLANE_INTERFACE_KIND= LINEAR_INTERPOLATION TURBULENT_MIXINGPLANE= YES -RAMP_OUTLET= NO -RAMP_OUTLET_COEFF= (400000.0, 10.0, 500) +RAMP_OUTLET_PRESSURE= NO +RAMP_OUTLET_PRESSURE_COEFF= (400000.0, 10.0, 500) AVERAGE_PROCESS_KIND= MIXEDOUT PERFORMANCE_AVERAGE_PROCESS_KIND= MIXEDOUT MIXEDOUT_COEFF= (1.0, 1.0E-05, 15) diff --git a/TestCases/turbomachinery/APU_turbocharger/rotor.cfg b/TestCases/turbomachinery/APU_turbocharger/rotor.cfg index 8558690af39c..e1b64c618bf4 100644 --- a/TestCases/turbomachinery/APU_turbocharger/rotor.cfg +++ b/TestCases/turbomachinery/APU_turbocharger/rotor.cfg @@ -3,5 +3,5 @@ GRID_MOVEMENT= ROTATING_FRAME MACH_MOTION= 0.35 ROTATION_RATE= 0.0 0.0 7508.3 -RAMP_MOTION_FRAME= YES -RAMP_MOTION_FRAME_COEFF= (0.0, 39.0, 500) +RAMP_ROTATING_FRAME= YES +RAMP_ROTATING_FRAME_COEFF= (0.0, 39.0, 500) diff --git a/TestCases/turbomachinery/APU_turbocharger/rotor_restart.cfg b/TestCases/turbomachinery/APU_turbocharger/rotor_restart.cfg index 09194a8eb4bc..df0cc2365455 100644 --- a/TestCases/turbomachinery/APU_turbocharger/rotor_restart.cfg +++ b/TestCases/turbomachinery/APU_turbocharger/rotor_restart.cfg @@ -3,5 +3,5 @@ GRID_MOVEMENT= ROTATING_FRAME MACH_MOTION= 0.35 ROTATION_RATE= 0.0 0.0 7508.3 -RAMP_MOTION_FRAME= NO -RAMP_MOTION_FRAME_COEFF= (0.0, 39.0, 500) +RAMP_ROTATING_FRAME= NO +RAMP_ROTATING_FRAME_COEFF= (0.0, 39.0, 500) diff --git a/TestCases/turbomachinery/Aachen_turbine/aachen_3D_MP_restart.cfg b/TestCases/turbomachinery/Aachen_turbine/aachen_3D_MP_restart.cfg index 8a8b23c08024..05c383114b8b 100755 --- a/TestCases/turbomachinery/Aachen_turbine/aachen_3D_MP_restart.cfg +++ b/TestCases/turbomachinery/Aachen_turbine/aachen_3D_MP_restart.cfg @@ -173,10 +173,10 @@ MIXINGPLANE_INTERFACE_KIND= LINEAR_INTERPOLATION TURBULENT_MIXINGPLANE= YES % % Specify ramp option for Outlet pressure (YES, NO) default NO -RAMP_OUTLET= NO +RAMP_OUTLET_PRESSURE= NO % % Parameters of the outlet pressure ramp (starting outlet pressure, updating-iteration-frequency, total number of iteration for the ramp) -RAMP_OUTLET_COEFF= (140000.0, 150.0, 2000) +RAMP_OUTLET_PRESSURE_COEFF= (140000.0, 150.0, 2000) % % Specify Kind of average process for linearizing the Navier-Stokes equation at inflow and outflow BC included mixing-plane % (ALGEBRAIC, AREA, MASSSFLUX, MIXEDOUT) default AREA diff --git a/TestCases/turbomachinery/Aachen_turbine/rotor.cfg b/TestCases/turbomachinery/Aachen_turbine/rotor.cfg index 2478ffd8e3e6..ed7d886a96bd 100644 --- a/TestCases/turbomachinery/Aachen_turbine/rotor.cfg +++ b/TestCases/turbomachinery/Aachen_turbine/rotor.cfg @@ -13,7 +13,7 @@ MOTION_ORIGIN= 0.0 0.0 0.0 ROTATION_RATE= 0.0 0.0 -366.52 % Specify ramp option fr rotating frame (YES, NO) default NO -RAMP_MOTION_FRAME= NO +RAMP_ROTATING_FRAME= NO % % Parameters of the rotating frame ramp (starting rotational speed, updating-iteration-frequency, total number of iteration for the ramp) -RAMP_MOTION_FRAME_COEFF= (0.0, 39.0, 500) +RAMP_ROTATING_FRAME_COEFF= (0.0, 39.0, 500) diff --git a/TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg b/TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg index 49cffd50b731..f53bdcf2baa4 100755 --- a/TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg +++ b/TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg @@ -81,8 +81,8 @@ SPATIAL_FOURIER= NO TURBOMACHINERY_KIND= AXIAL AXIAL TURBO_PERF_KIND = TURBINE TURBINE TURBULENT_MIXINGPLANE= YES -RAMP_OUTLET= NO -RAMP_OUTLET_COEFF= (140000.0, 10.0, 2000) +RAMP_OUTLET_PRESSURE= NO +RAMP_OUTLET_PRESSURE_COEFF= (140000.0, 10.0, 2000) AVERAGE_PROCESS_KIND= MIXEDOUT PERFORMANCE_AVERAGE_PROCESS_KIND= MIXEDOUT MIXEDOUT_COEFF= (1.0, 1.0E-05, 15) diff --git a/TestCases/turbomachinery/multi_interface/multi_interface_rst.cfg b/TestCases/turbomachinery/multi_interface/multi_interface_rst.cfg index b9d9220257f2..8d5c456d2a0e 100644 --- a/TestCases/turbomachinery/multi_interface/multi_interface_rst.cfg +++ b/TestCases/turbomachinery/multi_interface/multi_interface_rst.cfg @@ -78,7 +78,7 @@ TURBOMACHINERY_KIND= AXIAL, AXIAL, AXIAL TURBO_PERF_KIND= (TURBINE, TURBINE, TURBINE) MIXINGPLANE_INTERFACE_KIND= LINEAR_INTERPOLATION TURBULENT_MIXINGPLANE= YES -RAMP_OUTLET= NO +RAMP_OUTLET_PRESSURE= NO AVERAGE_PROCESS_KIND= MIXEDOUT PERFORMANCE_AVERAGE_PROCESS_KIND= MIXEDOUT MIXEDOUT_COEFF= (1.0, 1.0E-05, 100) diff --git a/TestCases/turbomachinery/transonic_stator_2D/transonic_stator_restart.cfg b/TestCases/turbomachinery/transonic_stator_2D/transonic_stator_restart.cfg index 46f007f1267c..9ae4300d381b 100644 --- a/TestCases/turbomachinery/transonic_stator_2D/transonic_stator_restart.cfg +++ b/TestCases/turbomachinery/transonic_stator_2D/transonic_stator_restart.cfg @@ -76,8 +76,8 @@ SPATIAL_FOURIER= YES % TURBOMACHINERY_KIND = AXIAL TURBO_PERF_KIND = TURBINE -RAMP_OUTLET= NO -RAMP_OUTLET_COEFF= (700000.0, 10.0, 500) +RAMP_OUTLET_PRESSURE= NO +RAMP_OUTLET_PRESSURE_COEFF= (700000.0, 10.0, 500) AVERAGE_PROCESS_KIND= MIXEDOUT PERFORMANCE_AVERAGE_PROCESS_KIND= MIXEDOUT MIXEDOUT_COEFF= (1.0, 1.0E-05, 15) From 5a60063b32dffdb53989e7046e2fa3529a597d8c Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Mon, 3 Mar 2025 14:21:50 +0100 Subject: [PATCH 40/57] Reverted pressure ramp option --- .../transonic_stator_2D/transonic_stator.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TestCases/disc_adj_turbomachinery/transonic_stator_2D/transonic_stator.cfg b/TestCases/disc_adj_turbomachinery/transonic_stator_2D/transonic_stator.cfg index 989aa9bd00c6..479586fc59ff 100644 --- a/TestCases/disc_adj_turbomachinery/transonic_stator_2D/transonic_stator.cfg +++ b/TestCases/disc_adj_turbomachinery/transonic_stator_2D/transonic_stator.cfg @@ -76,8 +76,8 @@ SPATIAL_FOURIER= YES % TURBOMACHINERY_KIND = AXIAL TURBO_PERF_KIND = TURBINE -RAMP_OUTLET= NO -RAMP_OUTLET_COEFF= (700000.0, 10.0, 500) +RAMP_OUTLET_PRESSURE= NO +RAMP_OUTLET_PRESSURE_COEFF= (700000.0, 10.0, 500) AVERAGE_PROCESS_KIND= MIXEDOUT PERFORMANCE_AVERAGE_PROCESS_KIND= MIXEDOUT MIXEDOUT_COEFF= (1.0, 1.0E-05, 15) From 06cd02375049c1624691464ca9c33b06c9cf8dc7 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Wed, 5 Mar 2025 14:35:46 +0100 Subject: [PATCH 41/57] Added tutorials branch to regression --- .github/workflows/regression.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 91fe553df80c..42f26a0d26c3 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -209,7 +209,7 @@ jobs: uses: docker://ghcr.io/su2code/su2/test-su2:240320-1536 with: # -t -c - args: -b ${{github.ref}} -t develop -c feature_PINN -s ${{matrix.testscript}} + args: -b ${{github.ref}} -t feature_PINN -c feature_PINN -s ${{matrix.testscript}} - name: Cleanup uses: docker://ghcr.io/su2code/su2/test-su2:240320-1536 with: From a9ceb0c142497dc2af694dbfa1a37361ec149149 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Wed, 5 Mar 2025 15:30:30 +0100 Subject: [PATCH 42/57] Updated regression test values according to changes to RANS solver --- TestCases/parallel_regression.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index dac29de62042..066a6f66d4a9 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1066,7 +1066,7 @@ def main(): datadriven_fluidModel.cfg_dir = "nicf/datadriven" datadriven_fluidModel.cfg_file = "datadriven_nozzle.cfg" datadriven_fluidModel.test_iter = 50 - datadriven_fluidModel.test_vals = [-5.506499, -3.447247, -3.859876, -1.251899, -2.140268, 1.267121] + datadriven_fluidModel.test_vals = [-6.337491, -3.836046, -4.350978, -1.846961, -2.671950, 0.839927] test_list.append(datadriven_fluidModel) ###################################### From 880b1a3d08d996aa5c8735a961172b8c77d155db Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Thu, 13 Mar 2025 13:15:51 +0100 Subject: [PATCH 43/57] Const correctness for Newton-solvers --- SU2_CFD/include/fluid/CDataDrivenFluid.hpp | 16 ++++++++-------- SU2_CFD/src/fluid/CDataDrivenFluid.cpp | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/SU2_CFD/include/fluid/CDataDrivenFluid.hpp b/SU2_CFD/include/fluid/CDataDrivenFluid.hpp index aba771f4932e..a7fda2c6dd36 100644 --- a/SU2_CFD/include/fluid/CDataDrivenFluid.hpp +++ b/SU2_CFD/include/fluid/CDataDrivenFluid.hpp @@ -68,6 +68,7 @@ class CDataDrivenFluid final : public CFluidModel { 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. */ @@ -83,8 +84,6 @@ 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. */ @@ -95,10 +94,11 @@ class CDataDrivenFluid final : public CFluidModel { vector outputs_rhoe; /*!< \brief Pointers to output variables. */ - vector> dsdrhoe; - vector>> d2sdrhoe2; + vector> dsdrhoe; /*!< \brief Entropy Jacobian terms. */ + vector>> d2sdrhoe2; /*!< \brief Entropy Hessian terms. */ + + bool use_MLP_derivatives; /*!< \brief Use physics-informed model. */ - 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. */ @@ -157,8 +157,8 @@ class CDataDrivenFluid final : public CFluidModel { * \param[in] dY2drho - Pointer to the partial derivative of quantity 2 w.r.t. density at constant energy. * \param[in] dY2de - Pointer to the partial derivative of quantity 2 w.r.t. energy at constant density. */ - void Run_Newton_Solver(const su2double Y1_target, const su2double Y2_target, su2double const & Y1, su2double const & Y2, su2double const & dY1drho, - su2double const & dY1de, su2double const & dY2drho, su2double const & dY2de); + void Run_Newton_Solver(const su2double Y1_target, const su2double Y2_target, const su2double & Y1, const su2double & Y2, const su2double & dY1drho, + const su2double & dY1de, const su2double & dY2drho, const su2double & dY2de); /*! * \brief 1D Newton solver for computing the density or energy corresponding to Y_target. @@ -167,7 +167,7 @@ class CDataDrivenFluid final : public CFluidModel { * \param[in] X - Pointer to controlling variable (density or energy). * \param[in] dYdX - Pointer to the partial derivative of target quantity w.r.t. controlling variable. */ - void Run_Newton_Solver(const su2double Y_target, su2double const & Y, su2double & X, su2double const & dYdX); + void Run_Newton_Solver(const su2double Y_target, const su2double & Y, su2double & X, const su2double & dYdX); void ComputeIdealGasQuantities(); diff --git a/SU2_CFD/src/fluid/CDataDrivenFluid.cpp b/SU2_CFD/src/fluid/CDataDrivenFluid.cpp index d25b5c2135c9..ca52697bebf9 100644 --- a/SU2_CFD/src/fluid/CDataDrivenFluid.cpp +++ b/SU2_CFD/src/fluid/CDataDrivenFluid.cpp @@ -338,8 +338,8 @@ void CDataDrivenFluid::Evaluate_Dataset(su2double rho, su2double e) { } } -void CDataDrivenFluid::Run_Newton_Solver(const su2double Y1_target, const su2double Y2_target, su2double const & Y1, su2double const & Y2, - su2double const & dY1drho, su2double const & dY1de, su2double const & dY2drho, su2double const & dY2de) { +void CDataDrivenFluid::Run_Newton_Solver(const su2double Y1_target, const su2double Y2_target, const su2double & Y1, const su2double & Y2, const su2double & dY1drho, + const su2double & dY1de, const su2double & dY2drho, const su2double & dY2de) { /*--- 2D Newton solver, computing the density and internal energy values corresponding to Y1_target and Y2_target. * ---*/ @@ -384,7 +384,7 @@ void CDataDrivenFluid::Run_Newton_Solver(const su2double Y1_target, const su2dou SetTDState_rhoe(Density, StaticEnergy); } -void CDataDrivenFluid::Run_Newton_Solver(const su2double Y_target, su2double const & Y, su2double &X, su2double const & dYdX) { +void CDataDrivenFluid::Run_Newton_Solver(const su2double Y_target, const su2double & Y, su2double & X, const su2double & dYdX) { /*--- 1D Newton solver, computing the density or internal energy value corresponding to Y_target. ---*/ bool converged = false; From e497514ec9899a25a450a61582473680898c10c2 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Tue, 18 Mar 2025 09:17:56 +0100 Subject: [PATCH 44/57] Added AD unit tests for fluid model classes. --- .../SU2_CFD/fluid/CFluidModel_tests_AD.cpp | 160 ++++++++++++++++++ UnitTests/meson.build | 4 +- 2 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 UnitTests/SU2_CFD/fluid/CFluidModel_tests_AD.cpp diff --git a/UnitTests/SU2_CFD/fluid/CFluidModel_tests_AD.cpp b/UnitTests/SU2_CFD/fluid/CFluidModel_tests_AD.cpp new file mode 100644 index 000000000000..715401bd5d78 --- /dev/null +++ b/UnitTests/SU2_CFD/fluid/CFluidModel_tests_AD.cpp @@ -0,0 +1,160 @@ +/*! + * \file CFluidModel_tests.cpp + * \brief AD unit tests for the fluid model classes. + * \author E.Bunschoten + * \version 8.1.0 "Harrier" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2024, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "catch.hpp" +#include +#include "../../../SU2_CFD/include/fluid/CFluidModel.hpp" +#include "../../../SU2_CFD/include/fluid/CIdealGas.hpp" +#include "../../../SU2_CFD/include/fluid/CDataDrivenFluid.hpp" +#include "../../../SU2_CFD/include/fluid/CPengRobinson.hpp" + +void FluidModelADChecks(CFluidModel * fluid_model, su2double val_p, su2double val_T) { + /*--- Consistency tests for the fluid model secondary variables and AD integration. ---*/ + + /*--- Extract fluid density and static energy. ---*/ + fluid_model->SetTDState_PT(val_p, val_T); + su2double val_rho = fluid_model->GetDensity(); + su2double val_e = fluid_model->GetStaticEnergy(); + + /*--- Test 1: check consistency of pressure derivatives. ---*/ + AD::Reset(); + AD::StartRecording(); + AD::RegisterInput(val_rho); + AD::RegisterInput(val_e); + + fluid_model->SetTDState_rhoe(val_rho, val_e); + su2double val_p_pred = fluid_model->GetPressure(); + AD::RegisterOutput(val_p_pred); + AD::StopRecording(); + + SU2_TYPE::SetDerivative(val_p_pred, 1.0); + AD::ComputeAdjoint(); + + /*--- Extract pressure derivatives from fluid model and AD. ---*/ + const su2double dpdrho_e_AD = SU2_TYPE::GetDerivative(val_rho); + const su2double dpde_rho_AD = SU2_TYPE::GetDerivative(val_e); + const su2double dpdrho_e_pred = fluid_model->GetdPdrho_e(); + const su2double dpde_rho_pred = fluid_model->GetdPde_rho(); + + CHECK(SU2_TYPE::GetValue(dpdrho_e_AD) == Approx(SU2_TYPE::GetValue(dpdrho_e_pred))); + CHECK(SU2_TYPE::GetValue(dpde_rho_AD) == Approx(SU2_TYPE::GetValue(dpde_rho_pred))); + + /*--- Test 2: check consistency of temperature derivatives. ---*/ + AD::Reset(); + AD::StartRecording(); + AD::RegisterInput(val_rho); + AD::RegisterInput(val_e); + + fluid_model->SetTDState_rhoe(val_rho, val_e); + su2double val_T_pred = fluid_model->GetTemperature(); + + AD::RegisterOutput(val_T_pred); + AD::StopRecording(); + + SU2_TYPE::SetDerivative(val_T_pred, 1.0); + AD::ComputeAdjoint(); + + /*--- Extract temperature derivatives from fluid model and AD. ---*/ + const su2double dTdrho_e_AD = SU2_TYPE::GetDerivative(val_rho); + const su2double dTde_rho_AD = SU2_TYPE::GetDerivative(val_e); + const su2double dTdrho_e_pred = fluid_model->GetdTdrho_e(); + const su2double dTde_rho_pred = fluid_model->GetdTde_rho(); + + CHECK(SU2_TYPE::GetValue(dTdrho_e_AD) == Approx(SU2_TYPE::GetValue(dTdrho_e_pred))); + CHECK(SU2_TYPE::GetValue(dTde_rho_AD) == Approx(SU2_TYPE::GetValue(dTde_rho_pred))); + + /*--- Test 3: check consistency of specific heat at constant pressure. ---*/ + const su2double drhode_p = -dpde_rho_AD/dpdrho_e_AD; + const su2double dTde_p = dTde_rho_AD + dTdrho_e_AD*drhode_p; + const su2double dhde_rho = 1 + dpde_rho_AD / val_rho; + const su2double dhdrho_e = -val_p * (1 / pow(val_rho, 2)) + dpdrho_e_AD / val_rho; + const su2double dhde_p = dhde_rho + drhode_p*dhdrho_e; + const su2double Cp_AD = dhde_p / dTde_p; + const su2double Cp_pred = fluid_model->GetCp(); + + CHECK(SU2_TYPE::GetValue(Cp_AD) == Approx(SU2_TYPE::GetValue(Cp_pred))); + + /*--- Test 4: check consistency of secondary variables for non-reflecting boundary conditions.---*/ + AD::Reset(); + AD::StartRecording(); + AD::RegisterInput(val_p); + AD::RegisterInput(val_rho); + + fluid_model->ComputeDerivativeNRBC_Prho(val_p, val_rho); + su2double val_s_pred = fluid_model->GetEntropy(); + + AD::RegisterOutput(val_s_pred); + AD::StopRecording(); + + SU2_TYPE::SetDerivative(val_s_pred, 1.0); + AD::ComputeAdjoint(); + const su2double dsdp_rho_AD = SU2_TYPE::GetDerivative(val_p); + const su2double dsdrho_p_AD = SU2_TYPE::GetDerivative(val_rho); + const su2double dsdp_rho_pred = fluid_model->GetdsdP_rho(); + const su2double dsdrho_p_pred = fluid_model->Getdsdrho_P(); + + CHECK(SU2_TYPE::GetValue(dsdp_rho_pred) == Approx(SU2_TYPE::GetValue(dsdp_rho_AD))); + CHECK(SU2_TYPE::GetValue(dsdrho_p_pred) == Approx(SU2_TYPE::GetValue(dsdrho_p_AD))); + +} + +TEST_CASE("AD test case for ideal gas fluid model","[AD tests]") { + + CIdealGas * fluid_model = new CIdealGas(1.4, 287.0,true); + FluidModelADChecks(fluid_model, 101325, 300.0); + + delete fluid_model; +} + + +TEST_CASE("AD test case for data-driven fluid model","[AD tests]") { + std::stringstream config_options; + + config_options << "SOLVER=RANS" << std::endl; + config_options<<"KIND_TURB_MODEL=SA"< Date: Tue, 18 Mar 2025 09:58:27 +0100 Subject: [PATCH 45/57] Added MLPCpp for AD unit tests --- .github/workflows/regression.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 42f26a0d26c3..9e9bbdbc79e6 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -30,7 +30,7 @@ jobs: - config_set: ReverseMPI flags: '-Denable-autodiff=true -Denable-normal=false -Denable-pywrapper=true -Denable-tests=true --warnlevel=3 --werror' - config_set: ForwardMPI - flags: '-Denable-directdiff=true -Denable-normal=false -Denable-tests=true --warnlevel=3 --werror' + flags: '-Denable-directdiff=true -Denable-normal=false -Denable-tests=true -Denable-mlpcpp=true --warnlevel=3 --werror' - config_set: BaseNoMPI flags: '-Denable-pywrapper=true -Denable-openblas=true -Dwith-mpi=disabled -Denable-mlpcpp=true -Denable-tests=true --warnlevel=3 --werror' - config_set: ReverseNoMPI From e22af0ea139864b6f8c73b625a704992313d108d Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Tue, 18 Mar 2025 09:58:54 +0100 Subject: [PATCH 46/57] Check if MLPCpp is enabled before configuring AD unit tests --- UnitTests/meson.build | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/UnitTests/meson.build b/UnitTests/meson.build index 48f55defb39c..3e64cfb9aa3d 100644 --- a/UnitTests/meson.build +++ b/UnitTests/meson.build @@ -19,8 +19,10 @@ su2_cfd_tests = files(['Common/geometry/primal_grid/CPrimalGrid_tests.cpp', 'SU2_CFD/windowing.cpp']) # Reverse-mode (algorithmic differentiation) tests: -su2_cfd_tests_ad = files(['Common/simple_ad_test.cpp', - 'SU2_CFD/fluid/CFluidModel_tests_AD.cpp']) +su2_cfd_tests_ad = files(['Common/simple_ad_test.cpp']) +if get_option('enable-mlpcpp') + su2_cfd_tests_ad = su2_cfd_tests_ad + files(['SU2_CFD/fluid/CFluidModel_tests_AD.cpp']) +endif # Forward-mode (direct differentiation) tests: su2_cfd_tests_dd = files(['Common/simple_directdiff_test.cpp']) From 51bf45c7bdb59295c320b74ed1616a47aaf97d96 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Tue, 18 Mar 2025 09:59:53 +0100 Subject: [PATCH 47/57] Set correct path for MLP file in fluid model AD unit test --- UnitTests/SU2_CFD/fluid/CFluidModel_tests_AD.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnitTests/SU2_CFD/fluid/CFluidModel_tests_AD.cpp b/UnitTests/SU2_CFD/fluid/CFluidModel_tests_AD.cpp index 715401bd5d78..86fbf12f6465 100644 --- a/UnitTests/SU2_CFD/fluid/CFluidModel_tests_AD.cpp +++ b/UnitTests/SU2_CFD/fluid/CFluidModel_tests_AD.cpp @@ -141,7 +141,7 @@ TEST_CASE("AD test case for data-driven fluid model","[AD tests]") { config_options << "FLUID_MODEL=DATADRIVEN_FLUID" << std::endl; config_options << "USE_PINN=YES" << std::endl; config_options << "INTERPOLATION_METHOD=MLP" << std::endl; - config_options << "FILENAMES_INTERPOLATOR=(/home/ecbunschoten/SU2_NICFD/UnitTests/SU2_CFD/fluid/MLP_PINN.mlp)"< Date: Tue, 18 Mar 2025 10:00:58 +0100 Subject: [PATCH 48/57] clang format --- .../SU2_CFD/fluid/CFluidModel_tests_AD.cpp | 44 +++++++++---------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/UnitTests/SU2_CFD/fluid/CFluidModel_tests_AD.cpp b/UnitTests/SU2_CFD/fluid/CFluidModel_tests_AD.cpp index 86fbf12f6465..dbc80e47287a 100644 --- a/UnitTests/SU2_CFD/fluid/CFluidModel_tests_AD.cpp +++ b/UnitTests/SU2_CFD/fluid/CFluidModel_tests_AD.cpp @@ -32,7 +32,7 @@ #include "../../../SU2_CFD/include/fluid/CDataDrivenFluid.hpp" #include "../../../SU2_CFD/include/fluid/CPengRobinson.hpp" -void FluidModelADChecks(CFluidModel * fluid_model, su2double val_p, su2double val_T) { +void FluidModelADChecks(CFluidModel* fluid_model, su2double val_p, su2double val_T) { /*--- Consistency tests for the fluid model secondary variables and AD integration. ---*/ /*--- Extract fluid density and static energy. ---*/ @@ -59,10 +59,10 @@ void FluidModelADChecks(CFluidModel * fluid_model, su2double val_p, su2double va const su2double dpde_rho_AD = SU2_TYPE::GetDerivative(val_e); const su2double dpdrho_e_pred = fluid_model->GetdPdrho_e(); const su2double dpde_rho_pred = fluid_model->GetdPde_rho(); - + CHECK(SU2_TYPE::GetValue(dpdrho_e_AD) == Approx(SU2_TYPE::GetValue(dpdrho_e_pred))); CHECK(SU2_TYPE::GetValue(dpde_rho_AD) == Approx(SU2_TYPE::GetValue(dpde_rho_pred))); - + /*--- Test 2: check consistency of temperature derivatives. ---*/ AD::Reset(); AD::StartRecording(); @@ -83,16 +83,16 @@ void FluidModelADChecks(CFluidModel * fluid_model, su2double val_p, su2double va const su2double dTde_rho_AD = SU2_TYPE::GetDerivative(val_e); const su2double dTdrho_e_pred = fluid_model->GetdTdrho_e(); const su2double dTde_rho_pred = fluid_model->GetdTde_rho(); - + CHECK(SU2_TYPE::GetValue(dTdrho_e_AD) == Approx(SU2_TYPE::GetValue(dTdrho_e_pred))); CHECK(SU2_TYPE::GetValue(dTde_rho_AD) == Approx(SU2_TYPE::GetValue(dTde_rho_pred))); /*--- Test 3: check consistency of specific heat at constant pressure. ---*/ - const su2double drhode_p = -dpde_rho_AD/dpdrho_e_AD; - const su2double dTde_p = dTde_rho_AD + dTdrho_e_AD*drhode_p; + const su2double drhode_p = -dpde_rho_AD / dpdrho_e_AD; + const su2double dTde_p = dTde_rho_AD + dTdrho_e_AD * drhode_p; const su2double dhde_rho = 1 + dpde_rho_AD / val_rho; const su2double dhdrho_e = -val_p * (1 / pow(val_rho, 2)) + dpdrho_e_AD / val_rho; - const su2double dhde_p = dhde_rho + drhode_p*dhdrho_e; + const su2double dhde_p = dhde_rho + drhode_p * dhdrho_e; const su2double Cp_AD = dhde_p / dTde_p; const su2double Cp_pred = fluid_model->GetCp(); @@ -116,40 +116,37 @@ void FluidModelADChecks(CFluidModel * fluid_model, su2double val_p, su2double va const su2double dsdrho_p_AD = SU2_TYPE::GetDerivative(val_rho); const su2double dsdp_rho_pred = fluid_model->GetdsdP_rho(); const su2double dsdrho_p_pred = fluid_model->Getdsdrho_P(); - + CHECK(SU2_TYPE::GetValue(dsdp_rho_pred) == Approx(SU2_TYPE::GetValue(dsdp_rho_AD))); CHECK(SU2_TYPE::GetValue(dsdrho_p_pred) == Approx(SU2_TYPE::GetValue(dsdrho_p_AD))); - } -TEST_CASE("AD test case for ideal gas fluid model","[AD tests]") { +TEST_CASE("AD test case for ideal gas fluid model", "[AD tests]") { + CIdealGas* fluid_model = new CIdealGas(1.4, 287.0, true); + FluidModelADChecks(fluid_model, 101325, 300.0); - CIdealGas * fluid_model = new CIdealGas(1.4, 287.0,true); - FluidModelADChecks(fluid_model, 101325, 300.0); - - delete fluid_model; + delete fluid_model; } - -TEST_CASE("AD test case for data-driven fluid model","[AD tests]") { +TEST_CASE("AD test case for data-driven fluid model", "[AD tests]") { std::stringstream config_options; config_options << "SOLVER=RANS" << std::endl; - config_options<<"KIND_TURB_MODEL=SA"< Date: Mon, 24 Mar 2025 13:59:14 +0100 Subject: [PATCH 49/57] CodeFactor suggestions --- TestCases/parallel_regression.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 92394d0f99c2..fb2b3c1c696e 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -344,7 +344,7 @@ def main(): poiseuille_profile.cfg_dir = "navierstokes/poiseuille" poiseuille_profile.cfg_file = "profile_poiseuille.cfg" poiseuille_profile.test_iter = 10 - poiseuille_profile.test_vals = [-12.007512, -7.227061, -0.000000, 2.089953] + poiseuille_profile.test_vals = [-12.007512, -7.227061, -0.000000, 2.089953] poiseuille_profile.test_vals_aarch64 = [-12.492864, -7.671632, -0.000000, 2.085796] test_list.append(poiseuille_profile) @@ -393,7 +393,7 @@ def main(): test_list.append(turb_flatplate_species) # Flat plate SST compressibility correction Wilcox - turb_flatplate_CC_Wilcox = TestCase('turb_flatplate_CC_Wilcox') + turb_flatplate_CC_Wilcox = TestCase('turb_flatplate_CC_Wilcox') turb_flatplate_CC_Wilcox.cfg_dir = "rans/flatplate" turb_flatplate_CC_Wilcox.cfg_file = "turb_SST_flatplate_compressibility_Wilcox.cfg" turb_flatplate_CC_Wilcox.test_iter = 20 @@ -401,7 +401,7 @@ def main(): test_list.append(turb_flatplate_CC_Wilcox) # Flat plate SST compressibility correction Sarkar - turb_flatplate_CC_Sarkar = TestCase('turb_flatplate_CC_Sarkar') + turb_flatplate_CC_Sarkar = TestCase('turb_flatplate_CC_Sarkar') turb_flatplate_CC_Sarkar.cfg_dir = "rans/flatplate" turb_flatplate_CC_Sarkar.cfg_file = "turb_SST_flatplate_compressibility_Sarkar.cfg" turb_flatplate_CC_Sarkar.test_iter = 20 @@ -570,7 +570,7 @@ def main(): test_list.append(inc_nozzle) # Laminar wall mounted cylinder, Euler walls, cylinder wall diagonally split - inc_cylinder_split = TestCase('inc_cylinder_split') + inc_cylinder_split = TestCase('inc_cylinder_split') inc_cylinder_split.cfg_dir = "incomp_navierstokes/cylinder_split" inc_cylinder_split.cfg_file = "cylinder_split.cfg" inc_cylinder_split.test_iter = 10 @@ -582,7 +582,7 @@ def main(): ############################# # Laminar cylinder - inc_lam_cylinder = TestCase('inc_lam_cylinder') + inc_lam_cylinder = TestCase('inc_lam_cylinder') inc_lam_cylinder.cfg_dir = "incomp_navierstokes/cylinder" inc_lam_cylinder.cfg_file = "incomp_cylinder.cfg" inc_lam_cylinder.test_iter = 10 @@ -590,7 +590,7 @@ def main(): test_list.append(inc_lam_cylinder) # Laminar sphere, Re=1. Last column: Cd=24/Re - inc_lam_sphere = TestCase('inc_lam_sphere') + inc_lam_sphere = TestCase('inc_lam_sphere') inc_lam_sphere.cfg_dir = "incomp_navierstokes/sphere" inc_lam_sphere.cfg_file = "sphere.cfg" inc_lam_sphere.test_iter = 5 @@ -598,7 +598,7 @@ def main(): test_list.append(inc_lam_sphere) # Buoyancy-driven cavity - inc_buoyancy = TestCase('inc_buoyancy') + inc_buoyancy = TestCase('inc_buoyancy') inc_buoyancy.cfg_dir = "incomp_navierstokes/buoyancy_cavity" inc_buoyancy.cfg_file = "lam_buoyancy_cavity.cfg" inc_buoyancy.test_iter = 20 @@ -606,7 +606,7 @@ def main(): test_list.append(inc_buoyancy) # Laminar heated cylinder with polynomial fluid model - inc_poly_cylinder = TestCase('inc_poly_cylinder') + inc_poly_cylinder = TestCase('inc_poly_cylinder') inc_poly_cylinder.cfg_dir = "incomp_navierstokes/cylinder" inc_poly_cylinder.cfg_file = "poly_cylinder.cfg" inc_poly_cylinder.test_iter = 20 @@ -614,7 +614,7 @@ def main(): test_list.append(inc_poly_cylinder) # X-coarse laminar bend as a mixed element CGNS test - inc_lam_bend = TestCase('inc_lam_bend') + inc_lam_bend = TestCase('inc_lam_bend') inc_lam_bend.cfg_dir = "incomp_navierstokes/bend" inc_lam_bend.cfg_file = "lam_bend.cfg" inc_lam_bend.test_iter = 10 From d83d7145ecb7bf91ad6d603b9a7e2bfdb94a3289 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Mon, 24 Mar 2025 14:07:03 +0100 Subject: [PATCH 50/57] CodeFactor suggestions --- TestCases/parallel_regression.py | 56 ++++++++++++++++---------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index fb2b3c1c696e..e117973415de 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -344,7 +344,7 @@ def main(): poiseuille_profile.cfg_dir = "navierstokes/poiseuille" poiseuille_profile.cfg_file = "profile_poiseuille.cfg" poiseuille_profile.test_iter = 10 - poiseuille_profile.test_vals = [-12.007512, -7.227061, -0.000000, 2.089953] + poiseuille_profile.test_vals = [-12.007512, -7.227061, -0.000000, 2.089953] poiseuille_profile.test_vals_aarch64 = [-12.492864, -7.671632, -0.000000, 2.085796] test_list.append(poiseuille_profile) @@ -393,7 +393,7 @@ def main(): test_list.append(turb_flatplate_species) # Flat plate SST compressibility correction Wilcox - turb_flatplate_CC_Wilcox = TestCase('turb_flatplate_CC_Wilcox') + turb_flatplate_CC_Wilcox = TestCase('turb_flatplate_CC_Wilcox') turb_flatplate_CC_Wilcox.cfg_dir = "rans/flatplate" turb_flatplate_CC_Wilcox.cfg_file = "turb_SST_flatplate_compressibility_Wilcox.cfg" turb_flatplate_CC_Wilcox.test_iter = 20 @@ -401,7 +401,7 @@ def main(): test_list.append(turb_flatplate_CC_Wilcox) # Flat plate SST compressibility correction Sarkar - turb_flatplate_CC_Sarkar = TestCase('turb_flatplate_CC_Sarkar') + turb_flatplate_CC_Sarkar = TestCase('turb_flatplate_CC_Sarkar') turb_flatplate_CC_Sarkar.cfg_dir = "rans/flatplate" turb_flatplate_CC_Sarkar.cfg_file = "turb_SST_flatplate_compressibility_Sarkar.cfg" turb_flatplate_CC_Sarkar.test_iter = 20 @@ -570,11 +570,11 @@ def main(): test_list.append(inc_nozzle) # Laminar wall mounted cylinder, Euler walls, cylinder wall diagonally split - inc_cylinder_split = TestCase('inc_cylinder_split') - inc_cylinder_split.cfg_dir = "incomp_navierstokes/cylinder_split" - inc_cylinder_split.cfg_file = "cylinder_split.cfg" - inc_cylinder_split.test_iter = 10 - inc_cylinder_split.test_vals = [-10.172747, -11.108149, -10.908852, 10.000000] + inc_cylinder_split = TestCase('inc_cylinder_split') + inc_cylinder_split.cfg_dir = "incomp_navierstokes/cylinder_split" + inc_cylinder_split.cfg_file = "cylinder_split.cfg" + inc_cylinder_split.test_iter = 10 + inc_cylinder_split.test_vals = [-10.172747, -11.108149, -10.908852, 10.000000] test_list.append(inc_cylinder_split) ############################# @@ -582,27 +582,27 @@ def main(): ############################# # Laminar cylinder - inc_lam_cylinder = TestCase('inc_lam_cylinder') - inc_lam_cylinder.cfg_dir = "incomp_navierstokes/cylinder" - inc_lam_cylinder.cfg_file = "incomp_cylinder.cfg" - inc_lam_cylinder.test_iter = 10 - inc_lam_cylinder.test_vals = [-4.004072, -3.194881, -0.076553, 7.780048] + inc_lam_cylinder = TestCase('inc_lam_cylinder') + inc_lam_cylinder.cfg_dir = "incomp_navierstokes/cylinder" + inc_lam_cylinder.cfg_file = "incomp_cylinder.cfg" + inc_lam_cylinder.test_iter = 10 + inc_lam_cylinder.test_vals = [-4.004072, -3.194881, -0.076553, 7.780048] test_list.append(inc_lam_cylinder) # Laminar sphere, Re=1. Last column: Cd=24/Re - inc_lam_sphere = TestCase('inc_lam_sphere') - inc_lam_sphere.cfg_dir = "incomp_navierstokes/sphere" - inc_lam_sphere.cfg_file = "sphere.cfg" - inc_lam_sphere.test_iter = 5 - inc_lam_sphere.test_vals = [-8.342926, -9.322789, 0.121003, 25.782687] + inc_lam_sphere = TestCase('inc_lam_sphere') + inc_lam_sphere.cfg_dir = "incomp_navierstokes/sphere" + inc_lam_sphere.cfg_file = "sphere.cfg" + inc_lam_sphere.test_iter = 5 + inc_lam_sphere.test_vals = [-8.342926, -9.322789, 0.121003, 25.782687] test_list.append(inc_lam_sphere) # Buoyancy-driven cavity - inc_buoyancy = TestCase('inc_buoyancy') - inc_buoyancy.cfg_dir = "incomp_navierstokes/buoyancy_cavity" - inc_buoyancy.cfg_file = "lam_buoyancy_cavity.cfg" - inc_buoyancy.test_iter = 20 - inc_buoyancy.test_vals = [-4.435827, 0.508037, 0.000000, 0.000000] + inc_buoyancy = TestCase('inc_buoyancy') + inc_buoyancy.cfg_dir = "incomp_navierstokes/buoyancy_cavity" + inc_buoyancy.cfg_file = "lam_buoyancy_cavity.cfg" + inc_buoyancy.test_iter = 20 + inc_buoyancy.test_vals = [-4.435827, 0.508037, 0.000000, 0.000000] test_list.append(inc_buoyancy) # Laminar heated cylinder with polynomial fluid model @@ -614,11 +614,11 @@ def main(): test_list.append(inc_poly_cylinder) # X-coarse laminar bend as a mixed element CGNS test - inc_lam_bend = TestCase('inc_lam_bend') - inc_lam_bend.cfg_dir = "incomp_navierstokes/bend" - inc_lam_bend.cfg_file = "lam_bend.cfg" - inc_lam_bend.test_iter = 10 - inc_lam_bend.test_vals = [-3.550744, -3.220213, -0.017606, 1.015086] + inc_lam_bend = TestCase('inc_lam_bend') + inc_lam_bend.cfg_dir = "incomp_navierstokes/bend" + inc_lam_bend.cfg_file = "lam_bend.cfg" + inc_lam_bend.test_iter = 10 + inc_lam_bend.test_vals = [-3.550744, -3.220213, -0.017606, 1.015086] test_list.append(inc_lam_bend) # 3D laminar channnel with 1 cell in flow direction, streamwise periodic From 3fdc949c2367670d8841e82ceeef3db0c0be280e Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Tue, 25 Mar 2025 15:20:45 +0100 Subject: [PATCH 51/57] CodeFactor spaces warnings --- TestCases/parallel_regression.py | 50 ++++++++++++++++---------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index e117973415de..65be01a1836c 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -344,7 +344,7 @@ def main(): poiseuille_profile.cfg_dir = "navierstokes/poiseuille" poiseuille_profile.cfg_file = "profile_poiseuille.cfg" poiseuille_profile.test_iter = 10 - poiseuille_profile.test_vals = [-12.007512, -7.227061, -0.000000, 2.089953] + poiseuille_profile.test_vals = [-12.007512, -7.227061, -0.000000, 2.089953] poiseuille_profile.test_vals_aarch64 = [-12.492864, -7.671632, -0.000000, 2.085796] test_list.append(poiseuille_profile) @@ -570,11 +570,11 @@ def main(): test_list.append(inc_nozzle) # Laminar wall mounted cylinder, Euler walls, cylinder wall diagonally split - inc_cylinder_split = TestCase('inc_cylinder_split') - inc_cylinder_split.cfg_dir = "incomp_navierstokes/cylinder_split" - inc_cylinder_split.cfg_file = "cylinder_split.cfg" - inc_cylinder_split.test_iter = 10 - inc_cylinder_split.test_vals = [-10.172747, -11.108149, -10.908852, 10.000000] + inc_cylinder_split = TestCase('inc_cylinder_split') + inc_cylinder_split.cfg_dir = "incomp_navierstokes/cylinder_split" + inc_cylinder_split.cfg_file = "cylinder_split.cfg" + inc_cylinder_split.test_iter = 10 + inc_cylinder_split.test_vals = [-10.172747, -11.108149, -10.908852, 10.000000] test_list.append(inc_cylinder_split) ############################# @@ -582,31 +582,31 @@ def main(): ############################# # Laminar cylinder - inc_lam_cylinder = TestCase('inc_lam_cylinder') - inc_lam_cylinder.cfg_dir = "incomp_navierstokes/cylinder" - inc_lam_cylinder.cfg_file = "incomp_cylinder.cfg" - inc_lam_cylinder.test_iter = 10 - inc_lam_cylinder.test_vals = [-4.004072, -3.194881, -0.076553, 7.780048] + inc_lam_cylinder = TestCase('inc_lam_cylinder') + inc_lam_cylinder.cfg_dir = "incomp_navierstokes/cylinder" + inc_lam_cylinder.cfg_file = "incomp_cylinder.cfg" + inc_lam_cylinder.test_iter = 10 + inc_lam_cylinder.test_vals = [-4.004072, -3.194881, -0.076553, 7.780048] test_list.append(inc_lam_cylinder) # Laminar sphere, Re=1. Last column: Cd=24/Re - inc_lam_sphere = TestCase('inc_lam_sphere') - inc_lam_sphere.cfg_dir = "incomp_navierstokes/sphere" - inc_lam_sphere.cfg_file = "sphere.cfg" - inc_lam_sphere.test_iter = 5 - inc_lam_sphere.test_vals = [-8.342926, -9.322789, 0.121003, 25.782687] + inc_lam_sphere = TestCase('inc_lam_sphere') + inc_lam_sphere.cfg_dir = "incomp_navierstokes/sphere" + inc_lam_sphere.cfg_file = "sphere.cfg" + inc_lam_sphere.test_iter = 5 + inc_lam_sphere.test_vals = [-8.342926, -9.322789, 0.121003, 25.782687] test_list.append(inc_lam_sphere) # Buoyancy-driven cavity - inc_buoyancy = TestCase('inc_buoyancy') - inc_buoyancy.cfg_dir = "incomp_navierstokes/buoyancy_cavity" - inc_buoyancy.cfg_file = "lam_buoyancy_cavity.cfg" - inc_buoyancy.test_iter = 20 - inc_buoyancy.test_vals = [-4.435827, 0.508037, 0.000000, 0.000000] + inc_buoyancy = TestCase('inc_buoyancy') + inc_buoyancy.cfg_dir = "incomp_navierstokes/buoyancy_cavity" + inc_buoyancy.cfg_file = "lam_buoyancy_cavity.cfg" + inc_buoyancy.test_iter = 20 + inc_buoyancy.test_vals = [-4.435827, 0.508037, 0.000000, 0.000000] test_list.append(inc_buoyancy) # Laminar heated cylinder with polynomial fluid model - inc_poly_cylinder = TestCase('inc_poly_cylinder') + inc_poly_cylinder = TestCase('inc_poly_cylinder') inc_poly_cylinder.cfg_dir = "incomp_navierstokes/cylinder" inc_poly_cylinder.cfg_file = "poly_cylinder.cfg" inc_poly_cylinder.test_iter = 20 @@ -617,8 +617,8 @@ def main(): inc_lam_bend = TestCase('inc_lam_bend') inc_lam_bend.cfg_dir = "incomp_navierstokes/bend" inc_lam_bend.cfg_file = "lam_bend.cfg" - inc_lam_bend.test_iter = 10 - inc_lam_bend.test_vals = [-3.550744, -3.220213, -0.017606, 1.015086] + inc_lam_bend.test_iter = 10 + inc_lam_bend.test_vals = [-3.550744, -3.220213, -0.017606, 1.015086] test_list.append(inc_lam_bend) # 3D laminar channnel with 1 cell in flow direction, streamwise periodic @@ -1441,7 +1441,7 @@ def main(): pywrapper_unsteadyCHT.cfg_dir = "py_wrapper/flatPlate_unsteady_CHT" pywrapper_unsteadyCHT.cfg_file = "unsteady_CHT_FlatPlate_Conf.cfg" pywrapper_unsteadyCHT.test_iter = 5 - pywrapper_unsteadyCHT.test_vals = [-1.614167, 2.246133, -0.001388, 0.172996] + pywrapper_unsteadyCHT.test_vals = [-1.614167, 2.246133, -0.001388, 0.172996] pywrapper_unsteadyCHT.command = TestCase.Command("mpirun -np 2", "python", "launch_unsteady_CHT_FlatPlate.py --parallel -f") pywrapper_unsteadyCHT.unsteady = True test_list.append(pywrapper_unsteadyCHT) From 1a0e3fb597d0a4040d2fc7ca7d56de5aa6199404 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Wed, 26 Mar 2025 09:50:08 +0100 Subject: [PATCH 52/57] Added regression test for NICFD PINN tutorial --- TestCases/tutorials.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/TestCases/tutorials.py b/TestCases/tutorials.py index ef4398b6f751..0fad5dd9d8cf 100644 --- a/TestCases/tutorials.py +++ b/TestCases/tutorials.py @@ -277,7 +277,7 @@ def main(): tutorial_turb_oneram6.test_vals = [-4.564441, -11.524295, 0.327905, 0.097340] test_list.append(tutorial_turb_oneram6) - # NICD Nozzle + # NICFD Nozzle tutorial_nicfd_nozzle = TestCase('nicfd_nozzle') tutorial_nicfd_nozzle.cfg_dir = "../Tutorials/compressible_flow/NICFD_nozzle" tutorial_nicfd_nozzle.cfg_file = "NICFD_nozzle.cfg" @@ -286,6 +286,16 @@ def main(): tutorial_nicfd_nozzle.no_restart = True test_list.append(tutorial_nicfd_nozzle) + # NICFD Nozzle using PINN + tutorial_nicfd_nozzle_pinn = TestCase('nicfd_nozzle_pinn') + tutorial_nicfd_nozzle_pinn.cfg_dir = "../Tutorials/compressible_flow/NICFD_nozzle/PhysicsInformed" + tutorial_nicfd_nozzle_pinn.cfg_file = "config_NICFD_PINN.cfg" + tutorial_nicfd_nozzle_pinn.test_iter = 20 + tutorial_nicfd_nozzle_pinn.test_vals = [-3.183101, -1.639749, -1.274703, 2.444611, -11.769635] + tutorial_nicfd_nozzle_pinn.no_restart = True + test_list.append(tutorial_nicfd_nozzle_pinn) + + # Unsteady NACA0012 tutorial_unst_naca0012 = TestCase('unsteady_naca0012') tutorial_unst_naca0012.cfg_dir = "../Tutorials/compressible_flow/Unsteady_NACA0012" From ac8318706be30e1c129933d5c724f27cb652ff55 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Wed, 26 Mar 2025 09:52:16 +0100 Subject: [PATCH 53/57] Added PINN options to config template and removed out-of-date comments --- Common/include/CConfig.hpp | 9 +-------- Common/include/geometry/CGeometry.hpp | 13 ------------- config_template.cfg | 26 ++++++++++++++++---------- 3 files changed, 17 insertions(+), 31 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index e81cd11b1acc..acb669e78193 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -536,14 +536,7 @@ class CConfig { Kind_TimeStep_Heat, /*!< \brief Time stepping method for the (fvm) heat equation. */ n_Datadriven_files; - 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. */ + DataDrivenFluid_ParsedOptions datadriven_ParsedOptions; /*!< \brief Options for data-driven fluid analysis. */ 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. */ diff --git a/Common/include/geometry/CGeometry.hpp b/Common/include/geometry/CGeometry.hpp index 7651284319b5..9519877e2533 100644 --- a/Common/include/geometry/CGeometry.hpp +++ b/Common/include/geometry/CGeometry.hpp @@ -954,19 +954,6 @@ class CGeometry { */ void SetCustomBoundary(CConfig* config); - /*! - * \brief General interface for setting the velocity in the geometry during motion ramps - * \param[in] config - config class - * \param[in] ramp_flag - flag for type of ramp - * \param[in] print - bool to print update to screen - */ - void SetVelocity(CConfig* config, bool print) { - if (config->GetKind_GridMovement() == ENUM_GRIDMOVEMENT::ROTATING_FRAME) - SetRotationalVelocity(config, print); - else if (config->GetKind_GridMovement() == ENUM_GRIDMOVEMENT::STEADY_TRANSLATION) - SetTranslationalVelocity(config, print); - }; - /*! * \brief Set cartesian grid velocity based on rotational speed and axis. * \param[in] config - Definition of the particular problem. diff --git a/config_template.cfg b/config_template.cfg index 246395cd10f6..eca8077f895a 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -441,7 +441,14 @@ FILENAMES_INTERPOLATOR= (MLP_1.mlp, MLP_2.mlp, MLP_3.mlp) % Relaxation factor for the Newton solvers in the data-driven fluid model DATADRIVEN_NEWTON_RELAXATION= 0.8 -% +% Use physics-informed neural network for calculation of the fluid caloric properties. +USE_PINN= YES + +% Optional initial guess for fluid density and static energy in data-driven fluid analysis. +DATADRIVEN_INITIAL_DENSITY= -1 +DATADRIVEN_INITIAL_ENERGY= -1 + + % Specify if there is ionization IONIZATION= NO % @@ -735,20 +742,19 @@ MIXINGPLANE_INTERFACE_KIND= LINEAR_INTERPOLATION % Specify option for turbulent mixing-plane (YES, NO) default NO TURBULENT_MIXINGPLANE= YES % -% Specify ramp option for Outlet Giles value (YES, NO) default NO -RAMP_OUTLET= NO +% Specify ramp option for Outlet pressure (YES, NO) default NO +RAMP_OUTLET_PRESSURE= NO % -% Parameters of the outlet Giles ramp (starting outlet value, +% Parameters of the outlet pressure ramp (starting outlet pressure, % updating-iteration-frequency, total number of iteration for the ramp) -RAMP_OUTLET_COEFF= (400000.0, 10.0, 500) +RAMP_OUTLET_PRESSURE_COEFF= (400000.0, 10.0, 500) % -% Specify ramp option for frame of motion (YES, NO) default NO -RAMP_MOTION_FRAME= YES +% Specify ramp option for rotating frame (YES, NO) default NO +RAMP_ROTATING_FRAME= YES % -% Parameters of the frame of motion ramp (starting frame of motion speed, +% Parameters of the rotating frame ramp (starting rotational speed, % updating-iteration-frequency, total number of iteration for the ramp) -RAMP_MOTION_FRAME_COEFF= (0.0, 39.0, 500) -% +RAMP_ROTATING_FRAME_COEFF= (0.0, 39.0, 500) % % Specify Kind of average process for linearizing the Navier-Stokes % equation at inflow and outflow BCs included at the mixing-plane interface From 088d8a6a214c5ed571d0f37dd407e7c0feb08fc6 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Wed, 26 Mar 2025 09:58:10 +0100 Subject: [PATCH 54/57] Whitespaces --- config_template.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config_template.cfg b/config_template.cfg index eca8077f895a..06d8238c590a 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -442,7 +442,7 @@ FILENAMES_INTERPOLATOR= (MLP_1.mlp, MLP_2.mlp, MLP_3.mlp) DATADRIVEN_NEWTON_RELAXATION= 0.8 % Use physics-informed neural network for calculation of the fluid caloric properties. -USE_PINN= YES +USE_PINN= YES % Optional initial guess for fluid density and static energy in data-driven fluid analysis. DATADRIVEN_INITIAL_DENSITY= -1 From 1a9faff8a53b04a5649d21fc43dbffe52dfebb56 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Wed, 26 Mar 2025 10:56:07 +0100 Subject: [PATCH 55/57] Updated regression test values for NICFD test case --- TestCases/parallel_regression.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 1eda1f440b87..4a27a3c5d6e1 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1074,7 +1074,7 @@ def main(): datadriven_fluidModel.cfg_dir = "nicf/datadriven" datadriven_fluidModel.cfg_file = "datadriven_nozzle.cfg" datadriven_fluidModel.test_iter = 50 - datadriven_fluidModel.test_vals = [-6.337491, -3.836046, -4.350978, -1.846961, -2.671950, 0.839927] + datadriven_fluidModel.test_vals = [-6.338276, -3.837338, -4.350653, -1.850454, -2.701016, 0.692050] test_list.append(datadriven_fluidModel) ###################################### From 91da295dae695cdb89c014965074688bcc108d87 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Wed, 26 Mar 2025 14:58:30 +0100 Subject: [PATCH 56/57] set tutorials branch and testcases branch to develop --- .github/workflows/regression.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 9e9bbdbc79e6..cef9d68216ed 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -209,7 +209,7 @@ jobs: uses: docker://ghcr.io/su2code/su2/test-su2:240320-1536 with: # -t -c - args: -b ${{github.ref}} -t feature_PINN -c feature_PINN -s ${{matrix.testscript}} + args: -b ${{github.ref}} -t develop -c develop -s ${{matrix.testscript}} - name: Cleanup uses: docker://ghcr.io/su2code/su2/test-su2:240320-1536 with: From fdb0e388ba731f1d339110eaf6b0cf5351636cff Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Thu, 27 Mar 2025 13:42:56 +0100 Subject: [PATCH 57/57] Fixed preaccumulation of SetTDState rhoe function --- SU2_CFD/src/fluid/CDataDrivenFluid.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/SU2_CFD/src/fluid/CDataDrivenFluid.cpp b/SU2_CFD/src/fluid/CDataDrivenFluid.cpp index ca52697bebf9..ecb06c53085e 100644 --- a/SU2_CFD/src/fluid/CDataDrivenFluid.cpp +++ b/SU2_CFD/src/fluid/CDataDrivenFluid.cpp @@ -180,9 +180,12 @@ void CDataDrivenFluid::MapInputs_to_Outputs() { void CDataDrivenFluid::SetTDState_rhoe(su2double rho, su2double e) { + Density = max(min(rho, rho_max), rho_min); + StaticEnergy = max(min(e, e_max), e_min); + AD::StartPreacc(); - AD::SetPreaccIn(rho); - AD::SetPreaccIn(e); + AD::SetPreaccIn(Density); + AD::SetPreaccIn(StaticEnergy); /*--- Compute thermodynamic state based on density and energy. ---*/ @@ -392,6 +395,7 @@ void CDataDrivenFluid::Run_Newton_Solver(const su2double Y_target, const su2doub AD::StartPreacc(); AD::SetPreaccIn(Y_target); + AD::SetPreaccIn(X); /*--- Initiating Newton solver. ---*/ while (!converged && (Iter < MaxIter_Newton)) { /*--- Determine thermodynamic state based on current density and energy. ---*/ @@ -411,7 +415,8 @@ void CDataDrivenFluid::Run_Newton_Solver(const su2double Y_target, const su2doub } Iter++; } - AD::SetPreaccOut(X); + AD::SetPreaccOut(Density); + AD::SetPreaccOut(StaticEnergy); AD::EndPreacc(); /*--- Calculate thermodynamic state based on converged values for density and energy. ---*/