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.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- */
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+ */
2727
2828#include " ../../include/fluid/CCoolProp.hpp"
2929
3030#ifdef USE_COOLPROP
31- #include " CoolProp.h"
3231#include " AbstractState.h"
32+ #include " CoolProp.h"
3333
3434CCoolProp::CCoolProp (string fluidname) : CFluidModel() {
35- fluid_entity = std::unique_ptr<CoolProp::AbstractState>(CoolProp::AbstractState::factory (" HEOS" ,fluidname));
36- Gas_Constant = fluid_entity->gas_constant ()/ fluid_entity->molar_mass ();
35+ fluid_entity = std::unique_ptr<CoolProp::AbstractState>(CoolProp::AbstractState::factory (" HEOS" , fluidname));
36+ Gas_Constant = fluid_entity->gas_constant () / fluid_entity->molar_mass ();
3737 Pressure_Critical = fluid_entity->p_critical ();
3838 Temperature_Critical = fluid_entity->T_critical ();
3939 acentric_factor = fluid_entity->acentric_factor ();
@@ -58,28 +58,28 @@ void CCoolProp::SetTDState_rhoe(su2double rho, su2double e) {
5858 if (fluid_entity->phase () == 6 ) {
5959 // assume it is pure gas
6060 fluid_entity->specify_phase (CoolProp::iphase_gas);
61- if (abs (Pressure/ Pressure_Critical- 1 )< 0.01 ){
61+ if (abs (Pressure / Pressure_Critical - 1 ) < 0.01 ) {
6262 // if P is very cloase to Pc, the CoolProp has issue
63- Pressure = Pressure_Critical* 0.99 ;
63+ Pressure = Pressure_Critical * 0.99 ;
6464 }
6565 fluid_entity->update (CoolProp::PT_INPUTS, Pressure, Temperature);
66- if (abs (fluid_entity->rhomass ()/ Density- 1 )* 100 < 1 ){
66+ if (abs (fluid_entity->rhomass () / Density - 1 ) * 100 < 1 ) {
6767 // origial phase is near saturation gas, then just compute sound speed
6868 SoundSpeed2 = pow (fluid_entity->speed_sound (), 2 );
6969 }
70- else {
70+ else {
7171 // original phase is not near saturation gas, then specify the phase as gas phase
7272 fluid_entity->specify_phase (CoolProp::iphase_gas);
73- SetTDState_PT (Pressure,Temperature);
73+ SetTDState_PT (Pressure, Temperature);
7474 }
7575 }
76- else {
76+ else {
7777 SoundSpeed2 = pow (fluid_entity->speed_sound (), 2 );
7878 }
7979}
8080
8181void CCoolProp::SetTDState_PT (su2double P, su2double T) {
82- if (abs (P/ Pressure_Critical- 1 )< 0.01 ) {
82+ if (abs (P / Pressure_Critical - 1 ) < 0.01 ) {
8383 P = Pressure_Critical * 0.99 ;
8484 }
8585 fluid_entity->update (CoolProp::PT_INPUTS, P, T);
@@ -89,17 +89,17 @@ void CCoolProp::SetTDState_PT(su2double P, su2double T) {
8989}
9090
9191void CCoolProp::SetTDState_Prho (su2double P, su2double rho) {
92- if (abs (P/ Pressure_Critical- 1 )< 0.01 ){
93- P = Pressure_Critical* 0.99 ;
92+ if (abs (P / Pressure_Critical - 1 ) < 0.01 ) {
93+ P = Pressure_Critical * 0.99 ;
9494 }
9595 fluid_entity->update (CoolProp::DmassP_INPUTS, rho, P);
9696 su2double e = fluid_entity->umass ();
9797 SetTDState_rhoe (rho, e);
9898}
9999
100- void CCoolProp::SetEnergy_Prho (su2double P, su2double rho){
101- if (abs (P/ Pressure_Critical- 1 )< 0.01 ){
102- P = Pressure_Critical* 0.99 ;
100+ void CCoolProp::SetEnergy_Prho (su2double P, su2double rho) {
101+ if (abs (P / Pressure_Critical - 1 ) < 0.01 ) {
102+ P = Pressure_Critical * 0.99 ;
103103 }
104104 fluid_entity->update (CoolProp::DmassP_INPUTS, rho, P);
105105 StaticEnergy = fluid_entity->umass ();
@@ -112,9 +112,9 @@ void CCoolProp::SetTDState_hs(su2double h, su2double s) {
112112 SetTDState_rhoe (rho, e);
113113}
114114
115- void CCoolProp::SetTDState_Ps (su2double P, su2double s) {
116- if (abs (P/ Pressure_Critical- 1 )< 0.01 ){
117- P = Pressure_Critical* 0.99 ;
115+ void CCoolProp::SetTDState_Ps (su2double P, su2double s) {
116+ if (abs (P / Pressure_Critical - 1 ) < 0.01 ) {
117+ P = Pressure_Critical * 0.99 ;
118118 }
119119 fluid_entity->update (CoolProp::PSmass_INPUTS, P, s);
120120 su2double rho = fluid_entity->rhomass ();
@@ -128,16 +128,19 @@ void CCoolProp::SetTDState_rhoT(su2double rho, su2double T) {
128128 SetTDState_rhoe (rho, e);
129129}
130130
131- void CCoolProp::ComputeDerivativeNRBC_Prho (su2double P, su2double rho) {
131+ void CCoolProp::ComputeDerivativeNRBC_Prho (su2double P, su2double rho) {
132132 SetTDState_Prho (P, rho);
133- dhdrho_P = fluid_entity->first_partial_deriv (CoolProp::iHmass,CoolProp::iDmass,CoolProp::iP);
134- dhdP_rho = fluid_entity->first_partial_deriv (CoolProp::iHmass,CoolProp::iP,CoolProp::iDmass);
135- dsdP_rho = fluid_entity->first_partial_deriv (CoolProp::iSmass,CoolProp::iP,CoolProp::iDmass);
136- dsdrho_P = fluid_entity->first_partial_deriv (CoolProp::iSmass,CoolProp::iDmass,CoolProp::iP);
133+ dhdrho_P = fluid_entity->first_partial_deriv (CoolProp::iHmass, CoolProp::iDmass, CoolProp::iP);
134+ dhdP_rho = fluid_entity->first_partial_deriv (CoolProp::iHmass, CoolProp::iP, CoolProp::iDmass);
135+ dsdP_rho = fluid_entity->first_partial_deriv (CoolProp::iSmass, CoolProp::iP, CoolProp::iDmass);
136+ dsdrho_P = fluid_entity->first_partial_deriv (CoolProp::iSmass, CoolProp::iDmass, CoolProp::iP);
137137}
138138
139139#else
140140CCoolProp::CCoolProp (string fluidname) {
141- SU2_MPI::Error (" SU2 was not compiled with CoolProp (-Denable-coolprop=true). Note that CoolProp cannot be used with directdiff or autodiff" , CURRENT_FUNCTION);
141+ SU2_MPI::Error (
142+ " SU2 was not compiled with CoolProp (-Denable-coolprop=true). Note that CoolProp cannot be used with directdiff "
143+ " or autodiff" ,
144+ CURRENT_FUNCTION);
142145}
143- #endif
146+ #endif
0 commit comments