7 annex - upcommons
TRANSCRIPT
7 Annex
7.1 Single plume class (SinglePlume)
1
2
3
4 ””” Contains the S i n g l e Plume c l a s s . ”””
5 from sc ipy . opt imize import f s o l v e
6 import numpy as np
7 import matp lo t l i b . pyplot as p l t
8 from psychrochart . chart import PsychroChart
9 from sc ipy . i n t e g r a t e import ode int
10 from c o o l i t . Mate r i a l s import AirVapour
11 from c o o l i t . Plume import GovernEq
12
13 c l a s s SinglePlume ( ob j e c t ) :
14 ””” Contains the a t r i b u t e s and methods f o r the plume s o l u t i o n .
15
16 On i n i t i a l i z a t i o n , the ob j e c t c a l c u l a t e s i t s ob j e c t v a r i a b l e s immediately .
17
18 The ob j e c t v a r i a b l e s i n c lude :
19
20 Input v a r i a b l e s :
21
22 ∗ s e l f . zetamax Maximum length to
i n t e g r a t e (m)
23 ∗ s e l f . a lpha p The axisymmetric
entrainment c o e f f i c i e n t f o r a point−source plume
24 ∗ s e l f . i n t e r v a l s t e p s Number o f s t ep s o f
i n t e g r a t i o n f o r s i n g l e plume
25 ∗ s e l f . P amb Ambient p r e s su r e (Pa)
26 ∗ s e l f . temp amb Ambient temperature (C)
27 ∗ s e l f . re l amb humidity Ambient r e l a t i v e humidity
(%)
28 ∗ s e l f . temp source Source temperature (C)
55
29 ∗ s e l f . r e l h u m i d i t y s o u r c e Re la t i v e humidity at the
source (%)
30 ∗ s e l f . v e l o c i t y s o u r c e Stack e x i t v e l o c i t y (m/ s )
31 ∗ s e l f . a r e a sou r c e Stack e x i t area (mˆ2)
32 ∗ s e l f . s p e c mo i s tu r e s ou r c e Source s p e c i f i c l i q u i d
moisture (Kg/Kg)
33
34 I n i c i a l i z a t i o n o f v a r i a b l e s / f i r s t c a l c u l a t i o n s :
35
36 ∗ s e l f .Ma Air molar mass ( kg/mole )
37 ∗ s e l f .Mv Water vapor molar mass (
kg/mole )
38 ∗ s e l f . Cpa S p e c i f i c heat o f ( dry )
a i r at constant p r e s su r e ( kJ/kg K)
39 ∗ s e l f .R Gas constant f o r dry a i r
( J /(Kg∗K) )
40 ∗ s e l f . g Grav i t a t i ona l
a c c e l e r a t i o n (m/ s ˆ2)
41 ∗ s e l f . P r e s su r e s ou r c e Source ’ s p r e s su r e (Pa)
42 ∗ s e l f . vap pressure amb Ambient vapor p r e s su r e at
the source (Pa)
43 ∗ s e l f . spec amb humidity Ambient s p e c i f i c humidity
at the source
44 ∗ s e l f . v irtual temp amb Vi r tua l temperature o f
the ambient
45 ∗ s e l f . v ap p r e s su r e s ou r c e Source vapor p r e s su r e (Pa
)
46 ∗ s e l f . spec humid i ty source S p e c i f i c humidity
47 ∗ s e l f . Volume source Source ’ s volume f l u x (m
ˆ3/ s )
48 ∗ s e l f . Momentum source Source ’ s momentum f l u x (m
ˆ4/ s ˆ2)
49 ∗ s e l f . t e m p e x c e s s f l u x s o u r c e Source ’ s temperature
exce s s f l u x
50 ∗ s e l f . s p e c h u m i d i t y e x c e s s f l u x s o u r c e Source ’ s s p e c i f i c
humidity exce s s f l u x
56
51 ∗ s e l f . s p e c m o i s t u r e f l u x s o u r c e Source ’ s s p e c i f i c l i q u i d
moisture f l u x
52 ∗ s e l f . t o t a l m o i s t u r e f l u x s o u r c e Total moisture f l u x at
the source
53 ∗ s e l f . t o t a l s e n s h e a t f l u x s o u r c e Total s e n s i b l e heat f l u x
at the source
54
55
56 ”””
57
58 de f i n i t ( s e l f , zetamax , alpha p , i n t e r v a l s t e p s , P amb , temp amb ,
\
59 re l amb humidity , temp source , r e l humid i ty sou r c e ,
\
60 v e l o c i t y s o u r c e , a r ea source , sp e c mo i s tu r e s ou r c e ) :
61 r ”””
62 I n i t i a l i z e the c l a s s and s e t i t s pe r sona l v a r i a b l e s .
63
64 Does a l l the c a l c u l a t i o n s at once , so v a r i a b l e s are immediately usab le
.
65
66 The ob j e c t v a r i a b l e s i n c lude :
67 ∗ s e l f . zetamax
68 ∗ s e l f . a lpha p
69 ∗ s e l f . i n t e r v a l s t e p s
70 ∗ s e l f . P amb
71 ∗ s e l f . temp amb
72 ∗ s e l f . re l amb humidity
73 ∗ s e l f . temp source
74 ∗ s e l f . r e l h u m i d i t y s o u r c e
75 ∗ s e l f . v e l o c i t y s o u r c e
76 ∗ s e l f . a r e a sou r c e
77 ∗ s e l f . s p e c mo i s tu r e s ou r c e
78
79 ∗ s e l f .Ma
80 ∗ s e l f .Mv
57
81 ∗ s e l f . Cpa
82 ∗ s e l f .R
83 ∗ s e l f . g
84 ∗ s e l f . P r e s su r e s ou r c e
85 ∗ s e l f . vap pressure amb
86 ∗ s e l f . spec amb humidity
87 ∗ s e l f . v irtual temp amb
88 ∗ s e l f . v ap p r e s su r e s ou r c e
89 ∗ s e l f . spec humid i ty source
90 ∗ s e l f . Volume source
91 ∗ s e l f . Momentum source
92 ∗ s e l f . t e m p e x c e s s f l u x s o u r c e
93 ∗ s e l f . s p e c h u m i d i t y e x c e s s f l u x s o u r c e
94 ∗ s e l f . s p e c m o i s t u r e f l u x s o u r c e
95 ∗ s e l f . t o t a l m o i s t u r e f l u x s o u r c e
96 ∗ s e l f . t o t a l s e n s h e a t f l u x s o u r c e
97
98 ”””
99 s e l f . zetamax = zetamax
100 s e l f . a lpha p = alpha p
101 s e l f . i n t e r v a l s t e p s = i n t e r v a l s t e p s
102 s e l f . P amb = P amb
103 s e l f . temp amb = temp amb
104 s e l f . re l amb humidity = rel amb humidity
105 s e l f . temp source = temp source
106 s e l f . r e l h u m i d i t y s o u r c e = r e l h u m i d i t y s o u r c e
107 s e l f . v e l o c i t y s o u r c e = v e l o c i t y s o u r c e
108 s e l f . a r e a sou r c e = ar ea sou r c e
109 s e l f . s p e c mo i s tu r e s ou r c e = spe c mo i s tu r e s ou r c e
110
111 s e l f .Ma = AirVapour ( temp source , temp source , P amb) .Ma
112 s e l f .Mv = AirVapour ( temp source , temp source , P amb) .Mv
113 s e l f . Cpa = AirVapour ( temp source , temp source ,
\
114 P amb) . s p e c i f i c h e a t [ 0 ] /1000
115 s e l f .R = AirVapour ( temp source , temp source , P amb) .R/ s e l f .Ma
58
116 s e l f . g = 9 .81
117 s e l f . P r e s su r e s ou r c e = P amb
118 s e l f . vap pressure amb = rel amb humidity ∗1e−2∗AirVapour ( temp amb ,
\
119 0 , 0) . s a t p r e s s u r e
120 s e l f . spec amb humidity = s e l f . vap pressure amb ∗ s e l f .Mv/( ( P amb−
\
121 s e l f . vap pressure amb ) ∗ s e l f .Ma
\
122 + s e l f . vap pressure amb ∗ s e l f .Mv)
123 s e l f . v irtual temp amb = s e l f . temp amb∗(1+0.608∗ s e l f . spec amb humidity )
124 s e l f . v ap p r e s su r e s ou r c e = r e l h u m i d i t y s o u r c e ∗1e−2∗
\
125 AirVapour ( temp source ,
\
126 temp source , P amb) . s a t p r e s s u r e
127 s e l f . spec humid i ty source = s e l f . v ap p r e s su r e s ou r c e ∗
\
128 s e l f .Mv/( ( s e l f . P r e s su r e s ou r c e −
\
129 s e l f . v ap p r e s su r e s ou r c e ) ∗ s e l f .Ma
\
130 + s e l f . v ap p r e s su r e s ou r c e ∗ s e l f .Mv)
131 s e l f . Volume source = v e l o c i t y s o u r c e ∗ a r ea sou r c e
132 s e l f . Momentum source = v e l o c i t y s o u r c e ∗∗2∗ a r ea sou r c e
133 s e l f . t e m p e x c e s s f l u x s o u r c e = ( temp source−temp amb ) ∗
\
134 s e l f . Volume source
135 s e l f . s p e c h u m i d i t y e x c e s s f l u x s o u r c e = ( s e l f . spec humid i ty source−
\
136 s e l f . spec amb humidity ) ∗
\
137 s e l f . Volume source
138 s e l f . s p e c m o i s t u r e f l u x s o u r c e = s e l f . s p e c mo i s tu r e s ou r c e ∗
\
139 s e l f . Volume source
59
140 s e l f . t o t a l m o i s t u r e f l u x s o u r c e=s e l f . s p e c h u m i d i t y e x c e s s f l u x s o u r c e
\
141 + s e l f . s p e c m o i s t u r e f l u x s o u r c e
142 s e l f . t o t a l s e n s h e a t f l u x s o u r c e = s e l f . t e m p e x c e s s f l u x s o u r c e
\
143 − AirVapour ( temp source , temp source , P amb) . l a t e n t h e a t /
\
144 s e l f . Cpa∗ s e l f . s p e c m o i s t u r e f l u x s o u r c e
145 s e l f . yy = [ s e l f . Volume source , s e l f . Momentum source ,
\
146 s e l f . P r e s su r e s ou r c e ]
147
148
149
150 de f s o l v e g o v e q ( s e l f ) :
151 ”””
152 Method that s o l v e s the governing equat ions ( volume , momentum and
153 pre s su r e ) and re tu rn s t h e i r va lue . The i n t e g r a t i o n i s c a r r i e d out by
154 ode int Python package from Scipy .
155
156 ”””
157 zetamin = 0 # I n i t i a l he ight (m)
158 i n i t = [ s e l f . Volume source , s e l f . Momentum source , s e l f . P r e s su r e s ou r c e
] # Source va lue s f o r odes in func t i on QM ICT Pressure Point
159 zeta span = np . l i n s p a c e ( zetamin , s e l f . zetamax , s e l f . i n t e r v a l s t e p s ) #
Range o f he ight va lue s
160 i n t e g r a t i o n = GovernEq ( s e l f . g , s e l f . alpha p , s e l f . Cpa , \
161 s e l f . t o t a l m o i s t u r e f l u x s o u r c e ,
\
162 s e l f . t o t a l s e n s h e a t f l u x s o u r c e , s e l f . temp amb ,
\
163 s e l f . spec amb humidity , s e l f .R,
\
164 s e l f . virtual temp amb , s e l f .Ma, s e l f .Mv, s e l f . yy )
165 QM = ode int ( i n t e g r a t i o n . govern eq , i n i t , z e ta span )
166 s e l f . z e ta = zeta span
60
167 s e l f . Volume = QM[ : , 0 ] # Volume f l u x o f the plume at d i f f e r e n t
e l e v a t i o n
168 s e l f .Momentum = QM[ : , 1 ] # Momentum f l u x o f the plume at d i f f e r e n t
e l e v a t i o n
169 s e l f . Pres sure = QM[ : , 2 ] # Ambient p r e s su r e ( which i s equal to the
p r e s su r e o f the plume at the same e l e v a t i o n )
170
171 re turn s e l f . Volume , s e l f .Momentum, s e l f . Pres sure
172
173
174 de f s o l v e v a r ( s e l f ) :
175 ”””
176 Method that c a l c u l a t e s a l l the v a r i a b l e s that c a r a c t e i z e s the plume
177 at the d i f f e r e n t he ight po in t s .
178
179 ”””
180
181 s e l f . Volume , s e l f .Momentum, s e l f . Pres sure = s e l f . s o l v e g o v e q ( )
182
183 # I n i z i a l i z e l i s t o f v a r i a b l e s a long the he ight ( ze ta )
184
185 TT = s e l f . t o t a l s e n s h e a t f l u x s o u r c e # Plume ’ s temperature exce s s
f l u x
186 s e l f . s p e c m o i s t u r e f l u x = np . z e ro s ( l en ( s e l f . z e ta ) ) # Plume ’ s s p e c i f i c
l i q u i d moisture f l u x
187 s e l f . s p e c humid i ty f l ux = np . z e r o s ( l en ( s e l f . z e ta ) ) # Plume ’ s s p e c i f i c
spec humid i ty f luxumid i ty f l u x
188 s e l f . plume temp = np . z e ro s ( l en ( s e l f . z e ta ) ) # Plume ’ s temperature (C)
189 s e l f . spec humidity = np . z e r o s ( l en ( s e l f . z e ta ) ) # Plume ’ s s p e c i f i c
humidity (Kg/Kg
190 s e l f . vap pre s sure = np . z e ro s ( l en ( s e l f . z e ta ) ) # Vapor p r e s su r e in the
plume (Pa)
191 s e l f . r e l humid i ty = np . z e ro s ( l en ( s e l f . z e ta ) ) # Re la t i v e humidity o f
the plume
192 # The r e s u l t s with vapour pressure wet bulb temp in s t ead o f
s a t p r e s s u r e change , high s e n s i b i l i t y to s a t p r e s s u r e
61
193
194 s e l f . spec mo i s ture = np . z e ro s ( l en ( s e l f . z e ta ) ) # The s p e c i f i c l i q u i d
moisture o f the plume
195 s e l f . dens i ty moi s t p lume = np . z e r o s ( l en ( s e l f . z e ta ) ) # The dens i ty o f
moist plume
196 s e l f . dens i ty amb a i r = np . z e r o s ( l en ( s e l f . z e ta ) ) # The dens i ty o f
ambient a i r
197 s e l f . abso lute humid i ty = np . z e ro s ( l en ( s e l f . z e ta ) ) # The humidity
r a t i o ( or abso lu t e humidity ) o f the plume
198 s e l f . humid i ty ra t i o = np . z e r o s ( l en ( s e l f . z e ta ) ) # This l i n e d e v i a t e s
from o r i g i n a l MATLAB CODE:
199 # In MATLAB code , y−ax i s o f psychometr ic chart i s s p e c i f i c humidy , but
the
200 # module in Python from MIT uses humidity r a t i o as the y−ax i s
201
202
203 f o r i in range (0 , l en ( s e l f . z e ta ) ) :
204 # Calcu la te v a r i a b l e s assuming there i s no condensat ion . T RH, to
see i f the re i s condensat ion
205 W = 0
206 s e l f . s p e c m o i s t u r e f l u x [ i ] = W
207 s e l f . s p e c humid i ty f l ux [ i ] = s e l f . t o t a l m o i s t u r e f l u x s o u r c e − W
208 s e l f . plume temp [ i ] = s e l f . temp amb + TT / s e l f . Volume [ i ]
209 s e l f . spec humidity [ i ] = s e l f . spec amb humidity +
\
210 s e l f . s p e c humid i ty f l ux [ i ] / s e l f . Volume [ i ]
211 s e l f . vap pre s sure [ i ] = s e l f . spec humidity [ i ] ∗
\
212 s e l f . Pres sure [ i ] / ( s e l f .Mv / s e l f .Ma
\
213 ∗ (1 − s e l f . spec humidity [ i ] ) +
\
214 s e l f . spec humidity [ i ] )
215 s e l f . r e l humid i ty [ i ] = s e l f . vap pre s sure [ i ] /
\
62
216 AirVapour ( s e l f . plume temp [ i ] , 0 ,
\
217 0) . s a t p r e s s u r e
218
219 i f s e l f . r e l humid i ty [ i ] >= 1 or s e l f . s p e c m o i s t u r e f l u x [ i ] > 1e
−10: # I f , a c tua l l y , the re i s condensat ion , modify the v a r i a b l e s ’ va lue
accord ing to that
220 s e l f . yy = np . array ( [ s e l f . Volume [ i ] , s e l f .Momentum[ i ] ,
\
221 s e l f . Pres sure [ i ] ] )
222 water = GovernEq ( s e l f . g , s e l f . alpha p , s e l f . Cpa , \
223 s e l f . t o t a l m o i s t u r e f l u x s o u r c e ,
\
224 s e l f . t o t a l s e n s h e a t f l u x s o u r c e , s e l f . temp amb ,
\
225 s e l f . spec amb humidity , s e l f .R,
\
226 s e l f . virtual temp amb , s e l f .Ma, s e l f .Mv, s e l f . yy )
227 W = f s o l v e ( water . condensat ion ,
\
228 s e l f . t o t a l m o i s t u r e f l u x s o u r c e /10)
229
230 s e l f . s p e c m o i s t u r e f l u x [ i ] = W
231 s e l f . s p e c humid i ty f l ux [ i ] = s e l f . t o t a l m o i s t u r e f l u x s o u r c e
\
232 − W
233 s e l f . plume temp [ i ] = ( s e l f . temp amb − 273 .15 +
\
234 s e l f . t o t a l s e n s h e a t f l u x s o u r c e /
\
235 s e l f . Volume [ i ]
\
236 + 597 .31∗4 .1868∗W/ s e l f . Volume [ i ] /
\
237 s e l f . Cpa) /(1 + 0 .57∗4 .1868∗W/
\
63
238 s e l f . Volume [ i ] / s e l f . Cpa) + 273.15
239 s e l f . spec humidity [ i ] = s e l f . spec amb humidity +
\
240 s e l f . s p e c humid i ty f l ux [ i ] /
\
241 s e l f . Volume [ i ]
242 s e l f . vap pre s sure [ i ] = s e l f . spec humidity [ i ] ∗
\
243 s e l f . Pres sure [ i ] / ( s e l f .Mv / s e l f .Ma
\
244 ∗ (1 − s e l f . spec humidity [ i ] ) +
\
245 s e l f . spec humidity [ i ] )
246 s e l f . r e l humid i ty [ i ] = s e l f . vap pre s sure [ i ] /
\
247 AirVapour ( s e l f . plume temp [ i ] , 0 ,
\
248 0) . s a t p r e s s u r e
249
250 Pre s su r e s ou r c e = s e l f . Pres sure [ i ]
251 s e l f . spec mo i s ture [ i ] = s e l f . s p e c m o i s t u r e f l u x [ i ] / s e l f . Volume [ i ]
252 s e l f . dens i ty amb a i r [ i ] = Pre s su r e s ou r c e / s e l f .R/
\
253 s e l f . v irtual temp amb
254 s e l f . dens i ty moi s t p lume [ i ] = Pre s su r e s ou r c e / s e l f .R/
\
255 ( s e l f . plume temp [ i ] ) /(1+0.608∗
\
256 s e l f . spec humidity [ i ]
\
257 − s e l f . spec mo i s ture [ i ] )
258 s e l f . abso lute humid i ty [ i ] = s e l f . vap pre s sure [ i ] ∗ s e l f .Mv/
\
259 ( Pre s sure source−
\
260 s e l f . vap pre s sure [ i ] ) / s e l f .Ma
64
261 s e l f . humid i ty ra t i o [ i ] = s e l f . spec humidity [ i ]/(1−
\
262 s e l f . spec humidity [ i ] )
263
264 re turn s e l f . r e l humid i ty , s e l f . s p e c mo i s tu r e f l ux ,
\
265 s e l f . spec humid i ty f lux , s e l f . plume temp ,
\
266 s e l f . spec humidity , s e l f . vap pressure , s e l f . humid i ty rat io ,
\
267 s e l f . spec mois ture , s e l f . dens i ty amb ai r ,
\
268 s e l f . dens i ty moist p lume , s e l f . abso lute humid i ty
269
270
271 de f p l o t r h ( s e l f ) :
272 ”””
273 Method that p l o t s the r e l a t i v e humidity in func t i on o f the he ight .
274
275 ”””
276 s e l f . r e l humid i ty , , , , , , , , , , = s e l f . s o l v e v a r ( )
277 # RH vs zeta
278 p l t . f i g u r e (1 )
279 p l t . p l o t ( s e l f . r e l humid i ty ∗100 , s e l f . zeta , ’ r−− ’ ,
\
280 l a b e l = ’ S i n g l e Plume ’ )
281 p l t . x l a b e l ( ”$RH p$” )
282 p l t . y l a b e l ( ’ z (m) ’ )
283 p l t . l egend ( )
284 p l t . show ( )
285
286 de f p l o t t d ( s e l f ) :
287 ”””
288 Method that p l o t s the temperature d i f f e r e n c e between the plume and
289 the ambient in func t i on o f the he ight .
290
65
291 ”””
292 , , , s e l f . plume temp , , , , , , , = s e l f . s o l v e v a r ( )
293 # ( t plume − t ambient ) vs ze ta
294 p l t . f i g u r e (2 )
295 p l t . p l o t ( s e l f . plume temp−s e l f . temp amb , s e l f . zeta , ’ r−− ’ ,
\
296 l a b e l = ’ S i n g l e Plume ’ )
297 p l t . x l a b e l ( ” $t p$ − $ t a$ ( $ˆ\ c i rc$C ) ” )
298 p l t . y l a b e l ( ’ z (m) ’ )
299 p l t . l egend ( )
300 p l t . show ( )
301
302 de f p l o t h r ( s e l f ) :
303 ”””
304 Method that p l o t s the temperature o f the plume in func t i on o f
305 the humidity r a t i o .
306
307 ”””
308 , , , , , , s e l f . humid i ty rat io , , , , = s e l f . s o l v e v a r ( )
309 # HR vs zeta
310 p l t . f i g u r e (3 )
311 p l t . p l o t ( s e l f . plume temp , s e l f . humid i ty ra t i o ∗1000 , ’ r−− ’ ,
\
312 l a b e l = ’ S i n g l e Plume ’ )
313 p l t . x l a b e l ( ” $t p$ (K) ” )
314 p l t . y l a b e l ( ”$HR p$” )
315 p l t . show ( )
316
317
318 de f p l o t p sych romet r i c ( s e l f ) :
319 ”””
320 Method that p l o t s the psychrometr ic chart o f the plume .
321
322 ”””
323
66
324 s e l f . r e l humid i ty , s e l f . s p e c mo i s tu r e f l ux , s e l f . spec humid i ty f lux ,
\
325 s e l f . plume temp , s e l f . spec humidity , s e l f . vap pressure ,
\
326 s e l f . humid i ty rat io , , , , = s e l f . s o l v e v a r ( )
327 p l t . f i g u r e (4 )
328
329 # Add the e l e v a t i o n s on the psychrometr ic chart and change
temperatures to C
330 zp = s e l f . zetamax/5
331 ip = np . z e r o s (5 )
332 f o r i in range (0 , l en ( s e l f . z e ta ) ) :
333 i f s e l f . z e ta [ i ] <= zp and s e l f . z e ta [ i +1] > zp :
334 ip [ 0 ] = i
335 e l i f s e l f . z e ta [ i ] <= zp∗2 and s e l f . z e ta [ i +1] > zp ∗2 :
336 ip [ 1 ] = i ;
337 e l i f s e l f . z e ta [ i ] <= zp∗3 and s e l f . z e ta [ i +1] > zp ∗3 :
338 ip [ 2 ] = i
339 e l i f s e l f . z e ta [ i ] <= zp∗4 and s e l f . z e ta [ i +1] > zp ∗4 :
340 ip [ 3 ] = i
341
342 s e l f . plume temp [ i ] = s e l f . plume temp [ i ] − 273 .15
343
344
345 ip [ 4 ] = l en ( s e l f . z e ta )
346 s t r 1 = s t r ( zp ) + ’ (m) ’
347 s t r 2 = s t r ( zp ∗2) + ’ (m) ’
348 s t r 3 = s t r ( zp ∗3) + ’ (m) ’
349 s t r 4 = s t r ( zp ∗4) + ’ (m) ’
350 s t r 5 = s t r ( zp ∗5) + ’ (m) ’
351
352 cus tom sty l e = {
353 ” l i m i t s ” : {
354
355 ” range temp c ” : [ 1 0 , 40 ] ,
356 ” range humid i ty g kg ” : [ 0 , 3 0 ] ,
67
357 ” pre s sure kpa ” : s e l f . Pres sure [ 0 ] / 1 0 0 0 ,
358 } ,
359 # ” s a t u ra t i o n ” : {” l i n ew id th ” : 10} , # i n c r e a s e s red l i n e
t h i c k n e s s
360 ” chart params ” : {
361 ” with zones ” : Fa l se # Removes Summer/Winter zones
362 }
363 }
364
365 axes = PsychroChart ( cus tom sty l e ) . p l o t ( ax=p l t . gca ( ) ) # ’ d e f a u l t ’ f o r
de fau l t , ’ ashrae ’ f o r b lack and white , ’ minimal ’ f o r minimal , ’ cu s tom sty l e
’ f o r custom l i m i t s
366 axes . t ex t (0 , 25 , ’ $P {amb}$ = %s (Pa) \ n$ t {amb}$ = %s (\ u2103 ) , $RH {
amb}$ = %s %% \ n$ t {0}$ = %s (\ u2103 ) , $RH 0$ = %s %%’ % ( s e l f . Pressure [ 0 ] ,
s e l f . temp amb − 273 .15 , s e l f . re l amb humidity , s e l f . temp source − 273 .15 ,
s e l f . r e l h u m i d i t y s o u r c e ) , f o n t s i z e =12)
367 axes . p l o t ( s e l f . plume temp , s e l f . humid i ty ra t i o ∗1000 , ’b− ’ , l a b e l = ’
S i n g l e Plume ’ )
368 axes . l egend ( )
369
370 axes . t ex t ( s e l f . plume temp [ i n t ( ip [0 ]−1) ] , s e l f . spec humidity [ i n t ( ip
[0 ]−1) ]∗1000 , s t r1 , ho r i zon ta l a l i gnment=’ r i g h t ’ , v e r t i c a l a l i g n m e n t=’ bottom ’ )
371 axes . t ex t ( s e l f . plume temp [ i n t ( ip [1 ]−1) ] , s e l f . spec humidity [ i n t ( ip
[1 ]−1) ]∗1000 , s t r2 , ho r i zon ta l a l i gnment=’ r i g h t ’ , v e r t i c a l a l i g n m e n t=’ bottom ’ )
372 axes . t ex t ( s e l f . plume temp [ i n t ( ip [2 ]−1) ] , s e l f . spec humidity [ i n t ( ip
[2 ]−1) ]∗1000 , s t r3 , ho r i zon ta l a l i gnment=’ r i g h t ’ , v e r t i c a l a l i g n m e n t=’ bottom ’ )
373 axes . t ex t ( s e l f . plume temp [ i n t ( ip [3 ]−1) ] , s e l f . spec humidity [ i n t ( ip
[3 ]−1) ]∗1000 , s t r4 , ho r i zon ta l a l i gnment=’ r i g h t ’ , v e r t i c a l a l i g n m e n t=’ bottom ’ )
374 axes . t ex t ( s e l f . plume temp [ i n t ( ip [4 ]−1) ] , s e l f . spec humidity [ i n t ( ip
[4 ]−1) ]∗1000 , s t r5 , ho r i zon ta l a l i gnment=’ r i g h t ’ , v e r t i c a l a l i g n m e n t=’ bottom ’ )
375
376 p l t . show ( )
377
378
379 de f f i nd condensa t i on ( s e l f ) :
380 ”””
68
381 Method that p r i n t s the i n t e r v a l o f he i gh t s where the re i s condensat ion
382 or , i f the re i s n ’ t condensat ion , the value and he ight where maximum
383 r e l a t i v e humidity i s achieved .
384
385 ”””
386 s e l f . r e l humid i ty , , , , , , , , , , = s e l f . s o l v e v a r ( )
387 RH max = max( s e l f . r e l humid i ty ) # Get the maximum r e l a t i v e humidity
with in the d i l u t i o n proce s s
388 i max = np . argmax ( s e l f . r e l humid i ty )
389 f lag RH = 0
390 EPS = 1e−6 # Margin e r r o r that s e t s when s t a r t s and f i n i s h e s
condensat ion
391 i f RH max >= 1 and s e l f . r e l humid i ty [−1] < 1 :
392 f o r i in range (0 , l en ( s e l f . r e l humid i ty ) ) :
393 i f abs ( s e l f . r e l humid i ty [ i ]−1) < EPS and flag RH == 0 :
394 zeta1 = s e l f . z e ta [ i ]
395 f lag RH = 1
396 i f abs ( s e l f . r e l humid i ty [ i ]−1) < EPS:
397 zeta2 = s e l f . z e ta [ i ]
398 re turn ’ Plume i s v i s i b l e between ’ + s t r ( round ( zeta1 , 2 ) ) + ’ (m)
and ’ + s t r ( round ( zeta2 , 2 ) ) + ’ (m) ( S i n g l e Plume) . ’ + ”\n\n”
399
400 e l s e :
401 re turn ’The maximum r e l a t i v e humidity i s ’ + s t r ( round (RH max , 2 )
∗100) + ’ % which i s reached at ’ + s t r ( round ( s e l f . z e ta [ i max ] , 2 ) ) + ’ (m)
( S i n g l e Plume) . ’ + ”\n\n”
Listing 1: SinglePlume.py
69
7.2 Governing equations class (GovernEq)
1
2
3
4 ””” Contains the Govern EQ c l a s s . ”””
5 from math import pi , s q r t
6 from sc ipy . opt imize import f s o l v e
7 from c o o l i t . Mate r i a l s import AirVapour
8
9 c l a s s GovernEq ( ob j e c t ) :
10 ”””
11 Contains the plume ’ s governing equt ions o f volume , momentum
12 and pre s su r e .
13
14 ”””
15
16 de f i n i t ( s e l f , g , alpha p , Cpa , t o t a l m o i s t u r e f l u x s o u r c e ,
\
17 t o t a l s e n s h e a t f l u x s o u r c e , temp amb , spec amb humidity ,
\
18 R, virtual temp amb , Ma, Mv, yy ) :
19 s e l f . g = g
20 s e l f . a lpha p = alpha p
21 s e l f . Cpa = Cpa
22 s e l f . t o t a l m o i s t u r e f l u x s o u r c e = t o t a l m o i s t u r e f l u x s o u r c e
23 s e l f . t o t a l s e n s h e a t f l u x s o u r c e = t o t a l s e n s h e a t f l u x s o u r c e
24 s e l f . temp amb = temp amb
25 s e l f . spec amb humidity = spec amb humidity
26 s e l f .R = R
27 s e l f . v irtual temp amb = virtual temp amb
28 s e l f .Ma = Ma
29 s e l f .Mv = Mv
30 s e l f . yy = yy
31
32
70
33 de f govern eq ( s e l f , Y, plume temp ) :
34 ”””
35 Function that eva lua t e s at each d i f f e r e n t i a l he igh ( zeta ) the
36 d i f f e r e n t a i l va lue s o f Volume , Momentum and Pressure , tak ing
37 i n t o account the e f f e c t s o f condensat ion ( s epa ra t ing wet and
38 dry plumes )
39
40 ”””
41 s e l f . yy = Y
42 y1 , y2 , y3 = Y # Var iab l e s o f the s o l u t i o n (Volume , Momentum,
Pressure )
43
44 # Calcu la te RH to see i f the re i s condensat ion
45 water content = 0
46 t emp exce s s f l ux = s e l f . t o t a l s e n s h e a t f l u x s o u r c e
47 spe c humid i ty f l ux = s e l f . t o t a l m o i s t u r e f l u x s o u r c e − water content
48 plume temp = s e l f . temp amb + temp exce s s f l ux / y1
49 spec humidity = s e l f . spec amb humidity + spec humid i ty f l ux /y1
50 vap pre s sure = spec humidity ∗ y3 / ( s e l f .Mv / s e l f .Ma ∗ (1 −
\
51 spec humidity ) + spec humidity )
52 r e l humid i ty = vap pre s sure / AirVapour ( plume temp , 0 , 0) . s a t p r e s s u r e
53
54 i f r e l humid i ty >= 1 or water content > 1e−10: # I f the re i s
condensat ion
55 water content = f s o l v e ( s e l f . condensat ion ,
56 s e l f . t o t a l m o i s t u r e f l u x s o u r c e /10) # Water
content because o f condensat ion
57 t p i = ( s e l f . temp amb − 273 .15 +
\
58 s e l f . t o t a l s e n s h e a t f l u x s o u r c e / y1 + 597.31 ∗ 4 .1868
\
59 ∗ water content / y1 / s e l f . Cpa) / (1 + 0.57 ∗ 4 .1868
\
60 ∗ water content / y1 / s e l f . Cpa) + 273.15
71
61 SHi = ( s e l f . t o t a l m o i s t u r e f l u x s o u r c e −
\
62 water content ) / y1 + s e l f . spec amb humidity
63 Tvi = t p i ∗ (1 + 0.608 ∗ SHi − water content / y1 )
64
65 e l s e : # I f the re i s NO condensat ion
66 SHi = s e l f . t o t a l m o i s t u r e f l u x s o u r c e /y1 +
\
67 s e l f . spec amb humidity
68 Tvi = ( s e l f . temp amb + s e l f . t o t a l s e n s h e a t f l u x s o u r c e /y1 ) ∗
\
69 (1 + 0.608∗ SHi − water content /y1 )
70
71 dy1dz = 2 ∗ s e l f . a lpha p ∗ s q r t ( p i ∗ y2 )
72 dy2dz = s e l f . g ∗ (1 − s e l f . v irtual temp amb / Tvi ) ∗ y1 ∗∗ 2 / y2
73 dy3dz = − s e l f . g ∗ y3 / s e l f .R / s e l f . v irtual temp amb
74
75 re turn [ dy1dz , dy2dz , dy3dz ]
76
77
78 de f condensat ion ( s e l f , water content ) :
79 ”””
80 Function that eva lua t e s the water content o f the plume
81
82 ”””
83 tp = ( s e l f . temp amb − 273 .15 + s e l f . t o t a l s e n s h e a t f l u x s o u r c e /
\
84 s e l f . yy [ 0 ] + 597.31 ∗ 4 .1868 \
85 ∗ water content / s e l f . yy [ 0 ] / s e l f . Cpa) / (1 + 0.57 ∗ 4 .1868
\
86 ∗ water content / s e l f . yy [ 0 ] / s e l f . Cpa) + 273.15
87 pl = AirVapour ( tp , 0 , 0)
88 SH sp = pl . s a t p r e s s u r e ∗ s e l f .Mv / ( ( s e l f . yy [ 2 ] −
\
89 pl . s a t p r e s s u r e ) ∗ s e l f .Ma + pl . s a t p r e s s u r e ∗ s e l f .Mv)
72
90 out = s e l f . t o t a l m o i s t u r e f l u x s o u r c e − ( SH sp −
\
91 s e l f . spec amb humidity ) ∗ s e l f . yy [ 0 ] − water content
92 re turn out
Listing 2: GovernEq.py
7.3 Air and vapour properties class (AirVapour)
1 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
2 #
3 # CoolIT : A c o o l i n g tower s imu la t i on and des ign so f tware
4 #
5 # Copyright (C) 2017 by Energy Systems Design Laboratory , Un ive r s i ty o f
Alberta
6 #
7 # This so f tware i s d i s t r i b u t e d under the MIT License .
8 # For more in format ion , s ee LICENSE. txt f i l e
9 #
10 # − Class : AirVapour
11 # − Desc r ip t i on : Contains f u n c t i o n s f o r the AirVapour Class .
12 # − Developers : J . Cook
13 #
14 # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
15 ””” Contains the AirVapour c l a s s . ”””
16 import math
17
18
19 c l a s s AirVapour ( ob j e c t ) :
20 ””” Contains the f u n c t i o n s f o r the a i r vapour mixtures .
21
22 On i n i t i a l i z a t i o n , the ob j e c t c a l c u l a t e s i t s ob j e c t v a r i a b l e s immediately .
23
24 The ob j e c t v a r i a b l e s i n c lude :
25 ∗ s e l f . l a t e n t h e a t o f e v a p o r a t i o n
73
26 ∗ s e l f . vapour pressure wet bulb temp
27 ∗ s e l f . s a t p r e s s u r e
28 ∗ s e l f . humidity
29 ∗ s e l f . d ens i ty
30 ∗ s e l f . v i s c o s i t y
31 ∗ s e l f . s p e c i f i c h e a t
32 ∗ s e l f . l a t e n t h e a t
33 ∗ s e l f . enthalpy
34
35 ”””
36
37 de f i n i t ( s e l f , T wb , T av , P av ) :
38 r ”””
39 I n i t i a l i z e the c l a s s and s e t i t s pe r sona l v a r i a b l e s .
40
41 Does a l l the c a l c u l a t i o n s at once , so v a r i a b l e s are immediately usab le
.
42
43 The ob j e c t v a r i a b l e s i n c lude :
44 ∗ s e l f . l a t e n t h e a t o f e v a p o r a t i o n
45 ∗ s e l f . vapour pressure wet bulb temp
46 ∗ s e l f . s a t p r e s s u r e
47 ∗ s e l f . humidity
48 ∗ s e l f . d ens i ty
49 ∗ s e l f . v i s c o s i t y
50 ∗ s e l f . s p e c i f i c h e a t
51 ∗ s e l f . l a t e n t h e a t
52 ∗ s e l f . enthalpy
53
54 ”””
55 s e l f . T wb = T wb
56 s e l f . T av = T av
57 s e l f . P av = P av
58
59 s e l f . l a t e n t h e a t o f e v a p o r a t i o n = 2501598.53344643
60 s e l f .Ma = 28.966 e−3 # Air molar mass ( kg/mole )
74
61 s e l f .Mv = 18.02 e−3 # Water vapor molar mass ( kg/mole )
62 s e l f .R = 8.3144598 # I d e a l gas constant ( J /( mole∗K) )
63 s e l f . s e t vapour pre s sure wet bu lb temp (T wb)
64 s e l f . s e t s a t p r e s s u r e (T wb)
65 s e l f . s e t humid i ty (T wb , T av , P av )
66 s e l f . s e t d e n s i t y (T wb , T av , P av )
67 s e l f . s e t v i s c o s i t y (T wb , T av , P av )
68 s e l f . s e t s p e c i f i c h e a t ( T av )
69 s e l f . s e t l a t e n t h e a t ( T av )
70 s e l f . s e t en tha lpy (T wb , T av , P av )
71
72 de f s t r ( s e l f ) :
73 ”””
74 The s t r i n g method f o r the c l a s s .
75
76 This w i l l p r i n t a l l the ob j e c t v a r i a b l e s in the c l a s s .
77
78 The ob j e c t v a r i a b l e s i n c lude :
79 ∗ s e l f . l a t e n t h e a t o f e v a p o r a t i o n
80 ∗ s e l f .Ma
81 ∗ s e l f .Mv
82 ∗ s e l f .R
83 ∗ s e l f . vapour pressure wet bulb temp
84 ∗ s e l f . s a t p r e s s u r e
85 ∗ s e l f . humidity
86 ∗ s e l f . d ens i ty
87 ∗ s e l f . v i s c o s i t y
88 ∗ s e l f . s p e c i f i c h e a t
89 ∗ s e l f . l a t e n t h e a t
90 ∗ s e l f . enthalpy
91 ”””
92 strName = ”<%s in s t ance at %s>” % ( s e l f . c l a s s . name , id ( s e l f ) )
\
93 + ”\n”
94 strT wb = ”Wet bulb temperature : ”
\
75
95 + s t r ( s e l f . T wb)
\
96 + ”\n”
97 strT av = ” Air vapour temperature : ”
\
98 + s t r ( s e l f . T av )
\
99 + ”\n”
100 s t rP av = ” Pressure o f the a i r vapour : ”
\
101 + s t r ( s e l f . P av )
\
102 + ”\n”
103 strLatentHeat = ” Latent heat o f evaporat ion : ”
\
104 + s t r ( s e l f . l a t e n t h e a t o f e v a p o r a t i o n )
\
105 + ”\n”
106 strMa = ” Air molar mass : ”
\
107 + s t r ( s e l f .Ma)
\
108 + ”\n”
109 strMv = ”Water vapor molar mass : ”
\
110 + s t r ( s e l f .Mv)
\
111 + ”\n”
112 strR = ” I d e a l gas constant : ”
\
113 + s t r ( s e l f .R)
\
114 + ”\n”
115 strVapourPress = ”Vapour p r e s su r e at wet bulb temp : ”
\
76
116 + s t r ( s e l f . vapour pressure wet bulb temp )
\
117 + ”\n”
118 s t rSa tPr e s s = ” Saturat ion pr e s su r e : ”
\
119 + s t r ( s e l f . s a t p r e s s u r e )
\
120 + ”\n”
121 strHumidity = ”Humidity : ”
\
122 + s t r ( s e l f . humidity )
\
123 + ”\n”
124 s t rDens i ty = ” Density : ”
\
125 + s t r ( s e l f . d ens i ty )
\
126 + ”\n”
127 s t r V i s c o s i t y = ” V i s c o s i t y : ”
\
128 + s t r ( s e l f . v i s c o s i t y )
\
129 + ”\n”
130 s t r S p e c i f i c H e a t = ” S p e c i f i c Heat : ”
\
131 + s t r ( s e l f . s p e c i f i c h e a t )
\
132 + ”\n”
133 strLatentHeatVap = ” Latent heat o f vapo r i z a t i on : ”
\
134 + s t r ( s e l f . l a t e n t h e a t )
\
135 + ”\n”
136 strEnthalpy = ” Enthalpy : ”
\
77
137 + s t r ( s e l f . enthalpy )
\
138 + ”\n”
139 re turn strName + strT wb + strT av + strP av + strLatentHeat + strMa
\
140 + strMv + strR + strVapourPress + s t rSa tPr e s s + strHumidity
\
141 + st rDens i ty + s t r V i s c o s i t y + s t r S p e c i f i c H e a t + strLatentHeatVap
\
142 + strEnthalpy
143
144 de f k e l v i n t o c e l c i u s ( s e l f , T k ) :
145 r ”””
146 Convert from degree s ∗K∗ to degree s ∗C∗ .
147
148 Args :
149 T k ( f l o a t ) : Temperature in degree s K
150
151 Returns :
152 T c ( f l o a t ) : Temperature in degree s C
153
154 ”””
155 re turn T k − 273 .15
156
157 de f s e t vapour pre s sure wet bu lb temp ( s e l f , T wb) :
158 r ”””
159 Calcu la te and s e t the vapour p r e s su r e at wet bulb temperature .
160
161 Function uses the WMO, Goff method to f i n d the vapour p r e s su r e at wet
162 bulb temperature .
163
164 Args :
165 T wb ( f l o a t ) : Wet Bulb Temperature in degree s K.
166
167 . . math : : P {av , sa t } = 10ˆ z
168
78
169 | where
170
171 . . math : :
172 z = &10.79574(1−273.16/T {wb}) \\
173 &− 5 .028 ∗ l o g {10}( T {wb}/273 .16) \\
174 &+ 1.50475 ∗ 10 − 4(1−10ˆ{−8.2969 ∗ ( T {wb}/273.16−1) }) \\
175 &+ 0.42873 ∗ 10 − 3(10ˆ(+4.76955 ∗ (1 − 273.16/ T {wb}) ) − 1) \\
176 &+ 2.78614
177
178 | and : math : ‘ T {wb} ‘ i s the wet bulb temperature in degree s ∗K∗ .
179
180 ”””
181
182 z = 10.79574 ∗ (1 − 273 .16/(T wb+1e−14) ) \
183 − 5 .028 ∗ math . log10 (T wb/273 .16) \
184 + 1.50475 ∗ math . pow(10 , −4) \
185 ∗ (1 − math . pow(10 , −8.2969 ∗ (T wb / 273 .16 − 1) ) ) \
186 + 0.42873 ∗ math . pow(10 , −3) \
187 ∗ (math . pow(10 , 4 .76955 ∗ (1 − 273 .16 / (T wb+1e−14) ) ) − 1) \
188 + 2.78614
189
190 s e l f . vapour pressure wet bulb temp = math . pow(10 , z )
191
192
193 de f s e t s a t p r e s s u r e ( s e l f , T wb) :
194 r ”””
195 Calculateand s e t the s a t u r a t i o n pr e s su r e at a g iven T ( a l t e r n a t i v e
method to vapour pressure wet bulb temp )
196
197 Args :
198 T wb : Temperature in degree s K
199
200 Output :
201 P sv : Saturated pr e s su r e (Pa)
202
203 ”””
79
204 P sv = math . exp (−5.8002206 e3/T wb+1.3914993−4.8640239e−2∗T wb +
\
205 4.1764768 e−5∗(T wb∗∗2) − 1.4452093 e−8∗(T wb∗∗3) +
\
206 6.5459673∗math . l og (T wb) )
207 s e l f . s a t p r e s s u r e = P sv
208
209
210
211
212
213 de f se t humid i ty ( s e l f , T wb k , T av k , P av ) :
214 r ”””
215 Calcu la te and s e t the humidity r a t i o .
216
217 Args :
218 T wb k ( f l o a t ) : Wet Bulb Temperature in degree s K.
219 T av k ( f l o a t ) : Air Vapour Temperature in degree s K.
220 P av ( f l o a t ) : Pressure o f the a i r−vapour mixture in Pa .
221
222 Equations are from the 1997 ASHRAE HANDBOOK − FUNDAMENTALS,
223 SI Edit ion , Chapter 6 (26) and (35)
224
225 . . math : : w { sa t } = 0.62198 \ f r a c {P {v , sa t }}{P {av} − P {v , sa t }}
226
227 where : math : ‘ P {av } ‘ i s the t o t a l mixture p r e s su r e in Pa .
228
229 . . math : :
230
231 w = \ f r a c {(2501−2.381T {wb, c e l }) w { sa t }−(T {av , c e l}−T {wb, c e l }) }
232 {2501+1.805T {av , c e l }−4.186T {wb, c e l }}
233
234 where : math : ‘ T {av , c e l } ‘ i s temperature in degree s Ce l s ius , w i s
235 humidity ra t i o , and the s u b s c r i p t ∗wb∗ i n d i c a t e s wet bulb co n d i t i o n s .
236
237 ”””
80
238 T wb cel = s e l f . k e l v i n t o c e l c i u s ( T wb k )
239 T av ce l = s e l f . k e l v i n t o c e l c i u s ( T av k )
240
241 P v sat = s e l f . vapour pressure wet bulb temp
242
243 w sat = 0.62198 ∗ P v sat / ( P av − P v sat + 1e−14)
244 w = ((2501 − 2 .381 ∗ T wb cel ) ∗ w sat − ( T av ce l − T wb cel ) )
\
245 / (2501 + 1.805 ∗ T av ce l − 4 .186 ∗ T wb cel )
246
247 s e l f . humidity = w sat , w
248
249 de f s e t d e n s i t y ( s e l f , T wb , T av , P av ) :
250 r ”””
251 Calcu la te and s e t the dens i ty o f the a i r vapour mixture .
252
253 Args :
254 T wb ( f l o a t ) : Wet bulb temperature in K
255 T av ( f l o a t ) : Temperature o f the a i r−vapour mixture in degree s K
256 P av ( f l o a t ) : Pressure o f the a i r−vapour mixture in Pa
257
258 Equation i s
259
260 . . math : :
261
262 \ rho {av}=(1+w)(1−w/(w+0.62198) ) P {av }/(287 .1 T {av })
263
264 where : math : ‘\ rho {av } ‘ i s the moist a i r dens i ty in : math : ‘ kg/mˆ3 ‘ ,
265 w i s humidity ra t i o ,
266 P i s the t o t a l mixture p r e s su r e in ∗Pa∗ , and
267 T i s the temperature in degree s ∗K∗ .
268
269 ”””
270 w = s e l f . humidity [ 1 ]
271 s e l f . d ens i ty = (1 + w) \
272 ∗ (1 − w / (w + 0.62198 + 1e−14) ) ∗ P av / (287 . 1 ∗ T av + 1e−14)
81
273
274 de f s e t v i s c o s i t y ( s e l f , T wb , T av , P av ) :
275 r ”””
276 Calcu la te and s e t the v i s c o s i t y o f the a i r vapour mixture .
277
278 Args :
279 T wb ( f l o a t ) : Wet bulb temperature in ∗K∗
280 T av ( f l o a t ) : Temperature o f the a i r−vapour mixture in ∗K∗
281 P av ( f l o a t ) : Pressure o f the a i r−vapour mixture in ∗Pa∗
282
283 Equations used are
284
285 . . math : :
286
287 X a = 1/(1+1.608w)
288
289 . . math : :
290
291 X v = w/(w+0.622)
292
293 . . math : :
294
295 \mu {a} = 2.287973 ∗ 10ˆ{−6}+6.259793 ∗ 10ˆ{−8}T {av}−3.131956
296 ∗ 10ˆ{−11}T {av}ˆ2 + 8.15038 ∗ 10ˆ{−15}T {av}ˆ3
297
298 . . math : :
299
300 \mu {v} = 2.562435 ∗ 10ˆ{−6}+1.816683 ∗ 10ˆ{−8}T {av}+2.579066
301 ∗ 10ˆ{−11}T {av}ˆ2 − 1.067299 ∗ 10ˆ{−14}T {av}ˆ3
302
303 . . math : :
304
305 \mu {av} = ( X a\mu aM aˆ{0.5}+X v\mu vM v ˆ{0 .5} ) /( X a M aˆ{0 .5}
306 + X vM v ˆ{0 .5} )
307
308 where
82
309 : math : ‘ M a = 28.97 kg/mol ‘ ,
310 : math : ‘ M v = 18.016 kg/mol ‘ ,
311 : math : ‘ T {av } ‘ i s temperature in degree s K,
312 : math : ‘\mu‘ i s dynamic v i s c o s i t y in ∗kg/ms∗
313
314 ”””
315 w = s e l f . humidity [ 1 ]
316 M a = 28.97
317 M v = 18.016
318 X a = 1 / (1 + 1.608 ∗ w)
319 X v = w / (w + 0 .622 )
320
321 u a = 2.287973 ∗ math . pow(10 , −6) \
322 + 6.259793 ∗ math . pow(10 , −8) ∗ T av \
323 − 3.131956 ∗ math . pow(10 , −11) ∗ math . pow( T av , 2) \
324 + 8.150380 ∗ math . pow(10 , −15) ∗ math . pow( T av , 3)
325
326 u v = 2.562435 ∗ math . pow(10 , −6) \
327 + 1.816683 ∗ math . pow(10 , −8) ∗ T av \
328 + 2.579066 ∗ math . pow(10 , −11) ∗ math . pow( T av , 2) \
329 − 1.067299 ∗ math . pow(10 , −14) ∗ math . pow( T av , 3)
330
331 s e l f . v i s c o s i t y = ( X a ∗ u a ∗ math . pow(M a , 0 . 5 )
332 + X v ∗ u v ∗ math . pow(M v , 0 . 5 ) ) \
333 / ( X a ∗ math . pow(M a , 0 . 5 ) + X v ∗ math . pow(M v , 0 . 5 ) )
334
335 de f s e t s p e c i f i c h e a t ( s e l f , T) :
336 r ”””
337 Calcu la te and s e t the s p e c i f i c heats o f the a i r and the vapour .
338
339 Args :
340 T ( f l o a t ) : Temperature in degree s K
341
342 Equations used are
343
344 . . math : :
83
345
346 c {pa} = 1.045356∗10ˆ3 − 3.161783∗10ˆ{−1}
347 T 0+7.083814∗10ˆ{−4}T 0ˆ2+8.15038∗10ˆ{−15}T 0ˆ3
348
349 . . math : :
350
351 c {pv} = 1.3605∗10ˆ3 + 2.31334 T 0−2.46784∗10ˆ{−10}T 0ˆ5+5.91332
352 ∗ 10ˆ{−13}T 0ˆ6
353
354 | where
355 | : math : ‘ T 0 ‘ i s : math : ‘ (T+273.15) /2 ‘
356 ( where T i s temperature in degree s ∗K∗) ,
357 | : math : ‘ c p ‘ i s s p e c i f i c heat at constant p r e s su r e in ∗J/kgK∗ .
358
359 ”””
360 T 0 = (T + 273 .15) / 2
361
362 c pa = 1.045356 ∗ math . pow(10 , 3) \
363 − 3.161783 ∗ math . pow(10 , −1) ∗ T 0 \
364 + 7.083814 ∗ math . pow(10 , −4) ∗ math . pow( T 0 , 2) \
365 − 2.705209 ∗ math . pow(10 , −7) ∗ math . pow( T 0 , 3)
366
367 c pv = 1.36050 ∗ math . pow(10 , 3) \
368 + 2.31334 ∗ T 0 \
369 − 2.46784 ∗ math . pow(10 , −10) ∗ math . pow( T 0 , 5) \
370 + 5.91332 ∗ math . pow(10 , −13) ∗ math . pow( T 0 , 6)
371
372 s e l f . s p e c i f i c h e a t = c pa , c pv
373
374
375 de f s e t l a t e n t h e a t ( s e l f , T) :
376 r ”””
377 Calcu la te and s e t the l a t e n t heat at a g iven temperature (T > 0
378 degree s c e l s i u s ) .
379
380 Args :
84
381 T ( f l o a t ) : Temperature in degree s K
382
383 Equations used i s
384
385 . . math : :
386
387 l v = (597.31−0.57∗T) ∗4.1868
388
389 | where
390 | : math : ‘ lv ‘ i s Latent heat o f evaporat ion in ∗J/g∗ (T > 0
391 degree s c e l s i u s ) .
392
393 ”””
394 T ce l = s e l f . k e l v i n t o c e l c i u s (T)
395
396 l v = (597.31−0.57∗ T ce l ) ∗4.1868 \
397
398 s e l f . l a t e n t h e a t = lv
399
400
401 de f s e t en tha lpy ( s e l f , T wb , T av , P av ) :
402 r ”””
403 Calcu la te and s e t the enthalpy o f the a i r vapour mixture .
404
405 . . todo : :
406
407 Fin i sh Documentation ( d e f i n i t i o n o f v a r i a b l e s )
408
409 Args :
410 T wb ( f l o a t ) : Wet Bulb Temperature in degree s K.
411 T av ( f l o a t ) : Air Vapour Temperature in degree s K.
412 P av ( f l o a t ) : Pressure o f the a i r−vapour mixture in Pa .
413
414 Equations used are
415
416 . . math : :
85
417
418 i {av} = c {pa }(T−273.15) + w( i { fgwo} + c {pv}(T−273.15) )
419
420 | where
421 | : math : ‘ i {av } ‘ i s enthalpy o f the damp a i r in ∗J/kg∗ dry a i r ,
422 | : math : ‘ i { fgwo } ‘ i s l a t e n t heat o f evaporat ion o f water
423 at 273 .15 ∗K∗
424 | T i s temperature in degree s ∗K∗ ,
425 | : math : ’ c {pa } ’ and : math : ‘ c {pv} ‘ are the s p e c i f i c heats o f water
426 and a i r at constant p r e s su r e in : math : ’ J/kgK ’
427 | w i s the humidity o f the a i r vapour mix
428
429 ”””
430 c pa , c pv = s e l f . s p e c i f i c h e a t
431 w = s e l f . humidity [ 1 ]
432
433 s e l f . enthalpy = c pa ∗ ( T av − 273 .15)
\
434 + w ∗ ( s e l f . l a t e n t h e a t o f e v a p o r a t i o n + c pv ∗ ( T av − 273 .15) )
435
436
437 i f name == ” main ” :
438 pass
Listing 3: AirVapour.py
86