@@ -59,8 +59,12 @@ void CCoolProp::SetTDState_rhoe(su2double rho, su2double e) {
5959 // assume it is pure gas
6060 fluid_entity->specify_phase (CoolProp::iphase_gas);
6161 if (abs (Pressure / Pressure_Critical - 1 ) < epsilon) {
62- // if P is very cloase to Pc, the CoolProp has issue
63- Pressure = Pressure_Critical * (1 -epsilon);
62+ if (Pressure >= Pressure_Critical){
63+ Pressure = Pressure_Critical * (1 + epsilon);
64+ }
65+ else {
66+ Pressure = Pressure_Critical * (1 - epsilon);
67+ }
6468 }
6569 fluid_entity->update (CoolProp::PT_INPUTS, Pressure, Temperature);
6670 if (abs (fluid_entity->rhomass () / Density - 1 ) < epsilon) {
@@ -80,7 +84,12 @@ void CCoolProp::SetTDState_rhoe(su2double rho, su2double e) {
8084
8185void CCoolProp::SetTDState_PT (su2double P, su2double T) {
8286 if (abs (P / Pressure_Critical - 1 ) < epsilon) {
83- P = Pressure_Critical * (1 -epsilon);
87+ if (P >= Pressure_Critical){
88+ P = Pressure_Critical * (1 + epsilon);
89+ }
90+ else {
91+ P = Pressure_Critical * (1 - epsilon);
92+ }
8493 }
8594 fluid_entity->update (CoolProp::PT_INPUTS, P, T);
8695 su2double rho = fluid_entity->rhomass ();
@@ -90,7 +99,12 @@ void CCoolProp::SetTDState_PT(su2double P, su2double T) {
9099
91100void CCoolProp::SetTDState_Prho (su2double P, su2double rho) {
92101 if (abs (P / Pressure_Critical - 1 ) < epsilon) {
93- P = Pressure_Critical * (1 -epsilon);
102+ if (P >= Pressure_Critical){
103+ P = Pressure_Critical * (1 + epsilon);
104+ }
105+ else {
106+ P = Pressure_Critical * (1 - epsilon);
107+ }
94108 }
95109 fluid_entity->update (CoolProp::DmassP_INPUTS, rho, P);
96110 su2double e = fluid_entity->umass ();
@@ -99,7 +113,12 @@ void CCoolProp::SetTDState_Prho(su2double P, su2double rho) {
99113
100114void CCoolProp::SetEnergy_Prho (su2double P, su2double rho) {
101115 if (abs (P / Pressure_Critical - 1 ) < epsilon) {
102- P = Pressure_Critical * (1 -epsilon);
116+ if (P >= Pressure_Critical){
117+ P = Pressure_Critical * (1 + epsilon);
118+ }
119+ else {
120+ P = Pressure_Critical * (1 - epsilon);
121+ }
103122 }
104123 fluid_entity->update (CoolProp::DmassP_INPUTS, rho, P);
105124 StaticEnergy = fluid_entity->umass ();
@@ -114,7 +133,12 @@ void CCoolProp::SetTDState_hs(su2double h, su2double s) {
114133
115134void CCoolProp::SetTDState_Ps (su2double P, su2double s) {
116135 if (abs (P / Pressure_Critical - 1 ) < epsilon) {
117- P = Pressure_Critical * (1 -epsilon);
136+ if (P >= Pressure_Critical){
137+ P = Pressure_Critical * (1 + epsilon);
138+ }
139+ else {
140+ P = Pressure_Critical * (1 - epsilon);
141+ }
118142 }
119143 fluid_entity->update (CoolProp::PSmass_INPUTS, P, s);
120144 su2double rho = fluid_entity->rhomass ();
0 commit comments