summaryrefslogtreecommitdiff
path: root/Basic_And_Applied_Thermodynamics_by_P._K._Nag/Chapter14.ipynb
blob: eab55652127fe9db162121f4fe2ffc5081eaf9b1 (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
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 14: Refrigeration cycle"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex14.1:pg-602"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Example 14.1\n",
      "\n",
      "\n",
      " Power required to drive the plane is  12.9850746269  kW\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "T2 = -5.0 # Cold storage temperature in degree Celsius\n",
    "T1 = 35.0 # Surrounding temperature in degree Celsius\n",
    "COP = (T2+273)/((T1+273)-(T2+273))\n",
    "ACOP = COP/3 # Actual COP\n",
    "Q2 = 29.0 # Heat leakage in kW\n",
    "W = Q2/ACOP\n",
    "print \"\\n Example 14.1\\n\"\n",
    "print \"\\n Power required to drive the plane is \",W ,\" kW\"\n",
    "#The answers vary due to round off error\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex14.2:pg-603"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Example 14.2\n",
      "\n",
      "\n",
      " The rate of heat removal is  8.5572  kW\n",
      "\n",
      " Power input to the compressor is  2.1606  kW\n",
      "\n",
      " The heat rejection rate in the condenser is  10.7178  kW\n",
      "\n",
      " COP is  3.9605665093  kW\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# At P = 0.14 MPa\n",
    "h1 = 236.04 # Enthalpy at state 1 in kJ/kg\n",
    "s1 = 0.9322 # Entropy at state 2 in kJ/kgK\n",
    "s2 = s1 # Isenthalpic process\n",
    "# At P = 0.8 MPa\n",
    "h2 = 272.05 # Enthalpy at state 2 in kJ/kg\n",
    "h3 = 93.42 # Enthalpy at state 3 in kJ/kg\n",
    "h4 = h3 # Isenthalpic process\n",
    "m = 0.06 # mass flow rate in kg/s\n",
    "Q2 = m*(h1-h4) # Heat absorption\n",
    "Wc = m*(h2-h1) # Compressor work\n",
    "Q1 = m*(h2-h4) # Heat rejection in evaporator\n",
    "COP = Q2/Wc # coefficient of performance\n",
    "\n",
    "print \"\\n Example 14.2\\n\"\n",
    "print \"\\n The rate of heat removal is \",Q2 ,\" kW\"\n",
    "print \"\\n Power input to the compressor is \",Wc ,\" kW\"\n",
    "print \"\\n The heat rejection rate in the condenser is \",Q1 ,\" kW\"\n",
    "print \"\\n COP is \",COP ,\" kW\"\n",
    "#The answers vary due to round off error\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex14.3:pg-604"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Example 14.3\n",
      "\n",
      "\n",
      " Refrigerant flow rate is  0.179046449765  kg/s\n",
      "\n",
      " Volume flow rate is  0.0137865766319  m**3/s\n",
      "\n",
      " Compressor discharge temperature is  48.0  degree Celsius \n",
      "\n",
      " Pressure ratio is  4.38417305586\n",
      "\n",
      " Heat rejected to the condenser is  24.1390423573  kW\n",
      "\n",
      " Flash gas percentage is  30.5290768345  percent\n",
      "\n",
      " COP is  4.14187643021  kW\n",
      "\n",
      " Power required to drive the compressor is  4.69459791283  kW\n",
      "\n",
      " Ratio of COP of cycle with  Carnot refrigerator is  0.787428979127\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "h1 = 183.19 # Enthalpy at state 1 in kJ/kg\n",
    "h2 = 209.41 # Enthalpy at state 2 in kJ/kg\n",
    "h3 = 74.59 # Enthalpy at state 3 in kJ/kg\n",
    "h4 = h3 # Isenthalpic process\n",
    "T1 = 40.0 # Evaporator temperature in degree Celsius \n",
    "T2 = -10.0 # Condenser temperature in degree Celsius\n",
    "W = 5.0 # Plant capacity in tonnes of refrigeration\n",
    "w = (W*14000/3600)/(h1-h4) # Refrigerant flow rate\n",
    "v1 = 0.077 # Specific volume of vapor in m**3/kg\n",
    "VFR = w*v1 # volume flow rate\n",
    "T = 48.0 # Compressor discharge temperature in degree Celsius\n",
    "P2 = 9.6066 # Pressure after compression\n",
    "P1 = 2.1912 # Pressure before compression\n",
    "rp = P2/P1 # Pressure ratio\n",
    "Q1 = w*(h2-h3) # Heat rejected in condenser\n",
    "hf = 26.87 # Enthalpy of fluid in kJ/kg\n",
    "hfg = 156.31# Latent heat of vaporization in kJ/kg\n",
    "x4 = (h4-hf)/hfg # quality of refrigerant\n",
    "COP_v = (h1-h4)/(h2-h1) # Actual coefficient of performance of cycle\n",
    "PI = w*(h2-h1) # Power input\n",
    "COP = (T2+273)/((T1+273)-(T2+273)) # Ideal coefficient of performance\n",
    "r = COP_v/COP\n",
    "print \"\\n Example 14.3\\n\"\n",
    "print \"\\n Refrigerant flow rate is \",w ,\" kg/s\"\n",
    "print \"\\n Volume flow rate is \",VFR ,\" m**3/s\"\n",
    "print \"\\n Compressor discharge temperature is \",T ,\" degree Celsius \"\n",
    "print \"\\n Pressure ratio is \",rp\n",
    "print \"\\n Heat rejected to the condenser is \",Q1 ,\" kW\"\n",
    "print \"\\n Flash gas percentage is \",x4*100 ,\" percent\"\n",
    "print \"\\n COP is \",COP_v ,\" kW\"\n",
    "print \"\\n Power required to drive the compressor is \",PI ,\" kW\"\n",
    "print \"\\n Ratio of COP of cycle with  Carnot refrigerator is \",r\n",
    "#The answers vary due to round off error\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex14.4:pg-605"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Example 14.4\n",
      "\n",
      "\n",
      " Refrigeration effect is  126  kJ/kg\n",
      "\n",
      " Refrigerant flow rate is  0  kg/s\n",
      "\n",
      " Diameter of cylinder is  100.0  cm\n",
      "\n",
      " Length of cylinder is  110.0  cm\n",
      "\n",
      " COP is  4\n",
      "\n",
      " Power required to drive the compressor is  0  kW\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "h3 = 882 # Enthalpy at state 3 in kJ/kg\n",
    "h2 = 1034 # Enthalpy at state 2 in kJ/kg\n",
    "h6 = 998 # Enthalpy at state 6 in kJ/kg\n",
    "h1 = 1008 # Enthalpy at state 1 in kJ/kg\n",
    "v1 = 0.084 # Specific volume at state 1 in m**3/kg\n",
    "t4 = 25 # Temperature at state 4 in degree Celsius\n",
    "m = 10 # mass flow rate in kg/s\n",
    "h4 = h3-h1+h6 \n",
    "h5 = h4 # isenthalpic process\n",
    "w = (m*14000)/((h6-h5)*3600) # in kg/s\n",
    "VFR = w*3600*v1 # Volume flow rate in m**3/h\n",
    "ve = 0.8 # volumetric efficiency\n",
    "CD = VFR/(ve*60) # Compressor displacement in m**3/min\n",
    "N = 900 # Number of strokes per minute\n",
    "n = 2 # number of cylinder\n",
    "\n",
    "D = ((CD*4)/(math.pi*1.1*N*n))**(1/3) # L = 1.1D L = length D = diameter\n",
    "L = 1.1*D\n",
    "COP = (h6-h5)/(h2-h1) # coefficient of performance\n",
    "PI = w*(h2-h1) # Power input\n",
    "\n",
    "print \"\\n Example 14.4\\n\"\n",
    "print \"\\n Refrigeration effect is \",h6-h5 ,\" kJ/kg\"\n",
    "print \"\\n Refrigerant flow rate is \",w ,\" kg/s\"\n",
    "print \"\\n Diameter of cylinder is \",D*100 ,\" cm\"\n",
    "print \"\\n Length of cylinder is \",L*100 ,\" cm\"\n",
    "print \"\\n COP is \",COP\n",
    "print \"\\n Power required to drive the compressor is \",PI ,\" kW\"\n",
    "\n",
    "#The answers vary due to round off error\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex14.5:pg-607"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Example 14.5\n",
      "\n",
      "\n",
      " Increase in work of compression for single stage  is  15.719846307  percent\n",
      "\n",
      " Increase in COP for 2 stage compression is  15.719846307  percent\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "P2 = 1554.3 # Pressure at state 2 in kPa\n",
    "P1 = 119.5# Pressure at state 1 in kPa\n",
    "Pi = math.sqrt(P1*P2)\n",
    "h1 = 1404.6 # Enthalpy at state1 in kJ/kg\n",
    "h2 = 1574.3 # Enthalpy at state2 in kJ/kg\n",
    "h3 = 1443.5 # Enthalpy at state3 in kJ/kg\n",
    "h4 = 1628.1# Enthalpy at state4 in kJ/kg\n",
    "h5 = 371.7 # Enthalpy at state5 in kJ/kg\n",
    "h6 = h5 # Isenthalpic process\n",
    "h7 = 181.5# Enthalpy at state7 in kJ/kg\n",
    "w = 30 # capacity of plant in tonnes of refrigeration\n",
    "m2_dot = (3.89*w)/(h1-h7) # mass flow rate in upper cycle\n",
    "m1_dot = m2_dot*((h2-h7)/(h3-h6))# mass flow rate in lower cycle\n",
    "Wc_dot = m2_dot*(h2-h1)+m1_dot*(h4-h3) # Compressor work\n",
    "COP = w*3.89/Wc_dot # Coefficient of performance of cycle\n",
    "# single stage\n",
    "h1_ = 1404.6 #Enthalpy at state1 in kJ/kg \n",
    "h2_ = 1805.1 # Enthalpy at state2 in kJ/kg \n",
    "h3_ = 371.1 # Enthalpy at state3 in kJ/kg \n",
    "h4_ = h3_ # Isenthalpic process\n",
    "m_dot = (3.89*30)/(h1_-h4_) # mass flow rate in cycle\n",
    "Wc = m_dot*(h2_-h1_) # Compressor work\n",
    "COP_ = w*3.89/Wc # Coefficient of performance of cycle\n",
    "IW = (Wc-Wc_dot)/Wc_dot # Increase in compressor work\n",
    "ICOP = (COP-COP_)/COP_ # Increase in COP for 2 stage compression\n",
    "print \"\\n Example 14.5\\n\"\n",
    "print \"\\n Increase in work of compression for single stage  is \",IW*100 ,\" percent\"\n",
    "print \"\\n Increase in COP for 2 stage compression is \",ICOP*100 ,\" percent\"\n",
    "#The answers vary due to round off error\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex14.6:pg-608"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Example 14.6\n",
      "\n",
      "\n",
      " The COP of the plant is  5.93506047745 , \n",
      " The mass flow rate of refrigerant in the evaporator is  3.38045251321  kg/s\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# Given that\n",
    "te = -10 # Evaporator temperature in degree celsius\n",
    "pc = 7.675 # Condenser pressure in bar\n",
    "pf = 4.139 # Flash chamber pressure in bar\n",
    "P = 100 # Power input to compressor in kW\n",
    "print \"\\n Example 14.6\\n\"\n",
    "# From the property table of R-134a,\n",
    "h7 = 140.96 # In kJ/kg\n",
    "hf = 113.29 # In kJ/kg\n",
    "hfg = 300.5-113.29 # In kJ/kg\n",
    "hg = 300.5 # In kJ/kg\n",
    "h1 = 288.86 # In kJ/kg\n",
    "s1 = 1.17189 # # In kJ/kgK\n",
    "s2 =s1\n",
    "#By interpolation \n",
    "h2 = 303.468 # In kJ/kg\n",
    "x8 = (h7-hf)/hfg\n",
    "m1=x8\n",
    "h5 = (1-m1)*h2 + m1*hg\n",
    "# By interpolation\n",
    "s5 = 1.7174 # In kJ/kgK\n",
    "s6=s5\n",
    "h6 = 315.79 # In kJ/kg\n",
    "m = P/((h6-h5) + (1-m1)*(h2-h1))\n",
    "m_e = (1-m1)*m\n",
    "COP = m_e*(h1-hf)/P\n",
    "print \"\\n The COP of the plant is \",COP ,\", \\n The mass flow rate of refrigerant in the evaporator is \",m_e ,\" kg/s\"\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex14.7:pg-609"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Example 14.7\n",
      "\n",
      "\n",
      " Steam flow rate required is  0.0644023696678  kg/s\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "tsat = 120.2 # Saturation temperature in degree Celsius\n",
    "hfg = 2201.9 # Latent heat of fusion in kJ/kg\n",
    "T1 = 120.2 # Generator temperature in degree Celsius\n",
    "T2 = 30 # Ambient temperature in degree Celsius\n",
    "Tr = -10 # Operating temperature of refrigerator in degree Celsius\n",
    "COP_max = (((T1+273)-(T2+273))*(Tr+273))/(((T2+273)-(Tr+273))*(T1+273)) # Ideal coefficient of performance \n",
    "ACOP = 0.4*COP_max # Actual COP\n",
    "L =  20 # Refrigeration load in tonnes\n",
    "Qe = (L*14000)/3600 # Heat extraction in KW\n",
    "Qg = Qe/ACOP # Heat transfer from generator \n",
    "x = 0.9 # Quality of refrigerant\n",
    "H = x*hfg # Heat extraction\n",
    "SFR = Qg/H # Steam flow rate\n",
    "print \"\\n Example 14.7\\n\"\n",
    "print \"\\n Steam flow rate required is \",SFR ,\" kg/s\"\n",
    "#The answers vary due to round off error\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex14.8:pg-611"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Example 14.8\n",
      "\n",
      "\n",
      "COP of the system is  5.50140730574\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# Given that\n",
    "tf = 5 # Temperature of flash chamber in degree celsius\n",
    "x = 0.98 # Quality of water vapour living the evaporator\n",
    "t2 = 14 # Returning temperature of chilled water in degree celsius\n",
    "t0 = 30 # Make up water temperature in degree celsius\n",
    "m = 12 # Mass flow rate of chilled water in kg/s\n",
    "nc = 0.8 # Compressor efficiecy \n",
    "pc = 0.1 # Condenser pressure in bar\n",
    "print \"\\n Example 14.8\\n\"\n",
    "#From the steam table\n",
    "hf = 58.62 # In kJ/kg at 14 degree celsius\n",
    "hf_ = 20.93 # In kJ/kg at 5 degree celsius\n",
    "hf__ = 125.73 # In kJ/kg at 30 degree celsius\n",
    "hv = x*2510.7\n",
    "Rc = m*(hf-hf_)/3.5\n",
    "m_v = Rc*3.5/(hv-hf__)\n",
    "# At 0.10 bar\n",
    "hg = 2800 # In kJ/kg \n",
    "Win = m_v*(hg-hv)/nc\n",
    "COP = Rc*3.5/Win\n",
    "print \"\\nCOP of the system is \",COP"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex14.9:pg-611"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Example 14.9\n",
      "\n",
      "\n",
      " COP of the refrigerator is  0.245731992881\n",
      "\n",
      " Driving power required is  47.4771987558  kW\n",
      "\n",
      " Mass flow rate is  0.64768311581  kg/s\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "T1 = 4.0 # Compressor inlet temperature in degree Celsius\n",
    "T3 = 55.0 # Cooling limit in heat exchanger in degree Celsius\n",
    "rp = 3.0 # Pressure ratio\n",
    "g = 1.4 # Heat capacity ratio\n",
    "cp = 1.005 # Constant volume heat capacity\n",
    "L = 3.0 # Cooling load in tonnes of refrigeration\n",
    "nc = 0.72 # compressor efficiency\n",
    "T2s = (T1+273)*(rp**((g-1)/g)) # Ideal temperature after compression\n",
    "T2 = (T1+273)+(T2s-T1-273)/nc # Actual temperature after compression\n",
    "T4s = (T3+273)/(rp**((g-1)/g)) # Ideal temperature after expansion\n",
    "T34 = 0.78*(T3+273-T4s) # Change in temperature during expansion process\n",
    "T4 = T3+273-T34 # Actual temperature after expansion\n",
    "COP = (T1+273-T4)/((T2-T1-273)-(T3+273-T4)) # Coefficient of performance of cycle\n",
    "P = (L*14000)/(COP*3600) # Driving power required\n",
    "m = (L*14000)/(cp*(T1+273-T4)) # Mass flow rate of air\n",
    "print \"\\n Example 14.9\\n\"\n",
    "print \"\\n COP of the refrigerator is \",COP\n",
    "print \"\\n Driving power required is \",P ,\" kW\"\n",
    "print \"\\n Mass flow rate is \",m/3600 ,\" kg/s\"\n",
    "#The answers vary due to round off error"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex14.10:pg-611"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Example 14.10\n",
      "\n",
      "\n",
      " Power input is  4.33428165007  kW\n",
      "\n",
      " Heating capacity is  20.972972973  kW\n",
      "\n",
      " COP is  4.83885789301\n",
      "\n",
      " The isentropic compressor efficiency is  79.9803085002  percent\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "P1 = 2.4  #Compressor inlet pressure in bar\n",
    "T1 = 0 # Compressor inlet temperature in degree Celsius\n",
    "h1 = 188.9 # Enthalpy of refrigerant at state 1 in kJ/kg\n",
    "s1 = 0.7177 # Entropy of refrigerant at state 1 in kJ/kgK\n",
    "v1 = 0.0703 # Specific volume at state 1 in m**3/kg\n",
    "P2 = 9 # Compressor outlet pressure in bar\n",
    "T2 = 60 # Compressor outlet pressure in degree Celsius\n",
    "h2 = 219.37 # Actual compressor outlet enthalpy in kJ/kgK\n",
    "h2s = 213.27 # Ideal compressor outlet enthalpy in kJ/kgK\n",
    "h3 = 71.93 # Enthalpy of refrigerant at state 3 in kJ/kg\n",
    "h4 = h3 # Isenthalpic process\n",
    "\n",
    "A1V1 = 0.6/60 # volume flow rate in kg/s\n",
    "m_dot = A1V1/v1 # mass flow rate\n",
    "Wc_dot = m_dot*(h2-h1) # Compressor work\n",
    "Q1_dot = m_dot*(h2-h3) # Heat extracted \n",
    "COP = Q1_dot/Wc_dot # Coefficient of performance\n",
    "nis = (h2s-h1)/(h2-h1) # Isentropic compressor efficiency\n",
    "print \"\\n Example 14.10\\n\"\n",
    "print \"\\n Power input is \",Wc_dot ,\" kW\"\n",
    "print \"\\n Heating capacity is \",Q1_dot ,\" kW\"\n",
    "print \"\\n COP is \",COP\n",
    "print \"\\n The isentropic compressor efficiency is \",nis*100 ,\" percent\"\n",
    "#The answers vary due to round off error"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##  Ex14.11:pg-611"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Example 14.11\n",
      "\n",
      "\n",
      " Pressure ratio for the turbine is  3.61111111111\n",
      "\n",
      " COP is  0.533011099882\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "T1 = 275.0 # Temperature of air at entrance to compressor in K \n",
    "T3 = 310.0 # Temperature of air at entrance to turbine in K \n",
    "P1 = 1.0  # Inlet presure in bar\n",
    "P2 = 4.0 # Outlet pressure in bar\n",
    "nc = 0.8 # Compressor efficiency\n",
    "T2s = T1*(P2/P1)**(.286) # Ideal temperature after compression\n",
    "T2 = T1 + (T2s-T1)/nc # Actual temperature after compression\n",
    "pr1 = 0.1 # Pressure loss in cooler in bar\n",
    "pr2 = 0.08 #Pressure loss in condensor in bar \n",
    "P3 = P2-0.1 # Actual pressure in condesor\n",
    "P4 = P1+0.08 # Actual pressure in evaporator\n",
    "PR = P3/P4 # Pressure ratio\n",
    "T4s = T3*(1/PR)**(0.286) # Ideal temperature after expansion\n",
    "nt = 0.85 # turbine efficiency\n",
    "T4 = T3-(T3-T4s)*nt # Actual temperature after expansion\n",
    "COP = (T1-T4)/((T2-T3)-(T1-T4)) # Coefficient of performance \n",
    "print \"\\n Example 14.11\\n\"\n",
    "print \"\\n Pressure ratio for the turbine is \",PR\n",
    "print \"\\n COP is \",COP\n",
    "#The answers vary due to round off error\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex14.12:pg-611"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Example 14.12\n",
      "\n",
      "\n",
      " Mass flow rate of air flowing through the cooling system is  1.16504854369\n",
      "\n",
      " COP is  0.255512245083\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# Given that\n",
    "L = 60.0 # Cooling load in kW\n",
    "p = 1.0 # Pressure in bar\n",
    "t = 20.0 # Temperature in degree celsius\n",
    "v = 900.0 # Speed of aircraft in km/h\n",
    "p1 = 0.35 # Pressure in bar\n",
    "T1 = 255 # Temperature in K\n",
    "nd = .85 # Diffuser efficiency \n",
    "rp = 6.0 # Pressure ratio of compressor\n",
    "nc = .85 # Copressor efficiency \n",
    "E = 0.9 # Effectiveness of air cooler\n",
    "nt = 0.88 # Turbine efficiency \n",
    "p_ = 0.08 # Pressure drop in air cooler in bar\n",
    "p5 =  1.08 # Pressure in bar\n",
    "cp = 1.005 # Heat capacity of air at constant pressure in kJ/kgK\n",
    "gama = 1.4 # Ratio of heat capacities of air\n",
    "print \"\\n Example 14.12\\n\"\n",
    "V = v*(5/18)\n",
    "T2_ = T1 + (V**2)/(2*cp*1000)\n",
    "T2 = T2_\n",
    "p2_ = p1*((T2_/T1)**((gama/(gama-1))))\n",
    "p2 = p1 + nd*(p2_-p1)\n",
    "p3 = rp*p2\n",
    "T3_ = T2*((p3/p2)**((gama-1)/gama))\n",
    "T3 = T2 + (T3_-T2)/nc\n",
    "P = cp*(T3-T2)\n",
    "p4 = p3 - p_\n",
    "T4 = T3 - E*(T3-T2)\n",
    "T5_ = T4/((p4/p5)**(.286))\n",
    "T5 = T4 - (T4-T5_)/nt\n",
    "RE = cp*(t+273 - T5)\n",
    "m = L/51.5\n",
    "Pr = m*P\n",
    "COP = L/Pr\n",
    "print \"\\n Mass flow rate of air flowing through the cooling system is \",m\n",
    "print \"\\n COP is \",COP\n",
    "#The answers vary due to round off error"
   ]
  }
 ],
 "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.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}