summaryrefslogtreecommitdiff
path: root/Thermodynamics,_Statistical_Thermodynamics,_&_Kinetics/Chapter06.ipynb
blob: c6258811f4a80bc19228a385d22214757fa76abf (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
{
 "metadata": {
  "name": "",
  "signature": "sha256:399beb745330e541e567baa0f45fde7ecc89dabcc65d8db71d8e5921a036072a"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 06: Chemical Equilibrium"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 6.1, Page Number 117"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "dHcCH4 = -891.0        #Std. heat of combustion for CH4, kJ/mol\n",
      "dHcC8H18 = -5471.0     #Std. heat of combustion for C8H18, kJ/mol\n",
      "\n",
      "T = 298.15\n",
      "SmCO2, SmCH4, SmH2O, SmO2, SmC8H18 = 213.8,186.3,70.0,205.2, 316.1\n",
      "dnCH4 = -2.\n",
      "dnC8H18 = 4.5\n",
      "R = 8.314\n",
      "#Calculations\n",
      "dACH4 = dHcCH4*1e3 - dnCH4*R*T - T*(SmCO2 + 2*SmH2O - SmCH4 - 2*SmO2)\n",
      "dAC8H18 = dHcC8H18*1e3 - dnC8H18*R*T - T*(8*SmCO2 + 9*SmH2O - SmC8H18 - 25.*SmO2/2) \n",
      "#Results \n",
      "print 'Maximum Available work through combustion of CH4 %4.1f kJ/mol'%(dACH4/1000)\n",
      "print 'Maximum Available work through combustion of C8H18 %4.1f kJ/mol'%(dAC8H18/1000)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Maximum Available work through combustion of CH4 -813.6 kJ/mol\n",
        "Maximum Available work through combustion of C8H18 -5320.9 kJ/mol\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 6.2, Page Number 118"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "dHcCH4 = -891.0        #Std. heat of combustion for CH4, kJ/mol\n",
      "dHcC8H18 = -5471.0     #Std. heat of combustion for C8H18, kJ/mol\n",
      "\n",
      "T = 298.15\n",
      "SmCO2, SmCH4, SmH2O, SmO2, SmC8H18 = 213.8,186.3,70.0,205.2, 316.1\n",
      "dnCH4 = -2.\n",
      "dnC8H18 = 4.5\n",
      "R = 8.314\n",
      "#Calculations\n",
      "dGCH4 = dHcCH4*1e3  - T*(SmCO2 + 2*SmH2O - SmCH4 - 2*SmO2)\n",
      "dGC8H18 = dHcC8H18*1e3 - T*(8*SmCO2 + 9*SmH2O - SmC8H18 - 25.*SmO2/2) \n",
      "#Results \n",
      "print 'Maximum nonexapnasion work through combustion of CH4 %4.1f kJ/mol'%(dGCH4/1000)\n",
      "print 'Maximum nonexapnasion work through combustion of C8H18 %4.1f kJ/mol'%(dGC8H18/1000)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Maximum nonexapnasion work through combustion of CH4 -818.6 kJ/mol\n",
        "Maximum nonexapnasion work through combustion of C8H18 -5309.8 kJ/mol\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 6.4, Page Number 123"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "dGf298 = 370.7     #Std. free energy of formation for Fe (g), kJ/mol\n",
      "dHf298 = 416.3     #Std. Enthalpy of formation for Fe (g), kJ/mol\n",
      "T0 = 298.15        #Temperature in K\n",
      "T = 400.           #Temperature in K\n",
      "R = 8.314\n",
      "\n",
      "#Calculations\n",
      "\n",
      "dGf = T*(dGf298*1e3/T0 + dHf298*1e3*(1./T - 1./T0))\n",
      "\n",
      "#Results \n",
      "print 'Std. free energy of formation for Fe(g) at 400 K is %4.1f kJ/mol'%(dGf/1000)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Std. free energy of formation for Fe(g) at 400 K is 355.1 kJ/mol\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 6.5, Page Number 127"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import log\n",
      "#Variable Declaration\n",
      "nHe = 1.0          #Number of moles of He\n",
      "nNe = 3.0          #Number of moles of Ne\n",
      "nAr = 2.0          #Number of moles of Ar\n",
      "nXe = 2.5          #Number of moles of Xe\n",
      "T = 298.15         #Temperature in K\n",
      "P = 1.0            #Pressure, bar\n",
      "R = 8.314\n",
      "\n",
      "#Calculations\n",
      "n = nHe + nNe + nAr + nXe\n",
      "dGmix = n*R*T*((nHe/n)*log(nHe/n) + (nNe/n)*log(nNe/n) +(nAr/n)*log(nAr/n) + (nXe/n)*log(nXe/n))\n",
      "dSmix = n*R*((nHe/n)*log(nHe/n) + (nNe/n)*log(nNe/n) +(nAr/n)*log(nAr/n) + (nXe/n)*log(nXe/n))\n",
      "\n",
      "#Results \n",
      "print 'Std. free energy Change on mixing is %3.1e J'%(dGmix)\n",
      "print 'Std. entropy Change on mixing is %4.1f J'%(dSmix)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Std. free energy Change on mixing is -2.8e+04 J\n",
        "Std. entropy Change on mixing is -93.3 J\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 6.6, Page Number 128"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "dGfFe  = 0.0       #Std. Gibbs energy of formation for Fe (S), kJ/mol\n",
      "dGfH2O = -237.1     #Std. Gibbs energy of formation for Water (g), kJ/mol\n",
      "dGfFe2O3 = -1015.4  #Std. Gibbs energy of formation for Fe2O3 (s), kJ/mol\n",
      "dGfH2 = 0.0        #Std. Gibbs energy of formation for Hydrogen (g), kJ/mol\n",
      "T0 = 298.15        #Temperature in K\n",
      "R = 8.314\n",
      "nFe, nH2, nFe2O3, nH2O = 3,-4,-1,4\n",
      "\n",
      "#Calculations\n",
      "dGR = nFe*dGfFe + nH2O*dGfH2O + nFe2O3*dGfFe2O3 + nH2*dGfH2  \n",
      "\n",
      "#Results \n",
      "print 'Std. Gibbs energy change for reaction is %4.2f kJ/mol'%(dGR)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Std. Gibbs energy change for reaction is 67.00 kJ/mol\n"
       ]
      }
     ],
     "prompt_number": 42
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 6.7, Page Number 128"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "dGR  = 67.0        #Std. Gibbs energy of formation for reaction, kJ, from previous problem\n",
      "dHfFe  = 0.0       #Enthalpy of formation for Fe (S), kJ/mol\n",
      "dHfH2O = -285.8    #Enthalpy of formation for Water (g), kJ/mol\n",
      "dHfFe2O3 = -1118.4 #Enthalpy of formation for Fe2O3 (s), kJ/mol\n",
      "dHfH2 = 0.0        #Enthalpy of formation for Hydrogen (g), kJ/mol\n",
      "T0 = 298.15        #Temperature in K\n",
      "T = 525.           #Temperature in K\n",
      "R = 8.314\n",
      "nFe, nH2, nFe2O3, nH2O = 3,-4,-1,4\n",
      "\n",
      "#Calculations\n",
      "dHR = nFe*dHfFe + nH2O*dHfH2O + nFe2O3*dHfFe2O3 + nH2*dHfH2  \n",
      "dGR2 = T*(dGR*1e3/T0 + dHR*1e3*(1./T - 1./T0))\n",
      "\n",
      "#Results \n",
      "print 'Std. Enthalpy change for reactionat %4.1f is %4.2f kJ/mol'%(T, dHR)\n",
      "print 'Std. Gibbs energy change for reactionat %4.1f is %4.0f kJ/mol'%(T, dGR2/1e3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Std. Enthalpy change for reactionat 525.0 is -24.80 kJ/mol\n",
        "Std. Gibbs energy change for reactionat 525.0 is  137 kJ/mol\n"
       ]
      }
     ],
     "prompt_number": 44
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 6.8, Page Number 130"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import log\n",
      "#Variable Declaration\n",
      "dGfNO2  = 51.3     #Std. Gibbs energy of formation for NO2 (g), kJ/mol\n",
      "dGfN2O4 = 99.8     #Std. Gibbs energy of formation for N2O4 (g), kJ/mol\n",
      "T0 = 298.15        #Temperature in K\n",
      "pNO2 = 0.350       #Partial pressure of NO2, bar\n",
      "pN2O4 = 0.650      #Partial pressure of N2O4, bar\n",
      "R = 8.314\n",
      "nNO2, nN2O4 = -2, 1 #Stoichiomentric coeff of NO2 and N2O4 respectively in reaction\n",
      "\n",
      "#Calculations\n",
      "dGR = nN2O4*dGfN2O4*1e3 + nNO2*dGfNO2*1e3 + R*T0*log(pN2O4/(pNO2)**2)\n",
      "\n",
      "#Results \n",
      "print 'Std. Gibbs energy change for reaction is %5.3f kJ/mol'%(dGR/1e3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Std. Gibbs energy change for reaction is 1.337 kJ/mol\n"
       ]
      }
     ],
     "prompt_number": 56
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 6.9, Page Number 131"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import exp\n",
      "\n",
      "#Variable Declaration\n",
      "dGfCO2  = -394.4   #Std. Gibbs energy of formation for CO2 (g), kJ/mol\n",
      "dGfH2 = 0.0        #Std. Gibbs energy of formation for H2 (g), kJ/mol\n",
      "dGfCO = 237.1      #Std. Gibbs energy of formation for CO (g), kJ/mol\n",
      "dGfH2O = 137.2     #Std. Gibbs energy of formation for H24 (l), kJ/mol\n",
      "T0 = 298.15        #Temperature in K\n",
      "R = 8.314\n",
      "nCO2, nH2, nCO, nH2O = 1,1,1,1 #Stoichiomentric coeff of CO2,H2,CO,H2O respectively in reaction\n",
      "\n",
      "#Calculations\n",
      "dGR = nCO2*dGfCO2 + nH2*dGfH2 + nCO*dGfCO + nH2O*dGfH2O\n",
      "Kp = exp(-dGR*1e3/(R*T0))\n",
      "\n",
      "#Results \n",
      "print 'Std. Gibbs energy change for reaction is %5.3f kJ/mol'%(dGR/1e3)\n",
      "print 'Equilibrium constant for reaction is %5.3f '%(Kp)\n",
      "if Kp > 1: print 'Kp >> 1. hence, mixture will consists of product CO2 and H2'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Std. Gibbs energy change for reaction is -0.020 kJ/mol\n",
        "Equilibrium constant for reaction is 3323.254 \n",
        "Kp >> 1. hence, mixture will consists of product CO2 and H2\n"
       ]
      }
     ],
     "prompt_number": 60
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 6.11, Page Number 133"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import exp, sqrt\n",
      "\n",
      "#Variable Declaration\n",
      "dGfCl2  = 0.0     #Std. Gibbs energy of formation for CO2 (g), kJ/mol\n",
      "dGfCl = 105.7     #Std. Gibbs energy of formation for H2 (g), kJ/mol\n",
      "dHfCl2 = 0.0      #Std. Gibbs energy of formation for CO (g), kJ/mol\n",
      "dHfCl = 121.3     #Std. Gibbs energy of formation for H24 (l), kJ/mol\n",
      "T0 = 298.15       #Temperature in K\n",
      "R = 8.314\n",
      "nCl2, nCl= -1,2 #Stoichiomentric coeff of Cl2,Cl respectively in reaction\n",
      "PbyP0 = 0.01\n",
      "#Calculations\n",
      "dGR = nCl*dGfCl + nCl2*dGfCl2 \n",
      "dHR = nCl*dHfCl + nCl2*dHfCl2 \n",
      "func = lambda T: exp(-dGR*1e3/(R*T0) - dHR*1e3*(1./T - 1./T0)/R)\n",
      "Kp8 = func(800)\n",
      "Kp15 = func(1500)\n",
      "Kp20 = func(2000)\n",
      "DDiss = lambda K: sqrt(K/(K+4*PbyP0))\n",
      "alp8 = DDiss(Kp8)\n",
      "alp15 = DDiss(Kp15)\n",
      "alp20 = DDiss(Kp20)\n",
      "\n",
      "#Results \n",
      "print 'Part A'\n",
      "print 'Std. Gibbs energy change for reaction is %5.3f kJ/mol'%(dGR)\n",
      "print 'Std. Enthalpy change for reaction is %5.3f kJ/mol'%(dHR)\n",
      "print 'Equilibrium constants at 800, 1500, and 2000 K are %4.3e, %4.3e, and %4.3e'%(Kp8,Kp15,Kp20)\n",
      "\n",
      "print 'Part B'\n",
      "print 'Degree of dissociation at 800, 1500, and 2000 K are %4.3e, %4.3e, and %4.3e'%(alp8,alp15,alp20)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Part A\n",
        "Std. Gibbs energy change for reaction is 211.400 kJ/mol\n",
        "Std. Enthalpy change for reaction is 242.600 kJ/mol\n",
        "Equilibrium constants at 800, 1500, and 2000 K are 4.223e-11, 1.042e-03, and 1.349e-01\n",
        "Part B\n",
        "Degree of dissociation at 800, 1500, and 2000 K are 3.249e-05, 1.593e-01, and 8.782e-01\n"
       ]
      }
     ],
     "prompt_number": 71
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 6.12, Page Number 134"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import exp\n",
      "#Variable Declaration\n",
      "dGfCaCO3  = -1128.8     #Std. Gibbs energy of formation for CaCO3 (s), kJ/mol\n",
      "dGfCaO = -603.3         #Std. Gibbs energy of formation for CaO (s), kJ/mol\n",
      "dGfCO2 = -394.4         #Std. Gibbs energy of formation for O2 (g), kJ/mol\n",
      "dHfCaCO3 = -1206.9      #Std. Enthalpy Change of formation for CaCO3 (s), kJ/mol\n",
      "dHfCaO = -634.9         #Std. Enthalpy Change of formation for CaO (s), kJ/mol\n",
      "dHfCO2 = -393.5         #Std. Enthalpy Change of formation for O2 (g), kJ/mol\n",
      "T0 = 298.15             #Temperature in K\n",
      "R = 8.314\n",
      "nCaCO3, nCaO, nO2 = -1,1,1 #Stoichiomentric coeff of CaCO3, CaO, O2 respectively in reaction\n",
      "\n",
      "#Calculations\n",
      "dGR = nCaO*dGfCaO + nO2*dGfCO2 + nCaCO3*dGfCaCO3\n",
      "dHR = nCaO*dHfCaO + nO2*dHfCO2 + nCaCO3*dHfCaCO3\n",
      "\n",
      "func = lambda T: exp(-dGR*1e3/(R*T0) - dHR*1e3*(1./T - 1./T0)/R)\n",
      "\n",
      "Kp10 = func(1000)\n",
      "Kp11 = func(1100)\n",
      "Kp12 = func(1200)\n",
      "\n",
      "#Results \n",
      "print 'Std. Gibbs energy change for reaction is %4.1f kJ/mol'%(dGR)\n",
      "print 'Std. Enthalpy change for reaction is %4.1f kJ/mol'%(dHR)\n",
      "print 'Equilibrium constants at 1000, 1100, and 1200 K are %4.4f, %4.3fe, and %4.3f'%(Kp10,Kp11,Kp12)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Std. Gibbs energy change for reaction is 131.1 kJ/mol\n",
        "Std. Enthalpy change for reaction is 178.5 kJ/mol\n",
        "Equilibrium constants at 1000, 1100, and 1200 K are 0.0956, 0.673e, and 3.423\n"
       ]
      }
     ],
     "prompt_number": 88
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 6.13, Page Number 135"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import exp\n",
      "\n",
      "#Variable Declaration\n",
      "dGfCG  = 0.0            #Std. Gibbs energy of formation for CaCO3 (s), kJ/mol\n",
      "dGfCD = 2.90            #Std. Gibbs energy of formation for CaO (s), kJ/mol\n",
      "rhoG = 2.25e3           #Density of Graphite, kg/m3\n",
      "rhoD = 3.52e3           #Density of dimond, kg/m3\n",
      "T0 = 298.15             #Std. Temperature, K\n",
      "R = 8.314               #Ideal gas constant, J/(mol.K) \n",
      "P0 = 1.0                #Pressure, bar\n",
      "M = 12.01               #Molceular wt of Carbon\n",
      "#Calculations\n",
      "P = P0*1e5 + dGfCD*1e3/((1./rhoG-1./rhoD)*M*1e-3)\n",
      "\n",
      "#Results \n",
      "print 'Pressure at which graphite and dimond will be in equilibrium is %4.2e bar'%(P/1e5)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure at which graphite and dimond will be in equilibrium is 1.51e+04 bar\n"
       ]
      }
     ],
     "prompt_number": 98
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 6.14, Page Number 143"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import exp\n",
      "\n",
      "#Variable Declaration\n",
      "beta = 2.04e-4          #Thermal exapansion coefficient, /K\n",
      "kapa = 45.9e-6          #Isothermal compressibility, /bar\n",
      "T = 298.15              #Std. Temperature, K\n",
      "R = 8.206e-2            #Ideal gas constant, atm.L/(mol.K) \n",
      "T1 = 320.0              #Temperature, K\n",
      "Pi = 1.0                #Initial Pressure, bar\n",
      "V = 1.00                #Volume, m3\n",
      "a = 1.35                #van der Waals constant a for nitrogen, atm.L2/mol2\n",
      "\n",
      "#Calculations\n",
      "dUbydV = Pf = (beta*T1-kapa*P0)/kapa\n",
      "dVT = V*kapa*(Pf-Pi)\n",
      "dVbyV = dVT*100/V\n",
      "Vm = Pi/(R*T1)\n",
      "dUbydVm = a/(Vm**2)\n",
      "\n",
      "#Results \n",
      "print 'dUbydV = %4.2e bar'%(dUbydV)\n",
      "print 'dVbyV = %4.3f percent'%(dVbyV)\n",
      "print 'dUbydVm = %4.0e atm'%(dUbydVm)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "dUbydV = 1.42e+03 bar\n",
        "dVbyV = 6.519 percent\n",
        "dUbydVm = 9e+02 atm\n"
       ]
      }
     ],
     "prompt_number": 113
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 6.15, Page Number 144"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import exp, log\n",
      "#Variable Declaration\n",
      "m = 1000.0                #mass of mercury, g\n",
      "Pi, Ti  = 1.00, 300.0     #Intial pressure and temperature, bar, K\n",
      "Pf, Tf  = 300., 600.0     #Final pressure and temperature, bar, K\n",
      "rho = 13534.              #Density of mercury, kg/m3\n",
      "beta = 18.1e-4            #Thermal exapansion coefficient for Hg, /K \n",
      "kapa = 3.91e-6            #Isothermal compressibility for Hg, /Pa\n",
      "Cpm = 27.98               #Molar Specific heat at constant pressure, J/(mol.K) \n",
      "M = 200.59                #Molecular wt of Hg, g/mol\n",
      "\n",
      "#Calculations\n",
      "Vi = m*1e-3/rho\n",
      "Vf = Vi*exp(-kapa*(Pf-Pi))\n",
      "Ut = m*Cpm*(Tf-Ti)/M \n",
      "Up =  (beta*Ti/kapa-Pi)*1e5*(Vf-Vi) + (Vi-Vf+Vf*log(Vf/Vi))*1e5/kapa\n",
      "dU = Ut + Up\n",
      "Ht = m*Cpm*(Tf-Ti)/M\n",
      "Hp = ((1 + beta*(Tf-Ti))*Vi*exp(-kapa*Pi)/kapa)*(exp(-kapa*Pi)-exp(-kapa*Pf))\n",
      "dH =  Ht + Hp\n",
      "#Results\n",
      "print 'Internal energy change is %6.2e J/mol in which \\ncontribution of temeprature dependent term %6.4f percent'%(dU,Ut*100/dH)\n",
      "print 'Enthalpy change is %4.3e J/mol in which \\ncontribution of temeprature dependent term %4.1f percent'%(dH,Ht*100/dH)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Internal energy change is 4.06e+04 J/mol in which \n",
        "contribution of temeprature dependent term 99.9999 percent\n",
        "Enthalpy change is 4.185e+04 J/mol in which \n",
        "contribution of temeprature dependent term 100.0 percent\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 6.16, Page Number 145"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "T = 300.0                   #Temperature of Hg, K \n",
      "beta = 18.1e-4              #Thermal exapansion coefficient for Hg, /K \n",
      "kapa = 3.91e-6              #Isothermal compressibility for Hg, /Pa\n",
      "M = 0.20059                 #Molecular wt of Hg, kg/mol \n",
      "rho = 13534                 #Density of mercury, kg/m3\n",
      "Cpm = 27.98                 #Experimental Molar specif heat at const pressure for mercury, J/(mol.K)\n",
      "\n",
      "#Calculations\n",
      "Vm = M/rho\n",
      "DCpmCv = T*Vm*beta**2/kapa\n",
      "Cvm = Cpm - DCpmCv\n",
      "#Results\n",
      "print 'Difference in molar specific heats \\nat constant volume and constant pressure %4.2e J/(mol.K)'%DCpmCv\n",
      "print 'Molar Specific heat of Hg at const. volume is %4.2f J/(mol.K)'%Cvm"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Difference in molar specific heats \n",
        "at constant volume and constant pressure 3.73e-03 J/(mol.K)\n",
        "Molar Specific heat of Hg at const. volume is 27.98 J/(mol.K)\n"
       ]
      }
     ],
     "prompt_number": 149
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 6.17, Page Number 147"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "T = 298.15                  #Std. Temperature, K \n",
      "P = 1.0                     #Initial Pressure, bar\n",
      "Hm0, Sm0 = 0.0,154.8        #Std. molar enthalpy and entropy of Ar(g), kJ, mol, K units\n",
      "Sm0H2, Sm0O2 = 130.7,205.2  #Std. molar entropy of O2 and H2 (g), kJ/(mol.K)\n",
      "dGfH2O = -237.1         #Gibbs energy of formation for H2O(l), kJ/mol  \n",
      "nH2, nO2 = 1, 1./2       #Stoichiomentric coefficients for H2 and O2 in water formation reaction \n",
      "\n",
      "#Calculations\n",
      "Gm0 = Hm0 - T*Sm0\n",
      "dGmH2O = dGfH2O*1000 - T*(nH2*Sm0H2 + nO2*Sm0O2)\n",
      "#Results\n",
      "print 'Molar Gibbs energy of Ar %4.3f kJ/mol'%(Gm0/1e3)\n",
      "print 'Molar Gibbs energy of Water %4.3f kJ/mol'%(dGmH2O/1e3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Molar Gibbs energy of Ar -46.154 kJ/mol\n",
        "Molar Gibbs energy of Water -306.658 kJ/mol\n"
       ]
      }
     ],
     "prompt_number": 26
    }
   ],
   "metadata": {}
  }
 ]
}