Skip to content

Commit c02a79c

Browse files
committed
check T
1 parent ce9b4ab commit c02a79c

2 files changed

Lines changed: 216 additions & 210 deletions

File tree

Lines changed: 148 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -1,149 +1,170 @@
11
/*!
2-
* \file CCoolProp.hpp
3-
* \brief Defines the state-of-the-art fluid model from CoolProp library.
4-
* \author P. Yan, G. Gori, A. Guardone
5-
* \version 7.5.1 "Blackbird"
6-
*
7-
* SU2 Project Website: https://su2code.github.io
8-
*
9-
* The SU2 Project is maintained by the SU2 Foundation
10-
* (http://su2foundation.org)
11-
*
12-
* Copyright 2012-2023, SU2 Contributors (cf. AUTHORS.md)
13-
*
14-
* SU2 is free software; you can redistribute it and/or
15-
* modify it under the terms of the GNU Lesser General Public
16-
* License as published by the Free Software Foundation; either
17-
* version 2.1 of the License, or (at your option) any later version.
18-
*
19-
* SU2 is distributed in the hope that it will be useful,
20-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22-
* Lesser General Public License for more details.
23-
*
24-
* You should have received a copy of the GNU Lesser General Public
25-
* License along with SU2. If not, see <http://www.gnu.org/licenses/>.
26-
*/
2+
* \file CCoolProp.hpp
3+
* \brief Defines the state-of-the-art fluid model from CoolProp library.
4+
* \author P. Yan, G. Gori, A. Guardone
5+
* \version 7.5.1 "Blackbird"
6+
*
7+
* SU2 Project Website: https://su2code.github.io
8+
*
9+
* The SU2 Project is maintained by the SU2 Foundation
10+
* (http://su2foundation.org)
11+
*
12+
* Copyright 2012-2023, SU2 Contributors (cf. AUTHORS.md)
13+
*
14+
* SU2 is free software; you can redistribute it and/or
15+
* modify it under the terms of the GNU Lesser General Public
16+
* License as published by the Free Software Foundation; either
17+
* version 2.1 of the License, or (at your option) any later version.
18+
*
19+
* SU2 is distributed in the hope that it will be useful,
20+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22+
* Lesser General Public License for more details.
23+
*
24+
* You should have received a copy of the GNU Lesser General Public
25+
* License along with SU2. If not, see <http://www.gnu.org/licenses/>.
26+
*/
2727

2828
#pragma once
2929
#include "CFluidModel.hpp"
3030
#if defined(HAVE_COOLPROP) && !defined(CODI_FORWARD_TYPE) && !defined(CODI_REVERSE_TYPE)
3131
#define USE_COOLPROP
3232
namespace CoolProp {
33-
class AbstractState;
33+
class AbstractState;
3434
}
3535
#endif
3636
#include <memory>
3737

38-
3938
/*!
40-
* \class CCoolProp
41-
* \brief Child class for defining fluid model from CoolProp library.
42-
* \author: P.Yan
43-
*/
39+
* \class CCoolProp
40+
* \brief Child class for defining fluid model from CoolProp library.
41+
* \author: P.Yan
42+
*/
4443
class CCoolProp final : public CFluidModel {
4544
private:
46-
su2double Gamma{1.4}; /*!< \brief Ratio of Specific Heats. */
47-
su2double Gas_Constant{297}; /*!< \brief specific Gas Constant. */
48-
su2double Pressure_Critical{0.0}; /*!< \brief critical pressure */
49-
su2double Temperature_Critical{0.0}; /*!< \brief critical temperature */
50-
su2double acentric_factor{0.0}; /*!< \brief acentric factor */
45+
su2double Gamma{1.4}; /*!< \brief Ratio of Specific Heats. */
46+
su2double Gas_Constant{297}; /*!< \brief specific Gas Constant. */
47+
su2double Pressure_Critical{0.0}; /*!< \brief critical pressure */
48+
su2double Temperature_Critical{0.0}; /*!< \brief critical temperature */
49+
su2double acentric_factor{0.0}; /*!< \brief acentric factor */
50+
const su2double dp{0.01}; /*!< threshold for pressure */
51+
const su2double dt{0.01}; /*!< threshold for temperature */
5152
#ifdef USE_COOLPROP
52-
std::unique_ptr<CoolProp::AbstractState> fluid_entity; /*!< \brief fluid entity */
53+
std::unique_ptr<CoolProp::AbstractState> fluid_entity; /*!< \brief fluid entity */
5354
#endif
55+
/*!
56+
* \brief Avoid critical pressure
57+
* \param[in,out] Pressure: Modified so that it is not too close to critical pressure to avoid issues in CoolProp.
58+
*/
59+
void CheckPressure(su2double& Pressure) const {
60+
if (Pressure > Pressure_Critical)
61+
Pressure = fmax(Pressure, (1 + dp) * Pressure_Critical);
62+
else
63+
Pressure = fmin(Pressure, (1 - dp) * Pressure_Critical);
64+
}
65+
66+
/*!
67+
* \brief Avoid critical temperature
68+
* \param[in,out] Temperature: Modified so that it is not too close to critical temperature to avoid issues in CoolProp.
69+
*/
70+
void CheckTemperature(su2double& Temperature) const {
71+
if (Temperature > Temperature_Critical)
72+
Temperature = fmax(Temperature, (1 + dt) * Temperature_Critical);
73+
else
74+
Temperature = fmin(Temperature, (1 + dt) * Temperature_Critical);
75+
}
5476

5577
public:
56-
/*!
57-
* \brief Constructor of the class.
58-
*/
59-
CCoolProp(string fluidname);
78+
/*!
79+
* \brief Constructor of the class.
80+
*/
81+
CCoolProp(string fluidname);
6082

6183
#ifdef USE_COOLPROP
62-
/*!
63-
* \brief Destructor of the class.
64-
* \note Needs to be defined in the .cpp to allow using only a forward declaration of CoolProp::AbstractState.
65-
*/
66-
~CCoolProp();
67-
68-
/*!
69-
* \brief Set the Dimensionless State using Density and Internal Energy
70-
* \param[in] rho - first thermodynamic variable.
71-
* \param[in] e - second thermodynamic variable.
72-
*/
73-
void SetTDState_rhoe(su2double rho, su2double e) override;
74-
75-
/*!
76-
* \brief Set the Dimensionless State using Pressure and Temperature
77-
* \param[in] P - first thermodynamic variable.
78-
* \param[in] T - second thermodynamic variable.
79-
*/
80-
void SetTDState_PT(su2double P, su2double T) override;
81-
82-
/*!
83-
* \brief Set the Dimensionless State using Pressure and Density
84-
* \param[in] P - first thermodynamic variable.
85-
* \param[in] rho - second thermodynamic variable.
86-
*/
87-
void SetTDState_Prho(su2double P, su2double rho) override;
88-
89-
/*!
90-
* \brief Set the Dimensionless Internal Energy using Pressure and Density
91-
* \param[in] P - first thermodynamic variable.
92-
* \param[in] rho - second thermodynamic variable.
93-
*/
94-
void SetEnergy_Prho(su2double P, su2double rho) override;
95-
96-
/*!
97-
* \brief Set the Dimensionless State using Enthalpy and Entropy
98-
* \param[in] th1 - first thermodynamic variable (h).
99-
* \param[in] th2 - second thermodynamic variable (s).
100-
*/
101-
void SetTDState_hs(su2double h, su2double s) override;
102-
103-
/*!
104-
* \brief Set the Dimensionless State using Density and Temperature
105-
* \param[in] th1 - first thermodynamic variable (rho).
106-
* \param[in] th2 - second thermodynamic variable (T).
107-
*/
108-
void SetTDState_rhoT(su2double rho, su2double T) override;
109-
110-
/*!
111-
* \brief Set the Dimensionless State using Pressure and Entropy
112-
* \param[in] th1 - first thermodynamic variable (P).
113-
* \param[in] th2 - second thermodynamic variable (s).
114-
*/
115-
void SetTDState_Ps(su2double P, su2double s) override;
116-
117-
/*!
118-
* \brief compute some derivatives of enthalpy and entropy needed for subsonic inflow BC
119-
* \param[in] th1 - first thermodynamic variable (P).
120-
* \param[in] th2 - second thermodynamic variable (rho).
121-
*/
122-
void ComputeDerivativeNRBC_Prho(su2double P, su2double rho) override;
84+
/*!
85+
* \brief Destructor of the class.
86+
* \note Needs to be defined in the .cpp to allow using only a forward declaration of CoolProp::AbstractState.
87+
*/
88+
~CCoolProp();
89+
90+
/*!
91+
* \brief Set the Dimensionless State using Density and Internal Energy
92+
* \param[in] rho - first thermodynamic variable.
93+
* \param[in] e - second thermodynamic variable.
94+
*/
95+
void SetTDState_rhoe(su2double rho, su2double e) override;
96+
97+
/*!
98+
* \brief Set the Dimensionless State using Pressure and Temperature
99+
* \param[in] P - first thermodynamic variable.
100+
* \param[in] T - second thermodynamic variable.
101+
*/
102+
void SetTDState_PT(su2double P, su2double T) override;
103+
104+
/*!
105+
* \brief Set the Dimensionless State using Pressure and Density
106+
* \param[in] P - first thermodynamic variable.
107+
* \param[in] rho - second thermodynamic variable.
108+
*/
109+
void SetTDState_Prho(su2double P, su2double rho) override;
110+
111+
/*!
112+
* \brief Set the Dimensionless Internal Energy using Pressure and Density
113+
* \param[in] P - first thermodynamic variable.
114+
* \param[in] rho - second thermodynamic variable.
115+
*/
116+
void SetEnergy_Prho(su2double P, su2double rho) override;
117+
118+
/*!
119+
* \brief Set the Dimensionless State using Enthalpy and Entropy
120+
* \param[in] th1 - first thermodynamic variable (h).
121+
* \param[in] th2 - second thermodynamic variable (s).
122+
*/
123+
void SetTDState_hs(su2double h, su2double s) override;
124+
125+
/*!
126+
* \brief Set the Dimensionless State using Density and Temperature
127+
* \param[in] th1 - first thermodynamic variable (rho).
128+
* \param[in] th2 - second thermodynamic variable (T).
129+
*/
130+
void SetTDState_rhoT(su2double rho, su2double T) override;
131+
132+
/*!
133+
* \brief Set the Dimensionless State using Pressure and Entropy
134+
* \param[in] th1 - first thermodynamic variable (P).
135+
* \param[in] th2 - second thermodynamic variable (s).
136+
*/
137+
void SetTDState_Ps(su2double P, su2double s) override;
138+
139+
/*!
140+
* \brief compute some derivatives of enthalpy and entropy needed for subsonic inflow BC
141+
* \param[in] th1 - first thermodynamic variable (P).
142+
* \param[in] th2 - second thermodynamic variable (rho).
143+
*/
144+
void ComputeDerivativeNRBC_Prho(su2double P, su2double rho) override;
123145
#endif
124146

125-
/*!
126-
* \brief Get the value of the critical pressure.
127-
* \return Critical pressure.
128-
*/
129-
su2double GetPressure_Critical(void) const { return Pressure_Critical; }
130-
131-
/*!
132-
* \brief Get the value of the critical temperature.
133-
* \return Critical temperature.
134-
*/
135-
su2double GetTemperature_Critical(void) const { return Temperature_Critical; }
136-
137-
/*!
138-
* \brief Get the value of specific gas constant.
139-
* \return Value of the constant: Gamma
140-
*/
141-
su2double GetGas_Constant(void) const { return Gas_Constant; }
142-
143-
/*!
144-
* \brief Get the value of specific gas constant.
145-
* \return Value of the constant: Gamma
146-
*/
147-
su2double GetGamma(void) const { return Gamma; }
148-
149-
};
147+
/*!
148+
* \brief Get the value of the critical pressure.
149+
* \return Critical pressure.
150+
*/
151+
su2double GetPressure_Critical(void) const { return Pressure_Critical; }
152+
153+
/*!
154+
* \brief Get the value of the critical temperature.
155+
* \return Critical temperature.
156+
*/
157+
su2double GetTemperature_Critical(void) const { return Temperature_Critical; }
158+
159+
/*!
160+
* \brief Get the value of specific gas constant.
161+
* \return Value of the constant: Gamma
162+
*/
163+
su2double GetGas_Constant(void) const { return Gas_Constant; }
164+
165+
/*!
166+
* \brief Get the value of specific gas constant.
167+
* \return Value of the constant: Gamma
168+
*/
169+
su2double GetGamma(void) const { return Gamma; }
170+
};

0 commit comments

Comments
 (0)