summaryrefslogtreecommitdiff
path: root/Chemical_Engineering_Thermodynamics_by_P._Ahuja/ch8_2.ipynb
blob: 6b83d68c12f1705a8d59e402d46178672eefae39 (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
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
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
{
 "metadata": {
  "name": "",
  "signature": "sha256:8df6804e24ffba947b26128cacd98ede56f82be4a3089c7567d672249f51ebda"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "\n",
      "Chapter 8 : Thermodynamic Cycles"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 8.1  Page Number : 287"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math\n",
      "\n",
      "# Variables\n",
      "P_1 = 30;\t\t\t#[bar]\n",
      "P_2 = 0.04;\t\t\t#[bar]\n",
      "\n",
      "\t\t\t#(1).Carnot cycle\n",
      "\t\t\t#It has been reported in the book that at 30 bar pressure (saturated) :\n",
      "H_liq_1 = 1008.42;\t\t\t#[kJ/kg]\n",
      "H_vap_1 = 2804.2;\t\t\t#[kJ/kg]\n",
      "S_liq_1 = 2.6457;\t\t\t#[kJ/kg-K]\n",
      "S_vap_1 = 6.1869;\t\t\t#[kJ/kh-K]\n",
      "\t\t\t#Therefore, H_1 = H_liq_1, H_2 = H_vap_1, S_1 = S_liq_1 and S_2 = S_vap_1\n",
      "H_1 = H_liq_1;\n",
      "H_2 = H_vap_1;\n",
      "S_1 = S_liq_1;\n",
      "S_2 = S_vap_1;\n",
      "\n",
      "#At 0.04 bar pressure (saturated) :\n",
      "H_liq_2 = 121.46;\t\t\t#[kJ/kg]\n",
      "H_vap_2 = 2554.4;\t\t\t#[kJ/kg]\n",
      "S_liq_2 = 0.4226;\t\t\t#[kJ/kg-K]\n",
      "S_vap_2 = 8.4746;\t\t\t#[kJ/kh-K]\n",
      "\n",
      "# Calculations and Results\n",
      "\t\t\t#Dryness fraction at state 3 can be found the fact that S_3 = S_2 \n",
      "x_3 = (S_2 - S_liq_2)/(S_vap_2 - S_liq_2);\n",
      "H_3 = H_liq_2*(1 - x_3) + x_3*H_vap_2;\t\t\t#[kJ/kg]\n",
      "\n",
      "\t\t\t#Dryness fraction at state 4 can be found the fact that S_4 = S_1\n",
      "x_4 = (S_1 - S_liq_2)/(S_vap_2 - S_liq_2);\n",
      "H_4 = H_liq_2*(1 - x_4) + x_4*H_vap_2;\t\t\t#[kJ/kg]\n",
      "\n",
      "\t\t\t#Work done by turbine W_tur = -delta_H = -(H_3 - H_2)\n",
      "W_tur = H_2 - H_3;\t\t\t#[kJ/kg]\n",
      "\n",
      "\t\t\t#Work supplied by boiler,\n",
      "q_H = H_2 - H_1;\t\t\t#[kJ/kg]\n",
      "\n",
      "\t\t\t#Work transfer in compressor is given by\n",
      "W_com = -(H_1 - H_4);\t\t\t#[kJ/kg]\n",
      "\n",
      "\t\t\t#Efficiency can now be calculated as\n",
      "\t\t\t#n = (Net work done/Work supplied by boiler)\n",
      "n_carnot = (W_tur + W_com)/q_H;\n",
      "\n",
      "\t\t\t#Efficiency of the Carnot cycle can also be determined from the formula\n",
      "\t\t\t# n = 1 - (T_L/T_H), Where T_L is saturated temperature at 0.04 bar and T_H is saturated temperature at 30 bar\n",
      "\n",
      "print \"1.Carnot cycle\";\n",
      "print \"The work done by the turbine is %f kJ/kg\"%(W_tur);\n",
      "print \"The heat transfer in the boiler is %f kJ/kg\"%(q_H);\n",
      "print \"The cycle efficiency is %f\"%(n_carnot);\n",
      "\n",
      "\t\t\t#(2).Rankine cycle\n",
      "\t\t\t#The enthalpies at state 2 and 3 remain as in the Carnot cycle\n",
      "\t\t\t#Saturated liquid enthalpy at 0.04 bar is \n",
      "H_4_prime = H_liq_2;\n",
      "\n",
      "\t\t\t#Saturated liquid volume at 0.04 bar as reported in the book is\n",
      "V_liq = 0.001004;\t\t\t#[m**(3)/kg]\n",
      "\t\t\t#Work transfer in pump can be calculated as\n",
      "W_pump = -V_liq*(P_1 - P_2)*100;\t\t\t#[kJ/kg]\n",
      "\n",
      "\t\t\t#Work transfer around pump gives, W_pump = -delta_H =  -(H_1_prime - H_4_prime);\n",
      "H_1_prime = H_4_prime - W_pump;\t\t\t#[kJ/kg]\n",
      "\n",
      "\t\t\t#Heat supplied to boiler is\n",
      "q_H_prime = H_2 - H_1_prime;\t\t\t#[kJ/kg]\n",
      "\n",
      "\t\t\t#Work done by turbine is\n",
      "W_tur_prime = H_2 - H_3;\t\t\t#[kJ/kg]\n",
      "\n",
      "\t\t\t#Efficiency can now be calculated as\n",
      "\t\t\t#n = (Net work done/Heat input)\n",
      "n_rankine = (W_tur_prime + W_pump)/q_H_prime;\t\t\t#\n",
      "\n",
      "print \"2.Rankine cycle\";\n",
      "print \"The work done by the turbine is %f kJ/kg\"%(W_tur_prime);\n",
      "print \"The heat transfer in the boiler is %f kJ/kg\"%(q_H_prime);\n",
      "print \"The cycle efficiency is %f\"%(n_rankine);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "1.Carnot cycle\n",
        "The work done by the turbine is 941.036567 kJ/kg\n",
        "The heat transfer in the boiler is 1795.780000 kJ/kg\n",
        "The cycle efficiency is 0.404166\n",
        "2.Rankine cycle\n",
        "The work done by the turbine is 941.036567 kJ/kg\n",
        "The heat transfer in the boiler is 2679.732016 kJ/kg\n",
        "The cycle efficiency is 0.350046\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 8.2  Page Number : 288"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "T_max = 700+273.15;\t\t\t#[K] - Maximum temperature.\n",
      "P_boiler = 10*10**(6);\t\t\t#[Pa] - Constant pressure in the boiler\n",
      "P_condenser = 10*10**(3);\t\t\t#[Pa] - Constant pressure in the condenser\n",
      "\n",
      "\t\t\t#At state 2 i.e, at 700 C and 10 MPa,it has been reported in the book that from steam table\n",
      "S_2 = 7.1687;\t\t\t#[kJ/kg-K] - Entropy\n",
      "H_2 = 3870.5;\t\t\t#[kJ/kg] - Enthalpy\n",
      "\n",
      "\t\t\t#At state 3 i.e, at 700 C and 10 KPa,\n",
      "S_3 = S_2;\t\t\t#[kJ/kg-K]- Entropy \n",
      "\n",
      "\t\t\t#For sturated steam at 10 kPa, it has been reported in the book that from steam table\n",
      "S_liq = 0.6493;\t\t\t#[kJ/kg-K]- Entropy of saturated liquid\n",
      "S_vap = 8.1502;\t\t\t#[kJ/kg-K] - Enthalpy of saturated liquid\n",
      "\t\t\t#Therefore steam is saturated and its dryness factor can be calculated as\n",
      "x = (S_2 - S_liq)/(S_vap - S_liq);\n",
      "\n",
      "# Calculations and Results\n",
      "\t\t\t#The enthalpy at state 3 is now calculated. For steam at 10 kPa,it has been reported in the book that from steam table\n",
      "H_liq = 191.83;\t\t\t#[kJ/kg]\n",
      "H_vap = 2584.7;\t\t\t#[kJ/kg]\n",
      "\t\t\t#Therefore enthalpy at state 3 is\n",
      "H_3 = H_liq*(1-x) + H_vap*x;\t\t\t#[kJ/kg]\n",
      "\n",
      "\t\t\t#Work done by the turbine \n",
      "W_tur = -(H_3 - H_2);\t\t\t#[kJ/kg]\n",
      "\n",
      "\t\t\t#Now we have to calculate work input to the pump\n",
      "\t\t\t#State 4:Saturated liquid at 10 kPa\n",
      "\t\t\t#State 4:Compressed liquid at 10 MPa\n",
      "\t\t\t#Since volume of liquid does not get affected by pressure we take volume of saturated liquid at 10 kPa,\n",
      "V_liq = 0.001010;\t\t\t#[m**(3)/kg]\n",
      "\n",
      "\t\t\t#Work transfer in the pump is\n",
      "W_pump = -V_liq*(P_boiler - P_condenser)*10**(-3);\t\t\t#[kJ/kg]\n",
      "\n",
      "\t\t\t#Energy balance around pump gives, W_pump = -delta_H =  -(H_1 - H_4)\n",
      "H_4 = H_liq;\t\t\t# Enthalpy at state 4 (saturated liquid at 10 kPa)\n",
      "H_1 = H_4 - W_pump;\t\t\t#[kJ/kg]\n",
      " \n",
      "\t\t\t#Heat supplied to boiler is\n",
      "q_H = H_2 - H_1;\t\t\t#[kJ/kg]\n",
      "\n",
      "\t\t\t#Efficiency can now be calculated as\n",
      "\t\t\t#n = (Net work done/Heat input)\n",
      "n_rankine = (W_tur + W_pump)/q_H;\n",
      "\n",
      "print \"The efficiency of the Rankine cycle is found to be %f\"%(n_rankine);\n",
      "\n",
      "\t\t\t#Now let us determine the efficiency of Carnot cycle. The maximun temperature is 700 C and minimum temperature is that of saturated steam at 10 kPa,\n",
      "T_min = 45.81 + 273.15;\t\t\t#[K] - From steam table as reported in the book\n",
      "n_carnot = 1-(T_min/T_max);\n",
      "\t\t\t#Note that the efficiency of Rankine cycle is less than that of carnot cycle"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The efficiency of the Rankine cycle is found to be 0.433088\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 8.3  Page Number : 291"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "W = 1.1;\t\t\t#[kW] - Work done per ton of refrigeration \n",
      "\t\t\t#1 ton refrigeration = 3.517 kW, therefore\n",
      "H = 3.517;\t\t\t#[kW] - Heat absorbed\n",
      "T_low = -30 + 273.15;\t\t\t#[K] - Low temperature maintained\n",
      "\n",
      "# Calculations\n",
      "\t\t\t#COP can be calculated as\n",
      "\t\t\t#COP = (Heat absorbed/Work done)\n",
      "COP = H/W;\n",
      "\n",
      "\t\t\t#For reversed carnot cycle, COP = T_low/(T_high - T_low). Solving this we get\n",
      "T_high = (T_low/COP) + T_low;\t\t\t#[K] - Higher temperature\n",
      "\n",
      "\t\t\t#Heat rejected is\n",
      "H_rej = W + H;\t\t\t#[kW];\n",
      "\n",
      "# Results\n",
      "print \"The COP is %f\"%(COP);\n",
      "print \"The higher temperature of the cycle is %f K\"%(T_high);\n",
      "print \"The heat rejected per ton of refrigeration is %f kW\"%(H_rej);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The COP is 3.197273\n",
        "The higher temperature of the cycle is 319.199190 K\n",
        "The heat rejected per ton of refrigeration is 4.617000 kW\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 8.4  Page Number : 292"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "T_high = 20 + 273.15;\t\t\t#[K] - High temperature\n",
      "T_low = 0 + 273.15;\t\t\t#[K] - Low temperature\n",
      "Q_H = 10;\t\t\t#[kW] - Heat supplied\n",
      "\n",
      "# Calculations\n",
      "\t\t\t#If 'Q_H' is the rate at which heat is taken from surrounding and 'W' is the rate at which work is done,then\n",
      "\t\t\t# Q_H = W + Q_L\n",
      "\t\t\t#(Q_H/Q_L) = (T_high/T_low)\n",
      "\t\t\t#Also for a reversible cycle, (Q_H/Q_L) = 1 + (W/Q_L). Solving we get,\n",
      "Q_L = (T_low/T_high)*Q_H;\t\t\t#[kW]\n",
      "W = (Q_H - Q_L) ;\t\t\t#[kW]\n",
      " \n",
      "# Results\n",
      "print \"The minimum power required is %f kW\"%(W);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The minimum power required is 0.682245 kW\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 8.5  Page Number : 292"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "T_high = 40 + 273.15;\t\t\t#[K] - High temperature\n",
      "T_low = -20 + 273.15;\t\t\t#[K] - Low temperature\n",
      "C = 10;\t\t\t#[tons of refrigeration] - Capacity\n",
      "\t\t\t#1 ton refrigeration = 3.517 kW, therefore\n",
      "H = C*3.517;\t\t\t#[kW] - Heat absorbed\n",
      "\n",
      "# Calculations\n",
      "\t\t\t#For reversed carnot cycle, COP = T_low/(T_high - T_low)\n",
      "COP = T_low/(T_high - T_low);\n",
      "\n",
      "\t\t\t# COP = (Refrigerating effect)/(Work input), therefore power required is given by\n",
      "P = (H/COP);\t\t\t#[kW]\n",
      "\n",
      "# Results\n",
      "print \"The COP is %f\"%(COP);\n",
      "print \"The power required is %f kW\"%(P);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The COP is 4.219167\n",
        "The power required is 8.335769 kW\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 8.6  Page Number : 292"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "COP = 4;\t\t\t#Coefficient of performance\n",
      "P = 10;\t\t\t#[kW] - Work done on the cycle\n",
      "\n",
      "# Calculations\n",
      "\t\t\t#For reversed carnot cycle, COP = T_low/(T_high - T_low)\n",
      "\t\t\t#ratio = (T_high/T_low),therefore\n",
      "ratio = -1/(COP + 1);\n",
      "\n",
      "\t\t\t# Refrigerating effect = (COP)*Work input, therefore refrigeration is given by\n",
      "H = COP*P;\t\t\t#[kW]\n",
      "\n",
      "\t\t\t#Maximum refrigearation in tons is given by\n",
      "H_max = (H/3.517);\n",
      "\n",
      "# Results\n",
      "print \"The maximum refrigeration value is %f ton\"%(H_max);\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The maximum refrigeration value is 11.373330 ton\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 8.7  Page Number : 292"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "m = 0.6;\t\t\t#[kg/s] - mass flow rate\n",
      "T_low = -20+273.15;\t\t\t#[K] - Temperature at which vapour enters the compressor\n",
      "T_high = 30+273.15;\t\t\t#[K] - Temperature at which vapour leaves the condenser\n",
      "\n",
      "\t\t\t#From saturated refrigeration-12 tables we get,at -20 C\n",
      "H_1 = 178.74;\t\t\t#[kJ/kg] - (H_1 = H_vap)\n",
      "P_1 = 0.15093;\t\t\t#[MPa] - (P_1 = P_sat)\n",
      "P_4 = P_1;\n",
      "S_1 = 0.7087;\t\t\t#[kJ/kg-K] - (S_1 = S_vap)\n",
      "S_2 = S_1;\n",
      "\n",
      "\t\t\t#At 30 C\n",
      "P_2 = 0.7449;\t\t\t#[MPa] - (P_2 = P_sat)\n",
      "P_3 = P_2;\n",
      "H_3 = 64.59;\t\t\t#[kJ/kg] - (H_3 = H_liq)\n",
      "H_4 = H_3;\n",
      "S_3 = 0.24;\t\t\t#[kJ/kg-K] - (S_3 = S_liq)\n",
      "\n",
      "# Calculations and Results\n",
      "\t\t\t#It is assumed that presssure drop in the evaporator and condenser are negligible. The heat transfer rate in the evaporator is\n",
      "Q_L = m*(H_1 - H_4);\n",
      "\n",
      "print \"The heat transfer rate in the evaporator is %f kW\"%(Q_L);\n",
      "\n",
      "\t\t\t#At state 2 (P = 0.7449 MPa and S = 0.7087 kJ/kg-K) and looking in the superheated tables we have to calculate the enthalpy at state 2\n",
      "\n",
      "\t\t\t#At P = 0.7 MPa and S = 0.6917 kJ/kg-K,\n",
      "H_11 = 200.46;\t\t\t#[kJ/kg]\n",
      "\n",
      "\t\t\t#At P = 0.7 MPa and S = 0.7153 kJ/kg-K,\n",
      "H_12 = 207.73;\t\t\t#[kJ/kg]\n",
      "\n",
      "\t\t\t#Thus at P = 0.7 MPa and S = 0.7087 kJ/kg-K, enthalpy is given by\n",
      "H_13 = ((S_2 -0.6917)/(0.7153 - 0.6917))*(H_12 - H_11) + H_11;\t\t\t#[kJ/kg]\n",
      "\n",
      "\t\t\t#At P = 0.8 MPa and S = 0.7021 kJ/kg-K,\n",
      "H_21 = 206.07;\t\t\t#[kJ/kg]\n",
      "\n",
      "\t\t\t#At P = 0.8 MPa and S = 0.7253 kJ/kg-K,\n",
      "H_22 = 213.45;\t\t\t#[kJ/kg]\n",
      "\n",
      "\t\t\t#Thus at P = 0.8 MPa and S = 0.7087 kJ/kg-K, enthalpy is given by\n",
      "H_23 = ((S_2 -0.7021)/(0.7253 - 0.7021))*(H_22 - H_21) + H_21;\t\t\t#[kJ/kg]\n",
      "\n",
      "\t\t\t#At P = 0.7449 MPa, S = 0.7087 kJ/kg-K, the enthalpy is\n",
      "H_2 = ((0.7449 - 0.7)/(0.8 - 0.7))*(H_23 - H_13) + H_13;\t\t\t#[kJ/kg]\n",
      "\n",
      "\t\t\t#Power consumed by the compressor is\n",
      "W_comp = m*(H_2 - H_1);\t\t\t#[kW]\n",
      "\n",
      "print \"The power consumed by the compressor is %f kW\"%(W_comp);\n",
      "\n",
      "\t\t\t#Heat removed in evaporator/work done on compressor\n",
      "COP_R = Q_L/W_comp;\n",
      "\n",
      "print \"The COP the refrigerator is %f kW\"%(COP_R);\n",
      "\n",
      "\n",
      "\t\t\t#At -20 C,saturated conditions \n",
      "H_liq = 17.82;\t\t\t#[kJ/kg]\n",
      "H_vap = 178.74;\t\t\t#[kJ/kg]\n",
      "x_4 = (H_4 - H_liq)/(H_vap - H_liq);\n",
      "\n",
      "print \"The dryness factor of refrigerant after the expansion valve is %f\"%(x_4);\n",
      "\n",
      "\t\t\t#The heat transfer rate in the condenser is\n",
      "Q_H = m*(H_3 - H_2);\t\t\t#[kW]\n",
      "\n",
      "print \"The heat transfer rate in the condenser is %f kW\"%(Q_H);\n",
      "\n",
      "\t\t\t#If the cycle would have worked as a pump then,\n",
      "\t\t\t#COP_HP = (Heat supplied from condenser/Work done on compressor)\n",
      "COP_HP = (-Q_H)/W_comp;\n",
      "\n",
      "print \"The COP if cycle would work as a heat pump is %f kW\"%(COP_HP);\n",
      "\n",
      "\t\t\t#If the cycle would have been a reversed Carnot cycle then\n",
      "COP_C = T_low/(T_high - T_low);\n",
      "\n",
      "print \"The COP if cycle would run as reversed Carnot cycle is %f kW\"%(COP_C);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The heat transfer rate in the evaporator is 68.490000 kW\n",
        "The power consumed by the compressor is 16.840242 kW\n",
        "The COP the refrigerator is 4.067044 kW\n",
        "The dryness factor of refrigerant after the expansion valve is 0.290641\n",
        "The heat transfer rate in the condenser is -85.330242 kW\n",
        "The COP if cycle would work as a heat pump is 5.067044 kW\n",
        "The COP if cycle would run as reversed Carnot cycle is 5.063000 kW\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 8.8  Page Number : 300"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "from scipy.optimize import fsolve \n",
      "import math \n",
      "\t\t\n",
      "\n",
      "# Variables\n",
      "H_1 = 310.38;\t\t\t#[kJ/kg]\n",
      "H_2 = 277.7;\t\t\t#[kJ/kg]\n",
      "H_5 = -122.6;\t\t\t#[kJ/kg]\n",
      "H_6 = 77.8;\t\t\t#[kJ/kg]\n",
      "\n",
      "\t\t\t#The enthalpy at point 3 is same at point 4 as the expansion is isenthalpic\n",
      "\n",
      "# Calculations and Results\n",
      "\t\t\t#The mass condensed is 1 kg and therefore m_1 = m+6 + 1\n",
      "\n",
      "\t\t\t#Enthalpy balance around heat exchanger\n",
      "\t\t\t#m_2*H_2 + m_2*H_6 = m_3*H_3 + m_7*H_7\n",
      "\n",
      "\t\t\t#Enthalpy balance around separator\n",
      "\t\t\t#m_4*H_4 = m_5*H_5 + m_6*H_6\n",
      "\t\t\t#It can be seen that m_1 = m_2 = m_3 = m_4\n",
      "\t\t\t#and m_6 = m_7 = m_1 - 1\n",
      "\n",
      "\t\t\t#Substituting the values for enthalpy balance around heat exchanger we get,\n",
      "\t\t\t#m_1*H_2 + (m_1 - 1)*(H_6) = m_1*H_3 + (m_1 - 1)*H_1\n",
      "\t\t\t#and substituting the values for enthalpy balance around seperator we get\n",
      "\t\t\t#m_1*H_3 = (1)*(-122.6) + (m_1 - 1)*77.8\n",
      "\t\t\t#H_3 = ((1)*(-122.6) + (m_1 - 1)*77.8)/m_1\n",
      "\t\t\t#Substituting the expression for 'H_3' in the above equation and then solving for m_1, we get\n",
      "def f(m_1): \n",
      "\t return m_1*H_2+(m_1-1)*(H_6)-m_1*(((1)*(-122.6) + (m_1 - 1)*77.8)/m_1)-(m_1-1)*H_1\n",
      "m_1 = fsolve(f,4)\n",
      "\t\t\t#Thus to liquify 1 kg of air compression of m_1 kg of air is carried out.\n",
      "\n",
      "\t\t\t#Now substituting this value of m_1 to get the value of H_3,\n",
      "H_3 = ((1)*(-122.6) + (m_1 - 1)*77.8)/m_1;\t\t\t#[kJ/kg]\n",
      "\n",
      "\t\t\t#From given compressed air table we see at 200 bar and 160 K,\n",
      "H_3_1 = 40.2;\t\t\t#[kJ/kg]\n",
      "\n",
      "\t\t\t#At 200 bar and 180 K,\n",
      "H_3_2 = 79.8;\t\t\t#[kJ/kg]\n",
      "\t\t\t#By interpolation we get,\n",
      "T_3 = ((H_3 - H_3_1)*(180 - 160))/(H_3_2 - H_3_1) + 160;\t\t\t#[K]\n",
      "\n",
      "print \"Temperature before throttling is %f K\"%(T_3);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Temperature before throttling is 171.350719 K\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 8.9  Page Number : 304"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "# Variables\n",
      "\t\t\t#At 1 bar, 310 K \n",
      "H_1 = 310.38;\t\t\t#[kJ/kg]\n",
      "\t\t\t#At 200 bar, 310 K\n",
      "H_2 = 277.7;\t\t\t#[kJ/kg]\n",
      "\t\t\t#At 1 bar, Saturated liquid\n",
      "H_7 = -122.6;\t\t\t#[kJ/kg]\n",
      "\t\t\t#At 1 bar, Saturated vapour\n",
      "H_8 = 77.8;\t\t\t#[kJ/kg]\n",
      "\t\t\t#At 200 bar, 200 K\n",
      "H_3 = 117.6;\t\t\t#[kJ/kg]\n",
      "\t\t\t#At 1 bar, 100 K\n",
      "H_11 = 98.3;\t\t\t#[kJ/kg]\n",
      "\n",
      "# Calculations and Results\n",
      "\t\t\t#For 1 kg of liquid air obtained,the overall enthalpy balance is\n",
      "\t\t\t#m_2*H_2 = W - 122.6 + (m_2 - 1)*H_1\n",
      "\t\t\t#W = - 0.8*m_2*(H_11 - H_3)\n",
      "\t\t\t#Overall enthalpy balance equation becomes\n",
      "\t\t\t#H_2*m_2 = 15.44*m_2 - H_7 + (m_2 - 1)*H_1, solving\n",
      "m_2_prime = (H_7 - H_1)/(H_2 - 15.44 - H_1);\n",
      "\n",
      "print \"The number of kimath.lograms of air compressed per kg of liquid air produced is %f kg\"%(m_2_prime);\n",
      "\n",
      "\t\t\t#(2)\n",
      "\t\t\t#Enthalpy balance around separator is \n",
      "\t\t\t#0.2*m_2*H_5 = -H_7 + (0.2*m_2 - 1)*H_8, solving\n",
      "m_2 = m_2_prime;\n",
      "H_5_prime = ((0.2*m_2-1)*H_8 - H_7)/(0.2*m_2);\n",
      "\n",
      "\t\t\t#At point 5, P = 200 bar and enthalpy is\n",
      "H_5_1 = -33.53;\t\t\t#[kJ/kg]\n",
      "\t\t\t#From compressed air tables at 200 bar and 140 K,\n",
      "H_5_2 = 0.2;\t\t\t#[kJ/kg]\n",
      "\t\t\t#At 200 bar and 120 K,\n",
      "H_5_3 = -38.0;\t\t\t#[kJ/kg]\n",
      "\t\t\t#Solving by interpolation we get\n",
      "T_5 = ((H_5_1 - H_5_3)*(140 - 120))/(H_5_2 - H_5_3) + 120;\t\t\t#[K]\n",
      "\n",
      "print \"The temperature of air before throttling is %f K\"%(T_5);\n",
      "\n",
      "\t\t\t#(3)\n",
      "\t\t\t#During mixing of streams 8 and 11 to produce stream 9, the enthalpy balance is\n",
      "\t\t\t# (0.2*m_2 - 1)*H_8 + 0.8*m_2*H_11 = (m_2 - 1)*H_9,Solving for H_9\n",
      "\n",
      "H_9_prime = ((0.2*m_2-1)*H_8+0.8*m_2*H_11)/(m_2 - 1);\n",
      "\n",
      "\t\t\t#From given compressed air tables at 1 bar and 100 K,\n",
      "H_9_1 = H_11;\n",
      "\t\t\t#At 1 bar and 90 K \n",
      "H_9_2 = 87.9;\t\t\t#[kJ/kg]\n",
      "\t\t\t#Solving by interpolation we get\n",
      "T_9 = ((H_9_prime - H_9_2)*(100 - 90))/(H_9_1 - H_9_2) + 90;\t\t\t#[K]\n",
      "\n",
      "print \"The temperature of stream entering second heat exchanger is %f K\"%(T_9);\n",
      "\n",
      "\t\t\t#(4)\n",
      "\t\t\t#Enthalpy balance around first heat exchanger is\n",
      "\t\t\t#H_2*m_2 + (m_2 - 1)*H_10 = H_3*m-2 + (m-2 - 1)*H_1, solving for H_10\n",
      "\n",
      "H_10_prime = ((m_2 - 1)*H_1 + H_3*m_2 - H_2*m_2)/(m_2 - 1);\n",
      "\n",
      "\t\t\t#From given compressed air tables at 1 bar and 140 K,\n",
      "H_10_1 = 139.1;\t\t\t#[kJ/kg]\n",
      "\t\t\t#At 1 bar and 120 K \n",
      "H_10_2 = 118.8;\t\t\t#[kJ/kg]\n",
      "\t\t\t#Solving by interpolation we get\n",
      "T_10 = ((H_10_prime - H_10_2)*(140 - 120))/(H_10_1 - H_10_2) + 120;\t\t\t#[K]\n",
      "\n",
      "print \"The temperature of stream exiting second heat exchanger is %f K\"%(T_10);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The number of kimath.lograms of air compressed per kg of liquid air produced is 8.997922 kg\n",
        "The temperature of air before throttling is 122.340314 K\n",
        "The temperature of stream entering second heat exchanger is 98.029358 K\n",
        "The temperature of stream exiting second heat exchanger is 131.292906 K\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 8.10  Page Number : 307"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "P_high = 40;\t\t\t#[bar]\n",
      "P_low = 5;\t\t\t#[bar]\n",
      "m_1 = 0.5;\t\t\t#[kg/s] - Rate of mass moving through the expander\n",
      "m_2 = 0.1;\t\t\t#[kg/s] - Rate of mass of vapour mixing with air\n",
      "e = 0.7;\t\t\t#Efficiency\n",
      "\n",
      "\t\t\t#At state 3,(40 bar and 200 K),enthalpy and entropy is given by\n",
      "H_3 = 179.7;\t\t\t#[kJ/kg]\n",
      "S_3 = 5.330;\t\t\t#[kJ/kg-K]\n",
      "\n",
      "\t\t\t#If isentropic conditions exits in the turbine then state 11 is at 5 bar\n",
      "S_11 = 5.330;\t\t\t#[kJ/kg-K]\n",
      "\t\t\t#From given compressed air tables at 5 bar and 120 K,\n",
      "H_11_1 = 113.6;\t\t\t#[kJ/kg]\n",
      "S_11_1 = 5.455;\t\t\t#[kJ/kg-K]\n",
      "\t\t\t#At 5 bar and 100 K \n",
      "H_11_2 = 90.6;\t\t\t#[kJ/kg]\n",
      "S_11_2 = 5.246;\t\t\t#[kJ/kg-K]\n",
      "\t\t\t#The enthalpy has to be determined when S = S_3\n",
      "\n",
      "# Calculations and Results\n",
      "\t\t\t#Solving by interpolation we get\n",
      "H_11_s = ((H_11_1 - H_11_2)*(S_3 - S_11_2))/(S_11_1 - S_11_2) + H_11_2;\t\t\t#[kJ/kg]\n",
      "\n",
      "\t\t\t#The adiabatic efficiency of tyrbine is given by\n",
      "\t\t\t#(H_3 - H_11_a)/(H_3 - H_11_s) = e\n",
      "H_11_a = H_3 - e*(H_3 - H_11_s);\t\t\t#[kJ/kg] - Actual enthalpy\n",
      "\n",
      " \t\t\t#At 5 bar,the saturated enthalpy is given to be\n",
      "H_8 = 88.7;\t\t\t#[kJ/kg]\n",
      "\t\t\t#From enthalpy balance during mixing we get,\n",
      "\t\t\t#0.1*H_8 + 0.5*H_11_a = 0.6*H_9\n",
      "H_9 = (m_2*H_8 + m_1*H_11_a)/(m_1 + m_2);\t\t\t#[kJ/kg]\n",
      "\n",
      "\t\t\t#From given compressed air tables at 5 bar and 140 K,\n",
      "H_9_1 = 135.3;\t\t\t#[kJ/kg]\n",
      "\t\t\t#At 5 bar and 120 K \n",
      "H_9_2 = 113.6;\t\t\t#[kJ/kg]\n",
      "\t\t\t#By interpolation we get\n",
      "T_9 = ((H_9 - H_11_1)*(140 - 120))/(H_9_1 - H_11_1) + 120;\t\t\t#[K]\n",
      "\n",
      "print \" The temperature of air entering the second heat exchanger is %f K\"%(T_9);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The temperature of air entering the second heat exchanger is 124.009841 K\n"
       ]
      }
     ],
     "prompt_number": 10
    }
   ],
   "metadata": {}
  }
 ]
}