1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
|
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#Chapter 1: Definitions and Basic Relations"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##Example 1.1, Page No. 38"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
" Enthalpy = 301.500000 kJ/kg\n",
" Internal Energy = 215.400000 kJ/kg\n",
"\n",
" Diameter = 46.824337 cm\n"
]
}
],
"source": [
"from math import pi;\n",
"from math import sqrt;\n",
"#variable declaration\n",
"R=0.287; #in kJ.kg K\n",
"c_p=1.005; #in kJ.kg K\n",
"m=3; #in kg/s\n",
"T=300; #in K\n",
"p=1.5; #in bar\n",
"c=10; #in m/s\n",
"p=p*10**5; #converts bar into Pa\n",
"\n",
"#calculation\n",
"c_v=c_p-R;\n",
"h=c_p*T;\n",
"u=c_v*T;\n",
"rho=p/(R*T*1000);\n",
"D=sqrt((4*m)/(pi*c*rho));\n",
"D=D*100; #converts m into cm\n",
"\n",
"#result\n",
"print('\\n Enthalpy = %f kJ/kg\\n Internal Energy = %f kJ/kg')%(h,u);\n",
"print '\\n Diameter = %f cm' %(D);\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##Example 1.2, Page No. 38"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
" Final Temperature = 382.397541 K\n",
" Enthalpy Drop = 88.473301 kJ/kg\n",
" Change in Internal Energy = 71.349436 kJ/kg\n"
]
}
],
"source": [
"#variable declaration\n",
"R=0.189; #in kJ/kg K\n",
"gamma_1=1.24; #no unit\n",
"T1=473; #in K\n",
"p1=3.0; #in bar\n",
"p2=1.0; #in bar\n",
"\n",
"#calculation\n",
"c_p=(gamma_1*R)/(gamma_1-1);\n",
"c_v=c_p/gamma_1;\n",
"ratio=(p2/p1)**((gamma_1-1)/gamma_1);\n",
"T2=ratio*T1;\n",
"h=c_p*(T1-T2);\n",
"u=c_v*(T1-T2);\n",
"\n",
"#result\n",
"print('\\n Final Temperature = %f K\\n Enthalpy Drop = %f kJ/kg\\n Change in Internal Energy = %f kJ/kg')%(T2,h,u);\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##Example 1.3, Page No. 39"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Change in Entropy = 0.165932\n",
"\n",
"\n",
"Note : There are computational problems in the book of this example\n"
]
}
],
"source": [
"#variable declaration\n",
"from math import log;\n",
"gamma_1=1.3; #no unit\n",
"T1=650; #in K\n",
"n=1.2; #no unit\n",
"p1=10.0; #in bar\n",
"p2=3.0; #in bar\n",
"c_p=2.15; #in kJ/kg K\n",
"\n",
"#cslculation\n",
"c_v=c_p/gamma_1;\n",
"ratio_p=p2/p1;\n",
"ratio_v=(1/ratio_p)**(1/n);\n",
"s=c_v*log(ratio_p)+c_p*log(ratio_v);\n",
"\n",
"#result\n",
"print('\\nChange in Entropy = %f')%(s);\n",
"print('\\n\\nNote : There are computational problems in the book of this example')\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##Example 1.4, Page No. 39"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Pressure at the exit of duct = 2.925336 bar\n",
"\n",
"\n",
"Note : There are computational problems in the book of this example\n"
]
}
],
"source": [
"#variable declaration\n",
"L=100; #in m\n",
"R=287; #in kJ/kg K\n",
"D=0.5; #in m\n",
"T=315; #in K\n",
"p=3.0; #in bar\n",
"c=15; #in m/s\n",
"f=0.025; #no unit\n",
"\n",
"#calculation\n",
"rho=p/(R*T);\n",
"delta_p=4*f*L*rho*c**2/(2*D)\n",
"p2=p-delta_p;\n",
"\n",
"#result\n",
"print('\\nPressure at the exit of duct = %f bar')%(p2);\n",
"print('\\n\\nNote : There are computational problems in the book of this example')\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##Example 1.5, Page No. 40"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
" Bulk Modulus of Elasticity = 31295.652174 bar\n",
"\n",
" More Accurate Value of Bulk Modulus of Elasticity = 29459.521175 bar\n"
]
}
],
"source": [
"#variable declaration\n",
"p1=1; #in bar\n",
"p2=3600; #in bar\n",
"v1=1; #in m^3\n",
"v2=0.885 #in m^3\n",
"\n",
"#calculation & result\n",
"K_t=-v1*(p2-p1)/(v2-v1);\n",
"print('\\n Bulk Modulus of Elasticity = %f bar')%(K_t);\n",
"K_t=(p2-p1)/log(v1/v2);\n",
"print('\\n More Accurate Value of Bulk Modulus of Elasticity = %f bar')%(K_t)\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##Example 1.6, Page No. 41"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"At Z=10000m\n",
"Temperature = 223.200000 K\n",
"Pressure = 0.264259 bar\n",
"Density = 0.412528 kg/m**3\n",
"Viscosity = 0.0000148 kg/ms\n",
"\n",
"At Z=15000m\n",
"Temperature = 216.500000 K\n",
"Pressure = 0.120714 bar\n",
"Density = 0.194276 kg/m**3\n",
"Viscosity = 0.0000142 kg/ms\n"
]
}
],
"source": [
"#variable declaration\n",
"from math import exp;\n",
"p0=1.0133; #in bar\n",
"#p0=p0*10**5; #conversion to Pa\n",
"T0=288.2; # in K\n",
"Tt=216.5; # in K\n",
"u0=1.79*10**-5; #in kg/ms\n",
"ut=1.42*10**-5; #in kg/ms\n",
"pt=0.227; #in bar\n",
"Z1=10000; #in m\n",
"Z2=15000; #in m\n",
"Zt=11000; #in m\n",
"R=287; #in J/kg K\n",
"a1=6.5/1000; #in deg C/m\n",
"g=9.81; #in m/s**2\n",
"\n",
"#calculation\n",
"rho0=p0/(R*T0);\n",
"T=T0-a1*Z1;\n",
"p=p0*(T/T0)**(g/(a1*R));\n",
"rho=p*10**5/(R*T);\n",
"u=u0*(T/T0)**0.75;\n",
"p1=pt*exp(-g*(Z2-Zt)/(R*Tt));\n",
"rho1=p1*10**5/(R*Tt);\n",
"\n",
"#result\n",
"print('\\nAt Z=10000m\\nTemperature = %f K\\nPressure = %f bar\\nDensity = %f kg/m**3\\nViscosity = %.7f kg/ms\\n\\nAt Z=15000m\\nTemperature = %f K\\nPressure = %f bar\\nDensity = %f kg/m**3\\nViscosity = %.7f kg/ms')%(T,p,rho,u,Tt,p1,rho1,ut);\n",
"\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.10"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
|