summaryrefslogtreecommitdiff
path: root/Elements_of_Physical_Chemistry/Chapter7.ipynb
blob: db391867300fe02cc97b046f4aa6fc7493ceca93 (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
{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 7 - Principles of chemical equilibrium"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E1 - Pg 147"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the reaction gibbs energy\n",
      "#Initialization of variables\n",
      "import math\n",
      "G=-31. #kJ/mol\n",
      "T=37+273. #K\n",
      "Cadp=1/1000. #mmol/L\n",
      "Cp=8/1000. #mmol/L\n",
      "Catp=8/1000. #mmol/L\n",
      "R=8.314 #J/K mol\n",
      "#calculations\n",
      "Q=Cadp*Cp/Catp\n",
      "deltaG=G+R*T*math.log(Q) /1000.\n",
      "#results\n",
      "print '%s %.1f %s' %(\"Reaction Gibbs energy =\",deltaG,\" kJ/mol\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Reaction Gibbs energy = -48.8  kJ/mol\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E2 - Pg 149"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the gibbs energy\n",
      "#Initialization of variables\n",
      "Hr=-285.83 #kJ/mol\n",
      "Sr=-163.34 #J/ K mol\n",
      "T=298.15 #K\n",
      "#calculations\n",
      "Gr=Hr-T*Sr/1000.\n",
      "#results\n",
      "print '%s %.2f %s' %('Gibbs energy =',Gr,'kJ/mol')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Gibbs energy = -237.13 kJ/mol\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E3 - Pg 153"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the change in gibbs energy\n",
      "#Initialization of variables\n",
      "import math\n",
      "aADP=1 #mol/L\n",
      "aP=1 #mol/L\n",
      "aATP=1 #mol/L\n",
      "aH2O=1 #mol/L\n",
      "aH=math.pow(10,-7) #mol/L\n",
      "G=10 #kJ/mol\n",
      "T=298. #K\n",
      "R=8.314 #J/K mol\n",
      "#calculations\n",
      "Q=aADP*aP*aH/(aATP*aH2O)\n",
      "Gr=G+R*T*math.log(Q)/1000.\n",
      "#results\n",
      "print '%s %.1f %s' %('Change in nGibbs energy =',Gr,'kJ/mol')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Change in nGibbs energy = -29.9 kJ/mol\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E4 - Pg 155"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the equivalent fration\n",
      "#Initialization of variables\n",
      "Gr=1.7*1000 #J/mol\n",
      "T=298. #K\n",
      "R=8.314 #J/K mol\n",
      "K=0.5\n",
      "#calculations\n",
      "GbyRT=Gr/(R*T)\n",
      "feq=K/(K+1)\n",
      "#results\n",
      "print '%s %.2f' %(\"Equivalent fraction = \",feq)\n",
      "print '%s' %(\"For the second part, Gr=1.7 + 2.48 ln(f/1-f)\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Equivalent fraction =  0.33\n",
        "For the second part, Gr=1.7 + 2.48 ln(f/1-f)\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E5 - Pg 157"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the pressure of N2,H2,NH3 gases\n",
      "#Initialization of variables\n",
      "import math\n",
      "import numpy\n",
      "species=(['N2', 'H2', 'NH3'])\n",
      "change=(['-x', '-3x', '2x'])\n",
      "E=(['1-x', '3-3x', '2x'])\n",
      "print '%s' %(\"Concentration table\")\n",
      "print '%s' %(\"species\")\n",
      "print '%s' %(\"change\")\n",
      "print(E)\n",
      "K=977.\n",
      "#Calculations\n",
      "g=math.sqrt(27*K/4.)\n",
      "vector=([g, -(2*g +1), g])\n",
      "sol=numpy.roots(vector)[1]\n",
      "\n",
      "PN2=1-sol\n",
      "PH2=3-3*sol\n",
      "PNH3=2*sol\n",
      "K=math.pow(PNH3,2)/(math.pow(PH2,3) *PN2)\n",
      "#results\n",
      "print '%s %.2f %s' %(\"Pressure of N2 gas = \",PN2,\"bar\")\n",
      "print '%s %.2f %s' %(\"\\n Pressure of H2 gas =\",PH2,\"bar\")\n",
      "print '%s %.2f %s' %(\"\\n Pressure of NH3 gas =\",PNH3,\"bar\")\n",
      "print '%s %.2e %s' %(\"\\n K final =\",K,\"> it is close to original value.\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Concentration table\n",
        "species\n",
        "change\n",
        "['1-x', '3-3x', '2x']\n",
        "Pressure of N2 gas =  0.10 bar\n",
        "\n",
        " Pressure of H2 gas = 0.31 bar\n",
        "\n",
        " Pressure of NH3 gas = 1.79 bar\n",
        "\n",
        " K final = 9.77e+02 > it is close to original value.\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example I2 - Pg 148"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the equilibrium constant\n",
      "#Initialization of variables\n",
      "import math\n",
      "Gr=-3.40 #kJ/mol\n",
      "R=8.314 #J/k mol\n",
      "T=298. #K\n",
      "#calculations\n",
      "lnK=Gr*1000./(R*T)\n",
      "K=math.exp(lnK)\n",
      "#results\n",
      "print '%s %.2f' %('Equilibrium constant K= ',K)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Equilibrium constant K=  0.25\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example I3 - Pg 149"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the decomposition temperature\n",
      "#Initialization of variables\n",
      "Hr=178. #kJ/mol\n",
      "Sr=161. #J/K mol\n",
      "#calculations\n",
      "T=Hr*1000 /Sr\n",
      "#results\n",
      "print '%s %.2e %s' %(\"Decompostion temperature =\",T,\"K\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Decompostion temperature = 1.11e+03 K\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example I4 - Pg 151"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the standard reaction gibbs energy\n",
      "#Initialization of variables\n",
      "GCO2=-394. #kJ/mol\n",
      "GCO=-137. #kJ/mol\n",
      "GO2=0\n",
      "#calculations\n",
      "deltaG=2*GCO2-2*GCO+GO2\n",
      "#results\n",
      "print '%s %d %s' %('Standard reaction gibbs energy =',deltaG,' kJ/mol')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Standard reaction gibbs energy = -514  kJ/mol\n"
       ]
      }
     ],
     "prompt_number": 9
    }
   ],
   "metadata": {}
  }
 ]
}