summaryrefslogtreecommitdiff
path: root/Fundamentals_Of_Thermodynamics/Chapter6_6.ipynb
blob: 953e821b41ead5f580dd47131444c43338e4029d (plain)
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
{

 "metadata": {

  "name": "",

  "signature": "sha256:c03e579abb4dafb7ea55c1a7f66b6338546355647f3c3d21afe4e72021a3ad5f"

 },

 "nbformat": 3,

 "nbformat_minor": 0,

 "worksheets": [

  {

   "cells": [

    {

     "cell_type": "heading",

     "level": 1,

     "metadata": {},

     "source": [

      "Chapter6:FIRST-LAW ANALYSIS FOR A CONTROL VOLUME"

     ]

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex6.1:pg-182"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#example 1\n",

      "#calculating mass flow rate in kg/s\n",

      "import math\n",

      "R=0.287 #in kJ/kg-K\n",

      "T=25 #temperature in celsius\n",

      "P=150 #pressure in kPa\n",

      "v=R*(T+273.15)/P #specific volume in m^3/kg\n",

      "D=0.2 #diameter of pipe in metre\n",

      "A=math.pi*D**2/4 #cross sectional area in m^2\n",

      "V=0.1 #velocity of air in m/s\n",

      "m=V*A/v #mass flow rate in kg/s\n",

      "print\"\\n hence,the mass flow rate is\",round(m,4),\"kg/s\""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "\n",

        " hence,the mass flow rate is 0.0055 kg/s\n"

       ]

      }

     ],

     "prompt_number": 11

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex6.2:pg-184"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#example 2\n",

      "#work done for adding the fluid\n",

      "\n",

      "P=600 #pressure in kPa\n",

      "m=1 #in kg\n",

      "v=0.001 #specific volume in m^3/kg\n",

      "W=P*m*v #necessary work in kJ for adding the fluid \n",

      "print\" \\n hence,the work involved in this process is\",round(W,4),\"kJ\""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "  \n",

        " hence,the work involved in this process is 0.6 kJ\n"

       ]

      }

     ],

     "prompt_number": 13

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex6.3:pg-188"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#example 3\n",

      "#rate of flow of water\n",

      "\n",

      "hir=441.89 #in kJ/kg for refrigerant using steam table \n",

      "her=249.10 #in kJ/kg for refrigerant using steam table\n",

      "hiw=42 #in kJ/kg for water using steam table\n",

      "hew=83.95 #in kJ/kg for water using steam table\n",

      "mr=0.2 #the rate at which refrigerant enters the condenser in kg/s\n",

      "mw=mr*(hir-her)/(hew-hiw) #rate of flow of water in kg/s\n",

      "print\"\\n hence,the rate at which cooling water flows thorugh the condenser is\",round(mw,3),\"kg/s\""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "\n",

        " hence,the rate at which cooling water flows thorugh the condenser is 0.919 kg/s\n"

       ]

      }

     ],

     "prompt_number": 15

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex6.4:pg-190"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#example 4\n",

      "#determining quality of steam\n",

      "\n",

      "hi=2850.1 #initial specific heat enthalpy for steam in kJ/kg\n",

      "Vi=50 #initial velocity of steam in m/s\n",

      "Ve=600 #final velocity of steam in m/s\n",

      "he=hi+Vi**2/(2*1000)-Ve**2/(2*1000) #final specific heat enthalpy for steam in kJ/kg\n",

      "hf=467.1 #at final state in kJ/kg\n",

      "hfg=2226.5 #at final state in kJ/kg\n",

      "xe=(he-hf)/hfg #quality of steam in final state\n",

      "print\" \\n hence, the quality is\",round(xe,2)"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        " \n",

        " hence, the quality is 0.99\n"

       ]

      }

     ],

     "prompt_number": 19

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex6.4E:pg-191"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#example 4E\n",

      "#determining quality of steam\n",

      "\n",

      "hi=1227.5 #initial specific heat enthalpy for steam in Btu/lbm\n",

      "Vi=200 #initial velocity of steam in ft/s\n",

      "Ve=2000 #final velocity of steam in ft/s\n",

      "he=hi+Vi**2/(2*32.17*778)-Ve**2/(2*32.17*778) #final specific heat enthalpy for steam in Btu/lbm\n",

      "hf=198.31 #at final state in Btu/lbm\n",

      "hfg=958.81 #at final state in Btu/lbm\n",

      "xe=(he-hf)/hfg #quality of steam in final state\n",

      "print\" \\n hence, the quality is\",round(xe,2)"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        " \n",

        " hence, the quality is 0.99\n"

       ]

      }

     ],

     "prompt_number": 2

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex6.5:pg-193"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#example 5\n",

      "#quality of ammonia leaving expansion valve\n",

      "\n",

      "hi=346.8 #specific heat enthalpy for ammonia at initial state in kJ/kg\n",

      "he=hi #specific heat enthalpy for ammonia at final state will be equal that at initial state because it is a throttling process\n",

      "hf=134.4 #at final state in kJ/kg\n",

      "hfg=1296.4#at final state in kJ/kg\n",

      "xe=(he-hf)*100/hfg #quality at final state\n",

      "print\"\\n hence,quality of the ammonia leaving the expansion valve is\",round(xe,2),\"%\" "

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "\n",

        " hence,quality of the ammonia leaving the expansion valve is 16.38 %\n"

       ]

      }

     ],

     "prompt_number": 23

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex6.6:pg-194"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#example 6\n",

      "#power output of turbine in kW\n",

      "\n",

      "hi=3137 #initial specific heat of enthalpy in kJ/kg\n",

      "he=2675.5 #final specific heat of enthalpy in kJ/kg\n",

      "Vi=50.0 #initial velocity of steam in m/s\n",

      "Ve=100 #final velocity of steam in m/s\n",

      "Zi=6 #height of inlet conditions in metres\n",

      "Ze=3 #height of exit conditions in metres\n",

      "m=1.5 #mass flow rate of steam in kg/s\n",

      "g=9.8066 #acc. due to gravity in m/s^2\n",

      "Qcv=-8.5 #heat transfer rate from turbine in kW\n",

      "Wcv=Qcv+m*(hi+Vi**2/(2*1000)+g*Zi/1000)-m*(he+Ve**2/(2*1000)+g*Ze/1000) #power output of turbine in kW\n",

      "print\"\\n hence,the power output of the turbine is\",round(Wcv,1),\"kW\""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "\n",

        " hence,the power output of the turbine is 678.2 kW\n"

       ]

      }

     ],

     "prompt_number": 28

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex6.7:pg-196"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#example 7\n",

      "#heat transfer rate in aftercooler\n",

      "\n",

      "V1=0 #we assume initial velocity to be zero because its given that it enters with a low velocity\n",

      "V2=25.0 #final velocity with which carbon dioxide exits in m/s\n",

      "h2=401.52 #final specific enthalpy of heat when carbon dioxide exits in kJ/kg\n",

      "h1=198 #initial specific enthalpy of heat in kJ/kg\n",

      "w=h1-h2-V2**2/(2*1000) #in kJ/kg\n",

      "Wc=-50 #power input to the compressor in kW\n",

      "m=Wc/w #mass flow rate of carbon dioxide in kg/s\n",

      "h3=257.9 #final specific enthalpy of heat when carbon dioxide flows into a constant pressure aftercooler\n",

      "Qcool=-m*(h3-h2) #heat transfer rate in the aftercooler in kW\n",

      "print\" \\n hence,heat transfer rate in the aftercooler is\",round(Qcool,1),\"kW\" \n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        " \n",

        " hence,heat transfer rate in the aftercooler is 35.2 kW\n"

       ]

      }

     ],

     "prompt_number": 30

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex6.8:pg-197"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#example 8\n",

      "#Required pump work\n",

      "\n",

      "m=1.5 #mass flow rate of water in kg/s\n",

      "g=9.807 #acceleration due to gravity in m/s^2\n",

      "Zin=-15 #depth of water pump in well in metres\n",

      "Zex=0 #in metres\n",

      "v=0.001001 #specific volume in m^3/kg\n",

      "Pex=400+101.3 #exit pressure in kPa\n",

      "Pin=90 #in kPa\n",

      "W=m*(g*(Zin-Zex)*0.001-(Pex-Pin)*v) #power input in kW\n",

      "print\" \\n Hence, the pump requires power of input is\",-round(W,2),\"kW\" "

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        " \n",

        " Hence, the pump requires power of input is 0.84 kW\n"

       ]

      }

     ],

     "prompt_number": 39

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex6.9:pg-198"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#example 9\n",

      "#heat tranfer in simple steam power plant\n",

      "\n",

      "h1=3023.5 #specific heat of enthalpy of steam leaving boiler in kJ/kg\n",

      "h2=3002.5 #specific heat of enthalpy of steam entering turbine in kJ/kg\n",

      "x=0.9 #quality of steam entering condenser\n",

      "hf=226 #in kJ/kg\n",

      "hfg=2373.1 #in kJ/kg\n",

      "h3=hf+x*hfg #specific heat of enthalpy of steam entering condenser in kJ/kg\n",

      "h4=188.5 #specific heat of enthalpy of steam entering pump in kJ/kg\n",

      "q12=h2-h1 #heat transfer in line between boiler and turbine in kJ/kg\n",

      "w23=h2-h3 #turbine work in kJ/kg\n",

      "q34=h4-h3 #heat transfer in condenser\n",

      "w45=-4 #pump work in kJ/kg\n",

      "h5=h4-w45 #in kJ/kg\n",

      "q51=h1-h5 #heat transfer in boiler in kJ/kg\n",

      "print\"\\n hence, heat transfer in line between boiler and turbine is\",round(q12,1),\"kJ/kg\"  \n",

      "print\"\\n hence, turbine work is\",round(w23,1),\"kJ/kg\" \n",

      "print\"\\n hence, heat transfer in condenser is \",round(q34,1),\"kJ/kg\" \n",

      "print\"\\n hence, heat transfer in boiler is \",round(q51,1),\"kJ/kg\" "

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "\n",

        " hence, heat transfer in line between boiler and turbine is -21.0 kJ/kg\n",

        "\n",

        " hence, turbine work is 640.7 kJ/kg\n",

        "\n",

        " hence, heat transfer in condenser is  -2173.3 kJ/kg\n",

        "\n",

        " hence, heat transfer in boiler is  2831.0 kJ/kg\n"

       ]

      }

     ],

     "prompt_number": 43

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex6.10:pg-200"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#example 10\n",

      "#analysis of refrigerator\n",

      "\n",

      "hf4=167.4 #in kJ/kg\n",

      "hfg4=215.6 #in kJ/kg\n",

      "h3=241.8 #specific heat of enthalpy of R-134a entering expansion valve\n",

      "h4=h3 #specific heat of enthalpy of R-134a leaving expansion valve\n",

      "h1=387.2 #in kJ/kg\n",

      "h2=435.1 #in kJ/kg\n",

      "x4=(h3-hf4)/hfg4 #quality of R-134a at evaporator inlet\n",

      "m=0.1 #mass flow rate in kg/s\n",

      "Qevap=m*(h1-h4) #rate of heat transfer to the evaporator\n",

      "Wcomp=-5 #power input to compressor in kW\n",

      "Qcomp=m*(h2-h1)+Wcomp #rate of heat transfer from compressor\n",

      "print\"\\n hence, the quality at the evaporator inlet is \",round(x4,3), \n",

      "print\"\\n hence, the rate of heat transfer to the evaporator is \",round(Qevap,2),\n",

      "print\"\\n hence, rate of heat transfer from the compressor is\",round(Qcomp,2), "

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "\n",

        " hence, the quality at the evaporator inlet is  0.345 \n",

        " hence, the rate of heat transfer to the evaporator is  14.54 \n",

        " hence, rate of heat transfer from the compressor is -0.21\n"

       ]

      }

     ],

     "prompt_number": 45

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex6.11:pg-204"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#example 11\n",

      "#Determining the final temperature of steam\n",

      "\n",

      "u2=3040.4 #final internal energy in kJ/kg\n",

      "hi=u2 #in kJ/kg\n",

      "P2=1.4 #final Pressure in MPa\n",

      "print\"Since, the final pressure is given as 1.4 MPa,we know two properties at the final state and hence,final state can be determined.The temperature corresponding to a pressure of 1.4 MPa and an internal energy of 3040.4 kJ/kg is found to be \"\n",

      "T2=452 #final temperature in Celsius"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "Since, the final pressure is given as 1.4 MPa,we know two properties at the final state and hence,final state can be determined.The temperature corresponding to a pressure of 1.4 MPa and an internal energy of 3040.4 kJ/kg is found to be \n"

       ]

      }

     ],

     "prompt_number": 46

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex6.12:pg-206"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#example 12\n",

      "#Calculating mass flow of steam in tank\n",

      "\n",

      "V1=0.4 #initial volume fo tank in m^3\n",

      "v1=0.5243 #initial specific volume in m^3/kg\n",

      "h1=3040.4 #initial specific enthalpy in kJ/kg\n",

      "u1=2548.9 #initial specific internal energy in kJ/kg\n",

      "m1=V1/v1 #initial mass of steam in tank in kg\n",

      "V2=0.4 #final volume in m^3\n",

      "print\"let x=V*(h1-u2)/v2-m1*(h1-u1).If we assume T2=300C, then v2=0.1823m^3/kg ,u2=2785.2kJ/kg and x=+ve.If we assume T2=350C,then v2=0.2003 m^3/kg, u2=2869.1kJ/kg and x=-ve.Hence,actualt T2 must be between these two assumed values in order that x=0.By interplotation\" \n",

      "T2=342 #final temperature in Celsius\n",

      "v2=0.1974 #final specific volume in m^3/kg\n",

      "m2=V2/v2 #final mass of the steam in the tank in kg\n",

      "m=m2-m1 #mass of steam that flowsinto the tank\n",

      "print\" \\n Hence,mass of the steam that flows into the tank is\",round(m,3),\"kg\""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "let x=V*(h1-u2)/v2-m1*(h1-u1).If we assume T2=300C, then v2=0.1823m^3/kg ,u2=2785.2kJ/kg and x=+ve.If we assume T2=350C,then v2=0.2003 m^3/kg, u2=2869.1kJ/kg and x=-ve.Hence,actualt T2 must be between these two assumed values in order that x=0.By interplotation\n",

        " \n",

        " Hence,mass of the steam that flows into the tank is 1.263 kg\n"

       ]

      }

     ],

     "prompt_number": 48

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex6.13:pg-207"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#example 13\n",

      "#Calculating mass flow of steam in tank\n",

      "\n",

      "vf1=0.001725 #in m^3/kg\n",

      "vf2=0.0016 #in m^3/kg\n",

      "uf1=368.7 #in kJ/kg\n",

      "uf2=226 #in kJ/kg\n",

      "vg1=0.08313 #in m^3/kg\n",

      "vfg2=0.20381\n",

      "ug1=1341 #in kJ/kg\n",

      "ufg2=1099.7 #in kJ/kg\n",

      "Vf=1 #initial volume of liquid in m^3\n",

      "Vg=1 #initial volume of vapor in m^3\n",

      "mf1=Vf/vf1 #initial mass of liquid in kg\n",

      "mg1=Vg/vg1 #initial mass of vapor in kg\n",

      "m1=mf1+mg1 #initial mass of liquid in kg\n",

      "he=1461.1 #in kJ/kg\n",

      "V=2 #volume of tank in m^3\n",

      "print\"m1u1=mf1*uf1+mg1*ug1.If x2 is the quality,then m2=V/v2=2/(0.00160+0.20381*x2) and u2=uf2+x2*ufg2=226.0+1099.7*x2.\"\n",

      "print\"Also,m2*(he-u2)=m1*he-m1u1.From this equation,we will get an equation for x2.\"\n",

      "x2=((2*1461.1)-(2*226)-(0.00160*634706))/((634706*0.20381)+(2*1099.7)) #quality of ammonia\n",

      "v2=0.00160+(0.20381*x2) #final specific volume in m^3/kg\n",

      "m2=V/v2 #final mass of ammonia in kg\n",

      "m=m1-m2 #mass of ammonia withdrawn\n",

      "print\" \\n Hence,mass of ammonia withdrawn is\",round(m,1),\"kg\""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "m1u1=mf1*uf1+mg1*ug1.If x2 is the quality,then m2=V/v2=2/(0.00160+0.20381*x2) and u2=uf2+x2*ufg2=226.0+1099.7*x2.\n",

        "Also,m2*(he-u2)=m1*he-m1u1.From this equation,we will get an equation for x2.\n",

        " \n",

        " Hence,mass of ammonia withdrawn is 72.7 kg\n"

       ]

      }

     ],

     "prompt_number": 50

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex6.13E:pg-209"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#example 13E\n",

      "#Calculating mass flow of steam in tank\n",

      "\n",

      "vf1=0.02747#in ft3/lbm\n",

      "vf2=0.02564#in ft3/lbm\n",

      "uf1=153.89#in Btu/lbm\n",

      "uf2=97.16#in Btu/lbm\n",

      "vg1=1.4168 #in ft^3/lbm\n",

      "vfg2=3.2647#in ft^3/lbm\n",

      "ug1=576.23#in Btu/lbm\n",

      "ufg2=472.78#in Btu/lbm\n",

      "Vf=25 #initial volume of liquid in ft^3\n",

      "Vg=25 #initial volume of vapor in ft^3\n",

      "mf1=Vf/vf1 #initial mass of liquid in lbm\n",

      "mg1=Vg/vg1 #initial mass of vapor in lbm\n",

      "m1=mf1+mg1 #initial mass of liquid in lbm\n",

      "he=628 #in Btu/lbm\n",

      "V=50 #volume of tank in ft^3\n",

      "print\"m1u1=mf1*uf1+mg1*ug1.If x2 is the quality,then m2=V/v2=2/(0.02564+3.2647*x2) and u2=uf2+x2*ufg2=97.16+3.2647*x2.\"\n",

      "print\"Also,m2*(he-u2)=m1*he-m1u1.From this equation,we will get an equation for x2.\"\n",

      "x2=((50*628)-(50*97.16)-(432391*0.02564))/((432391*3.2647)+(50*472.98)) #quality of ammonia\n",

      "x2=round(x2,6)\n",

      "v2=0.02564+(3.2647*x2) #final specific volume in ft^3/lbm\n",

      "v2=round(v2,6)\n",

      "m2=V/v2 #final mass of ammonia in lbm\n",

      "m=m1-m2 #mass of ammonia withdrawn\n",

      "print\" \\n Hence,mass of ammonia withdrawn is\",round(m,1),\"lbm\""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "m1u1=mf1*uf1+mg1*ug1.If x2 is the quality,then m2=V/v2=2/(0.02564+3.2647*x2) and u2=uf2+x2*ufg2=97.16+3.2647*x2.\n",

        "Also,m2*(he-u2)=m1*he-m1u1.From this equation,we will get an equation for x2.\n",

        " \n",

        " Hence,mass of ammonia withdrawn is 105.3 lbm\n"

       ]

      }

     ],

     "prompt_number": 27

    }

   ],

   "metadata": {}

  }

 ]

}