@@ -58,68 +58,38 @@ void CCoolProp::SetTDState_rhoe(su2double rho, su2double e) {
5858 if (fluid_entity->phase () == CoolProp::iphase_twophase) {
5959 // assume it is pure gas
6060 fluid_entity->specify_phase (CoolProp::iphase_gas);
61- if (abs (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- }
68- }
61+ Check_Pressure (Pressure);
6962 fluid_entity->update (CoolProp::PT_INPUTS, Pressure, Temperature);
7063 if (abs (fluid_entity->rhomass () / Density - 1 ) < epsilon) {
7164 // origial phase is near saturation gas, then just compute sound speed
7265 SoundSpeed2 = pow (fluid_entity->speed_sound (), 2 );
73- }
74- else {
66+ } else {
7567 // original phase is not near saturation gas, then specify the phase as gas phase
7668 fluid_entity->specify_phase (CoolProp::iphase_gas);
7769 SetTDState_PT (Pressure, Temperature);
7870 }
79- }
80- else {
71+ } else {
8172 SoundSpeed2 = pow (fluid_entity->speed_sound (), 2 );
8273 }
8374}
8475
8576void CCoolProp::SetTDState_PT (su2double P, su2double T) {
86- if (abs (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- }
93- }
77+ Check_Pressure (P);
9478 fluid_entity->update (CoolProp::PT_INPUTS, P, T);
9579 su2double rho = fluid_entity->rhomass ();
9680 su2double e = fluid_entity->umass ();
9781 SetTDState_rhoe (rho, e);
9882}
9983
10084void CCoolProp::SetTDState_Prho (su2double P, su2double rho) {
101- if (abs (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- }
108- }
85+ Check_Pressure (P);
10986 fluid_entity->update (CoolProp::DmassP_INPUTS, rho, P);
11087 su2double e = fluid_entity->umass ();
11188 SetTDState_rhoe (rho, e);
11289}
11390
11491void CCoolProp::SetEnergy_Prho (su2double P, su2double rho) {
115- if (abs (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- }
122- }
92+ Check_Pressure (P);
12393 fluid_entity->update (CoolProp::DmassP_INPUTS, rho, P);
12494 StaticEnergy = fluid_entity->umass ();
12595}
@@ -132,14 +102,7 @@ void CCoolProp::SetTDState_hs(su2double h, su2double s) {
132102}
133103
134104void CCoolProp::SetTDState_Ps (su2double P, su2double s) {
135- if (abs (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- }
142- }
105+ Check_Pressure (P);
143106 fluid_entity->update (CoolProp::PSmass_INPUTS, P, s);
144107 su2double rho = fluid_entity->rhomass ();
145108 su2double e = fluid_entity->umass ();
0 commit comments