summaryrefslogtreecommitdiff
path: root/Fundamentals_Of_Thermodynamics/Chapter16_6.ipynb
blob: c155fdc68a8c76f75f44ef8f9c356970e7158124 (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
{

 "metadata": {

  "name": "",

  "signature": "sha256:2573953a96bd6739252db580058edb8938919cec53d4f1d76f9484cfa4f2a1d5"

 },

 "nbformat": 3,

 "nbformat_minor": 0,

 "worksheets": [

  {

   "cells": [

    {

     "cell_type": "heading",

     "level": 1,

     "metadata": {},

     "source": [

      "Chapter 16:INTRODUCTION TO PHASE AND CHEMICAL EQUILIBRIUM"

     ]

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex16.1:676"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#ques1\n",

      "# pressure required to make diamonds from graphite\n",

      "import math\n",

      "T=25 # temp in degree C\n",

      "ggrp= 0 # g for fraphite\n",

      "gdiamnd=2867.8 # g for diamond in kJ/mol\n",

      "vgrp=0.000444  # specific volume of graphite in m^3/kg\n",

      "vdiamnd=0.000284 # specific volume of graphite in m^3/kg\n",

      "BetaTgrp=0.304e-6 # beta for graphite in 1/MPa\n",

      "BetaTdiamnd=0.016e-6 #  beta for diamond in 1/MPa\n",

      "\n",

      "P=-(-2*(vgrp-vdiamnd)+math.sqrt((2*vgrp-2*vdiamnd)**2-4*(vgrp*BetaTgrp-vdiamnd*BetaTdiamnd)*(2*gdiamnd/(12.011*1000))))/(2*(vgrp*BetaTgrp-vdiamnd*BetaTdiamnd))\n",

      "print int(P),\" MPa is the pressure at which possibility exists for conversion from graphite to diamonds\""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "1493  MPa is the pressure at which possibility exists for conversion from graphite to diamonds\n"

       ]

      }

     ],

     "prompt_number": 18

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex16.2:PG-681"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#ques2\n",

      "#to determine change in gibbs free energy\n",

      "\n",

      "#1-H2\n",

      "#2-O2\n",

      "#3-H2O\n",

      "\n",

      "#at T=298 K\n",

      "T1=298.0;#K\n",

      "Hf1=0;#Enthalpy of formation of H2 at 298 K\n",

      "Hf2=0;#Enthalpy of formation of O2 at 298 K\n",

      "Hf3=-241826;#enthalpy of formation of H2O at 298 K in kJ\n",

      "dH=2*Hf1+Hf2-2*Hf3;#Change in enthalpy in kJ\n",

      "Sf1=130.678;#Entropy of H2 at 298 K n kJ/K\n",

      "Sf2=205.148;#Entropy of O2 at 298 K in kJ/K\n",

      "Sf3=188.834;#entropy of H2O at 298 K in kJ/K\n",

      "dS=2*Sf1+Sf2-2*Sf3;#Change in entropy in kJ/K\n",

      "dG1=dH-T1*dS;#change n gibbs free energy in kJ\n",

      "print\" Change in gibbs free energy at\",T1,\"kelvin is\",round(dG1),\"kJ \"\n",

      "#at T=2000 K\n",

      "T2=2000.0;#K\n",

      "Hf1=52942-0;#Enthalpy of formation of H2 at 2000 K\n",

      "Hf2=59176-0;#Enthalpy of formation of O2 at 2000 K\n",

      "Hf3=-241826+72788;#enthalpy of formation of H2O at 2000 K in kJ\n",

      "dH=2*Hf1+Hf2-2*Hf3;#Change in enthalpy in kJ\n",

      "Sf1=188.419;#Entropy of H2 at 2000 K n kJ/K\n",

      "Sf2=268.748;#Entropy of O2 at 2000 K in kJ/K\n",

      "Sf3=264.769;#entropy of H2O at 2000 K in kJ/K\n",

      "dS=2*Sf1+Sf2-2*Sf3;#Change in entropy in kJ/K\n",

      "dG2=dH-(T2*dS);#change n gibbs free energy in kJ\n",

      "print\" Change in gibbs free energy at\",T2,\"kelvin is\",round(dG2),\" kJ \""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        " Change in gibbs free energy at 298.0 kelvin is 457179.0 kJ \n",

        " Change in gibbs free energy at 2000.0 kelvin is 271040.0  kJ \n"

       ]

      }

     ],

     "prompt_number": 21

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex16.3:PG-683"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#ques3\n",

      "#calculating equilibrium constant \n",

      "\n",

      "dG1=-457.166;#change in gibbs free energy at temp 298 K from example2 in kJ\n",

      "dG2=-271.040;#change in gibbs free energy at temp 2000 K from example2 n kJ\n",

      "T1=298;#K\n",

      "T2=2000;#K\n",

      "R=8.3145;#gas constant\n",

      "K1=dG1*1000/(R*T1);\n",

      "K2=dG2*1000/(R*T2);\n",

      "print\" Equilibrium constant at \",T1,\"K = \",round(K1,2)\n",

      "print\" Equilibrium constant at \",T2,\"K = \",round(K2,3)"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        " Equilibrium constant at  298 K =  -184.51\n",

        " Equilibrium constant at  2000 K =  -16.299\n"

       ]

      }

     ],

     "prompt_number": 6

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex16.4:Pg-684"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# The example is about proving that Equlibrium constant can be found using table hence doesn't require solution in python  "

     ],

     "language": "python",

     "metadata": {},

     "outputs": [],

     "prompt_number": 19

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex16.5:Pg-685"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# ques 5\n",

      "# To determine Heat Transfer\n",

      "# The process is two step as:\n",

      "# Combustion: C + O2--->CO2\n",

      "# Dissociation reaction: 2CO2---->2CO + O2\n",

      "# overall process : C + O2 \u2192 0.5622 CO2 + 0.4378 CO + 0.2189 O2\n",

      "nCO2=0.5622 # moles of CO2\n",

      "nCO=0.4378 # moles of CO\n",

      "nO2=0.2189 # moles of NO2\n",

      "\n",

      "# from Table A.9:\n",

      "hfCO2=0 # enthalpy of formation\n",

      "hfC=0 # enthalpy of formation\n",

      "hfCO=0 # enthalpy of formation\n",

      "hfO2=0 # enthalpy of formation\n",

      "hfCO23000=-393522 # enthalpy @ 3000K\n",

      "hfCO3000=-110527 # enthalpy @ 3000K\n",

      "hfO23000=0 # enthalpy @ 3000K\n",

      "hfCO2298=-152853 # enthalpy @ 298K\n",

      "hfCO298=-93504 # enthalpy @ 298K\n",

      "hfO2298=-98013 # enthalpy @ 298K\n",

      "\n",

      "Hr=hfC+hfO2 # enthalpy of reactants\n",

      "Hp=nCO2*(hfCO2+hfCO23000-hfCO2298)+nCO*(hfCO+hfCO3000-hfCO298)+nO2*(hfO2+hfO23000-hfO2298)\n",

      "\n",

      "Qcv=Hp-Hr # using first law\n",

      "print round(Qcv),\"kJ/kmol C is the heat transfer \""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "-121302.0 kJ/kmol C is the heat transfer \n"

       ]

      }

     ],

     "prompt_number": 22

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex16.6:Pg-687"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# ques 6\n",

      "# to determine the composition\n",

      "# the standard equation is C + 2O2 \u2192 CO2 + O2\n",

      "# from equilibrium C + 2O2 \u2192 (1 \u2212 2z)CO2 + 2zCO + (1 + z)O2\n",

      "T=3000 # temp in K\n",

      "P=0.1 # prssure in MPa\n",

      "z = 0.1553 # from equilibrium equation using table\n",

      "yCO2=(1-2*z)/(2+z) # mole fraction of CO2\n",

      "yCO = 2*z/(2+z) # mole fraction of CO\n",

      "yO2=(1+z)/(2+z) # mole fraction of O2\n",

      "print \"The mole fraction is \",round(yCO2,3),\" for CO2 \\n\"\n",

      "print \"The mole fraction is \",round(yCO,3),\" for CO \\n\"\n",

      "print \"The mole fraction is \",round(yO2,3),\" for O2 \\n\""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "The mole fraction is  0.32  for CO2 \n",

        "\n",

        "The mole fraction is  0.144  for CO \n",

        "\n",

        "The mole fraction is  0.536  for O2 \n",

        "\n"

       ]

      }

     ],

     "prompt_number": 24

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex16.7:Pg-691"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# ques 7\n",

      "# to determine the equilibrium composition\n",

      "# The reaction equation is:\n",

      "# (1): 2.H2O -->2H2 + O2\n",

      "# (2): 2 H2O -->H2 + 2OH\n",

      "# the equilibrium equation is \n",

      "# H2O \u2192 (1 \u2212 2a \u2212 2b)H2O + (2a + b)H2 + aO2 + 2bOH\n",

      "P= 0.1 # pressure in MPa\n",

      "T=3000 # temp in Kelvin\n",

      "a=0.0534 # using value of K from Table A.11 @ 3000k\n",

      "b=0.0551 # using value of K from Table A.11 @ 3000k\n",

      "nH2O= (1-2*a-b) # moles of H2O\n",

      "nH2=2*a+b# moles of H2\n",

      "nO2=a# moles of O2\n",

      "nOH= 2*b# moles of OH\n",

      "X=nH2O+nH2+nO2+nOH\n",

      "yH2O=nH2O/X # mole fraction\n",

      "yH2=nH2/X # mole fraction\n",

      "yO2=nO2/X # mole fraction\n",

      "yOH=nOH/X # mole fraction\n",

      "print \"The mole fraction of H2O is\",round(yH2O,2),\"\\n\"\n",

      "print \"The mole fraction of H2 is\",round(yH2,2),\"\\n\"\n",

      "print \"The mole fraction of O2 is\",round(yO2,2),\"\\n\"\n",

      "print \"The mole fraction of OH is\",round(yOH,2),\"\\n\"\n",

      "# the answers are slightly different due to approximation in textbook while here the answers are precise"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "The mole fraction of H2O is 0.72 \n",

        "\n",

        "The mole fraction of H2 is 0.139 \n",

        "\n",

        "The mole fraction of O2 is 0.046 \n",

        "\n",

        "The mole fraction of OH is 0.095 \n",

        "\n"

       ]

      }

     ],

     "prompt_number": 27

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex16.8:pg-696"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# ques 8\n",

      "# determine the the equilibrium composition\n",

      "P= 1 # pressure in Kpa\n",

      "T=10000 # temp in Kelvin\n",

      "z=0.2008 # using k from table \n",

      "# the chemical equation is Ar -->Ar^(+) + e\u2212\n",

      "\n",

      "yAr=(1-z)/(1 + z) # mole fraction of Ar\n",

      "yArpositive= z/(1+z) # mole fraction of Ar(+)\n",

      "yenegative=z/(1+z) # mole fraction of ye-\n",

      "print \"The mole fraction of Ar is\",round(yAr,3),\"\\n\"\n",

      "print \"The mole fraction of Ar+ is\",round(yArpositive,3),\"\\n\"\n",

      "print \"The mole fraction of e- is\",round(yenegative,3),\"\\n\"\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "The mole fraction of Ar is 0.666 \n",

        "\n",

        "The mole fraction of Ar+ is 0.167 \n",

        "\n",

        "The mole fraction of e- is 0.167 \n",

        "\n"

       ]

      }

     ],

     "prompt_number": 32

    }

   ],

   "metadata": {}

  }

 ]

}