Coverage for backend/pinch_service/OpenPinch/src/utils/water_properties.py: 24%

62 statements  

« prev     ^ index     » next       coverage.py v7.10.7, created at 2025-11-06 23:27 +0000

1from CoolProp.CoolProp import PropsSI 

2 

3FLUID = 'Water' 

4 

5def Tsat_p(P): 

6 P = toSIunit_p(P) 

7 T = PropsSI('T', 'P', P, 'Q', 1, FLUID) 

8 return fromSIunit_T(T) 

9 

10def psat_T(T): 

11 T = toSIunit_T(T) 

12 p = PropsSI('P', 'T', T, 'Q', 1, FLUID) 

13 return fromSIunit_p(p) 

14 

15def hV_p(P): 

16 P = toSIunit_p(P) 

17 h = PropsSI('H', 'P', P, 'Q', 1, FLUID) 

18 return fromSIunit_h(h) 

19 

20def hL_p(P): 

21 P = toSIunit_p(P) 

22 h = PropsSI('H', 'P', P, 'Q', 0, FLUID) 

23 return fromSIunit_h(h) 

24 

25def h_pT(P, T): 

26 P = toSIunit_p(P) 

27 T = toSIunit_T(T) 

28 h = PropsSI('H', 'P', P, 'T', T, FLUID) 

29 return fromSIunit_h(h) 

30 

31def h_ps(P, s): 

32 P = toSIunit_p(P) 

33 s = toSIunit_s(s) 

34 h = PropsSI('H', 'P', P, "S", s, FLUID) 

35 return fromSIunit_h(h) 

36 

37def s_ph(P, H): 

38 P = toSIunit_p(P) 

39 H = toSIunit_h(H) 

40 s = PropsSI("S", "H", H, "P", P, FLUID) 

41 return fromSIunit_s(s) 

42 

43 

44"""'*********************************************************************************************************** 

45'*6 Units * 

46'*********************************************************************************************************** 

47""" 

48 

49 

50def toSIunit_p(Ins): 

51 # Translate bar to Pa 

52 if Ins == None: 

53 Ins = 0 

54 return Ins * 100000 

55 

56def fromSIunit_p(Ins): 

57 # Translate MPa to bar 

58 if Ins == None: 

59 Ins = 0 

60 return Ins / 100000 

61 

62def toSIunit_T(Ins): 

63 # Translate degC to Kelvin 

64 if Ins == None: 

65 Ins = 0 

66 return Ins + 273.15 

67 

68def fromSIunit_T(Ins): 

69 # Translate Kelvin to degC 

70 if Ins == None: 

71 Ins = 0 

72 return Ins - 273.15 

73 

74def toSIunit_h(Ins): 

75 if Ins == None: 

76 Ins = 0 

77 return Ins * 1000 

78 

79def fromSIunit_h(Ins): 

80 if Ins == None: 

81 Ins = 0 

82 return Ins / 1000 

83 

84def toSIunit_s(Ins): 

85 return Ins 

86 

87def fromSIunit_s(Ins): 

88 return Ins