summaryrefslogtreecommitdiff
path: root/Basic_Engineering_Thermodynamics_by_Rayner_Joel/Chapter7.ipynb
blob: fceaae2bef9525fff251d8bae3b41061aaa271c5 (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
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 7 - Entropy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1: pg 159"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 7.1\n",
      " The specific entropy of water is (kJ/kg K) =  1.304\n",
      " From table The accurate value of sf in this case is (kJ/kg K) =  1.307\n",
      "There is small error in book's final value of sf\n"
     ]
    }
   ],
   "source": [
    "#pg 159\n",
    "print('Example 7.1');\n",
    "import math\n",
    "#  aim : To determine\n",
    "#  the specific enthalpy of water\n",
    "\n",
    "#  Given values\n",
    "Tf = 273.+100;#  Temperature,[K]\n",
    "\n",
    "#  solution\n",
    "#  from steam table\n",
    "cpl = 4.187;# [kJ/kg K]\n",
    "#  using equation [8]\n",
    "sf = cpl*math.log(Tf/273.16);#  [kJ/kg*K]\n",
    "print ' The specific entropy of water is (kJ/kg K) = ',round(sf,3)\n",
    "\n",
    "#  using steam table\n",
    "sf = 1.307;#  [kJ/kg K]\n",
    "print ' From table The accurate value of sf in this case is (kJ/kg K) = ',sf\n",
    "\n",
    "print \"There is small error in book's final value of sf\"\n",
    "\n",
    "#  End\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2: pg 160"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 7.2\n",
      " (a) The specific entropy of wet steam is (kJ/kg K) =  5.52\n",
      " (b) The specific entropy using steam table is (kJ/kg K) =  5.559\n"
     ]
    }
   ],
   "source": [
    "#pg 160\n",
    "print('Example 7.2');\n",
    "\n",
    "#  aim : To determine\n",
    "#  the specific entropy\n",
    "import math\n",
    "#  Given values\n",
    "P = 2.;#  pressure,[MN/m^2]\n",
    "x = .8;#  dryness fraction\n",
    "\n",
    "#  solution\n",
    "#  from steam table at given pressure\n",
    "Tf = 485.4;#  [K]\n",
    "cpl = 4.187;#  [kJ/kg K]\n",
    "hfg = 1888.6;#  [kJ/kg]\n",
    "\n",
    "#  (a) finding entropy by calculation\n",
    "s = cpl*math.log(Tf/273.16)+x*hfg/Tf;#  formula for entropy calculation\n",
    "\n",
    "print ' (a) The specific entropy of wet steam is (kJ/kg K) = ',round(s,2)\n",
    "\n",
    "#  (b) calculation of entropy using steam table\n",
    "#  from steam table at given pressure\n",
    "sf = 2.447;#  [kJ/kg K]\n",
    "sfg = 3.89;#  [kJ/kg K]\n",
    "#  hence\n",
    "s = sf+x*sfg;#  [kJ/kg K]\n",
    "\n",
    "print ' (b) The specific entropy using steam table is (kJ/kg K) = ',s\n",
    "\n",
    "#  End\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3: pg 161"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 7.3\n",
      " (a) The specific entropy of steam is (kJ/kg K) =  6.822\n",
      " (b) The accurate value of specific entropy from steam table is (kJ/kg K) =  6.919\n"
     ]
    }
   ],
   "source": [
    "#pg 161\n",
    "print('Example 7.3');\n",
    "import math\n",
    "#  aim : To determine\n",
    "#  the specific entropy of steam\n",
    "\n",
    "#  Given values\n",
    "P = 1.5;#pressure,[MN/m^2]\n",
    "T = 273.+300;#temperature,[K]\n",
    "\n",
    "#  solution\n",
    "\n",
    "#  (a)\n",
    "#  from steam table\n",
    "cpl = 4.187;#  [kJ/kg K]\n",
    "Tf = 471.3;#  [K]\n",
    "hfg = 1946.;#  [kJ/kg]\n",
    "cpv = 2.093;#  [kJ/kg K]\n",
    "\n",
    "#  usung equation [2]\n",
    "s = cpl*math.log(Tf/273.15)+hfg/Tf+cpv*math.log(T/Tf);#  [kJ/kg K]\n",
    "print ' (a) The specific entropy of steam is (kJ/kg K) = ',round(s,3)\n",
    "\n",
    "#  (b)\n",
    "#  from steam tables\n",
    "s = 6.919;#  [kJ/kg K]\n",
    "print ' (b) The accurate value of specific entropy from steam table is (kJ/kg K) = ',s\n",
    "\n",
    "#  End\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4: pg 164"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 7.4\n",
      " The final dryness fraction of steam is x2  =  0.989\n"
     ]
    }
   ],
   "source": [
    "#pg 164\n",
    "print('Example 7.4');\n",
    "\n",
    "#  aim : To determine\n",
    "#  the dryness fraction of steam\n",
    "\n",
    "#  Given values\n",
    "P1 = 2.;#  initial pressure, [MN/m^2]\n",
    "t = 350.;#  temperature, [C]\n",
    "P2 = .28;#  final pressure, [MN/m^2]\n",
    "\n",
    "#  solution\n",
    "#  at 2 MN/m^2 and 350 C,steam is superheated because the saturation temperature is 212.4 C\n",
    "#  From steam table\n",
    "s1 = 6.957;#  [kJ/kg K]\n",
    "\n",
    "#  for isentropic process\n",
    "s2 = s1;\n",
    "#  also\n",
    "sf2 = 1.647;#  [kJ/kg K]\n",
    "sfg2 = 5.368;#  [kJ/kg K]\n",
    "\n",
    "#  using\n",
    "#  s2 = sf2+x2*sfg2, where x2 is dryness fraction of steam\n",
    "#  hence\n",
    "x2 = (s2-sf2)/sfg2;\n",
    "print ' The final dryness fraction of steam is x2  = ',round(x2,3)\n",
    "\n",
    "#  End\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5: pg 165"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 7.5\n",
      " (a) From steam table at .06 MN/m^2 steam is superheated and has temperature of 100 C with specific volume is (m^3/kg) =  2.83\n",
      " (b) The change in specific entropy during the hyperbolic process is (kJ/kg K) =  0.679\n"
     ]
    }
   ],
   "source": [
    "#pg 165\n",
    "print('Example 7.5');\n",
    "\n",
    "#  aim : To determine\n",
    "#  the  final condition of steam...\n",
    "#  the change in specific entropy during hyperbolic process\n",
    "\n",
    "#  Given values\n",
    "P1 = 2;#  pressure, [MN/m^2]\n",
    "t = 250.;#  temperature, [C]\n",
    "P2 = .36;#  pressure, [MN/m^2]\n",
    "P3 = .06;#  pressure, [MN/m^2]\n",
    "\n",
    "#  solution\n",
    "\n",
    "#  (a)\n",
    "#  from steam table\n",
    "s1 = 6.545;#  [kJ/kg K]\n",
    "#  at .36 MN/m^2\n",
    "sg = 6.930;#  [kJ/kg*K]\n",
    "\n",
    "sf2 = 1.738;#  [kJ/kg K]\n",
    "sfg2 = 5.192;#  [kJ/kg K]\n",
    "vg2 = .510;#  [m^3]\n",
    "\n",
    "#  so after isentropic expansion, steam is wet\n",
    "#  hence, s2=sf2+x2*sfg2, where x2 is dryness fraction\n",
    "#  also\n",
    "s2 = s1;\n",
    "#  so\n",
    "x2 = (s2-sf2)/sfg2;\n",
    "#  and\n",
    "v2 = x2*vg2;#  [m^3]\n",
    "\n",
    "#  for  hyperbolic process\n",
    "#  P2*v2=P3*v3\n",
    "#  hence\n",
    "v3 = P2*v2/P3;#  [m^3]\n",
    "\t\n",
    "print ' (a) From steam table at .06 MN/m^2 steam is superheated and has temperature of 100 C with specific volume is (m^3/kg) = ',round(v3,2)\n",
    "\n",
    "#  (b)\n",
    "#  at this condition\n",
    "s3 = 7.609;#  [kJ/kg*K]\n",
    "#  hence\n",
    "change_s23 = s3-sg;#  change in specific entropy during the hyperblic process[kJ/kg*K]\n",
    "print ' (b) The change in specific entropy during the hyperbolic process is (kJ/kg K) = ',change_s23\n",
    "\n",
    "# In the book they have taken sg instead of s2 for part (b), so answer is not matching\n",
    "\n",
    "#  End\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6: pg 166"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 7.6\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAEZCAYAAABmTgnDAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmYnFWd9vHvHXaEhLBDgLCvskPYhDQkBBkUmHFkAAeR\niDOjzisjLyNkFBMcFeOr4zLiMg4y4IZxRAFFSSJpNglLCGvCTkIIkAAJIRACWX7vH+cUVRRVXZWu\nrq7q7vtzXX2l6qmnzvOrpqm7znPOc0oRgZmZWVcGtboAMzNrfw4LMzOryWFhZmY1OSzMzKwmh4WZ\nmdXksDAzs5ocFgOQpB9I+nyr6+gOSUdKekzSq5JObnU9vUHSSEnzWl0HgKQTJF3T6jrKSVpX0mxJ\nm7W6lv7KYdHPSJojaZmkJZIWSbpN0j9KUmGfiPhkRHyllXU24EvAdyNicERc1+pielG3LoiSdIOk\npTlcX5X0pqT7u9h/A0nfl/SipMWSOst2+TJwqaTtS9pdKmm1pNdKth3VnXq7KyLeAi4HxvXmcQeS\ntVtdgPW4AE6KiGmS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f7Gf2fKqaz20AAAAAElFTkSu\nQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0xa5a7fd0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " (a) The heat transfer during the expansion is  (kJ)  (received) =  1224.986976\n",
      " (b) The work done during the expansion is (kJ) =  2705.234976\n"
     ]
    }
   ],
   "source": [
    "#pg 166\n",
    "print('Example 7.6');\n",
    "\n",
    "#  aim : To determine the\n",
    "#  (a) heat transfer during the expansion and\n",
    "#  (b) work done durind the expansion\n",
    "%matplotlib inline\n",
    "import matplotlib\n",
    "from matplotlib import pyplot\n",
    "#  given values\n",
    "m = 4.5;  #  mass of steam,[kg]\n",
    "P1 = 3.;  #  initial pressure,[MN/m^2]\n",
    "T1 = 300.+273;  #  initial temperature,[K]\n",
    "\n",
    "P2 = .1;  #  final pressure,[MN/m^2]\n",
    "x2 = .96;  #  dryness fraction at final stage\n",
    "\n",
    "#  solution\n",
    "#  for state point 1,using steam table\n",
    "s1 = 6.541;#  [kJ/kg/K]\n",
    "u1 = 2751;# [kJ/kg]\n",
    "\n",
    "#  for state point 2\n",
    "sf2 = 1.303;#  [kJ/kg/K]\n",
    "sfg2 = 6.056;#  [kJ/kg/k]\n",
    "T2 = 273+99.6;#  [K]\n",
    "hf2 = 417;#  [kJ/kg]\n",
    "hfg2 = 2258;#  [kJ/kg]\n",
    "vg2 = 1.694;#   [m^3/kg]\n",
    "\n",
    "#  hence\n",
    "s2 = sf2+x2*sfg2;# [kJ/kg/k]\n",
    "h2 = hf2+x2*hfg2;# [kJ/kg]\n",
    "u2 = h2-P2*x2*vg2*10**3;# [kJ/kg]\n",
    "\n",
    "#  Diagram of example 7.6\n",
    "x = ([s1, s2]);\n",
    "y = ([T1, T2]);\n",
    "pyplot.plot(x,y);\n",
    "pyplot.title('Diagram for example 7.6(T vs s)');\n",
    "pyplot.xlabel('Entropy (kJ/kg K)');\n",
    "pyplot.ylabel('Temperature (K)');\n",
    "x = ([s1,s1]);\n",
    "y = ([0,T1]);\n",
    "pyplot.plot(x,y);\n",
    "x = ([s2,s2]);\n",
    "y = ([0,T2]);\n",
    "pyplot.plot(x,y);\n",
    "pyplot.show()\n",
    "#  (a)\n",
    "#  Q_rev is area of T-s diagram\n",
    "Q_rev = (T1+T2)/2*(s2-s1);# [kJ/kg]\n",
    "#  so total heat transfer is\n",
    "Q_rev = m*Q_rev;# [kJ]\n",
    "\n",
    "#  (b)\n",
    "del_u = u2-u1;#  change in internal energy, [kJ/kg]\n",
    "#  using 1st law of thermodynamics\n",
    "W = Q_rev-m*del_u;#  [kJ]\n",
    "\n",
    "print ' (a) The heat transfer during the expansion is  (kJ)  (received) = ',Q_rev\n",
    "\n",
    "print ' (b) The work done during the expansion is (kJ) = ',W\n",
    "\n",
    "#  End\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7: pg 176"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 7.7\n",
      " (a) The change of entropy is (kJ/K) =  -0.046\n",
      " (b) The approximate change of entropy obtained by dividing the heat transferred by the gas by the mean absolute temperature during the compression (kJ/K) =  -0.0448\n"
     ]
    }
   ],
   "source": [
    "#pg 176\n",
    "print('Example 7.7');\n",
    "\n",
    "#  aim : To determine the  \n",
    "#  (a) change of entropy\n",
    "#  (b)  The approximate change of entropy obtained by dividing the heat transferred by the gas by the mean absolute temperature during the compression\n",
    "import math\n",
    "#  Given values\n",
    "P1 = 140.;# initial pressure,[kN/m^2]\n",
    "V1 = .14;# initial volume, [m^3]\n",
    "T1 = 273.+25;# initial temperature,[K]\n",
    "P2 = 1400.;# final pressure [kN/m^2]\n",
    "n = 1.25; # polytropic index\n",
    "cp = 1.041;# [kJ/kg K]\n",
    "cv = .743;# [kJ/kg K]\n",
    "\n",
    "#  solution\n",
    "# (a)\n",
    "R = cp-cv;# [kJ/kg/K]\n",
    "#  using ideal gas equation \n",
    "m = P1*V1/(R*T1);# mass of gas,[kg]\n",
    "#  since gas is following law P*V^n=constant ,so \n",
    "V2 = V1*(P1/P2)**(1./n);#  [m^3]\n",
    "\n",
    "#  using eqn [9]\n",
    "del_s = m*(cp*math.log(V2/V1)+cv*math.log(P2/P1));#  [kJ/K]\n",
    "print ' (a) The change of entropy is (kJ/K) = ',round(del_s,3)\n",
    "\n",
    "#  (b)\n",
    "W = (P1*V1-P2*V2)/(n-1);# polytropic work,[kJ]\n",
    "Gamma = cp/cv;# heat capacity ratio\n",
    "Q = (Gamma-n)/(Gamma-1)*W;# heat transferred,[kJ]\n",
    "\n",
    "# Again using polytropic law\n",
    "T2 = T1*(V1/V2)**(n-1);# final temperature, [K]\n",
    "T_avg = (T1+T2)/2;# mean absolute temperature, [K]\n",
    "\n",
    "# so approximate change in entropy is\n",
    "del_s = Q/T_avg;# [kJ/K]\n",
    "\n",
    "print ' (b) The approximate change of entropy obtained by dividing the heat transferred by the gas by the mean absolute temperature during the compression (kJ/K) = ',round(del_s,4)\n",
    "\n",
    "#  End\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 8: pg 179"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 7.8\n",
      " The change of entropy in constant volume process is (kJ/kg K) =  0.149\n",
      " The change of entropy in constant pressure process is (kJ/kg K) =  0.332\n",
      "there is misprint in the book's result\n"
     ]
    }
   ],
   "source": [
    "#pg 179\n",
    "print('Example 7.8');\n",
    "\n",
    "#  aim : To determine\n",
    "#  the change of entropy\n",
    "import math\n",
    "#  Given values\n",
    "m = .3;#  [kg]\n",
    "P1 = 350.;#  [kN/m^2]\n",
    "T1 = 273.+35;#  [K]\n",
    "P2 = 700.;#  [kN/m^2]\n",
    "V3 = .2289;#  [m^3]\n",
    "cp = 1.006;#  [kJ/kg K]\n",
    "cv = .717;#  [kJ/kg K]\n",
    "\n",
    "#  solution\n",
    "#  for constant volume process\n",
    "R = cp-cv;#  [kJ/kg K]\n",
    "#  using PV=mRT\n",
    "V1 = m*R*T1/P1;#  [m^3]\n",
    "\n",
    "#  for constant volume process P/T=constant,so\n",
    "T2 = T1*P2/P1;#  [K]\n",
    "s21 = m*cv*math.log(P2/P1);#  formula for entropy change for constant volume process\n",
    "print ' The change of entropy in constant volume process is (kJ/kg K) = ',round(s21,3)\n",
    "\n",
    "# 'For the above part result given in the book is wrong\n",
    "\n",
    "V2 = V1;\n",
    "# for constant pressure process\n",
    "T3 = T2*V3/V2;#  [K]\n",
    "s32 = m*cp*math.log(V3/V2);#  [kJ/kg K]\n",
    "\n",
    "print ' The change of entropy in constant pressure process is (kJ/kg K) = ',round(s32,3)\n",
    "\n",
    "print \"there is misprint in the book's result\"\n",
    "\n",
    "# End\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 9: pg 181"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 7.9\n",
      " The change of entropy is (kJ/kg K) =  0.04151\n"
     ]
    }
   ],
   "source": [
    "#pg 181\n",
    "print('Example 7.9');\n",
    "import math\n",
    "#  aim : To determine\n",
    "#  the  change of entropy\n",
    "\n",
    "# Given values\n",
    "P1 = 700.;# initial pressure, [kN/m^2]\n",
    "T1 = 273.+150;#  Temperature ,[K]\n",
    "V1 = .014;# initial volume, [m^3]\n",
    "V2 = .084;#  final volume, [m^3]\n",
    "\n",
    "#  solution\n",
    "#  since process is isothermal so\n",
    "T2 = T1;\n",
    "# and using fig.7.10\n",
    "del_s = P1*V1*math.log(V2/V1)/T1 ;#  [kJ/K]\n",
    "#results\n",
    "print ' The change of entropy is (kJ/kg K) = ',round(del_s,5)\n",
    "\n",
    "#  End\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}