├── .gitattributes ├── README.md ├── .gitignore ├── LICENSE.md ├── example.py ├── psySI.py └── psyIP.py /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Summary 2 | Python library to calculate psychrometric states of moist air. 3 | 4 | # Installation 5 | Place either psySI.py or psyIP.py file in your working directory. If you 6 | are working with the international system of units (i.e. SI) then use psySI.py. 7 | If you are are working with imperial units (i.e. IP) then use psyIP.py. 8 | 9 | # Description 10 | psypy is a python library that calculates psychrometric states of moist air 11 | using ASHRAE 2009 Fundamentals formulations. Atmospheric pressure, and two 12 | independent properties must be given to calculate all other state properties. 13 | The state properties include: dry bulb temperature (DBT), specific enthalpy 14 | (H), relative humidity (RH), specific volume (V), humidity ratio (W), and wet 15 | bulb temperature (WBT). Examples can be found in the examples.py file. 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear on external disk 35 | .Spotlight-V100 36 | .Trashes 37 | 38 | # Directories potentially created on remote AFP share 39 | .AppleDB 40 | .AppleDesktop 41 | Network Trash Folder 42 | Temporary Items 43 | .apdisk 44 | 45 | # User defined files and directories to ignore 46 | __pycache__ 47 | check.py 48 | check.xmcd 49 | convert.py 50 | unit.db 51 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 wlong007 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /example.py: -------------------------------------------------------------------------------- 1 | # import the psypy modules, psySI for SI units and psyIP for IP units. 2 | import psySI as SI 3 | 4 | # The main function to be used is the state function. 5 | 6 | # psySI.state(p1, p1val, p2, p2val, P) 7 | 8 | # p1 - A string that is a valid state property. Valid state properties are: 9 | # DBT - Dry bulb temperature 10 | # H - Specific enthalpy 11 | # RH - Relative humidity 12 | # V - Specific volume 13 | # W - Humidity ratio 14 | # WBT - Wet bulb temperature 15 | 16 | # p1val - A numeric that is in base units of which ever property that is given. 17 | # Valid base SI units are (with IP units in parenthesis): 18 | # DBT - Kelvins (degrees Rankine) 19 | # H - KiloJoules per kilogram (British thermal unit per pound mass) 20 | # RH - decimal number, not a percentage (same as SI) 21 | # V - cubic meters per kilogram (cubic feet per pound mass) 22 | # W - kilogram per kilogram (pounds mass per pound mass) 23 | # WBT - Kelvins (degrees Rankine) 24 | 25 | # p2 - A string that is a valid state property but must not be the same as p1 26 | 27 | # p2val - A numeric that is in base units of which ever property that is given. 28 | 29 | # P - A numeric that is the atmospheric pressure in Pascals of SI units or 30 | # pounds per square inch for IP units. 31 | 32 | # The state function returns a list of all state property values in the 33 | # following order: 34 | # Dry bulb temperature (DBT) 35 | # Specific enthalpy (H) 36 | # Relative humidity (RH) 37 | # Specific volume (V) 38 | # Humidity ratio (W) 39 | # Wet bulb temperature (WBT) 40 | 41 | # Example - For a dry bulb temperature of 300 Kelvin and a relative humidity 42 | # of 0.32 (i.e. 32%) at standard atompspheric pressure, the other 43 | # state properties can be calculated by the following. 44 | S=SI.state("DBT",300,"RH",0.32,101325) 45 | print("The dry bulb temperature is ", S[0]) 46 | print("The specific enthalpy is ", S[1]) 47 | print("The relative humidity is ", S[2]) 48 | print("The specific volume is ", S[3]) 49 | print("The humidity ratio is ", S[4]) 50 | print("The wet bulb temperature is ", S[5]) 51 | # All calculated values are in base SI units as listed above. 52 | -------------------------------------------------------------------------------- /psySI.py: -------------------------------------------------------------------------------- 1 | import math as m 2 | 3 | # All functions expect base SI units for any arguments given 4 | # DBT - Dry bulb temperature - Kelvins, K 5 | # DPT - Dew point temperature - Kelvins, K 6 | # H - Specific enthalpy - kiloJoules per kilogram, kJ/kg 7 | # P - Atmospheric pressure - Pascals, Pa 8 | # Pw - Water vapor partial pressure - Pascals, Pa 9 | # RH - Relative humidity - Decimal (i.e. not a percentage) 10 | # V - Specific volume - Cubic meters per kilogram, m^3/kg 11 | # W - Humidity ratio - kilograms per kilograms, kg/kg 12 | # WBT - Wet bulb temperature - Kelvins, K 13 | 14 | # Minimum dry bulb temperature 15 | Min_DBT=273.15 16 | # Maximum dry bulb temperature 17 | Max_DBT=473.15 18 | # Convergence tolerance 19 | TOL=0.0005 20 | 21 | def __DBT_H_RH_P(H, RH, P): 22 | [DBTa, DBTb]=[Min_DBT, Max_DBT] 23 | DBT=(DBTa+DBTb)/2 24 | while DBTb-DBTa>TOL: 25 | ya=__W_DBT_RH_P(DBTa, RH, P)-__W_DBT_H(DBTa, H) 26 | y=__W_DBT_RH_P(DBT, RH, P)-__W_DBT_H(DBT, H) 27 | if __is_positive(y)==__is_positive(ya): 28 | DBTa=DBT 29 | else: 30 | DBTb=DBT 31 | DBT=(DBTa+DBTb)/2 32 | return DBT 33 | 34 | def __DBT_H_V_P(H, V, P): 35 | [DBTa, DBTb]=[Min_DBT, Max_DBT] 36 | DBT=(DBTa+DBTb)/2 37 | while DBTb-DBTa>TOL: 38 | ya=__W_DBT_V_P(DBTa, V, P)-__W_DBT_H(DBTa, H) 39 | y=__W_DBT_V_P(DBT, V, P)-__W_DBT_H(DBT, H) 40 | if __is_positive(y)==__is_positive(ya): 41 | DBTa=DBT 42 | else: 43 | DBTb=DBT 44 | DBT=(DBTa+DBTb)/2 45 | return DBT 46 | 47 | def __DBT_H_W(H, W): 48 | [DBTa, DBTb]=[Min_DBT, Max_DBT] 49 | DBT=(DBTa+DBTb)/2 50 | while DBTb-DBTa>TOL: 51 | ya=W-__W_DBT_H(DBTa, H) 52 | y=W-__W_DBT_H(DBT, H) 53 | if __is_positive(y)==__is_positive(ya): 54 | DBTa=DBT 55 | else: 56 | DBTb=DBT 57 | DBT=(DBTa+DBTb)/2 58 | return DBT 59 | 60 | def __DBT_H_WBT_P(H, WBT, P): 61 | [DBTa, DBTb]=[Min_DBT, Max_DBT] 62 | DBT=(DBTa+DBTb)/2 63 | while DBTb-DBTa>TOL: 64 | ya=__W_DBT_WBT_P(DBTa, WBT, P)-__W_DBT_H(DBTa, H) 65 | y=__W_DBT_WBT_P(DBT, WBT, P)-__W_DBT_H(DBT, H) 66 | if __is_positive(y)==__is_positive(ya): 67 | DBTa=DBT 68 | else: 69 | DBTb=DBT 70 | DBT=(DBTa+DBTb)/2 71 | return DBT 72 | 73 | def __DBT_RH_V_P(RH, V, P): 74 | [DBTa, DBTb]=[Min_DBT, Max_DBT] 75 | DBT=(DBTa+DBTb)/2 76 | while DBTb-DBTa>TOL: 77 | ya=__W_DBT_RH_P(DBTa, RH, P)-__W_DBT_V_P(DBTa, V, P) 78 | y=__W_DBT_RH_P(DBT, RH, P)-__W_DBT_V_P(DBT, V, P) 79 | if __is_positive(y)==__is_positive(ya): 80 | DBTa=DBT 81 | else: 82 | DBTb=DBT 83 | DBT=(DBTa+DBTb)/2 84 | return DBT 85 | 86 | def __DBT_RH_W_P(RH, W, P): 87 | [DBTa, DBTb]=[Min_DBT, Max_DBT] 88 | DBT=(DBTa+DBTb)/2 89 | while DBTb-DBTa>TOL: 90 | ya=__W_DBT_RH_P(DBTa, RH, P)-W 91 | y=__W_DBT_RH_P(DBT, RH, P)-W 92 | if __is_positive(y)==__is_positive(ya): 93 | DBTa=DBT 94 | else: 95 | DBTb=DBT 96 | DBT=(DBTa+DBTb)/2 97 | return DBT 98 | 99 | def __DBT_RH_WBT_P(RH, WBT, P): 100 | [DBTa, DBTb]=[Min_DBT, Max_DBT] 101 | DBT=(DBTa+DBTb)/2 102 | while DBTb-DBTa>TOL: 103 | ya=__W_DBT_WBT_P(DBTa, WBT, P)-__W_DBT_RH_P(DBTa, RH, P) 104 | y=__W_DBT_WBT_P(DBT, WBT, P)-__W_DBT_RH_P(DBT, RH, P) 105 | if __is_positive(y)==__is_positive(ya): 106 | DBTa=DBT 107 | else: 108 | DBTb=DBT 109 | DBT=(DBTa+DBTb)/2 110 | return DBT 111 | 112 | def __DBT_V_W_P(V, W, P): 113 | [DBTa, DBTb]=[Min_DBT, Max_DBT] 114 | DBT=(DBTa+DBTb)/2 115 | while DBTb-DBTa>TOL: 116 | ya=W-__W_DBT_V_P(DBTa, V, P) 117 | y=W-__W_DBT_V_P(DBT, V, P) 118 | if __is_positive(y)==__is_positive(ya): 119 | DBTa=DBT 120 | else: 121 | DBTb=DBT 122 | DBT=(DBTa+DBTb)/2 123 | return DBT 124 | 125 | def __DBT_V_WBT_P(V, WBT, P): 126 | [DBTa, DBTb]=[Min_DBT, Max_DBT] 127 | DBT=(DBTa+DBTb)/2 128 | while DBTb-DBTa>TOL: 129 | ya=__W_DBT_WBT_P(DBTa, WBT, P)-__W_DBT_V_P(DBTa, V, P) 130 | y=__W_DBT_WBT_P(DBT, WBT, P)-__W_DBT_V_P(DBT, V, P) 131 | if __is_positive(y)==__is_positive(ya): 132 | DBTa=DBT 133 | else: 134 | DBTb=DBT 135 | DBT=(DBTa+DBTb)/2 136 | return DBT 137 | 138 | def __DBT_W_WBT_P(W, WBT, P): 139 | [DBTa, DBTb]=[Min_DBT, Max_DBT] 140 | DBT=(DBTa+DBTb)/2 141 | while DBTb-DBTa>TOL: 142 | ya=__W_DBT_WBT_P(DBTa, WBT, P)-W 143 | y=__W_DBT_WBT_P(DBT, WBT, P)-W 144 | if __is_positive(y)==__is_positive(ya): 145 | DBTa=DBT 146 | else: 147 | DBTb=DBT 148 | DBT=(DBTa+DBTb)/2 149 | return DBT 150 | 151 | # ASHRAE 2009 Chapter 1 Equation 39 152 | def __DPT_Pw(Pw): 153 | Pw=Pw/1000 154 | C14=6.54 155 | C15=14.529 156 | C16=0.7389 157 | C17=0.09486 158 | C18=0.4569 159 | a=m.log(Pw) 160 | return (C14+C15*a+C16*a**2+C17*a**3+C18*Pw**0.1984)+273.15 161 | 162 | # ASHRAE 2009 Chapter 1 Equation 32 163 | def __H_DBT_W(DBT, W): 164 | if __valid_DBT(DBT): 165 | DBT=DBT-273.15 166 | return 1.006*DBT+W*(2501+1.86*DBT) 167 | 168 | def __is_positive(x): 169 | if x>0: 170 | return True 171 | else: 172 | return False 173 | 174 | # ASHRAE 2009 Chapter 1 Equation 22 175 | def __Pw_W_P(W, P): 176 | return W*P/(W+0.621945) 177 | 178 | # ASHRAE 2009 Chapter 1 Equation 6 179 | def __Pws(DBT): 180 | if __valid_DBT(DBT): 181 | C8=-5.8002206*10**3 182 | C9=1.3914993 183 | C10=-4.8640239*10**-2 184 | C11=4.1764768*10**-5 185 | C12=-1.4452093*10**-8 186 | C13=6.5459673 187 | return m.exp(C8/DBT+C9+C10*DBT+C11*DBT**2+C12*DBT**3+C13*m.log(DBT)) 188 | 189 | def state(prop1, prop1val, prop2, prop2val,P): 190 | if prop1==prop2: 191 | print("Properties must be independent.") 192 | return 193 | prop=["DBT","WBT","RH","W","V","H"] 194 | if prop1 not in prop or prop2 not in prop: 195 | print("Valid property must be given.") 196 | return 197 | prop1i=prop.index(prop1) 198 | prop2i=prop.index(prop2) 199 | if prop1iTOL: 352 | Ws=__W_DBT_WBT_P(DBT, WBT, P) 353 | if W>Ws: 354 | WBTa=WBT 355 | else: 356 | WBTb=WBT 357 | WBT=(WBTa+WBTb)/2 358 | return WBT 359 | 360 | def __valid_DBT(DBT): 361 | if Min_DBT<=DBT<=Max_DBT: 362 | return True 363 | else: 364 | return False 365 | -------------------------------------------------------------------------------- /psyIP.py: -------------------------------------------------------------------------------- 1 | import math as m 2 | 3 | # All functions expect base SI units for any arguments given 4 | # DBT - Dry bulb temperature - Degrees Rankine, R 5 | # DPT - Dew point temperature - Degress Rankine, R 6 | # H - Specific enthalpy - British thermal unit per pound mass, 7 | # Btu/lbm 8 | # P - Atmospheric pressure - Pounds force per square inch, psi 9 | # Pw - Water vapor partial pressure - Pounds force per square inch, psi 10 | # RH - Relative humidity - Decimal (i.e. not a percentage) 11 | # V - Specific volume - Cubic feet per pound mass, ft^3/lbm 12 | # W - Humidity ratio - pounds mass per pound mass, lbm/lbm 13 | # WBT - Wet bulb temperature - Degrees Rankine, R 14 | 15 | # Minimum dry bulb temperature 16 | Min_DBT=491.67 17 | # Maximum dry bulb temperature 18 | Max_DBT=851.67 19 | # Convergence tolerance 20 | TOL=0.0000005 21 | 22 | def __DBT_H_RH_P(H, RH, P): 23 | [DBTa, DBTb]=[Min_DBT, Max_DBT] 24 | DBT=(DBTa+DBTb)/2 25 | while DBTb-DBTa>TOL: 26 | ya=__W_DBT_RH_P(DBTa, RH, P)-__W_DBT_H(DBTa, H) 27 | y=__W_DBT_RH_P(DBT, RH, P)-__W_DBT_H(DBT, H) 28 | if __is_positive(y)==__is_positive(ya): 29 | DBTa=DBT 30 | else: 31 | DBTb=DBT 32 | DBT=(DBTa+DBTb)/2 33 | return DBT 34 | 35 | def __DBT_H_V_P(H, V, P): 36 | [DBTa, DBTb]=[Min_DBT, Max_DBT] 37 | DBT=(DBTa+DBTb)/2 38 | while DBTb-DBTa>TOL: 39 | ya=__W_DBT_V_P(DBTa, V, P)-__W_DBT_H(DBTa, H) 40 | y=__W_DBT_V_P(DBT, V, P)-__W_DBT_H(DBT, H) 41 | if __is_positive(y)==__is_positive(ya): 42 | DBTa=DBT 43 | else: 44 | DBTb=DBT 45 | DBT=(DBTa+DBTb)/2 46 | return DBT 47 | 48 | def __DBT_H_W(H, W): 49 | [DBTa, DBTb]=[Min_DBT, Max_DBT] 50 | DBT=(DBTa+DBTb)/2 51 | while DBTb-DBTa>TOL: 52 | ya=W-__W_DBT_H(DBTa, H) 53 | y=W-__W_DBT_H(DBT, H) 54 | if __is_positive(y)==__is_positive(ya): 55 | DBTa=DBT 56 | else: 57 | DBTb=DBT 58 | DBT=(DBTa+DBTb)/2 59 | return DBT 60 | 61 | def __DBT_H_WBT_P(H, WBT, P): 62 | [DBTa, DBTb]=[Min_DBT, Max_DBT] 63 | DBT=(DBTa+DBTb)/2 64 | while DBTb-DBTa>TOL: 65 | ya=__W_DBT_WBT_P(DBTa, WBT, P)-__W_DBT_H(DBTa, H) 66 | y=__W_DBT_WBT_P(DBT, WBT, P)-__W_DBT_H(DBT, H) 67 | if __is_positive(y)==__is_positive(ya): 68 | DBTa=DBT 69 | else: 70 | DBTb=DBT 71 | DBT=(DBTa+DBTb)/2 72 | return DBT 73 | 74 | def __DBT_RH_V_P(RH, V, P): 75 | [DBTa, DBTb]=[Min_DBT, Max_DBT] 76 | DBT=(DBTa+DBTb)/2 77 | while DBTb-DBTa>TOL: 78 | ya=__W_DBT_RH_P(DBTa, RH, P)-__W_DBT_V_P(DBTa, V, P) 79 | y=__W_DBT_RH_P(DBT, RH, P)-__W_DBT_V_P(DBT, V, P) 80 | if __is_positive(y)==__is_positive(ya): 81 | DBTa=DBT 82 | else: 83 | DBTb=DBT 84 | DBT=(DBTa+DBTb)/2 85 | return DBT 86 | 87 | def __DBT_RH_W_P(RH, W, P): 88 | [DBTa, DBTb]=[Min_DBT, Max_DBT] 89 | DBT=(DBTa+DBTb)/2 90 | while DBTb-DBTa>TOL: 91 | ya=__W_DBT_RH_P(DBTa, RH, P)-W 92 | y=__W_DBT_RH_P(DBT, RH, P)-W 93 | if __is_positive(y)==__is_positive(ya): 94 | DBTa=DBT 95 | else: 96 | DBTb=DBT 97 | DBT=(DBTa+DBTb)/2 98 | return DBT 99 | 100 | def __DBT_RH_WBT_P(RH, WBT, P): 101 | [DBTa, DBTb]=[Min_DBT, Max_DBT] 102 | DBT=(DBTa+DBTb)/2 103 | while DBTb-DBTa>TOL: 104 | ya=__W_DBT_WBT_P(DBTa, WBT, P)-__W_DBT_RH_P(DBTa, RH, P) 105 | y=__W_DBT_WBT_P(DBT, WBT, P)-__W_DBT_RH_P(DBT, RH, P) 106 | if __is_positive(y)==__is_positive(ya): 107 | DBTa=DBT 108 | else: 109 | DBTb=DBT 110 | DBT=(DBTa+DBTb)/2 111 | return DBT 112 | 113 | def __DBT_V_W_P(V, W, P): 114 | [DBTa, DBTb]=[Min_DBT, Max_DBT] 115 | DBT=(DBTa+DBTb)/2 116 | while DBTb-DBTa>TOL: 117 | ya=W-__W_DBT_V_P(DBTa, V, P) 118 | y=W-__W_DBT_V_P(DBT, V, P) 119 | if __is_positive(y)==__is_positive(ya): 120 | DBTa=DBT 121 | else: 122 | DBTb=DBT 123 | DBT=(DBTa+DBTb)/2 124 | return DBT 125 | 126 | def __DBT_V_WBT_P(V, WBT, P): 127 | [DBTa, DBTb]=[Min_DBT, Max_DBT] 128 | DBT=(DBTa+DBTb)/2 129 | while DBTb-DBTa>TOL: 130 | ya=__W_DBT_WBT_P(DBTa, WBT, P)-__W_DBT_V_P(DBTa, V, P) 131 | y=__W_DBT_WBT_P(DBT, WBT, P)-__W_DBT_V_P(DBT, V, P) 132 | if __is_positive(y)==__is_positive(ya): 133 | DBTa=DBT 134 | else: 135 | DBTb=DBT 136 | DBT=(DBTa+DBTb)/2 137 | return DBT 138 | 139 | def __DBT_W_WBT_P(W, WBT, P): 140 | [DBTa, DBTb]=[Min_DBT, Max_DBT] 141 | DBT=(DBTa+DBTb)/2 142 | while DBTb-DBTa>TOL: 143 | ya=__W_DBT_WBT_P(DBTa, WBT, P)-W 144 | y=__W_DBT_WBT_P(DBT, WBT, P)-W 145 | if __is_positive(y)==__is_positive(ya): 146 | DBTa=DBT 147 | else: 148 | DBTb=DBT 149 | DBT=(DBTa+DBTb)/2 150 | return DBT 151 | 152 | # ASHRAE 2009 Chapter 1 Equation 39 153 | def __DPT_Pw(Pw): 154 | Pw=Pw 155 | C14=100.45 156 | C15=33.193 157 | C16=2.319 158 | C17=0.17074 159 | C18=1.2063 160 | a=m.log(Pw) 161 | return (C14+C15*a+C16*a**2+C17*a**3+C18*Pw**0.1984)+459.67 162 | 163 | # ASHRAE 2009 Chapter 1 Equation 32 164 | def __H_DBT_W(DBT, W): 165 | if __valid_DBT(DBT): 166 | DBT=DBT-459.67 167 | return 0.240*DBT+W*(1061+0.444*DBT) 168 | 169 | def __is_positive(x): 170 | if x>0: 171 | return True 172 | else: 173 | return False 174 | 175 | # ASHRAE 2009 Chapter 1 Equation 22 176 | def __Pw_W_P(W, P): 177 | return W*P/(W+0.621945) 178 | 179 | # ASHRAE 2009 Chapter 1 Equation 6 180 | def __Pws(DBT): 181 | if __valid_DBT(DBT): 182 | C8=-1.0440397*10**4 183 | C9=-1.1294650*10**1 184 | C10=-2.7022355*10**-2 185 | C11=1.2890360*10**-5 186 | C12=-2.4780681*10**-9 187 | C13=6.5459673 188 | return m.exp(C8/DBT+C9+C10*DBT+C11*DBT**2+C12*DBT**3+C13*m.log(DBT)) 189 | 190 | def state(prop1, prop1val, prop2, prop2val,P): 191 | if prop1==prop2: 192 | print("Properties must be independent.") 193 | return 194 | prop=["DBT","WBT","RH","W","V","H"] 195 | if prop1 not in prop or prop2 not in prop: 196 | print("Valid property must be given.") 197 | return 198 | prop1i=prop.index(prop1) 199 | prop2i=prop.index(prop2) 200 | if prop1iTOL: 353 | Ws=__W_DBT_WBT_P(DBT, WBT, P) 354 | if W>Ws: 355 | WBTa=WBT 356 | else: 357 | WBTb=WBT 358 | WBT=(WBTa+WBTb)/2 359 | return WBT 360 | 361 | def __valid_DBT(DBT): 362 | if Min_DBT<=DBT<=Max_DBT: 363 | return True 364 | else: 365 | return False 366 | --------------------------------------------------------------------------------