@@ -42,7 +42,7 @@ class CIncIdealGasPolynomial final : public CFluidModel {
4242 /* !
4343 * \brief Constructor of the class.
4444 */
45- CIncIdealGasPolynomial (su2double val_gas_constant, su2double val_operating_pressure) {
45+ CIncIdealGasPolynomial (su2double val_gas_constant, su2double val_operating_pressure, su2double val_Temperature_Ref ) {
4646 /* In the incompressible ideal gas model, the thermodynamic pressure is decoupled
4747 from the governing equations and held constant. The density is therefore only a
4848 function of temperature variations. We also use a molecular weight (g/mol) and the
@@ -51,20 +51,17 @@ class CIncIdealGasPolynomial final : public CFluidModel {
5151 Gas_Constant = val_gas_constant;
5252 Pressure = val_operating_pressure;
5353 Gamma = 1.0 ;
54+ Std_Ref_Temp_ND = val_Temperature_Ref;
5455 }
5556
5657 /* !
5758 * \brief Set the temperature polynomial coefficients for variable Cp.
5859 * \param[in] config - configuration container for the problem.
5960 */
60- void SetCpModel (const CConfig* config) override {
61- const su2double t_ref = config->GetStandard_RefTemperatureND ();
62- Enthalpy_Ref = 0.0 ;
63- su2double t_i = 1.0 ;
61+ void SetCpModel (const CConfig* config, su2double val_Temperature_Ref) override {
6462 for (int i = 0 ; i < N; ++i) {
65- t_i *= t_ref;
63+ /* --- Note that we use cp = dh/dt here. --- */
6664 coeffs_[i] = config->GetCp_PolyCoeffND (i);
67- Enthalpy_Ref += coeffs_[i] * t_i / (i + 1 );
6865 }
6966 Temperature_Min = config->GetTemperatureLimits (0 );
7067 }
@@ -80,12 +77,14 @@ class CIncIdealGasPolynomial final : public CFluidModel {
8077
8178 /* Evaluate the new Cp and enthalpy from the coefficients and temperature. */
8279 Cp = coeffs_[0 ];
83- Enthalpy = coeffs_[0 ] * t - Enthalpy_Ref ;
80+ Enthalpy = coeffs_[0 ] * ( t - Std_Ref_Temp_ND) ;
8481 su2double t_i = 1.0 ;
82+ su2double tref_i = 1.0 ;
8583 for (int i = 1 ; i < N; ++i) {
8684 t_i *= t;
85+ tref_i *= Std_Ref_Temp_ND;
8786 Cp += coeffs_[i] * t_i;
88- Enthalpy += coeffs_[i] * t_i * t / (i + 1 );
87+ Enthalpy += coeffs_[i] * ( t_i * t - tref_i * Std_Ref_Temp_ND) / (i + 1 );
8988 }
9089 Cv = Cp / Gamma;
9190 }
@@ -106,16 +105,18 @@ class CIncIdealGasPolynomial final : public CFluidModel {
106105
107106 int counter = 0 ;
108107
109- /* --- Computing temperature given enthalpy using Newton-Raphson. ---*/
108+ /* --- Compute temperature given enthalpy using Newton-Raphson. ---*/
110109 while ((abs (delta_temp_iter) > toll) && (counter++ < counter_limit)) {
111110 /* Evaluate the new Cp and enthalpy from the coefficients and temperature. */
112111 Cp_iter = coeffs_[0 ];
113- su2double Enthalpy_iter = coeffs_[0 ] * temp_iter - Enthalpy_Ref ;
112+ su2double Enthalpy_iter = coeffs_[0 ] * ( temp_iter - Std_Ref_Temp_ND) ;
114113 su2double t_i = 1.0 ;
114+ su2double tref_i = 1.0 ;
115115 for (int i = 1 ; i < N; ++i) {
116116 t_i *= temp_iter;
117+ tref_i *= Std_Ref_Temp_ND;
117118 Cp_iter += coeffs_[i] * t_i;
118- Enthalpy_iter += coeffs_[i] * t_i * temp_iter / (i + 1 );
119+ Enthalpy_iter += coeffs_[i] * ( t_i * temp_iter - tref_i * Std_Ref_Temp_ND) / (i + 1 );
119120 }
120121
121122 delta_enthalpy_iter = Enthalpy - Enthalpy_iter;
@@ -124,15 +125,16 @@ class CIncIdealGasPolynomial final : public CFluidModel {
124125
125126 temp_iter += delta_temp_iter;
126127 if (temp_iter < Temperature_Min) {
127- cout << " Warning: Negative temperature has been found during Newton-Raphson" << endl;
128+ cout << " Warning: Negative temperature has been found during Newton-Raphson. " << endl;
128129 temp_iter = Temperature_Min;
129130 break ;
130131 }
131132 }
133+
132134 Temperature = temp_iter;
133135 Cp = Cp_iter;
134136 if (counter == counter_limit) {
135- cout << " Warning Newton-Raphson exceed number of max iteration in temperature computation" << endl;
137+ cout << " Warning: Newton-Raphson exceeds max. iterations in temperature computation. " << endl;
136138 }
137139 Density = Pressure / (Temperature * Gas_Constant);
138140 Cv = Cp / Gamma;
@@ -141,7 +143,7 @@ class CIncIdealGasPolynomial final : public CFluidModel {
141143 private:
142144 su2double Gas_Constant{0.0 }; /* !< \brief Specific Gas Constant. */
143145 su2double Gamma{0.0 }; /* !< \brief Ratio of specific heats. */
146+ su2double Std_Ref_Temp_ND{0.0 }; /* !< \brief Nondimensional standard reference temperature for enthalpy. */
144147 array<su2double, N> coeffs_; /* !< \brief Polynomial coefficients for heat capacity as a function of temperature. */
145- su2double Enthalpy_Ref; /* !< \brief Enthalpy computed at the reference temperature. */
146148 su2double Temperature_Min; /* !< \brief Minimum temperature value allowed in Newton-Raphson iterations. */
147149};
0 commit comments