11/* !
2- * \file CCoolProp.cpp
3- * \brief Source of the fluid model from CoolProp.
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.cpp
3+ * \brief Source of the fluid model from CoolProp.
4+ * \author P. Yan, G. Gori, A. Guardone
5+ * \version 7.4.0 "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-2022 , 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#include " ../../include/fluid/CCoolProp.hpp"
2929
@@ -56,28 +56,51 @@ void CCoolProp::SetTDState_rhoe(su2double rho, su2double e) {
5656 dTdrho_e = fluid_entity->first_partial_deriv (CoolProp::iT, CoolProp::iDmass, CoolProp::iUmass);
5757 dTde_rho = fluid_entity->first_partial_deriv (CoolProp::iT, CoolProp::iUmass, CoolProp::iDmass);
5858 if (fluid_entity->phase () == 6 ) {
59+ // assume it is pure gas
60+ fluid_entity->specify_phase (CoolProp::iphase_gas);
61+ if (abs (Pressure/Pressure_Critical-1 )<0.01 ){
62+ // if P is very cloase to Pc, the CoolProp has issue
63+ Pressure = Pressure_Critical*0.99 ;
64+ }
65+ fluid_entity->update (CoolProp::PT_INPUTS, Pressure, Temperature);
66+ if (abs (fluid_entity->rhomass ()/Density-1 )*100 < 1 ){
67+ // origial phase is near saturation gas, then just compute sound speed
68+ SoundSpeed2 = pow (fluid_entity->speed_sound (), 2 );
69+ }
70+ else {
71+ // original phase is not near saturation gas, then specify the phase as gas phase
5972 fluid_entity->specify_phase (CoolProp::iphase_gas);
6073 SetTDState_PT (Pressure,Temperature);
74+ }
6175 }
6276 else {
63- SoundSpeed2 = pow (fluid_entity->speed_sound (), 2 );
77+ SoundSpeed2 = pow (fluid_entity->speed_sound (), 2 );
6478 }
6579}
6680
6781void CCoolProp::SetTDState_PT (su2double P, su2double T) {
82+ if (abs (P/Pressure_Critical-1 )<0.01 ) {
83+ P = Pressure_Critical * 0.99 ;
84+ }
6885 fluid_entity->update (CoolProp::PT_INPUTS, P, T);
6986 su2double rho = fluid_entity->rhomass ();
7087 su2double e = fluid_entity->umass ();
7188 SetTDState_rhoe (rho, e);
7289}
7390
7491void CCoolProp::SetTDState_Prho (su2double P, su2double rho) {
92+ if (abs (P/Pressure_Critical-1 )<0.01 ){
93+ P = Pressure_Critical*0.99 ;
94+ }
7595 fluid_entity->update (CoolProp::DmassP_INPUTS, rho, P);
7696 su2double e = fluid_entity->umass ();
7797 SetTDState_rhoe (rho, e);
7898}
7999
80- void CCoolProp::SetEnergy_Prho (su2double P, su2double rho) {
100+ void CCoolProp::SetEnergy_Prho (su2double P, su2double rho){
101+ if (abs (P/Pressure_Critical-1 )<0.01 ){
102+ P = Pressure_Critical*0.99 ;
103+ }
81104 fluid_entity->update (CoolProp::DmassP_INPUTS, rho, P);
82105 StaticEnergy = fluid_entity->umass ();
83106}
@@ -90,17 +113,19 @@ void CCoolProp::SetTDState_hs(su2double h, su2double s) {
90113}
91114
92115void CCoolProp::SetTDState_Ps (su2double P, su2double s) {
116+ if (abs (P/Pressure_Critical-1 )<0.01 ){
117+ P = Pressure_Critical*0.99 ;
118+ }
93119 fluid_entity->update (CoolProp::PSmass_INPUTS, P, s);
94- su2double Rho = fluid_entity->rhomass ();
120+ su2double rho = fluid_entity->rhomass ();
95121 su2double e = fluid_entity->umass ();
96- SetTDState_rhoe (Rho , e);
122+ SetTDState_rhoe (rho , e);
97123}
98124
99125void CCoolProp::SetTDState_rhoT (su2double rho, su2double T) {
100126 fluid_entity->update (CoolProp::DmassT_INPUTS, rho, T);
101- su2double Rho = fluid_entity->rhomass ();
102127 su2double e = fluid_entity->umass ();
103- SetTDState_rhoe (Rho , e);
128+ SetTDState_rhoe (rho , e);
104129}
105130
106131void CCoolProp::ComputeDerivativeNRBC_Prho (su2double P, su2double rho) {
0 commit comments