diff --git a/pyXSteam/Constants.py b/pyXSteam/Constants.py index 43f0854..df16137 100755 --- a/pyXSteam/Constants.py +++ b/pyXSteam/Constants.py @@ -5,10 +5,12 @@ Sources: -* IAPWS Industrial formulation 1997 for the Thermodynamic Properties of Water and Steam, September 1997 - -* IAWPS Release on Vaues of Temperature, Pressure and Density of Ordinary and Heavy Water Substances at their Respective Critical Points Released September 1992, Revision of the Release of 1992 +* IAPWS Industrial formulation 1997 for the Thermodynamic Properties of Water +and Steam, September 1997 +* IAWPS Release on Vaues of Temperature, Pressure and Density of Ordinary and +Heavy Water Substances at their Respective Critical Points Released +September 1992, Revision of the Release of 1992 """ from enum import IntEnum @@ -48,16 +50,21 @@ class UnitSystem(IntEnum): + """enum for supported unit systems""" + BARE = 1 # m/kg/sec/K/MPa/W MKS = 1 # m/kg/sec/°C/bar/W FLS = 2 # ft/lb/sec/°F/psi/btu @classmethod - def has_value(cls, value): + def has_value(cls, value: int): + """check if value is member of enum""" return value in cls._value2member_map_ class IceType(IntEnum): + """enum for the types of ice""" + Ih = 1 III = 3 V = 5 @@ -66,11 +73,14 @@ class IceType(IntEnum): NONE = -1 @classmethod - def has_value(cls, value): + def has_value(cls, value: int): + """check if value is member of enum""" return value in cls._value2member_map_ class DiagramRegion(IntEnum): + """enum for the regions""" + NILL = 0 # Error, Outside valid area R1 = 1 R2 = 2 diff --git a/pyXSteam/IAPWS_R12.py b/pyXSteam/IAPWS_R12.py index 4cc1ecf..f197b82 100644 --- a/pyXSteam/IAPWS_R12.py +++ b/pyXSteam/IAPWS_R12.py @@ -19,7 +19,7 @@ def _my_dash_0(T_dash: float) -> float: numerator = 100 * math.sqrt(T_dash) denominator = 0 for i in range(0, 4): - denominator += H[i] / T_dash ** i + denominator += H[i] / T_dash**i return numerator / denominator @@ -79,15 +79,13 @@ def _y(xi: float) -> float: coefficient_1 = 1 - summand_0 + summand_1 - summand_2 return coefficient_0 * coefficient_1 - psi_D = math.acos((1 + (q_D ** 2) * (xi ** 2)) ** (-1 / 2)) # ep 17 + psi_D = math.acos((1 + (q_D**2) * (xi**2)) ** (-1 / 2)) # ep 17 summand_0 = 1 / 12 * math.sin(3 * psi_D) # ep16, part 1 summand_1 = (1 / (4 * q_C * xi)) * math.sin(2 * psi_D) # ep16, part 2 - summand_2 = ( - (1 / (q_C * xi) ** 2) * (1 - (5 / 4) * (q_C * xi) ** 2) * math.sin(psi_D) - ) # ep16, part 3 + summand_2 = (1 / (q_C * xi) ** 2) * (1 - (5 / 4) * (q_C * xi) ** 2) * math.sin(psi_D) # ep16, part 3 w = abs((q_C * xi - 1) / (q_C * xi + 1)) ** (1 / 2) * math.tan(psi_D / 2) # ep 19 sum3_sub0 = (1 - (3 / 2 * (q_C * xi) ** 2)) * psi_D @@ -105,9 +103,7 @@ def _sigma(rho_dash: float, T_dash: float) -> float: # eq 21a # TODO logger.debug("rho_dash %f T_dash %f", rho_dash, T_dash) - raise NotImplementedError( - "use derivative of density on pressure at constant temperature" - ) + raise NotImplementedError("use derivative of density on pressure at constant temperature") return -1 @@ -121,7 +117,6 @@ def _delta_chi_dash(rho_dash: float, T_dash: float) -> float: def _my_dash_2(T: float, rho: float, T_dash: float, rho_dash: float) -> float: - if 645.91 < T < 650.77 and 245.8 < rho < 405.3: # eq 13, page 6 logger.debug("values for T and rho are within critical region") # critical region @@ -143,9 +138,7 @@ def _my_dash_2(T: float, rho: float, T_dash: float, rho_dash: float) -> float: logger.debug("value for my_dash_2:%f", my_dash_2) return my_dash_2 - logger.debug( - "values for T and rho are outside of critical region, use my_dash_2=1.0" - ) + logger.debug("values for T and rho are outside of critical region, use my_dash_2=1.0") return 1.0 # section 2.8, page 8 @@ -189,10 +182,7 @@ def eq10(T: float, rho: float, industrial: bool = True) -> float: my_dash = my_dash_0 * my_dash_1 * my_dash_2 # eq 10 - logger.debug( - "calculated values µ_0=%f µ_1=%f µ_2=%f µ_dash=%f" - % (my_dash_0, my_dash_1, my_dash_2, my_dash) - ) + logger.debug("calculated values µ_0=%f µ_1=%f µ_2=%f µ_dash=%f" % (my_dash_0, my_dash_1, my_dash_2, my_dash)) my = my_dash * my_star # eq8, value is in µPa*s # my = my * 10E6 # in Pa*s diff --git a/pyXSteam/IAPWS_R14.py b/pyXSteam/IAPWS_R14.py index adec2ae..02ef4a9 100755 --- a/pyXSteam/IAPWS_R14.py +++ b/pyXSteam/IAPWS_R14.py @@ -48,7 +48,7 @@ def pmelt_T_iceIII(T: float) -> float: T_star = 251.165 p_star = 208.566 theta = T / T_star - pi_melt = 1 - 0.299948 * (1.0 - theta ** 60) + pi_melt = 1 - 0.299948 * (1.0 - theta**60) p_melt = pi_melt * p_star logger.debug("result for 'melting preasure of ice type III': %f", p_melt) return p_melt @@ -67,7 +67,7 @@ def pmelt_T_iceV(T: float) -> float: T_star = 256.164 p_star = 350.1 theta = T / T_star - pi_melt = 1 - 1.18721 * (1.0 - theta ** 8) + pi_melt = 1 - 1.18721 * (1.0 - theta**8) p_melt = pi_melt * p_star logger.debug("result for 'melting preasure of ice type V': %f", p_melt) return p_melt @@ -86,7 +86,7 @@ def pmelt_T_iceVI(T: float) -> float: T_star = 273.31 p_star = 632.4 theta = T / T_star - pi_melt = 1 - 1.07476 * (1.0 - theta ** 4.6) + pi_melt = 1 - 1.07476 * (1.0 - theta**4.6) p_melt = pi_melt * p_star logger.debug("result for 'melting preasure of ice type VI': %f", p_melt) return p_melt @@ -105,9 +105,9 @@ def pmelt_T_iceVII(T: float) -> float: T_star = 355.0 p_star = 2216.0 theta = T / T_star - p1 = 0.173683e1 * (1 - (theta ** -1)) - p2 = 0.544606e-1 * (1 - (theta ** 5)) - p3 = 0.806106e-7 * (1 - (theta ** 22)) + p1 = 0.173683e1 * (1 - (theta**-1)) + p2 = 0.544606e-1 * (1 - (theta**5)) + p3 = 0.806106e-7 * (1 - (theta**22)) pi_melt = math.exp(p1 - p2 + p3) p_melt = pi_melt * p_star logger.debug("result for 'melting preasure of ice type VII': %f", p_melt) @@ -132,7 +132,7 @@ def psubl_T(T: float) -> float: temp_sum = 0 for i in range(0, 3): temp_sum += a[i] * theta ** b[i] - pi_subl = math.exp((theta ** -1) * temp_sum) + pi_subl = math.exp((theta**-1) * temp_sum) p_subl = pi_subl * p_star logger.debug("result for 'sublimation preasure of ice': %f", p_subl) return p_subl diff --git a/pyXSteam/IAPWS_R4.py b/pyXSteam/IAPWS_R4.py index 91027fe..c091ed7 100755 --- a/pyXSteam/IAPWS_R4.py +++ b/pyXSteam/IAPWS_R4.py @@ -33,13 +33,11 @@ def myHW_rhoT_R4(rho: float, T: float) -> float: A = [1.0, 0.940695, 0.578377, -0.202044] sum_A_T = 0 for i in range(0, 4): - sum_A_T += A[i] / (T_dash ** i) + sum_A_T += A[i] / (T_dash**i) my_0_dash = math.sqrt(T_dash) / sum_A_T - B = list() - B.append( - [0.4864192, -0.2448372, -0.8702035, 0.8716056, -1.051126, 0.3458395] - ) # j= 0 + B = [] + B.append([0.4864192, -0.2448372, -0.8702035, 0.8716056, -1.051126, 0.3458395]) # j= 0 B.append([0.3509007, 1.315436, 1.297752, 1.353448, 0.0, 0.0]) # j= 1 B.append([-0.2847572, -1.037026, -1.287846, 0.0, 0.0, -0.02148229]) # j= 2 B.append([0.07013759, 0.4660127, 0.2292075, -0.4857462, 0.0, 0.0]) # j= 3 @@ -67,10 +65,12 @@ def myHW_rhoT_R4(rho: float, T: float) -> float: def tcHW_rhoT_R4(rho: float, T: float) -> float: """ - Thermal conductivity as a function of density and temperature for heavy water substance. + Thermal conductivity as a function of density and temperature for heavy + water substance. Returns NaN if arguments are out of range - Note: function name is using tc instead of lambda to minimize the confusion with the python + Note: function name is using tc instead of lambda to minimize the confusion + with the python function of the same name. :param rho: density value for heavy water in [kg / m³] @@ -78,9 +78,7 @@ def tcHW_rhoT_R4(rho: float, T: float) -> float: :return: thermal conductivity λ or NaN, in [W / (m * K)] """ - logger.debug( - "calculating 'thermal conductivity of heavy water' for ρ=%f and T=%f", rho, T - ) + logger.debug("calculating 'thermal conductivity of heavy water' for ρ=%f and T=%f", rho, T) T_star = 643.847 # K rho_star = 358 # kg / m³ @@ -102,32 +100,30 @@ def tcHW_rhoT_R4(rho: float, T: float) -> float: rho_r1 = 0.125698 D_1 = -741.112 tau = T_dash / (math.fabs(T_dash - 1.1) + 1.1) # B15 - f_1 = math.exp(C_T1 * T_dash + C_T2 * (T_dash ** 2)) # B12 - f_2 = math.exp(C_R1 * (rho_dash - 1.0) ** 2) + C_R2 * math.exp( - C_R3 * (rho_dash - rho_r1) ** 2 - ) # B13 + f_1 = math.exp(C_T1 * T_dash + C_T2 * (T_dash**2)) # B12 + f_2 = math.exp(C_R1 * (rho_dash - 1.0) ** 2) + C_R2 * math.exp(C_R3 * (rho_dash - rho_r1) ** 2) # B13 f_3 = 1 + math.exp(60.0 * (tau - 1.0) + 20.0) # B14 f_4 = 1 + math.exp(100.0 * (tau - 1.0) + 15.0) # B14 - part_C2 = (C_2 * f_1 ** 4) / f_3 + part_C2 = (C_2 * f_1**4) / f_3 part_f2 = (3.5 * f_2) / f_4 # equation B8 temp_sum = 0 for i in range(0, 6): - temp_sum += A[i] * (T_dash ** i) + temp_sum += A[i] * (T_dash**i) tc_o = temp_sum # equation B9 temp_sum = 0 for i in range(1, 5): - temp_sum += B[i] * (rho_dash ** i) + temp_sum += B[i] * (rho_dash**i) delta_tc = B[0] * (1.0 - math.exp(B_e * rho_dash)) + temp_sum # equation B10 - delta_tc_c = C_1 * f_1 * f_2 * (1.0 + f_2 ** 2 * (part_C2 + part_f2)) + delta_tc_c = C_1 * f_1 * f_2 * (1.0 + f_2**2 * (part_C2 + part_f2)) # equation B11 - delta_tc_L = D_1 * f_1 ** 1.2 * (1.0 - math.exp(-1.0 * (rho_dash / 2.5) ** 10)) + delta_tc_L = D_1 * f_1**1.2 * (1.0 - math.exp(-1.0 * (rho_dash / 2.5) ** 10)) # equation B7 tc_dash = tc_o + delta_tc + delta_tc_c + delta_tc_L diff --git a/pyXSteam/IAPWS_R5.py b/pyXSteam/IAPWS_R5.py index b1acbef..6d341c2 100644 --- a/pyXSteam/IAPWS_R5.py +++ b/pyXSteam/IAPWS_R5.py @@ -5,7 +5,6 @@ Revised Release on Surface Tension of Heavy Water Substance http://www.iapws.org/relguide/surfd2o.pdf """ -import math import logging from .Constants import TRIPLE_POINT_TEMPERATURE, CRITICAL_TEMPERATURE_D20_1992 @@ -27,7 +26,6 @@ def surface_tension_T(T: float) -> float: my = 1.25 if TRIPLE_POINT_TEMPERATURE < T < CRITICAL_TEMPERATURE_D20_1992: tau = 1 - T / CRITICAL_TEMPERATURE_D20_1992 - return B * tau ** my * (1 + bb * tau) - else: - logger.warning("Temperature out of range of validity") - return float("NaN") + return B * tau**my * (1 + bb * tau) + logger.warning("Temperature out of range of validity") + return float("NaN") diff --git a/pyXSteam/RegionBorders.py b/pyXSteam/RegionBorders.py index 1d8a364..4ee88f5 100755 --- a/pyXSteam/RegionBorders.py +++ b/pyXSteam/RegionBorders.py @@ -8,12 +8,15 @@ logger = logging.getLogger(__name__) -def B23p_T(T: float) -> float: - """function B23p_T = B23p_T(T) +def pB23_T(T: float) -> float: + """ + calculate preasure from temperature for boundary between region 2 and 3 Section 4.1 Boundary between region 2 and 3. - Release on the IAPWS Industrial formulation 1997 for the Thermodynamic Properties of Water and Steam 1997 Section 4 Auxiliary Equation for the Boundary between Regions 2 and 3 + Release on the IAPWS Industrial formulation 1997 for the Thermodynamic Properties + of Water and Steam 1997 Section 4 Auxiliary Equation for the Boundary + between Regions 2 and 3 Eq 5, Page 5 @@ -21,15 +24,18 @@ def B23p_T(T: float) -> float: :return: preasure in [MPa] """ - return 348.05185628969 - 1.1671859879975 * T + 1.0192970039326e-03 * (T ** 2) + return 348.05185628969 - 1.1671859879975 * T + 1.0192970039326e-03 * (T**2) -def B23T_p(p: float) -> float: - """function B23T_p = B23T_p(p) +def TB23_p(p: float) -> float: + """ + calculate temperature from preasure for boundary between region 2 and 3 Section 4.1 Boundary between region 2 and 3. - Release on the IAPWS Industrial formulation 1997 for the Thermodynamic Properties of Water and Steam 1997 Section 4 Auxiliary Equation for the Boundary between Regions 2 and 3 + Release on the IAPWS Industrial formulation 1997 for the Thermodynamic Properties + of Water and Steam 1997 Section 4 Auxiliary Equation for the Boundary + between Regions 2 and 3 Eq 6, Page 6 @@ -40,82 +46,16 @@ def B23T_p(p: float) -> float: return 572.54459862746 + ((p - 13.91883977887) / 1.0192970039326e-03) ** 0.5 -def p3sat_h(h: float) -> float: - """function p3sat_h = p3sat_h(h) - - Section 4.2 Region 3. pSat_h & pSat_s - - Revised Supplementary Release on Backward Equations for the functions T(p,h), v(p,h) s& T(p,s), v(p,s) for Region 3 of the IAPWS Industrial formulation 1997 for the Thermodynamic Properties of Water & Steam 2004 Section 4 Boundary Equations psat(h) & psat(s) for the Saturation Lines of Region 3 - - See pictures Page 17, Eq 10, Table 17, Page 18 - - :param h: enthalpy in [kJ / kg] - - :return: saturation preasure in [MPa] - """ - Ii = [0, 1, 1, 1, 1, 5, 7, 8, 14, 20, 22, 24, 28, 36] - Ji = [0, 1, 3, 4, 36, 3, 0, 24, 16, 16, 3, 18, 8, 24] - ni = [ - 0.600073641753024, - -9.36203654849857, - 24.6590798594147, - -107.014222858224, - -91582131580576.8, - -8623.32011700662, - -23.5837344740032, - 2.52304969384128e17, - -3.89718771997719e18, - -3.33775713645296e22, - 35649946963.6328, - -1.48547544720641e26, - 3.30611514838798e18, - 8.13641294467829e37, - ] - hs = h / 2600 - ps = 0 - for i in range(0, 14): - ps = ps + ni[i] * (hs - 1.02) ** Ii[i] * (hs - 0.608) ** Ji[i] - return ps * 22 - - -def p3sat_s(s: float) -> float: - """function p3sat_s = p3sat_s(s) - - Section 4.2 Region 3. pSat_h & pSat_s - - :param s: Specific entropy in [kJ / (kg K)] - - :return: saturation preasure in [MPa] - """ - Ii = [0, 1, 1, 4, 12, 12, 16, 24, 28, 32] - Ji = [0, 1, 32, 7, 4, 14, 36, 10, 0, 18] - ni = [ - 0.639767553612785, - -12.9727445396014, - -2.24595125848403e15, - 1774667.41801846, - 7170793495.71538, - -3.78829107169011e17, - -9.55586736431328e34, - 1.87269814676188e23, - 119254746466.473, - 1.10649277244882e36, - ] - Sigma = s / 5.2 - Pi = 0 - for i in range(0, 10): - Pi = Pi + ni[i] * (Sigma - 1.03) ** Ii[i] * (Sigma - 0.699) ** Ji[i] - return Pi * 22 - - def hB13_s(s: float) -> float: - """function hB13_s = hB13_s(s) + """ + calculate enthalpy from specific entropy for border between region 1 and 3 Section 4.3 Region boundary 1 to 3 & 3to2 as a functions of s - Supplementary Release on Backward Equations ( ) , p h s for Region 3, Chapter 4.5 page 23. + Supplementary Release on Backward Equations ( ) , p h s for Region 3, + Chapter 4.5 page 23. - :param s: Specific entropy in [kJ / (kg K)] + :param s: specific entropy in [kJ / (kg K)] :return: enthalpy in [kJ / kg] """ @@ -137,11 +77,14 @@ def hB13_s(s: float) -> float: def TB23_hs(h: float, s: float) -> float: - """function TB23_hs = TB23_hs(h, s) + """ + calculate temperature from specific entropy and enthalpy for border + between region 2 and 3 - Section 4.3 Region boundary 1to3 & 3to2 as a functions of s + Section 4.3 Region boundary 1 to 3 & 3 to 2 as a functions of s - Supplementary Release on Backward Equations () , p h s for Region 3, Chapter 4.6 page 25. + Supplementary Release on Backward Equations () , p h s for Region 3, + Chapter 4.6 page 25. :param h: enthalpy in [kJ / kg] :param s: Specific entropy in [kJ / (kg K)] diff --git a/pyXSteam/RegionSelection.py b/pyXSteam/RegionSelection.py index 5fe9dd3..f59d188 100755 --- a/pyXSteam/RegionSelection.py +++ b/pyXSteam/RegionSelection.py @@ -5,7 +5,7 @@ """ import math import logging -from .RegionBorders import B23p_T, B23T_p, p3sat_h, p3sat_s, hB13_s, TB23_hs +from .RegionBorders import pB23_T, TB23_p, hB13_s, TB23_hs from .Regions import Region1, Region2, Region3, Region4, Region5 from .Constants import ( CRITICAL_TEMPERATURE, @@ -21,23 +21,18 @@ def select_region_pT(p: float, T: float) -> DiagramRegion: """ Section 3.1 Regions as a function of p and T Select diagram region based on values of preasure and temperature - Returns DiagramRegion.NILL if arguments lead to no valid region + Returns `DiagramRegion.NILL` if arguments lead to no valid region :param p: preasure in [MPa] :param T: temperature in [K] :return: diagram region """ - if (T > 1073.15) and (p < 50.0) and (T < 2273.15) and (p > 0.000611): + if 0.000611 < p < 50.0 and 1073.15 < T < 2273.15: return DiagramRegion.R5 - elif ( - (T <= 1073.15) - and (T > FREEZING_TEMPERATURE_H2O) - and (p <= 100) - and (p > 0.000611) - ): + if FREEZING_TEMPERATURE_H2O < T <= 1073.15 and 0.000611 < p <= 100: if T > 623.15: - if p > B23p_T(T): + if p > pB23_T(T): region_pT_number = DiagramRegion.R3 if T < CRITICAL_TEMPERATURE: ps = Region4.p4_T(T) @@ -86,19 +81,13 @@ def select_region_ph(p: float, h: float) -> DiagramRegion: if p < 16.5292: # Below region 3, Check region 1, 4, 2, 5 # Check Region 1 Ts = Region4.T4_p(p) - hL = ( - 109.6635 * math.log(p) + 40.3481 * p + 734.58 - ) # Approximate function for hL_p - if ( - math.fabs(h - hL) < 100 - ): # if approximate is not god enough use real function + hL = 109.6635 * math.log(p) + 40.3481 * p + 734.58 # Approximate function for hL_p + if math.fabs(h - hL) < 100: # if approximate is not god enough use real function hL = Region1.h1_pT(p, Ts) if h <= hL: return DiagramRegion.R1 # Check Region 4 - hV = ( - 45.1768 * math.log(p) - 20.158 * p + 2804.4 - ) # Approximate function for hV_p + hV = 45.1768 * math.log(p) - 20.158 * p + 2804.4 # Approximate function for hV_p if math.fabs(h - hV) < 50: # if approximate is not god enough use real function hV = Region2.h2_pT(p, Ts) if h < hV: @@ -119,21 +108,19 @@ def select_region_ph(p: float, h: float) -> DiagramRegion: return DiagramRegion.R5 logger.warning("Enthalpy outside valid area") return DiagramRegion.NILL - else: # for p > 16.5292 - # Check if in region1 - if h < Region1.h1_pT(p, 623.15): - # region_ph = 1; - return DiagramRegion.R1 - # Check if in region 3 or 4 (Below Reg 2) - if h < Region2.h2_pT(p, B23T_p(p)): - # Region 3 or 4 - if p > p3sat_h(h): - return DiagramRegion.R3 - else: - return DiagramRegion.R4 - # Check if region 2 - if h < Region2.h2_pT(p, 1073.15): - return DiagramRegion.R2 + # for p > 16.5292 + # Check if in region1 + if h < Region1.h1_pT(p, 623.15): + return DiagramRegion.R1 + # Check if in region 3 or 4 (Below Reg 2) + if h < Region2.h2_pT(p, TB23_p(p)): + # Region 3 or 4 + if p > Region3.psat3_h(h): + return DiagramRegion.R3 + return DiagramRegion.R4 + # Check if region 2 + if h < Region2.h2_pT(p, 1073.15): + return DiagramRegion.R2 logger.warning("Preasure outside valid area") return DiagramRegion.NILL @@ -142,32 +129,26 @@ def select_region_ps(p: float, s: float) -> DiagramRegion: """ Section 3.3 Regions as a function of p and s Select diagram region based on values of preasure and specific entropy - Returns DiagramRegion.NILL if arguments lead to no valid region + Returns `DiagramRegion.NILL` if arguments lead to no valid region :param p: preasure in [MPa] :param s: specific entropy in [kJ / (kg K)] :return: diagram region """ - if ( - (p < TRIPLE_POINT_PRESSURE) - or (p > 100) - or (s < 0) - or (s > Region5.s5_pT(p, 2273.15)) - ): + if (p < TRIPLE_POINT_PRESSURE) or (p > 100) or (s < 0) or (s > Region5.s5_pT(p, 2273.15)): logger.warning("Preasure or Entropy outside valid area") return DiagramRegion.NILL # Check region 5 if s > Region2.s2_pT(p, 1073.15): if p <= 10: return DiagramRegion.R5 - else: - logger.warning("Preasure outside valid area") - return DiagramRegion.NILL + logger.warning("Preasure outside valid area") + return DiagramRegion.NILL # Check region 2 if p > 16.529: # Between 5.047 & 5.261. Use to speed up ! - ss = Region2.s2_pT(p, B23T_p(p)) + ss = Region2.s2_pT(p, TB23_p(p)) else: ss = Region2.s2_pT(p, Region4.T4_p(p)) if s > ss: @@ -175,10 +156,9 @@ def select_region_ps(p: float, s: float) -> DiagramRegion: # Check region 3 ss = Region1.s1_pT(p, 623.15) if (p > 16.529) and (s > ss): - if p > p3sat_s(s): + if p > Region3.psat3_s(s): return DiagramRegion.R3 - else: - return DiagramRegion.R4 + return DiagramRegion.R4 # Check region 4 (Not inside region 3) if (p < 16.529) and (s > Region1.s1_pT(p, Region4.T4_p(p))): return DiagramRegion.R4 @@ -193,7 +173,7 @@ def select_region_hs(h: float, s: float) -> DiagramRegion: """ Section 3.4 Regions as a function of h and s Select diagram region based on values of enthalpy and specific entropy - Returns DiagramRegion.NILL if arguments lead to no valid region + Returns `DiagramRegion.NILL` if arguments lead to no valid region :param h: enthalpy in [kJ / kg] :param s: specific entropy in [kJ / (kg K)] @@ -209,48 +189,39 @@ def select_region_hs(h: float, s: float) -> DiagramRegion: logger.warning("Entalpy or Entropy outside valid area") return DiagramRegion.NILL # Kolla 1 eller 4. (+liten bit ???ver B13) - if (s >= -0.0001545495919) and (s <= 3.77828134): + if -0.0001545495919 <= s <= 3.77828134: if h < Region4.h4_s(s): return DiagramRegion.R4 - elif s < 3.397782955: # 100MPa line is limiting + if s < 3.397782955: # 100MPa line is limiting TMax = Region1.T1_ps(100, s) hMax = Region1.h1_pT(100, TMax) if h < hMax: return DiagramRegion.R1 - else: - logger.warning("Entalpy outside valid area") - return DiagramRegion.NILL - else: # The point is either in region 4,1,3. Check B23 - hB = hB13_s(s) - if h < hB: - return DiagramRegion.R1 - TMax = Region3.T3_ps(100, s) - vmax = Region3.v3_ps(100, s) - hMax = Region3.h3_rhoT(1 / vmax, TMax) - if h < hMax: - return DiagramRegion.R3 - else: - logger.warning("Entalpy outside valid area") - return DiagramRegion.NILL + logger.warning("Entalpy outside valid area") + return DiagramRegion.NILL + # The point is either in region 4,1,3. Check B23 + hB = hB13_s(s) + if h < hB: + return DiagramRegion.R1 + TMax = Region3.T3_ps(100, s) + vmax = Region3.v3_ps(100, s) + hMax = Region3.h3_rhoT(1 / vmax, TMax) + if h < hMax: + return DiagramRegion.R3 + logger.warning("Entalpy outside valid area") + return DiagramRegion.NILL # Kolla region 2 eller 4. (???vre delen av omr???de b23-> max) - if (s >= 5.260578707) and (s <= 11.9212156897728): + if 5.260578707 <= s <= 11.9212156897728: if s > 9.155759395: # Above region 4 Tmin = Region2.T2_ps(0.000611, s) hMin = Region2.h2_pT(0.000611, Tmin) # function adapted to h(1073.15,s) - hMax = ( - -0.07554022 * s ** 4 - + 3.341571 * s ** 3 - - 55.42151 * s ** 2 - + 408.515 * s - + 3031.338 - ) - if (h > hMin) and (h < hMax): + hMax = -0.07554022 * s**4 + 3.341571 * s**3 - 55.42151 * s**2 + 408.515 * s + 3031.338 + if hMin < h < hMax: return DiagramRegion.R2 - else: - logger.warning("Entalpy outside valid area") - return DiagramRegion.NILL + logger.warning("Entalpy outside valid area") + return DiagramRegion.NILL hV = Region4.h4_s(s) if h < hV: # Region 4. Under region 3. return DiagramRegion.R4 @@ -259,20 +230,13 @@ def select_region_hs(h: float, s: float) -> DiagramRegion: hMax = Region2.h2_pT(100, TMax) else: # function adapted to h(1073.15,s) - hMax = ( - -2.988734 * s ** 4 - + 121.4015 * s ** 3 - - 1805.15 * s ** 2 - + 11720.16 * s - - 23998.33 - ) + hMax = -2.988734 * s**4 + 121.4015 * s**3 - 1805.15 * s**2 + 11720.16 * s - 23998.33 if h < hMax: # Region 2. ???ver region 4. return DiagramRegion.R2 - else: - logger.warning("Entalpy outside valid area") - return DiagramRegion.NILL + logger.warning("Entalpy outside valid area") + return DiagramRegion.NILL # Check region 3 or 4 below the critical point. - if (s >= 3.77828134) and (s <= 4.41202148223476): + if 3.77828134 <= s <= 4.41202148223476: hL = Region4.h4_s(s) if h < hL: return DiagramRegion.R4 @@ -281,11 +245,10 @@ def select_region_hs(h: float, s: float) -> DiagramRegion: hMax = Region3.h3_rhoT(1 / vmax, TMax) if h < hMax: return DiagramRegion.R3 - else: - logger.warning("Entalpy outside valid area") - return DiagramRegion.NILL + logger.warning("Entalpy outside valid area") + return DiagramRegion.NILL # Check region 3 or 4 from the critical point to the upper part of B23 - if (s >= 4.41202148223476) and (s <= 5.260578707): + if 4.41202148223476 <= s <= 5.260578707: hV = Region4.h4_s(s) if h < hV: return DiagramRegion.R4 @@ -296,34 +259,28 @@ def select_region_hs(h: float, s: float) -> DiagramRegion: hMax = Region3.h3_rhoT(1 / vmax, TMax) if h < hMax: return DiagramRegion.R3 - else: + logger.warning("Entalpy outside valid area") + return DiagramRegion.NILL + # In the area of B23 in s area. + if h > 2812.942061: # Above B23 in h_led + if s > 5.09796573397125: + TMax = Region2.T2_ps(100, s) + hMax = Region2.h2_pT(100, TMax) + if h < hMax: + return DiagramRegion.R2 logger.warning("Entalpy outside valid area") return DiagramRegion.NILL - else: # In the area of B23 in s area. - if h > 2812.942061: # Above B23 in h_led - if s > 5.09796573397125: - TMax = Region2.T2_ps(100, s) - hMax = Region2.h2_pT(100, TMax) - if h < hMax: - return DiagramRegion.R2 - else: - logger.warning("Entalpy outside valid area") - return DiagramRegion.NILL - else: - logger.warning("Entropy outside valid area") - return DiagramRegion.NILL - if ( - h < 2563.592004 - ): # Below B23 in h_led but we have already checked above for hV2c3b - return DiagramRegion.R3 - # We are in the B23 field in both s and h joints. - Tact = TB23_hs(h, s) - pact = Region2.p2_hs(h, s) - pBound = B23p_T(Tact) - if pact > pBound: - return DiagramRegion.R3 - else: - return DiagramRegion.R2 + logger.warning("Entropy outside valid area") + return DiagramRegion.NILL + if h < 2563.592004: # Below B23 in h_led but we have already checked above for hV2c3b + return DiagramRegion.R3 + # We are in the B23 field in both s and h joints. + Tact = TB23_hs(h, s) + pact = Region2.p2_hs(h, s) + pBound = pB23_T(Tact) + if pact > pBound: + return DiagramRegion.R3 + return DiagramRegion.R2 logger.warning("Entropy and Entalpy outside valid area") return DiagramRegion.NILL @@ -332,7 +289,7 @@ def select_region_prho(p: float, rho: float) -> DiagramRegion: """ Section 3.5 Regions as a function of p and rho Select diagram region based on values of preasure and density - Returns DiagramRegion.NILL if arguments lead to no valid region + Returns `DiagramRegion.NILL` if arguments lead to no valid region :param p: preasure in [MPa] :param rho: density in [kg / m³] @@ -344,9 +301,9 @@ def select_region_prho(p: float, rho: float) -> DiagramRegion: logger.warning("Preasure outside valid area") return DiagramRegion.NILL if p < 16.5292: # Below region 3, Check region 1,4,2 - if v < Region1.v1_pT( - p, FREEZING_TEMPERATURE_H2O - ): # Observe that this is not actually min of v. Not valid Water of 4???C is ligther. + if v < Region1.v1_pT(p, FREEZING_TEMPERATURE_H2O): + # Observe that this is not actually min of v. Not valid for Water + # if temperature is smaler than 4°C since it is ligther. logger.warning("Specific volume outside valid area") return DiagramRegion.NILL if v <= Region1.v1_pT(p, Region4.T4_p(p)): @@ -361,24 +318,21 @@ def select_region_prho(p: float, rho: float) -> DiagramRegion: if v <= Region5.v5_pT(p, 2073.15): return DiagramRegion.R5 else: # Check region 1,3,4,3,2 (Above the lowest point of region 3.) - if v < Region1.v1_pT( - p, FREEZING_TEMPERATURE_H2O - ): # Observe that this is not actually min of v. Not valid Water of 4°C is ligther. + if v < Region1.v1_pT(p, FREEZING_TEMPERATURE_H2O): + # Observe that this is not actually min of v. Not valid for Water + # if temperature is smaler than 4°C since it is ligther. logger.warning("Specific volume outside valid area") return DiagramRegion.NILL if v < Region1.v1_pT(p, 623.15): return DiagramRegion.R1 # Check if in region 3 or 4 (Below Reg 2) - if v < Region2.v2_pT(p, B23T_p(p)): + if v < Region2.v2_pT(p, TB23_p(p)): # Region 3 or 4 if p > 22.064: # Above region 4 return DiagramRegion.R3 - if (v < Region3.v3_ph(p, Region4.h4L_p(p))) or ( - v > Region3.v3_ph(p, Region4.h4V_p(p)) - ): # Uses iteration!! + if (v < Region3.v3_ph(p, Region4.h4L_p(p))) or (v > Region3.v3_ph(p, Region4.h4V_p(p))): # Uses iteration!! return DiagramRegion.R3 - else: - return DiagramRegion.R4 + return DiagramRegion.R4 # Check if region 2 if v < Region2.v2_pT(p, 1073.15): return DiagramRegion.R2 diff --git a/pyXSteam/Regions.py b/pyXSteam/Regions.py index ac8c3dc..06f6d80 100755 --- a/pyXSteam/Regions.py +++ b/pyXSteam/Regions.py @@ -6283,7 +6283,7 @@ def h4L_p(cls, p: float) -> float: :return: enthalpy in [kJ / kg] """ hs = float("NaN") - if (p > TRIPLE_POINT_PRESSURE) and (p < CRITICAL_PRESSURE): + if TRIPLE_POINT_PRESSURE < p < CRITICAL_PRESSURE: Ts = Region4.T4_p(p) if p < 16.529: h4L_p = Region1.h1_pT(p, Ts) @@ -6325,7 +6325,7 @@ def h4V_p(cls, p: float) -> float: :return: enthalpy in [kJ / kg] """ hs = float("NaN") - if (p > TRIPLE_POINT_PRESSURE) and (p < CRITICAL_PRESSURE): + if TRIPLE_POINT_PRESSURE < p < CRITICAL_PRESSURE: Ts = Region4.T4_p(p) if p < 16.529: h4V_p = Region2.h2_pT(p, Ts) diff --git a/pyXSteam/TransportProperties.py b/pyXSteam/TransportProperties.py index f830a70..8a36281 100755 --- a/pyXSteam/TransportProperties.py +++ b/pyXSteam/TransportProperties.py @@ -8,9 +8,6 @@ from .RegionSelection import ( select_region_pT, select_region_ph, - select_region_ps, - select_region_hs, - select_region_prho, ) from .Regions import Region1, Region2, Region3, Region4, Region5 from .Constants import CRITICAL_TEMPERATURE, FREEZING_TEMPERATURE_H2O @@ -55,14 +52,14 @@ def my_AllRegions_pT(p: float, T: float) -> float: # Check valid area if ( (T > (900 + FREEZING_TEMPERATURE_H2O)) - or ((T > (600 + FREEZING_TEMPERATURE_H2O)) and (p > 300)) - or ((T > (150 + FREEZING_TEMPERATURE_H2O)) and (p > 350)) + or (T > (600 + FREEZING_TEMPERATURE_H2O) and (p > 300)) + or (T > (150 + FREEZING_TEMPERATURE_H2O) and (p > 350)) or (p > 500) ): logger.warning("Temperature and/or Preasure out of range of validity") return float("NaN") - my0 = Ts ** 0.5 / (1 + 0.978197 / Ts + 0.579829 / (Ts ** 2) - 0.202354 / (Ts ** 3)) + my0 = Ts**0.5 / (1 + 0.978197 / Ts + 0.579829 / (Ts**2) - 0.202354 / (Ts**3)) temp_sum = 0 for i in range(0, 6): temp_sum = ( @@ -136,7 +133,7 @@ def my_AllRegions_ph(p: float, h: float) -> float: logger.warning("Temperature and/or Preasure out of range of validity") return float("NaN") - my0 = Ts ** 0.5 / (1 + 0.978197 / Ts + 0.579829 / (Ts ** 2) - 0.202354 / (Ts ** 3)) + my0 = Ts**0.5 / (1 + 0.978197 / Ts + 0.579829 / (Ts**2) - 0.202354 / (Ts**3)) temp_sum = 0 for i in range(0, 6): @@ -170,11 +167,11 @@ def tc_ptrho(p: float, T: float, rho: float) -> float: if T < FREEZING_TEMPERATURE_H2O: logger.warning("Temperature out of range of validity") return float("NaN") - elif T < 500 + FREEZING_TEMPERATURE_H2O: + if T < 500 + FREEZING_TEMPERATURE_H2O: if p > 100: logger.warning("Preasure out of range of validity") return float("NaN") - elif T <= 650 + FREEZING_TEMPERATURE_H2O: + if T <= 650 + FREEZING_TEMPERATURE_H2O: if p > 70: logger.warning("Preasure out of range of validity") return float("NaN") @@ -187,15 +184,9 @@ def tc_ptrho(p: float, T: float, rho: float) -> float: T = T / 647.26 # Page 8, Eq 4 rho = rho / 317.7 # Page 8, Eq 5 - tc0 = T ** 0.5 * ( - 0.0102811 + 0.0299621 * T + 0.0156146 * (T ** 2) - 0.00422464 * (T ** 3) - ) # Page 9, Eq 9 + tc0 = T**0.5 * (0.0102811 + 0.0299621 * T + 0.0156146 * (T**2) - 0.00422464 * (T**3)) # Page 9, Eq 9 - tc1 = ( - -0.397070 - + 0.400302 * rho - + 1.06 * math.exp(-0.171587 * ((rho + 2.392190) ** 2)) - ) # Page 9, Eq 10 + tc1 = -0.397070 + 0.400302 * rho + 1.06 * math.exp(-0.171587 * ((rho + 2.392190) ** 2)) # Page 9, Eq 10 dT = abs(T - 1) + 0.00308976 # Page 9, Eq 12 Q = 2 + 0.0822994 / (dT ** (3 / 5)) # Page 10, Eq 13 @@ -205,11 +196,9 @@ def tc_ptrho(p: float, T: float, rho: float) -> float: s = 10.0932 / (dT ** (3 / 5)) tc2 = ( - (0.0701309 / (T ** 10) + 0.0118520) - * (rho ** (9 / 5)) - * math.exp(0.642857 * (1 - rho ** (14 / 5))) - + 0.00169937 * s * (rho ** Q) * math.exp((Q / (1 + Q)) * (1 - rho ** (1 + Q))) - - 1.02 * math.exp(-4.11717 * (T ** (3 / 2)) - 6.17937 / (rho ** 5)) + (0.0701309 / (T**10) + 0.0118520) * (rho ** (9 / 5)) * math.exp(0.642857 * (1 - rho ** (14 / 5))) + + 0.00169937 * s * (rho**Q) * math.exp((Q / (1 + Q)) * (1 - rho ** (1 + Q))) + - 1.02 * math.exp(-4.11717 * (T ** (3 / 2)) - 6.17937 / (rho**5)) ) # Page 9, Eq 11 return tc0 + tc1 + tc2 # Page 9, Eq 8 @@ -238,4 +227,4 @@ def surface_tension_T(T: float) -> float: return float("NaN") tau = 1 - T / tc - return B * tau ** my * (1 + bb * tau) + return B * tau**my * (1 + bb * tau) diff --git a/pyXSteam/XSteam.py b/pyXSteam/XSteam.py index 914f5e2..953632f 100755 --- a/pyXSteam/XSteam.py +++ b/pyXSteam/XSteam.py @@ -376,9 +376,8 @@ def hV_p(self, p: float) -> float: p = self._unit_converter.toSIunit_p(p) if TRIPLE_POINT_PRESSURE < p < CRITICAL_PRESSURE: return self._unit_converter.fromSIunit_h(Region4.h4V_p(p)) - else: - self.logger.warning("pressure %f out of range", p) - return float("NaN") + self.logger.warning("pressure %f out of range", p) + return float("NaN") def hL_p(self, p: float) -> float: """ @@ -392,9 +391,8 @@ def hL_p(self, p: float) -> float: p = self._unit_converter.toSIunit_p(p) if TRIPLE_POINT_PRESSURE < p < CRITICAL_PRESSURE: return self._unit_converter.fromSIunit_h(Region4.h4L_p(p)) - else: - self.logger.warning("pressure %f out of range", p) - return float("NaN") + self.logger.warning("pressure %f out of range", p) + return float("NaN") def hV_t(self, t: float) -> float: """ @@ -409,9 +407,8 @@ def hV_t(self, t: float) -> float: if FREEZING_TEMPERATURE_H2O < T < CRITICAL_TEMPERATURE: p = Region4.p4_T(T) return self._unit_converter.fromSIunit_h(Region4.h4V_p(p)) - else: - self.logger.warning("temperature %f out of range", T) - return float("NaN") + self.logger.warning("temperature %f out of range", T) + return float("NaN") def hL_t(self, t: float) -> float: """ @@ -426,9 +423,8 @@ def hL_t(self, t: float) -> float: if FREEZING_TEMPERATURE_H2O < T < CRITICAL_TEMPERATURE: p = Region4.p4_T(T) return self._unit_converter.fromSIunit_h(Region4.h4L_p(p)) - else: - self.logger.warning("temperature %f out of range", T) - return float("NaN") + self.logger.warning("temperature %f out of range", T) + return float("NaN") def h_pt(self, p: float, t: float) -> float: """ @@ -445,27 +441,27 @@ def h_pt(self, p: float, t: float) -> float: region = select_region_pT(p, T) if region == DiagramRegion.R1: return self._unit_converter.fromSIunit_h(Region1.h1_pT(p, T)) - elif region == DiagramRegion.R2: + if region == DiagramRegion.R2: return self._unit_converter.fromSIunit_h(Region2.h2_pT(p, T)) - elif region == DiagramRegion.R3: + if region == DiagramRegion.R3: return self._unit_converter.fromSIunit_h(Region3.h3_pT(p, T)) - elif region == DiagramRegion.R4: + if region == DiagramRegion.R4: self.logger.warning( "function h_pt is not available in region 4 for input p %f and T %f", p, T, ) return float("NaN") - elif region == DiagramRegion.R5: + if region == DiagramRegion.R5: return self._unit_converter.fromSIunit_h(Region5.h5_pT(p, T)) - else: - self.logger.warning( - "Region switch h_pt returned unknown value %d for input p %f and T %f", - region, - p, - T, - ) - return float("NaN") + + self.logger.warning( + "Region switch h_pt returned unknown value %d for input p %f and T %f", + region, + p, + T, + ) + return float("NaN") def h_ps(self, p: float, s: float) -> float: """ @@ -482,23 +478,23 @@ def h_ps(self, p: float, s: float) -> float: region = select_region_ps(p, s) if region == DiagramRegion.R1: return self._unit_converter.fromSIunit_h(Region1.h1_pT(p, Region1.T1_ps(p, s))) - elif region == DiagramRegion.R2: + if region == DiagramRegion.R2: return self._unit_converter.fromSIunit_h(Region2.h2_pT(p, Region2.T2_ps(p, s))) - elif region == DiagramRegion.R3: + if region == DiagramRegion.R3: return self._unit_converter.fromSIunit_h(Region3.h3_rhoT(1 / Region3.v3_ps(p, s), Region3.T3_ps(p, s))) - elif region == DiagramRegion.R4: + if region == DiagramRegion.R4: xs = Region4.x4_ps(p, s) return self._unit_converter.fromSIunit_h(xs * Region4.h4V_p(p) + (1 - xs) * Region4.h4L_p(p)) - elif region == DiagramRegion.R5: + if region == DiagramRegion.R5: return self._unit_converter.fromSIunit_h(Region5.h5_pT(p, Region5.T5_ps(p, s))) - else: - self.logger.warning( - "Region switch h_ps returned unknown value %d for input p %f and s %f ", - region, - p, - s, - ) - return float("NaN") + + self.logger.warning( + "Region switch h_ps returned unknown value %d for input p %f and s %f ", + region, + p, + s, + ) + return float("NaN") def h_px(self, p: float, x: float) -> float: """ @@ -534,11 +530,11 @@ def h_prho(self, p: float, rho: float) -> float: region = select_region_prho(p, rho) if region == DiagramRegion.R1: return self._unit_converter.fromSIunit_h(Region1.h1_pT(p, Region1.T1_prho(p, rho))) - elif region == DiagramRegion.R2: + if region == DiagramRegion.R2: return self._unit_converter.fromSIunit_h(Region2.h2_pT(p, Region2.T2_prho(p, rho))) - elif region == DiagramRegion.R3: + if region == DiagramRegion.R3: return self._unit_converter.fromSIunit_h(Region3.h3_rhoT(rho, Region3.T3_prho(p, rho))) - elif region == DiagramRegion.R4: + if region == DiagramRegion.R4: if p < 16.529: vV = Region2.v2_pT(p, Region4.T4_p(p)) vL = Region1.v1_pT(p, Region4.T4_p(p)) @@ -549,16 +545,16 @@ def h_prho(self, p: float, rho: float) -> float: hL = Region4.h4L_p(p) x = (1 / rho - vL) / (vV - vL) return self._unit_converter.fromSIunit_h((1 - x) * hL + x * hV) - elif region == DiagramRegion.R5: + if region == DiagramRegion.R5: return self._unit_converter.fromSIunit_h(Region5.h5_pT(p, Region5.T5_prho(p, rho))) - else: - self.logger.warning( - "Region switch h_prho returned unknown value %d for input p %f and rho %f", - region, - p, - rho, - ) - return float("NaN") + + self.logger.warning( + "Region switch h_prho returned unknown value %d for input p %f and rho %f", + region, + p, + rho, + ) + return float("NaN") def h_tx(self, t: float, x: float) -> float: """ @@ -594,11 +590,9 @@ def vV_p(self, p: float) -> float: if TRIPLE_POINT_PRESSURE < p < CRITICAL_PRESSURE: if p < 16.529: return self._unit_converter.fromSIunit_v(Region2.v2_pT(p, Region4.T4_p(p))) - else: - return self._unit_converter.fromSIunit_v(Region3.v3_ph(p, Region4.h4V_p(p))) - else: - self.logger.warning("pressure %f out of range", p) - return float("NaN") + return self._unit_converter.fromSIunit_v(Region3.v3_ph(p, Region4.h4V_p(p))) + self.logger.warning("pressure %f out of range", p) + return float("NaN") def vL_p(self, p: float) -> float: """ @@ -613,11 +607,9 @@ def vL_p(self, p: float) -> float: if TRIPLE_POINT_PRESSURE < p < CRITICAL_PRESSURE: if p < 16.529: return self._unit_converter.fromSIunit_v(Region1.v1_pT(p, Region4.T4_p(p))) - else: - return self._unit_converter.fromSIunit_v(Region3.v3_ph(p, Region4.h4L_p(p))) - else: - self.logger.warning("pressure %f out of range", p) - return float("NaN") + return self._unit_converter.fromSIunit_v(Region3.v3_ph(p, Region4.h4L_p(p))) + self.logger.warning("pressure %f out of range", p) + return float("NaN") def vV_t(self, t: float) -> float: """ @@ -632,11 +624,9 @@ def vV_t(self, t: float) -> float: if FREEZING_TEMPERATURE_H2O < T < CRITICAL_TEMPERATURE: if T <= 623.15: return self._unit_converter.fromSIunit_v(Region2.v2_pT(Region4.p4_T(T), T)) - else: - return self._unit_converter.fromSIunit_v(Region3.v3_ph(Region4.p4_T(T), Region4.h4V_p(Region4.p4_T(T)))) - else: - self.logger.warning("temperature %f out of range", T) - return float("NaN") + return self._unit_converter.fromSIunit_v(Region3.v3_ph(Region4.p4_T(T), Region4.h4V_p(Region4.p4_T(T)))) + self.logger.warning("temperature %f out of range", T) + return float("NaN") def vL_t(self, t: float) -> float: """ @@ -651,11 +641,9 @@ def vL_t(self, t: float) -> float: if FREEZING_TEMPERATURE_H2O < T < CRITICAL_TEMPERATURE: if T <= 623.15: return self._unit_converter.fromSIunit_v(Region1.v1_pT(Region4.p4_T(T), T)) - else: - return self._unit_converter.fromSIunit_v(Region3.v3_ph(Region4.p4_T(T), Region4.h4L_p(Region4.p4_T(T)))) - else: - self.logger.warning("temperature %f out of range", T) - return float("NaN") + return self._unit_converter.fromSIunit_v(Region3.v3_ph(Region4.p4_T(T), Region4.h4L_p(Region4.p4_T(T)))) + self.logger.warning("temperature %f out of range", T) + return float("NaN") def v_pt(self, p: float, t: float) -> float: """ @@ -874,11 +862,9 @@ def sV_p(self, p: float) -> float: if TRIPLE_POINT_PRESSURE < p < CRITICAL_PRESSURE: if p < 16.529: return self._unit_converter.fromSIunit_s(Region2.s2_pT(p, Region4.T4_p(p))) - else: - return self._unit_converter.fromSIunit_s(Region3.s3_rhoT(1 / (Region3.v3_ph(p, Region4.h4V_p(p))), Region4.T4_p(p))) - else: - self.logger.warning("pressure %f out of range", p) - return float("NaN") + return self._unit_converter.fromSIunit_s(Region3.s3_rhoT(1 / (Region3.v3_ph(p, Region4.h4V_p(p))), Region4.T4_p(p))) + self.logger.warning("pressure %f out of range", p) + return float("NaN") def sL_p(self, p: float) -> float: """ @@ -893,11 +879,9 @@ def sL_p(self, p: float) -> float: if TRIPLE_POINT_PRESSURE < p < CRITICAL_PRESSURE: if p < 16.529: return self._unit_converter.fromSIunit_s(Region1.s1_pT(p, Region4.T4_p(p))) - else: - return self._unit_converter.fromSIunit_s(Region3.s3_rhoT(1 / (Region3.v3_ph(p, Region4.h4L_p(p))), Region4.T4_p(p))) - else: - self.logger.warning("pressure %f out of range", p) - return float("NaN") + return self._unit_converter.fromSIunit_s(Region3.s3_rhoT(1 / (Region3.v3_ph(p, Region4.h4L_p(p))), Region4.T4_p(p))) + self.logger.warning("pressure %f out of range", p) + return float("NaN") def sV_t(self, t: float) -> float: """ @@ -912,16 +896,14 @@ def sV_t(self, t: float) -> float: if FREEZING_TEMPERATURE_H2O < T < CRITICAL_TEMPERATURE: if T <= 623.15: return self._unit_converter.fromSIunit_s(Region2.s2_pT(Region4.p4_T(T), T)) - else: - return self._unit_converter.fromSIunit_s( - Region3.s3_rhoT( - 1 / (Region3.v3_ph(Region4.p4_T(T), Region4.h4V_p(Region4.p4_T(T)))), - T, - ) + return self._unit_converter.fromSIunit_s( + Region3.s3_rhoT( + 1 / (Region3.v3_ph(Region4.p4_T(T), Region4.h4V_p(Region4.p4_T(T)))), + T, ) - else: - self.logger.warning("temperature %f out of range", T) - return float("NaN") + ) + self.logger.warning("temperature %f out of range", T) + return float("NaN") def sL_t(self, t: float) -> float: """ @@ -936,16 +918,14 @@ def sL_t(self, t: float) -> float: if FREEZING_TEMPERATURE_H2O < T < CRITICAL_TEMPERATURE: if T <= 623.15: return self._unit_converter.fromSIunit_s(Region1.s1_pT(Region4.p4_T(T), T)) - else: - return self._unit_converter.fromSIunit_s( - Region3.s3_rhoT( - 1 / (Region3.v3_ph(Region4.p4_T(T), Region4.h4L_p(Region4.p4_T(T)))), - T, - ) + return self._unit_converter.fromSIunit_s( + Region3.s3_rhoT( + 1 / (Region3.v3_ph(Region4.p4_T(T), Region4.h4L_p(Region4.p4_T(T)))), + T, ) - else: - self.logger.warning("temperature %f out of range", T) - return float("NaN") + ) + self.logger.warning("temperature %f out of range", T) + return float("NaN") def s_pt(self, p: float, t: float) -> float: """ @@ -962,25 +942,25 @@ def s_pt(self, p: float, t: float) -> float: region = select_region_pT(p, T) if region == DiagramRegion.R1: return self._unit_converter.fromSIunit_s(Region1.s1_pT(p, T)) - elif region == DiagramRegion.R2: + if region == DiagramRegion.R2: return self._unit_converter.fromSIunit_s(Region2.s2_pT(p, T)) - elif region == DiagramRegion.R3: + if region == DiagramRegion.R3: hs = Region3.h3_pT(p, T) rhos = 1 / Region3.v3_ph(p, hs) return self._unit_converter.fromSIunit_s(Region3.s3_rhoT(rhos, T)) - elif region == DiagramRegion.R4: + if region == DiagramRegion.R4: self.logger.warning("function s_pt is not available in region 4 (p %f, T %f)", p, T) return float("NaN") - elif region == DiagramRegion.R5: + if region == DiagramRegion.R5: return self._unit_converter.fromSIunit_s(Region5.s5_pT(p, T)) - else: - self.logger.warning( - "Region switch s_pt returned unknown value %d for input p %f and T %f", - region, - p, - T, - ) - return float("NaN") + + self.logger.warning( + "Region switch s_pt returned unknown value %d for input p %f and T %f", + region, + p, + T, + ) + return float("NaN") def s_ph(self, p: float, h: float) -> float: """ @@ -1020,14 +1000,13 @@ def s_ph(self, p: float, h: float) -> float: elif region == DiagramRegion.R5: T = Region5.T5_ph(p, h) return self._unit_converter.fromSIunit_s(Region5.s5_pT(p, T)) - else: - self.logger.warning( - "Region switch s_ph returned unknown value %d for input p %f and h %f", - region, - p, - h, - ) - return float("NaN") + self.logger.warning( + "Region switch s_ph returned unknown value %d for input p %f and h %f", + region, + p, + h, + ) + return float("NaN") def uV_p(self, p: float) -> float: """ @@ -1042,10 +1021,8 @@ def uV_p(self, p: float) -> float: if TRIPLE_POINT_PRESSURE < p < CRITICAL_PRESSURE: if p < 16.529: return self._unit_converter.fromSIunit_u(Region2.u2_pT(p, Region4.T4_p(p))) - else: - return self._unit_converter.fromSIunit_u(Region3.u3_rhoT(1 / (Region3.v3_ph(p, Region4.h4V_p(p))), Region4.T4_p(p))) - else: - return float("NaN") + return self._unit_converter.fromSIunit_u(Region3.u3_rhoT(1 / (Region3.v3_ph(p, Region4.h4V_p(p))), Region4.T4_p(p))) + return float("NaN") def uL_p(self, p: float) -> float: """ @@ -1060,11 +1037,9 @@ def uL_p(self, p: float) -> float: if TRIPLE_POINT_PRESSURE < p < CRITICAL_PRESSURE: if p < 16.529: return self._unit_converter.fromSIunit_u(Region1.u1_pT(p, Region4.T4_p(p))) - else: - return self._unit_converter.fromSIunit_u(Region3.u3_rhoT(1 / (Region3.v3_ph(p, Region4.h4L_p(p))), Region4.T4_p(p))) - else: - self.logger.warning("pressure %f out of range", p) - return float("NaN") + return self._unit_converter.fromSIunit_u(Region3.u3_rhoT(1 / (Region3.v3_ph(p, Region4.h4L_p(p))), Region4.T4_p(p))) + self.logger.warning("pressure %f out of range", p) + return float("NaN") def uV_t(self, t: float) -> float: """ @@ -1079,16 +1054,14 @@ def uV_t(self, t: float) -> float: if FREEZING_TEMPERATURE_H2O < T < CRITICAL_TEMPERATURE: if T <= 623.15: return self._unit_converter.fromSIunit_u(Region2.u2_pT(Region4.p4_T(T), T)) - else: - return self._unit_converter.fromSIunit_u( - Region3.u3_rhoT( - 1 / (Region3.v3_ph(Region4.p4_T(T), Region4.h4V_p(Region4.p4_T(T)))), - T, - ) + return self._unit_converter.fromSIunit_u( + Region3.u3_rhoT( + 1 / (Region3.v3_ph(Region4.p4_T(T), Region4.h4V_p(Region4.p4_T(T)))), + T, ) - else: - self.logger.warning("temperature %f out of range", T) - return float("NaN") + ) + self.logger.warning("temperature %f out of range", T) + return float("NaN") def uL_t(self, t: float) -> float: """ @@ -1271,11 +1244,9 @@ def CpV_p(self, p: float) -> float: if TRIPLE_POINT_PRESSURE < p < CRITICAL_PRESSURE: if p < 16.529: return self._unit_converter.fromSIunit_Cp(Region2.Cp2_pT(p, Region4.T4_p(p))) - else: - return self._unit_converter.fromSIunit_Cp(Region3.Cp3_rhoT(1 / (Region3.v3_ph(p, Region4.h4V_p(p))), Region4.T4_p(p))) - else: - self.logger.warning("preassure %f out of range", p) - return float("NaN") + return self._unit_converter.fromSIunit_Cp(Region3.Cp3_rhoT(1 / (Region3.v3_ph(p, Region4.h4V_p(p))), Region4.T4_p(p))) + self.logger.warning("preassure %f out of range", p) + return float("NaN") def CpL_p(self, p: float) -> float: """ @@ -1290,11 +1261,9 @@ def CpL_p(self, p: float) -> float: if TRIPLE_POINT_PRESSURE < p < CRITICAL_PRESSURE: if p < 16.529: return self._unit_converter.fromSIunit_Cp(Region1.Cp1_pT(p, Region4.T4_p(p))) - else: - return self._unit_converter.fromSIunit_Cp(Region3.Cp3_rhoT(1 / (Region3.v3_ph(p, Region4.h4L_p(p))), Region4.T4_p(p))) - else: - self.logger.warning("preassure %f out of range", p) - return float("NaN") + return self._unit_converter.fromSIunit_Cp(Region3.Cp3_rhoT(1 / (Region3.v3_ph(p, Region4.h4L_p(p))), Region4.T4_p(p))) + self.logger.warning("preassure %f out of range", p) + return float("NaN") def CpV_t(self, t: float) -> float: """ @@ -1309,16 +1278,14 @@ def CpV_t(self, t: float) -> float: if FREEZING_TEMPERATURE_H2O < T < CRITICAL_TEMPERATURE: if T <= 623.15: return self._unit_converter.fromSIunit_Cp(Region2.Cp2_pT(Region4.p4_T(T), T)) - else: - return self._unit_converter.fromSIunit_Cp( - Region3.Cp3_rhoT( - 1 / (Region3.v3_ph(Region4.p4_T(T), Region4.h4V_p(Region4.p4_T(T)))), - T, - ) + return self._unit_converter.fromSIunit_Cp( + Region3.Cp3_rhoT( + 1 / (Region3.v3_ph(Region4.p4_T(T), Region4.h4V_p(Region4.p4_T(T)))), + T, ) - else: - self.logger.warning("temperature %f out of range", T) - return float("NaN") + ) + self.logger.warning("temperature %f out of range", T) + return float("NaN") def CpL_t(self, t: float) -> float: """ @@ -2415,9 +2382,8 @@ def psubl_t(self, t: float) -> float: T = self._unit_converter.toSIunit_T(t) if 50 <= T < 273.16: return self._unit_converter.fromSIunit_p(psubl_T(T)) - else: - self.logger.warning("temperature %f out of range", T) - return float("NaN") + self.logger.warning("temperature %f out of range", T) + return float("NaN") def R12_my_rhot(self, rho: float, t: float, industrial_application: bool = True) -> float: """shear viscosity of pure water substance over an extensive range of fluid states diff --git a/pyXSteam/__init__.py b/pyXSteam/__init__.py index 5f04605..6038a8e 100755 --- a/pyXSteam/__init__.py +++ b/pyXSteam/__init__.py @@ -11,5 +11,7 @@ from .UnitConverter import UnitConverter from .Constants import UnitSystem, IceType -name = "pyXSteam" -__version__ = "0.4.9" +__version__ = "0.5.x" +__author__ = "drunsinn" +__license__ = "MIT" +__email__ = "dr.unsinn@googlemail.com" diff --git a/pyXSteam/scripts/__init__.py b/pyXSteam/scripts/__init__.py new file mode 100755 index 0000000..79f701a --- /dev/null +++ b/pyXSteam/scripts/__init__.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +.. codeauthor:: drunsinn +.. Licensed under the GNU General Public License v2 (GPLv2) +.. Source at https://github.com/drunsinn/pyXSteam + +Collection of demo scripts for pyXSteam""" diff --git a/bin/pyXSteamDemo.py b/pyXSteam/scripts/pyXSteamDemo.py similarity index 95% rename from bin/pyXSteamDemo.py rename to pyXSteam/scripts/pyXSteamDemo.py index 2491711..580adef 100644 --- a/bin/pyXSteamDemo.py +++ b/pyXSteam/scripts/pyXSteamDemo.py @@ -3,7 +3,7 @@ """collection of demos presenting the functionality of pyXSteam""" import time import logging -import matplotlib.pyplot as pyplot +from matplotlib import pyplot import numpy as np from pyXSteam.XSteam import XSteam from pyXSteam.XSteam_HW import XSteam_HW @@ -24,9 +24,7 @@ def demo_simpel_values(): print(f" tcV_p(1.0) = {steam_table.tcV_p(1.0)}") print("saturated vapour thermal conductivity @ 25 °C") print(f" tcL_t(25.0) = {steam_table.tcV_t(25.0)}") - print( - "thermal conductivity @ enthalpy 100 kJ / kg and specific entropy 0.34 kJ / (kg °C)" - ) + print("thermal conductivity @ enthalpy 100 kJ / kg and specific entropy 0.34 kJ / (kg °C)") print(f" tc_hs(100.0, 0.34) = {steam_table.tc_hs(100.0, 0.34)}") print("thermal conductivity @ 1 bar and enthalpy 100 kJ / kg") print(f" tc_ph(1.0, 100.0) = {steam_table.tc_ph(1.0, 100.0)}") @@ -40,16 +38,14 @@ def demo_generate_ph_diagramm(precision=1.0): """Generate a p(h) Diagram showing the Saturation Line""" steam_table = XSteam(XSteam.UNIT_SYSTEM_MKS) - p_krit = ( - steam_table.criticalPressure() - 0.0001 - ) # minus 0.0001 or else hL_V returns NaN + p_krit = steam_table.criticalPressure() - 0.0001 # minus 0.0001 or else hL_V returns NaN h_krit = steam_table.hL_p(p_krit) p_range = np.arange(0.0, 1000, precision) p2_range = np.arange(0.5, p_krit, precision) vf_range = np.arange(0.1, 1.0, 0.1) - h_range = np.arange(200.0, 4500.0, 100.0) + # h_range = np.arange(200.0, 4500.0, 100.0) temp_range = np.arange(0, 900, 30) nph_px = np.frompyfunc(steam_table.h_px, 2, 1) @@ -123,9 +119,7 @@ def demo_generate_pvT_diagramm(): v = npv_pt(p, t) colour_map = pyplot.get_cmap("hot") - ax.plot_surface( - p, t, v, cmap=colour_map, rstride=1, cstride=1, linewidth=0, shade=True - ) + ax.plot_surface(p, t, v, cmap=colour_map, rstride=1, cstride=1, linewidth=0, shade=True) pyplot.title("v(p,t)") ax.set_xlabel("p in [bar]") @@ -226,7 +220,7 @@ def demo_simpel_values_heavy_water(): print(f" tc_rhoT(1.0, 320.0) = {steam_table_hw.tc_rhoT(1.0, 320.0)}") -if __name__ == "__main__": +def main(): logging.basicConfig(level=logging.ERROR) print("Collection of simple demos on how to use pyXSteam") @@ -284,3 +278,7 @@ def demo_simpel_values_heavy_water(): print("Unknown selection") print("------------------------------") + + +if __name__ == "__main__": + main() diff --git a/bin/pyXSteamRankineDemo.py b/pyXSteam/scripts/pyXSteamRankineDemo.py similarity index 85% rename from bin/pyXSteamRankineDemo.py rename to pyXSteam/scripts/pyXSteamRankineDemo.py index 075517c..a5d9012 100644 --- a/bin/pyXSteamRankineDemo.py +++ b/pyXSteam/scripts/pyXSteamRankineDemo.py @@ -36,7 +36,7 @@ def demo_simple_cycle(): # %% State Point 1 # condenser outlet / feed pump inlet - state_point_1 = dict() + state_point_1 = {} state_point_1["p"] = 0.08 # bar - given state_point_1["x"] = 0.0 # given state_point_1["t"] = steam_table.tsat_p(state_point_1["p"]) @@ -46,7 +46,7 @@ def demo_simple_cycle(): # %% State Point 2 # feed pump discharge / Reactor core inlet # process: isentropic compression - state_point_2 = dict() + state_point_2 = {} state_point_2["s"] = state_point_1["s"] state_point_2["p"] = 71.1 # bar - given state_point_2["h"] = steam_table.t_ps(state_point_2["p"], state_point_2["s"]) @@ -58,7 +58,7 @@ def demo_simple_cycle(): # %% State Point 3 # reactor core outlet / turbine inlet # % process: isobaric heat addition - state_point_3 = dict() + state_point_3 = {} state_point_3["p"] = state_point_2["p"] state_point_3["x"] = 1.0 state_point_3["t"] = steam_table.tsat_p(state_point_3["p"]) @@ -70,7 +70,7 @@ def demo_simple_cycle(): # %% State Point 4 # turbine exhaust / condenser inlet # % process: isentropic expansion - state_point_4 = dict() + state_point_4 = {} state_point_4["s"] = state_point_3["s"] state_point_4["p"] = state_point_1["p"] # % for isobaric heat rejection in next step @@ -99,9 +99,7 @@ def demo_ms_and_ofwh(): converted example from Stu Blair, found at https://github.com/stu314159/xsteam/blob/42767648a05c6759ad11aea95256cb24e4fc9499/Examples/Rankine_MS_and_OFWH.m """ print("converted example from Stu Blair / https://github.com/stu314159") - print( - "Purpose: test XSteam functionality with slightly more complex Rankine. Uses scipy.optimize.fsolve" - ) + print("Purpose: test XSteam functionality with slightly more complex Rankine. Uses scipy.optimize.fsolve") print( """Problem Description: A Pressurized Water Reactor transfers heat to a Rankine cycle with the following properties: @@ -119,7 +117,7 @@ def demo_ms_and_ofwh(): # % Calculations # %% state point 1 - condenser outlet - state_point_1 = dict() + state_point_1 = {} state_point_1["p"] = 3.0 # % psia - given state_point_1["x"] = 0.0 # % quality - given state_point_1["t"] = steam_table.hL_p(state_point_1["p"]) @@ -129,16 +127,14 @@ def demo_ms_and_ofwh(): # %% state point 2 # % compression in main condensate pump eta_mcp = 0.84 # % pump isentropic efficiency - given - state_point_2 = dict() + state_point_2 = {} state_point_2["s_s"] = state_point_1["s"] state_point_2["p"] = 164.0 # % psia - given state_point_2["h_s"] = steam_table.h_ps(state_point_2["p"], state_point_2["s_s"]) - state_point_2["h"] = ( - state_point_1["h"] - (state_point_1["h"] - state_point_2["h_s"]) / eta_mcp - ) + state_point_2["h"] = state_point_1["h"] - (state_point_1["h"] - state_point_2["h_s"]) / eta_mcp # %% state point 3 OFWH exit - state_point_3 = dict() + state_point_3 = {} state_point_3["p"] = state_point_2["p"] # % constant pressure in OFWH state_point_3["x"] = 0.0 state_point_3["h"] = steam_table.hL_p(state_point_3["p"]) @@ -146,16 +142,14 @@ def demo_ms_and_ofwh(): # %% State point 4 MFP exit eta_mfp = 0.84 - state_point_4 = dict() + state_point_4 = {} state_point_4["p"] = 820.0 # % psia - given state_point_4["s_s"] = state_point_3["s"] state_point_4["h_s"] = steam_table.h_ps(state_point_4["p"], state_point_4["s_s"]) - state_point_4["h"] = ( - state_point_3["h"] - (state_point_3["h"] - state_point_4["h_s"]) / eta_mfp - ) + state_point_4["h"] = state_point_3["h"] - (state_point_3["h"] - state_point_4["h_s"]) / eta_mfp # %% State point 5 S/G Exit - state_point_5 = dict() + state_point_5 = {} state_point_5["p"] = state_point_4["p"] # % assume isobaric in S/G state_point_5["x"] = 1.0 # % saturated steam; given state_point_5["h"] = steam_table.hV_p(state_point_5["p"]) @@ -163,17 +157,15 @@ def demo_ms_and_ofwh(): # %% State point 6 HP Turbine Exhaust eta_hpt = 0.94 # % hp turbine isentropic efficiency; given - state_point_6 = dict() + state_point_6 = {} state_point_6["p"] = 164.0 # % psia - given state_point_6["s_s"] = state_point_5["s"] state_point_6["h_s"] = steam_table.h_ps(state_point_6["p"], state_point_6["s_s"]) - state_point_6["h"] = state_point_5["h"] - eta_hpt * ( - state_point_5["h"] - state_point_6["h_s"] - ) + state_point_6["h"] = state_point_5["h"] - eta_hpt * (state_point_5["h"] - state_point_6["h_s"]) state_point_6["x"] = steam_table.x_ph(state_point_6["p"], state_point_6["h"]) # %% State point 7 Moisture Separator vapor exit - state_point_7 = dict() + state_point_7 = {} state_point_7["p"] = state_point_6["p"] # assume isobaric process in M/S state_point_7["x"] = 1.0 # quality - given state_point_7["h"] = steam_table.hV_p(state_point_7["p"]) @@ -181,17 +173,15 @@ def demo_ms_and_ofwh(): # %% State point 8 LP Turbine exhaust eta_lpt = 0.94 # % lp turbine isentropic efficiency; given - state_point_8 = dict() + state_point_8 = {} state_point_8["p"] = state_point_1["p"] state_point_8["s_s"] = state_point_7["s"] state_point_8["h_s"] = steam_table.h_ps(state_point_8["p"], state_point_8["s_s"]) - state_point_8["h"] = state_point_7["h"] - eta_lpt * ( - state_point_7["h"] - state_point_8["h_s"] - ) + state_point_8["h"] = state_point_7["h"] - eta_lpt * (state_point_7["h"] - state_point_8["h_s"]) state_point_8["x"] = steam_table.x_ph(state_point_8["p"], state_point_8["h"]) # %% State point 9 Moisture Separator liquid drain to OFWH - state_point_9 = dict() + state_point_9 = {} # % same pressure as HP Turbine exhaust state_point_9["p"] = state_point_6["p"] state_point_9["h"] = steam_table.hL_p(state_point_9["p"]) @@ -245,102 +235,90 @@ def demo_reheat_ms_ofwh(): steam_table = XSteam(XSteam.UNIT_SYSTEM_FLS) # %% State point 1 - condenser exit - state_point_1 = dict() + state_point_1 = {} state_point_1["p"] = 1.5 # % psia state_point_1["h"] = steam_table.hL_p(state_point_1["p"]) state_point_1["s"] = steam_table.sL_p(state_point_1["p"]) # %% State point 1 -> 2, main condensate pump eta_mcp = 0.84 - state_point_2 = dict() + state_point_2 = {} state_point_2["p"] = 164.0 # % psia state_point_2["s_s"] = state_point_1["s"] state_point_2["h_s"] = steam_table.h_ps(state_point_2["p"], state_point_2["s_s"]) - state_point_2["h"] = ( - state_point_1["h"] - (state_point_1["h"] - state_point_2["h_s"]) / eta_mcp - ) + state_point_2["h"] = state_point_1["h"] - (state_point_1["h"] - state_point_2["h_s"]) / eta_mcp # %% State point 3, OFWH exit, saturated liquid - state_point_3 = dict() + state_point_3 = {} state_point_3["p"] = state_point_2["p"] state_point_3["h"] = steam_table.hL_p(state_point_3["p"]) state_point_3["s"] = steam_table.sL_p(state_point_3["p"]) # %% State point 3 -> 4, main feed pump eta_mfp = 0.84 - state_point_4 = dict() + state_point_4 = {} state_point_4["p"] = 820.0 # % psia state_point_4["s_s"] = state_point_3["s"] state_point_4["h_s"] = steam_table.h_ps(state_point_4["p"], state_point_4["s_s"]) - state_point_4["h"] = ( - state_point_3["h"] - (state_point_3["h"] - state_point_4["h_s"]) / eta_mfp - ) + state_point_4["h"] = state_point_3["h"] - (state_point_3["h"] - state_point_4["h_s"]) / eta_mfp # %% State point 5 - Steam generator exit - state_point_5 = dict() + state_point_5 = {} state_point_5["p"] = state_point_4["p"] state_point_5["h"] = steam_table.hV_p(state_point_5["p"]) state_point_5["s"] = steam_table.sV_p(state_point_5["p"]) # %% State point 6 - HP Turbine Exhaust eta_hpt = 0.94 - state_point_6 = dict() + state_point_6 = {} state_point_6["p"] = 164.0 # % psia state_point_6["s_s"] = state_point_5["s"] state_point_6["h_s"] = steam_table.h_ps(state_point_6["p"], state_point_6["s_s"]) - state_point_6["h"] = state_point_5["h"] - eta_hpt * ( - state_point_5["h"] - state_point_6["h_s"] - ) + state_point_6["h"] = state_point_5["h"] - eta_hpt * (state_point_5["h"] - state_point_6["h_s"]) state_point_6["x"] = steam_table.x_ph(state_point_6["p"], state_point_6["h"]) # %% State point 7 - Moisture Separator Exit - state_point_7 = dict() + state_point_7 = {} state_point_7["p"] = state_point_6["p"] state_point_7["h"] = steam_table.hV_p(state_point_7["p"]) state_point_7["s"] = steam_table.sV_p(state_point_7["p"]) # %% State point 8 - Reheater Mid-Pressure Steam exit - state_point_8 = dict() + state_point_8 = {} state_point_8["p"] = state_point_7["p"] state_point_8["t"] = 490.0 # % degrees F state_point_8["h"] = steam_table.h_pt(state_point_8["p"], state_point_8["t"]) state_point_8["s"] = steam_table.s_pt(state_point_8["p"], state_point_8["t"]) # %% State point 9 - LP Turbine Exhaust - state_point_9 = dict() + state_point_9 = {} state_point_9["p"] = state_point_1["p"] eta_lpt = 0.94 state_point_9["s_s"] = state_point_8["s"] state_point_9["h_s"] = steam_table.h_ps(state_point_9["p"], state_point_9["s_s"]) - state_point_9["h"] = state_point_8["h"] - eta_lpt * ( - state_point_8["h"] - state_point_9["h_s"] - ) + state_point_9["h"] = state_point_8["h"] - eta_lpt * (state_point_8["h"] - state_point_9["h_s"]) # %% State point 10 - Reheater HP Steam exit - state_point_10 = dict() + state_point_10 = {} state_point_10["p"] = state_point_5["p"] # % assume steam exits as a saturated liquid. state_point_10["h"] = steam_table.hL_p(state_point_10["p"]) # %% State point 11 - pressure trap exit to OFWH - state_point_11 = dict() + state_point_11 = {} state_point_11["p"] = state_point_2["p"] # % assume isenthalpic expansion in the trap. state_point_11["h"] = state_point_10["h"] # %% State point 12 - Moisture Separator liquid drain to OFWH - state_point_12 = dict() + state_point_12 = {} state_point_12["p"] = state_point_6["p"] state_point_12["h"] = steam_table.hL_p(state_point_12["p"]) # %% Heat Balance - find the flow fractions def RH_heatBalance(f): - return ( - f[0] * state_point_5["h"] - + (1 - f[0]) * state_point_6["x"] * (1 - f[1]) * state_point_7["h"] - ) - ( - f[0] * state_point_10["h"] - + (1 - f[0]) * state_point_6["x"] * (1 - f[1]) * state_point_8["h"] + return (f[0] * state_point_5["h"] + (1 - f[0]) * state_point_6["x"] * (1 - f[1]) * state_point_7["h"]) - ( + f[0] * state_point_10["h"] + (1 - f[0]) * state_point_6["x"] * (1 - f[1]) * state_point_8["h"] ) def OFWH_heatBalance(f): @@ -360,29 +338,14 @@ def totalFunctional(f): f = fmin(func=totalFunctional, x0=initialGuess) # % % calculate heat and energy balances - w_mcp = ( - (state_point_1["h"] - state_point_2["h"]) - * (1 - f[0]) - * (1 - f[1]) - * state_point_6["x"] - ) + w_mcp = (state_point_1["h"] - state_point_2["h"]) * (1 - f[0]) * (1 - f[1]) * state_point_6["x"] w_mfp = state_point_3["h"] - state_point_4["h"] w_hpt = (state_point_5["h"] - state_point_6["h"]) * (1 - f[0]) - w_lpt = ( - (state_point_8["h"] - state_point_9["h"]) - * (1 - f[0]) - * (1 - f[1]) - * state_point_6["x"] - ) + w_lpt = (state_point_8["h"] - state_point_9["h"]) * (1 - f[0]) * (1 - f[1]) * state_point_6["x"] w_net = w_mcp + w_mfp + w_hpt + w_lpt - q_cond = ( - (state_point_1["h"] - state_point_9["h"]) - * (1 - f[0]) - * (1 - f[1]) - * state_point_6["x"] - ) + q_cond = (state_point_1["h"] - state_point_9["h"]) * (1 - f[0]) * (1 - f[1]) * state_point_6["x"] q_sg = state_point_5["h"] - state_point_4["h"] q_net = q_cond + q_sg @@ -394,7 +357,7 @@ def totalFunctional(f): print(f"Thermal efficiency: {eta_th*100:.2f} percent") -if __name__ == "__main__": +def main(): logger = logging.getLogger("pyXSteam") logger.setLevel(logging.ERROR) sh = logging.StreamHandler() @@ -434,3 +397,7 @@ def totalFunctional(f): print("Unknown selection") print("------------------------------") + + +if __name__ == "__main__": + main() diff --git a/tests/test_MKS.py b/tests/test_MKS.py index f52917f..8e8be8b 100644 --- a/tests/test_MKS.py +++ b/tests/test_MKS.py @@ -21,8 +21,7 @@ def test_tsat_p(self): self.assertLess( error, self.maxError, - "tsat_p not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "tsat_p not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_t_ph(self): @@ -30,8 +29,7 @@ def test_t_ph(self): self.assertLess( error, self.maxError, - "t_ph not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "t_ph not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_t_ps(self): @@ -39,8 +37,7 @@ def test_t_ps(self): self.assertLess( error, self.maxError, - "t_ps not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "t_ps not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_t_hs(self): @@ -48,8 +45,7 @@ def test_t_hs(self): self.assertLess( error, self.maxError, - "t_hs not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "t_hs not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_psat_t(self): @@ -57,8 +53,7 @@ def test_psat_t(self): self.assertLess( error, self.maxError, - "psat_t not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "psat_t not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_p_hs(self): @@ -66,8 +61,7 @@ def test_p_hs(self): self.assertLess( error, self.maxError, - "p_hs not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "p_hs not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_hV_p(self): @@ -75,8 +69,7 @@ def test_hV_p(self): self.assertLess( error, self.maxError, - "hV_p not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "hV_p not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_hL_p(self): @@ -84,8 +77,7 @@ def test_hL_p(self): self.assertLess( error, self.maxError, - "hL_p not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "hL_p not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_hV_t(self): @@ -93,8 +85,7 @@ def test_hV_t(self): self.assertLess( error, self.maxError, - "hV_t not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "hV_t not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_hL_t(self): @@ -102,8 +93,7 @@ def test_hL_t(self): self.assertLess( error, self.maxError, - "hL_t not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "hL_t not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_h_pt(self): @@ -111,8 +101,7 @@ def test_h_pt(self): self.assertLess( error, self.maxError, - "h_pt not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "h_pt not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_h_ps(self): @@ -120,8 +109,7 @@ def test_h_ps(self): self.assertLess( error, self.maxError, - "h_ps not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "h_ps not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_h_px(self): @@ -129,8 +117,7 @@ def test_h_px(self): self.assertLess( error, self.maxError, - "h_px not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "h_px not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_h_prho(self): @@ -138,8 +125,7 @@ def test_h_prho(self): self.assertLess( error, self.maxError, - "h_prho not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "h_prho not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_h_tx(self): @@ -147,8 +133,7 @@ def test_h_tx(self): self.assertLess( error, self.maxError, - "h_tx not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "h_tx not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_vV_p(self): @@ -156,8 +141,7 @@ def test_vV_p(self): self.assertLess( error, self.maxError, - "vV_p not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "vV_p not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_vL_p(self): @@ -165,8 +149,7 @@ def test_vL_p(self): self.assertLess( error, self.maxError, - "vL_p not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "vL_p not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_vV_t(self): @@ -174,8 +157,7 @@ def test_vV_t(self): self.assertLess( error, self.maxError, - "vV_t not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "vV_t not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_vL_t(self): @@ -183,8 +165,7 @@ def test_vL_t(self): self.assertLess( error, self.maxError, - "vL_t not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "vL_t not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_v_pt(self): @@ -192,8 +173,7 @@ def test_v_pt(self): self.assertLess( error, self.maxError, - "v_pt not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "v_pt not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_v_ph(self): @@ -201,8 +181,7 @@ def test_v_ph(self): self.assertLess( error, self.maxError, - "v_ph not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "v_ph not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_v_ps(self): @@ -210,8 +189,7 @@ def test_v_ps(self): self.assertLess( error, self.maxError, - "v_ps not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "v_ps not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_rhoV_p(self): @@ -219,8 +197,7 @@ def test_rhoV_p(self): self.assertLess( error, self.maxError, - "rhoV_p not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "rhoV_p not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_rhoL_p(self): @@ -228,8 +205,7 @@ def test_rhoL_p(self): self.assertLess( error, self.maxError, - "rhoL_p not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "rhoL_p not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_rhoV_t(self): @@ -237,8 +213,7 @@ def test_rhoV_t(self): self.assertLess( error, self.maxError, - "rhoV_t not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "rhoV_t not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_rhoL_t(self): @@ -246,8 +221,7 @@ def test_rhoL_t(self): self.assertLess( error, self.maxError, - "rhoL_t not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "rhoL_t not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_rho_pt(self): @@ -255,8 +229,7 @@ def test_rho_pt(self): self.assertLess( error, self.maxError, - "rho_pt not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "rho_pt not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_rho_ph(self): @@ -264,8 +237,7 @@ def test_rho_ph(self): self.assertLess( error, self.maxError, - "rho_ph not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "rho_ph not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_rho_ps(self): @@ -273,8 +245,7 @@ def test_rho_ps(self): self.assertLess( error, self.maxError, - "rho_ps not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "rho_ps not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_sV_p(self): @@ -282,8 +253,7 @@ def test_sV_p(self): self.assertLess( error, self.maxError, - "sV_p not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "sV_p not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_sL_p(self): @@ -291,8 +261,7 @@ def test_sL_p(self): self.assertLess( error, self.maxError, - "sL_p not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "sL_p not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_sV_t(self): @@ -300,8 +269,7 @@ def test_sV_t(self): self.assertLess( error, self.maxError, - "sV_t not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "sV_t not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_sL_t(self): @@ -309,8 +277,7 @@ def test_sL_t(self): self.assertLess( error, self.maxError, - "sL_t not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "sL_t not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_s_pt(self): @@ -318,8 +285,7 @@ def test_s_pt(self): self.assertLess( error, self.maxError, - "s_pt not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "s_pt not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_s_ph(self): @@ -327,8 +293,7 @@ def test_s_ph(self): self.assertLess( error, self.maxError, - "s_ph not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "s_ph not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_uV_p(self): @@ -336,8 +301,7 @@ def test_uV_p(self): self.assertLess( error, self.maxError, - "uV_p not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "uV_p not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_uL_p(self): @@ -345,8 +309,7 @@ def test_uL_p(self): self.assertLess( error, self.maxError, - "uL_p not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "uL_p not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_uV_t(self): @@ -354,8 +317,7 @@ def test_uV_t(self): self.assertLess( error, self.maxError, - "uV_t not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "uV_t not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_uL_t(self): @@ -363,8 +325,7 @@ def test_uL_t(self): self.assertLess( error, self.maxError, - "uL_t not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "uL_t not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_u_pt(self): @@ -372,8 +333,7 @@ def test_u_pt(self): self.assertLess( error, self.maxError, - "u_pt not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "u_pt not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_u_ph(self): @@ -381,8 +341,7 @@ def test_u_ph(self): self.assertLess( error, self.maxError, - "u_ph not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "u_ph not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_u_ps(self): @@ -390,8 +349,7 @@ def test_u_ps(self): self.assertLess( error, self.maxError, - "u_ps not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "u_ps not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_CpV_p(self): @@ -399,8 +357,7 @@ def test_CpV_p(self): self.assertLess( error, self.maxError, - "cpV_p not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "cpV_p not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_CpL_p(self): @@ -408,8 +365,7 @@ def test_CpL_p(self): self.assertLess( error, self.maxError, - "cpL_p not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "cpL_p not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_CpV_t(self): @@ -417,8 +373,7 @@ def test_CpV_t(self): self.assertLess( error, self.maxError, - "cpV_t not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "cpV_t not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_CpL_t(self): @@ -426,8 +381,7 @@ def test_CpL_t(self): self.assertLess( error, self.maxError, - "cpL_t not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "cpL_t not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_Cp_pt(self): @@ -435,8 +389,7 @@ def test_Cp_pt(self): self.assertLess( error, self.maxError, - "cp_pt not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "cp_pt not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_Cp_ph(self): @@ -444,8 +397,7 @@ def test_Cp_ph(self): self.assertLess( error, self.maxError, - "Cp_ph not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Cp_ph not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_Cp_ps(self): @@ -453,8 +405,7 @@ def test_Cp_ps(self): self.assertLess( error, self.maxError, - "Cp_ps not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Cp_ps not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_CvV_p(self): @@ -462,8 +413,7 @@ def test_CvV_p(self): self.assertLess( error, self.maxError, - "CvV_p not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "CvV_p not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_CvL_p(self): @@ -471,8 +421,7 @@ def test_CvL_p(self): self.assertLess( error, self.maxError, - "CvL_p not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "CvL_p not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_CvV_t(self): @@ -480,8 +429,7 @@ def test_CvV_t(self): self.assertLess( error, self.maxError, - "CvV_t not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "CvV_t not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_CvL_t(self): @@ -489,8 +437,7 @@ def test_CvL_t(self): self.assertLess( error, self.maxError, - "CvL_t not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "CvL_t not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_Cv_pt(self): @@ -498,8 +445,7 @@ def test_Cv_pt(self): self.assertLess( error, self.maxError, - "Cv_pt not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Cv_pt not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_Cv_ph(self): @@ -507,8 +453,7 @@ def test_Cv_ph(self): self.assertLess( error, self.maxError, - "Cv_ph not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Cv_ph not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_Cv_ps(self): @@ -516,8 +461,7 @@ def test_Cv_ps(self): self.assertLess( error, self.maxError, - "Cv_ps not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Cv_ps not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_wV_p(self): @@ -525,8 +469,7 @@ def test_wV_p(self): self.assertLess( error, self.maxError, - "wV_p not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "wV_p not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_wL_p(self): @@ -534,8 +477,7 @@ def test_wL_p(self): self.assertLess( error, self.maxError, - "wL_p not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "wL_p not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_wV_t(self): @@ -543,8 +485,7 @@ def test_wV_t(self): self.assertLess( error, self.maxError, - "wV_t not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "wV_t not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_wL_t(self): @@ -552,8 +493,7 @@ def test_wL_t(self): self.assertLess( error, self.maxError, - "wL_t not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "wL_t not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_w_pt(self): @@ -561,8 +501,7 @@ def test_w_pt(self): self.assertLess( error, self.maxError, - "w_pt not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "w_pt not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_w_ph(self): @@ -570,8 +509,7 @@ def test_w_ph(self): self.assertLess( error, self.maxError, - "w_ph not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "w_ph not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_w_ps(self): @@ -579,8 +517,7 @@ def test_w_ps(self): self.assertLess( error, self.maxError, - "w_ps not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "w_ps not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_my_pt(self): @@ -588,8 +525,7 @@ def test_my_pt(self): self.assertLess( error, self.maxError, - "my_pt not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "my_pt not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_my_ph(self): @@ -597,8 +533,7 @@ def test_my_ph(self): self.assertLess( error, self.maxError, - "my_ph not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "my_ph not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_my_ps(self): @@ -606,8 +541,7 @@ def test_my_ps(self): self.assertLess( error, self.maxError, - "my_ps not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "my_ps not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_tcL_p(self): @@ -615,8 +549,7 @@ def test_tcL_p(self): self.assertLess( error, self.maxError, - "tcL_p not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "tcL_p not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_tcV_p(self): @@ -624,8 +557,7 @@ def test_tcV_p(self): self.assertLess( error, self.maxError, - "tcV_p not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "tcV_p not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_tcL_t(self): @@ -633,8 +565,7 @@ def test_tcL_t(self): self.assertLess( error, self.maxError, - "tcL_t not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "tcL_t not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_tcV_t(self): @@ -642,8 +573,7 @@ def test_tcV_t(self): self.assertLess( error, self.maxError, - "tcV_t not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "tcV_t not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_tc_pt(self): @@ -651,8 +581,7 @@ def test_tc_pt(self): self.assertLess( error, self.maxError, - "tc_pt not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "tc_pt not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_tc_ph(self): @@ -660,8 +589,7 @@ def test_tc_ph(self): self.assertLess( error, self.maxError, - "tc_ph not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "tc_ph not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_tc_hs(self): @@ -669,8 +597,7 @@ def test_tc_hs(self): self.assertLess( error, self.maxError, - "tc_hs not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "tc_hs not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_st_t(self): @@ -678,8 +605,7 @@ def test_st_t(self): self.assertLess( error, self.maxError, - "st_t not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "st_t not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_st_p(self): @@ -687,8 +613,7 @@ def test_st_p(self): self.assertLess( error, self.maxError, - "st_p not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "st_p not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_x_ph(self): @@ -696,8 +621,7 @@ def test_x_ph(self): self.assertLess( error, self.maxError, - "x_ph not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "x_ph not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_x_ps(self): @@ -705,8 +629,7 @@ def test_x_ps(self): self.assertLess( error, self.maxError, - "x_ps not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "x_ps not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_vx_ph(self): @@ -714,8 +637,7 @@ def test_vx_ph(self): self.assertLess( error, self.maxError, - "vx_ph not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "vx_ph not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_vx_ps(self): @@ -723,6 +645,5 @@ def test_vx_ps(self): self.assertLess( error, self.maxError, - "vx_ps not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "vx_ps not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) diff --git a/tests/test_R14.py b/tests/test_R14.py index 93ba288..906cb2e 100644 --- a/tests/test_R14.py +++ b/tests/test_R14.py @@ -21,8 +21,7 @@ def test_R14_pmelt_T_function_Ih_1(self): self.assertLess( error, self.maxError_ice_Ih, - "pmelt_T_iceIh not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError_ice_Ih}, + "pmelt_T_iceIh not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError_ice_Ih}, ) def test_R14_pmelt_T_function_Ih_2(self): @@ -30,8 +29,7 @@ def test_R14_pmelt_T_function_Ih_2(self): self.assertLess( error, self.maxError_ice_Ih, - "pmelt_T_iceIh not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError_ice_Ih}, + "pmelt_T_iceIh not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError_ice_Ih}, ) def test_R14_pmelt_T_function_III_1(self): @@ -39,8 +37,7 @@ def test_R14_pmelt_T_function_III_1(self): self.assertLess( error, self.maxError_ice_III, - "pmelt_T_iceIII not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError_ice_III}, + "pmelt_T_iceIII not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError_ice_III}, ) def test_R14_pmelt_T_function_III_2(self): @@ -48,8 +45,7 @@ def test_R14_pmelt_T_function_III_2(self): self.assertLess( error, self.maxError_ice_III, - "pmelt_T_iceIII not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError_ice_III}, + "pmelt_T_iceIII not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError_ice_III}, ) def test_R14_pmelt_T_function_V_1(self): @@ -57,8 +53,7 @@ def test_R14_pmelt_T_function_V_1(self): self.assertLess( error, self.maxError_ice_V, - "pmelt_t not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError_ice_V}, + "pmelt_t not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError_ice_V}, ) def test_R14_pmelt_T_function_V_2(self): @@ -66,8 +61,7 @@ def test_R14_pmelt_T_function_V_2(self): self.assertLess( error, self.maxError_ice_V, - "pmelt_t not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError_ice_V}, + "pmelt_t not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError_ice_V}, ) def test_R14_pmelt_T_function_VI_1(self): @@ -75,8 +69,7 @@ def test_R14_pmelt_T_function_VI_1(self): self.assertLess( error, self.maxError_ice_VI, - "pmelt_t not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError_ice_VI}, + "pmelt_t not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError_ice_VI}, ) def test_R14_pmelt_T_function_VI_2(self): @@ -84,8 +77,7 @@ def test_R14_pmelt_T_function_VI_2(self): self.assertLess( error, self.maxError_ice_VI, - "pmelt_t not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError_ice_VI}, + "pmelt_t not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError_ice_VI}, ) def test_R14_pmelt_T_function_VII_1(self): @@ -93,8 +85,7 @@ def test_R14_pmelt_T_function_VII_1(self): self.assertLess( error, self.maxError_ice_VII, - "pmelt_t not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError_ice_VII}, + "pmelt_t not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError_ice_VII}, ) def test_R14_pmelt_T_function_VII_2(self): @@ -102,8 +93,7 @@ def test_R14_pmelt_T_function_VII_2(self): self.assertLess( error, self.maxError_ice_VII, - "pmelt_t not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError_ice_VII}, + "pmelt_t not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError_ice_VII}, ) def test_R14_psubl_T_function(self): @@ -111,6 +101,5 @@ def test_R14_psubl_T_function(self): self.assertLess( error, self.maxError, - "psubl_t not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "psubl_t not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) diff --git a/tests/test_Regions.py b/tests/test_Regions.py index 0ce7046..26a3e68 100644 --- a/tests/test_Regions.py +++ b/tests/test_Regions.py @@ -330,8 +330,7 @@ def test_v_ph_function(self): self.assertLess( v3_ph_error, 1e-7, - "Test of v(p,h) Function for Region 3 failed. Error was %(error)e allowed:" - " %(max)e" % {"error": v3_ph_error, "max": 1e-7}, + "Test of v(p,h) Function for Region 3 failed. Error was %(error)e allowed:" " %(max)e" % {"error": v3_ph_error, "max": 1e-7}, ) def test_T_ps_function(self): @@ -419,8 +418,7 @@ def test_pT_function(self): self.assertLess( h3_pT_error, 1e-6, - "Test of h(p,T) Function for Region 3 failed. Error was %(error)e allowed:" - " %(max)e" % {"error": h3_pT_error, "max": 1e-6}, + "Test of h(p,T) Function for Region 3 failed. Error was %(error)e allowed:" " %(max)e" % {"error": h3_pT_error, "max": 1e-6}, ) @@ -562,6 +560,5 @@ def test_ps_function(self): self.assertLess( T5_ps_error, 1e-4, - "Test of T(p,s) Function for Region 5 failed. Error was %(error)e allowed:" - " %(max)e" % {"error": T5_ps_error, "max": 1e-4}, + "Test of T(p,s) Function for Region 5 failed. Error was %(error)e allowed:" " %(max)e" % {"error": T5_ps_error, "max": 1e-4}, ) diff --git a/tests/test_UnitConverter.py b/tests/test_UnitConverter.py index 3bc07a6..9bbe3b2 100644 --- a/tests/test_UnitConverter.py +++ b/tests/test_UnitConverter.py @@ -20,8 +20,7 @@ def test_toSIunit_p_1_MKS(self): self.assertLess( error, self.maxError, - "Test of toSIunit_p for MKS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of toSIunit_p for MKS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_toSIunit_p_2_MKS(self): @@ -29,8 +28,7 @@ def test_toSIunit_p_2_MKS(self): self.assertLess( error, self.maxError, - "Test of toSIunit_p for MKS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of toSIunit_p for MKS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_fromSIunit_p_1_MKS(self): @@ -38,8 +36,7 @@ def test_fromSIunit_p_1_MKS(self): self.assertLess( error, self.maxError, - "Test of fromSIunit_p for MKS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of fromSIunit_p for MKS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_fromSIunit_p_2_MKS(self): @@ -47,8 +44,7 @@ def test_fromSIunit_p_2_MKS(self): self.assertLess( error, self.maxError, - "Test of fromSIunit_p for MKS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of fromSIunit_p for MKS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_toSIunit_T_1_MKS(self): @@ -56,8 +52,7 @@ def test_toSIunit_T_1_MKS(self): self.assertLess( error, self.maxError, - "Test of toSIunit_T for MKS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of toSIunit_T for MKS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_toSIunit_T_2_MKS(self): @@ -65,8 +60,7 @@ def test_toSIunit_T_2_MKS(self): self.assertLess( error, self.maxError, - "Test of toSIunit_T for MKS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of toSIunit_T for MKS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_fromSIunit_T_1_MKS(self): @@ -74,8 +68,7 @@ def test_fromSIunit_T_1_MKS(self): self.assertLess( error, self.maxError, - "Test of fromSIunit_T for MKS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of fromSIunit_T for MKS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_fromSIunit_T_2_MKS(self): @@ -83,8 +76,7 @@ def test_fromSIunit_T_2_MKS(self): self.assertLess( error, self.maxError, - "Test of fromSIunit_T for MKS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of fromSIunit_T for MKS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) @@ -101,8 +93,7 @@ def test_toSIunit_p_FLS(self): self.assertLess( error, self.maxError, - "Test of toSIunit_p for FLS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of toSIunit_p for FLS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_fromSIunit_p_FLS(self): @@ -110,8 +101,7 @@ def test_fromSIunit_p_FLS(self): self.assertLess( error, self.maxError, - "Test of fromSIunit_p for FLS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of fromSIunit_p for FLS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_toSIunit_T_FLS(self): @@ -119,8 +109,7 @@ def test_toSIunit_T_FLS(self): self.assertLess( error, self.maxError, - "Test of toSIunit_T for FLS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of toSIunit_T for FLS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_fromSIunit_T_FLS(self): @@ -128,8 +117,7 @@ def test_fromSIunit_T_FLS(self): self.assertLess( error, self.maxError, - "Test of fromSIunit_T for FLS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of fromSIunit_T for FLS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_toSIunit_h_FLS(self): @@ -137,8 +125,7 @@ def test_toSIunit_h_FLS(self): self.assertLess( error, self.maxError, - "Test of toSIunit_h for FLS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of toSIunit_h for FLS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_fromSIunit_h_FLS(self): @@ -146,8 +133,7 @@ def test_fromSIunit_h_FLS(self): self.assertLess( error, self.maxError, - "Test of fromSIunit_h for FLS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of fromSIunit_h for FLS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_toSIunit_v_FLS(self): @@ -155,8 +141,7 @@ def test_toSIunit_v_FLS(self): self.assertLess( error, self.maxError, - "Test of toSIunit_v for FLS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of toSIunit_v for FLS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_fromSIunit_v_FLS(self): @@ -164,8 +149,7 @@ def test_fromSIunit_v_FLS(self): self.assertLess( error, self.maxError, - "Test of fromSIunit_v for FLS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of fromSIunit_v for FLS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_toSIunit_s_FLS(self): @@ -173,8 +157,7 @@ def test_toSIunit_s_FLS(self): self.assertLess( error, self.maxError, - "Test of toSIunit_s for FLS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of toSIunit_s for FLS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_fromSIunit_s_FLS(self): @@ -182,8 +165,7 @@ def test_fromSIunit_s_FLS(self): self.assertLess( error, self.maxError, - "Test of fromSIunit_s for FLS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of fromSIunit_s for FLS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_toSIunit_u_FLS(self): @@ -191,8 +173,7 @@ def test_toSIunit_u_FLS(self): self.assertLess( error, self.maxError, - "Test of toSIunit_u for FLS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of toSIunit_u for FLS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_fromSIunit_u_FLS(self): @@ -200,8 +181,7 @@ def test_fromSIunit_u_FLS(self): self.assertLess( error, self.maxError, - "Test of fromSIunit_u for FLS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of fromSIunit_u for FLS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_toSIunit_Cp_FLS(self): @@ -209,8 +189,7 @@ def test_toSIunit_Cp_FLS(self): self.assertLess( error, self.maxError, - "Test of toSIunit_Cp for FLS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of toSIunit_Cp for FLS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_fromSIunit_Cp_FLS(self): @@ -218,8 +197,7 @@ def test_fromSIunit_Cp_FLS(self): self.assertLess( error, self.maxError, - "Test of fromSIunit_Cp for FLS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of fromSIunit_Cp for FLS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_toSIunit_Cv_FLS(self): @@ -227,8 +205,7 @@ def test_toSIunit_Cv_FLS(self): self.assertLess( error, self.maxError, - "Test of toSIunit_Cv for FLS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of toSIunit_Cv for FLS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_fromSIunit_Cv_FLS(self): @@ -236,8 +213,7 @@ def test_fromSIunit_Cv_FLS(self): self.assertLess( error, self.maxError, - "Test of fromSIunit_Cv for FLS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of fromSIunit_Cv for FLS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_toSIunit_w_FLS(self): @@ -245,8 +221,7 @@ def test_toSIunit_w_FLS(self): self.assertLess( error, self.maxError, - "Test of toSIunit_w for FLS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of toSIunit_w for FLS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_fromSIunit_w_FLS(self): @@ -254,8 +229,7 @@ def test_fromSIunit_w_FLS(self): self.assertLess( error, self.maxError, - "Test of fromSIunit_w for FLS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of fromSIunit_w for FLS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_toSIunit_tc_FLS(self): @@ -263,8 +237,7 @@ def test_toSIunit_tc_FLS(self): self.assertLess( error, self.maxError, - "Test of toSIunit_tc for FLS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of toSIunit_tc for FLS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_fromSIunit_tc_FLS(self): @@ -272,8 +245,7 @@ def test_fromSIunit_tc_FLS(self): self.assertLess( error, self.maxError, - "Test of fromSIunit_tc for FLS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of fromSIunit_tc for FLS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_toSIunit_st_FLS(self): @@ -281,8 +253,7 @@ def test_toSIunit_st_FLS(self): self.assertLess( error, self.maxError, - "Test of toSIunit_st for FLS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of toSIunit_st for FLS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_fromSIunit_st_FLS(self): @@ -290,8 +261,7 @@ def test_fromSIunit_st_FLS(self): self.assertLess( error, self.maxError, - "Test of fromSIunit_st for FLS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of fromSIunit_st for FLS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_toSIunit_x_FLS(self): @@ -299,8 +269,7 @@ def test_toSIunit_x_FLS(self): self.assertLess( error, self.maxError, - "Test of toSIunit_x for FLS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of toSIunit_x for FLS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_fromSIunit_x_FLS(self): @@ -308,8 +277,7 @@ def test_fromSIunit_x_FLS(self): self.assertLess( error, self.maxError, - "Test of fromSIunit_x for FLS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of fromSIunit_x for FLS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_toSIunit_vx_FLS(self): @@ -317,8 +285,7 @@ def test_toSIunit_vx_FLS(self): self.assertLess( error, self.maxError, - "Test of toSIunit_vx for FLS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of toSIunit_vx for FLS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_fromSIunit_vx_FLS(self): @@ -326,8 +293,7 @@ def test_fromSIunit_vx_FLS(self): self.assertLess( error, self.maxError, - "Test of fromSIunit_vx for FLS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of fromSIunit_vx for FLS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_toSIunit_my_FLS(self): @@ -335,8 +301,7 @@ def test_toSIunit_my_FLS(self): self.assertLess( error, self.maxError, - "Test of toSIunit_my for FLS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of toSIunit_my for FLS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_fromSIunit_my_FLS(self): @@ -344,6 +309,5 @@ def test_fromSIunit_my_FLS(self): self.assertLess( error, self.maxError, - "Test of fromSIunit_my for FLS failed. Error was %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "Test of fromSIunit_my for FLS failed. Error was %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) diff --git a/tests/test_fixedbugs.py b/tests/test_fixedbugs.py index 58171bb..cd44465 100644 --- a/tests/test_fixedbugs.py +++ b/tests/test_fixedbugs.py @@ -23,8 +23,7 @@ def test_inf_loop_h_pt(self): self.assertLess( error, self.maxError, - "h_pt not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "h_pt not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_inf_loop_rho_pt(self): @@ -36,8 +35,7 @@ def test_inf_loop_rho_pt(self): self.assertLess( error, self.maxError, - "rho_pt not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + "rho_pt not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) def test_missing_unit_conversion_h_xx(self): @@ -51,14 +49,12 @@ def test_missing_unit_conversion_h_xx(self): self.assertLess( error, self.maxError, - " not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + " not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, ) error = self.steamTable.h_tx(160, 0.5) - 628.905695 self.assertLess( error, self.maxError, - " not passed Error %(error)e allowed: %(max)e" - % {"error": error, "max": self.maxError}, + " not passed Error %(error)e allowed: %(max)e" % {"error": error, "max": self.maxError}, )