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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
|
{
"metadata": {
"name": "",
"signature": "sha256:37c7e0de5d214bd8e1262734b18b139b442cc87b722d8f6c3ad97dd3d8903ad3"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Chapter 11 - The ideal gas and mixture relationships"
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Example 1 - Pg 184"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"#calculate the work done\n",
"#Initialization of variables\n",
"n=1.3\n",
"T1=460+60. #R\n",
"P1=14.7 #psia\n",
"P2=125. #psia\n",
"R=1545.\n",
"M=29.\n",
"#calculations\n",
"T2=T1*(P2/P1)**((n-1)/n)\n",
"wrev=R/M *(T2-T1)/(1-n)\n",
"#results\n",
"print '%s %d %s' %(\"Work done =\",wrev,\"ft-lbf/lbm\")\n",
"print '%s' %(\"The answer is a bit different due to rounding off error in textbook\")\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Work done = -58988 ft-lbf/lbm\n",
"The answer is a bit different due to rounding off error in textbook\n"
]
}
],
"prompt_number": 1
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Example 2 - Pg 184"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"#calculate the Change in kinetic energy\n",
"#Initialization of variables\n",
"P2=10 #psia\n",
"P1=100 #psia\n",
"T1=900 #R\n",
"w=50 #Btu/lbm\n",
"k=1.39\n",
"cp=0.2418\n",
"#calculations\n",
"T2=T1*(P2/P1)**((k-1)/k)\n",
"T2=477\n",
"KE=-w-cp*(T2-T1)\n",
"#results\n",
"print '%s %.1f %s' %(\"Change in kinetic energy =\",KE,\"Btu/lbm\")\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Change in kinetic energy = 52.3 Btu/lbm\n"
]
}
],
"prompt_number": 2
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Example 3 - Pg 190"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"#calculate the Final temperature\n",
"#Initialization of variables\n",
"T1=900 #R\n",
"P1=100 #psia\n",
"P2=10 #psia\n",
"#calculations\n",
"print '%s' %(\"From table B-9\")\n",
"pr1=8.411\n",
"pr2=pr1*P2/P1\n",
"T2=468 #R\n",
"#results\n",
"print '%s %.1f %s' %(\"Final temperature =\",T2,\"R \")\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"From table B-9\n",
"Final temperature = 468.0 R \n"
]
}
],
"prompt_number": 3
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Example 4 - Pg 190"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"#calculate the final temperature and pressure, work done and enthalpy\n",
"#Initialization of variables\n",
"cr=6\n",
"p1=14.7 #psia\n",
"t1=60.3 #F\n",
"M=29\n",
"R=1.986\n",
"#calculations\n",
"print '%s' %(\"from table b-9\")\n",
"vr1=158.58 \n",
"u1=88.62 #Btu/lbm\n",
"pr1=1.2147\n",
"vr2=vr1/cr\n",
"T2=1050 #R\n",
"u2=181.47 #Btu/lbm\n",
"pr2=14.686\n",
"p2=p1*(pr2/pr1)\n",
"dw=u1-u2\n",
"h2=u2+T2*R/M\n",
"#results\n",
"print '%s %d %s' %(\"final temperature =\",T2,\"R\")\n",
"print '%s %.1f %s' %(\"\\n final pressure =\",p2,\" psia\")\n",
"print '%s %.2f %s' %(\"\\n work done =\",dw,\" Btu/lbm\")\n",
"print '%s %.1f %s' %(\"\\n final enthalpy =\",h2,\" Btu/lbm\")\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"from table b-9\n",
"final temperature = 1050 R\n",
"\n",
" final pressure = 177.7 psia\n",
"\n",
" work done = -92.85 Btu/lbm\n",
"\n",
" final enthalpy = 253.4 Btu/lbm\n"
]
}
],
"prompt_number": 4
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Example 5 - Pg 193"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"#calculate the mole fractions of oxygen and nitrogen, Average molecular weight and partial pressures, densities, volumes\n",
"#Initialization of variables\n",
"m1=10. #lbm\n",
"m2=15. #lnm\n",
"p=50. #psia\n",
"t=60.+460 #R\n",
"M1=32.\n",
"M2=28.02\n",
"R0=10.73 \n",
"#calculations\n",
"n1=m1/M1\n",
"n2=m2/M2\n",
"x1=n1/(n1+n2)\n",
"x2=n2/(n1+n2)\n",
"M=x1*M1+x2*M2\n",
"R=1545/M\n",
"V=(n1+n2)*R0*t/p\n",
"rho=p/(R0*t)\n",
"rho2=M*rho\n",
"p1=x1*p\n",
"p2=x2*p\n",
"v1=x1*V\n",
"v2=x2*V\n",
"#results\n",
"print '%s' %(\"part a\")\n",
"print '%s %.3f %s %.3f %s' %(\"Mole fractions of oxygen and nitrogen are\",x1,\" and\",x2,\" respectively\")\n",
"print '%s' %(\"part b\")\n",
"print '%s %.1f' %(\"Average molecular weight = \",M)\n",
"print '%s' %(\"part c\")\n",
"print '%s %.2f %s' %(\"specific gas constant =\",R,\"psia ft^3/lbm R\")\n",
"print '%s' %(\"part d\")\n",
"print '%s %.1f %s' %(\"volume of mixture =\",V,\"ft^3\")\n",
"print '%s %.5f %s %.3f %s' %(\"density of mixture is\",rho, \"mole/ft^3 and\",rho2, \"lbm/ft^3\")\n",
"print '%s' %(\"part e\")\n",
"print '%s %.2f %s %.2f %s' %(\"partial pressures of oxygen and nitrogen are\",p1,\"psia and\",p2,\"psia respectively\")\n",
"print '%s %.2f %s %.2f %s' %(\"partial volumes of oxygen and nitrogen are\",v1,\"ft^3 and\",v2,\"ft^3 respectively\")"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"part a\n",
"Mole fractions of oxygen and nitrogen are 0.369 and 0.631 respectively\n",
"part b\n",
"Average molecular weight = 29.5\n",
"part c\n",
"specific gas constant = 52.40 psia ft^3/lbm R\n",
"part d\n",
"volume of mixture = 94.6 ft^3\n",
"density of mixture is 0.00896 mole/ft^3 and 0.264 lbm/ft^3\n",
"part e\n",
"partial pressures of oxygen and nitrogen are 18.43 psia and 31.57 psia respectively\n",
"partial volumes of oxygen and nitrogen are 34.87 ft^3 and 59.74 ft^3 respectively\n"
]
}
],
"prompt_number": 5
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Example 6 - Pg 195"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"#calculate the gravimetric and ultimate analysis\n",
"#Initialization of variables\n",
"m1=5.28\n",
"m2=1.28\n",
"m3=23.52\n",
"#calculations\n",
"m=m1+m2+m3\n",
"x1=m1/m*100\n",
"x2=m2/m*100\n",
"x3=m3/m*100\n",
"C=12./44 *m1/ m*100\n",
"O=(32./44 *m1 + m2)/m*100\n",
"N=m3/m*100\n",
"#results\n",
"print '%s %.1f %s %.1f %s %.1f %s' %(\"From gravimetric analysis, co2 =\",x1,\"percent , o2 =\",x2,\"percent and n2 =\",x3,\"percent\")\n",
"print '%s %.2f %s %.2f %s %.2f %s' %(\"\\n From ultimate analysis, co2 =\",C,\"percent , o2 =\",O,\" percent and n2 =\",N,\" percent\")\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"From gravimetric analysis, co2 = 17.6 percent , o2 = 4.3 percent and n2 = 78.2 percent\n",
"\n",
" From ultimate analysis, co2 = 4.79 percent , o2 = 17.02 percent and n2 = 78.19 percent\n"
]
}
],
"prompt_number": 6
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Example 7 - Pg 197"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"#calculate the Entropy of the mixture\n",
"#Initialization of variables\n",
"import math\n",
"x1=1/3.\n",
"n1=1.\n",
"n2=2.\n",
"x2=2/3.\n",
"p=12.7 #psia\n",
"cp1=7.01 #Btu/mole R\n",
"cp2=6.94 #Btu/mole R\n",
"R0=1.986\n",
"T2=460+86.6 #R\n",
"T1=460. #R\n",
"p0=14.7 #psia\n",
"#calculations\n",
"p1=x1*p\n",
"p2=x2*p\n",
"ds1= cp1*math.log(T2/T1) - R0*math.log(p1/p0)\n",
"ds2= cp2*math.log(T2/T1) - R0*math.log(p2/p0)\n",
"S=n1*ds1+n2*ds2\n",
"#results\n",
"print '%s %.2f %s' %(\"Entropy of mixture =\",S,\"Btu/R\")\n",
"print '%s' %(\"\\n the answer given in textbook is wrong. please check using a calculator\")\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Entropy of mixture = 8.27 Btu/R\n",
"\n",
" the answer given in textbook is wrong. please check using a calculator\n"
]
}
],
"prompt_number": 7
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Example 8 - Pg 198"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"#calculate the change in internal energy and entropy\n",
"#Initialization of variables\n",
"import math\n",
"c1=4.97 #Btu/mol R\n",
"c2=5.02 #Btu/mol R\n",
"n1=2\n",
"n2=1\n",
"T1=86.6+460 #R\n",
"T2=50.+460 #R\n",
"#calculations\n",
"du=(n1*c1+n2*c2)*(T2-T1)\n",
"ds=(n1*c1+n2*c2)*math.log(T2/T1)\n",
"#results\n",
"print '%s %d %s' %(\"Change in internal energy =\",du,\" Btu\")\n",
"print '%s %.3f %s' %(\"\\n Change in entropy =\",ds,\"Btu/R\")\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Change in internal energy = -547 Btu\n",
"\n",
" Change in entropy = -1.037 Btu/R\n"
]
}
],
"prompt_number": 8
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Example 9 - Pg 198"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"#calculate the Pressure of the mixture\n",
"#Initialization of variables\n",
"n1=1\n",
"n2=2\n",
"c1=5.02\n",
"c2=4.97\n",
"t1=60. #F\n",
"t2=100. #F\n",
"R0=10.73\n",
"p1=30. #psia\n",
"p2=10. #psia\n",
"#calcualtions\n",
"t=(n1*c1*t1+n2*c2*t2)/(n1*c1+n2*c2)\n",
"V1= n1*R0*(t1+460)/p1\n",
"V2=n2*R0*(t2+460)/p2\n",
"V=V1+V2\n",
"pm=(n1+n2)*R0*(t+460)/V\n",
"#results\n",
"print '%s %.1f %s' %(\"Pressure of mixture =\",pm,\" psia\")\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Pressure of mixture = 12.7 psia\n"
]
}
],
"prompt_number": 9
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Example 10 - Pg 199"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"#calculate the change in entropy of gas \n",
"#Initialization of variables\n",
"import math\n",
"T2=546.6 #R\n",
"T1=520 #R\n",
"T3=560 #R\n",
"v2=1389.2\n",
"v1=186.2\n",
"R0=1.986\n",
"c1=5.02\n",
"c2=4.97\n",
"n1=1\n",
"n2=2\n",
"v3=1203\n",
"#calculations\n",
"ds1=n1*c1*math.log(T2/T1) + n1*R0*math.log(v2/v1)\n",
"ds2=n2*c2*math.log(T2/T3)+n2*R0*math.log(v2/v3)\n",
"ds=ds1+ds2\n",
"#results\n",
"print '%s %.3f %s' %(\"Change in entropy for gas 1 =\",ds1,\" Btu/R\")\n",
"print '%s %.3f %s' %(\"\\n Change in entropy for gas 1 =\",ds2,\"Btu/R\")\n",
"print '%s %.3f %s' %(\"\\n Net change in entropy =\",ds,\"Btu/R\")\n",
"print '%s' %(\"The answer is a bit different due to rounding off error in the textbook\")\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Change in entropy for gas 1 = 4.242 Btu/R\n",
"\n",
" Change in entropy for gas 1 = 0.331 Btu/R\n",
"\n",
" Net change in entropy = 4.572 Btu/R\n",
"The answer is a bit different due to rounding off error in the textbook\n"
]
}
],
"prompt_number": 10
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Example 11 - Pg 200"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"#calculate the Final temperature and change in entropy of air and water.\n",
"#Initialization of variables\n",
"import math\n",
"m1=1. #lbm\n",
"m2=0.94 #lbm\n",
"M1=29.\n",
"M2=18.\n",
"p1=50. #psia\n",
"p2=100. #psia\n",
"t1=250 +460. #R\n",
"R0=1.986\n",
"cpa=6.96\n",
"cpb=8.01\n",
"#calculations\n",
"xa = (m1/M1)/((m1/M1)+ m2/M2)\n",
"xb=1-xa\n",
"t2=t1*(p2/p1)**(R0/(xa*cpa+xb*cpb))\n",
"d=R0/(xa*cpa+xb*cpb)\n",
"k=1/(1.-d)\n",
"dsa=cpa*math.log(t2/t1) -R0*math.log(p2/p1)\n",
"dSa=(m1/M1)*dsa\n",
"dSw=-dSa\n",
"dsw=dSw*M2/m2\n",
"#results\n",
"print '%s %d %s' %(\"Final temperature =\",t2,\" R\")\n",
"print '%s %.3f %s %.5f %s' %(\"\\n Change in entropy of air =\",dsa,\" btu/mole R and\",dSa, \"Btu/R\")\n",
"print '%s %.4f %s %.5f %s' %(\"\\n Change in entropy of water =\",dsw,\"btu/mole R and\",dSw,\" Btu/R\")\n",
"print '%s' %(\"The answers are a bit different due to rounding off error in textbook\")\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Final temperature = 851 R\n",
"\n",
" Change in entropy of air = -0.115 btu/mole R and -0.00395 Btu/R\n",
"\n",
" Change in entropy of water = 0.0757 btu/mole R and 0.00395 Btu/R\n",
"The answers are a bit different due to rounding off error in textbook\n"
]
}
],
"prompt_number": 11
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Example 12 - Pg 202"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"#calculate the volume occupied and mass of steam\n",
"#Initialization of variables\n",
"T=250. + 460 #R\n",
"p=29.825 #psia\n",
"pt=50 #psia\n",
"vg=13.821 #ft^3/lbm\n",
"M=29.\n",
"R=10.73\n",
"#calculations\n",
"pa=pt-p\n",
"V=1/M *R*T/pa\n",
"ma=V/vg\n",
"xa=p/pt\n",
"mb=xa/M *18./(1.-xa)\n",
"#results\n",
"print '%s %.2f %s' %(\"In case 1, volume occupied =\",V,\" ft^3\")\n",
"print '%s %.2f %s' %(\"\\n In case 1, mass of steam =\",ma,\" lbm steam\")\n",
"print '%s %.3f %s' %(\"\\n In case 2, mass of steam =\",mb,\" lbm steam\")\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"In case 1, volume occupied = 13.02 ft^3\n",
"\n",
" In case 1, mass of steam = 0.94 lbm steam\n",
"\n",
" In case 2, mass of steam = 0.918 lbm steam\n"
]
}
],
"prompt_number": 12
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Example 13 - Pg 203"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"#calcualte the percentage\n",
"#Initialization of variables\n",
"ps=0.64 #psia\n",
"p=14.7 #psia\n",
"M=29.\n",
"M2=46.\n",
"#calculations\n",
"xa=ps/p\n",
"mb=xa*9./M *M2/(1-xa)*100\n",
"#results\n",
"print '%s %.1f %s' %(\"percentage =\",mb,\"percent\")\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"percentage = 65.0 percent\n"
]
}
],
"prompt_number": 13
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Example 14 - Pg 203"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"#calculate the partial pressure of water vapor\n",
"#Initialization of variables\n",
"ps=0.5069 #psia\n",
"p=20 #psia\n",
"m1=0.01\n",
"m2=1\n",
"M1=18.\n",
"M2=29.\n",
"#calculations\n",
"xw= (m1/M1)/(m1/M1+m2/M2)\n",
"pw=xw*p\n",
"#results\n",
"print '%s %.3f %s' %(\"partial pressure of water vapor =\",pw,\"psia\")\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"partial pressure of water vapor = 0.317 psia\n"
]
}
],
"prompt_number": 14
}
],
"metadata": {}
}
]
}
|