Skip to content

Commit

Permalink
solving P > Psat more elegantly :: INCOMP pressure is now limited by …
Browse files Browse the repository at this point in the history
…Psat - removing use of PropsSI
  • Loading branch information
mrk committed Nov 2, 2023
1 parent d97dcd7 commit 4d2458e
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/tespy/tools/fluid_properties/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,17 @@ def h_ps(self, p, s):
self.AS.update(CP.PSmass_INPUTS, p, s)
return self.AS.hmass()

def _ensure_incomp_is_liquid(self,p,T):
self.AS.update(CP.QT_INPUTS, 0, T)
psat = self.AS.p() # pressure must always be greater than saturation for incompressibles
p = max(p,psat*(1+ERR))
if T == (self._T_max + self._T_min) / 2:
T += ERR
return p,T

def h_pT(self, p, T):
if self.back_end == "INCOMP":
if self.fluid == "Water":
T = min(T,CP.CoolProp.PropsSI("T","P",p,"Q",0,"HEOS::"+self.fluid))
if T == (self._T_max + self._T_min) / 2:
T += ERR
p,T = self._ensure_incomp_is_liquid(p,T)
self.AS.update(CP.PT_INPUTS, p, T)
return self.AS.hmass()

Expand Down Expand Up @@ -186,6 +191,8 @@ def d_ph(self, p, h):
return self.AS.rhomass()

def d_pT(self, p, T):
if self.back_end == "INCOMP":
p,T = self._ensure_incomp_is_liquid(p,T)
self.AS.update(CP.PT_INPUTS, p, T)
return self.AS.rhomass()

Expand All @@ -198,6 +205,8 @@ def viscosity_ph(self, p, h):
return self.AS.viscosity()

def viscosity_pT(self, p, T):
if self.back_end == "INCOMP":
p,T = self._ensure_incomp_is_liquid(p,T)
self.AS.update(CP.PT_INPUTS, p, T)
return self.AS.viscosity()

Expand All @@ -206,6 +215,8 @@ def s_ph(self, p, h):
return self.AS.smass()

def s_pT(self, p, T):
if self.back_end == "INCOMP":
p,T = self._ensure_incomp_is_liquid(p,T)
self.AS.update(CP.PT_INPUTS, p, T)
return self.AS.smass()

Expand Down

0 comments on commit 4d2458e

Please sign in to comment.