summaryrefslogtreecommitdiff
path: root/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch7.ipynb
blob: 7020eec30fe76509ec8726370b3389024a006a74 (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:1516bb23afc335a7092a1afab7991f3ed9c5be7c83937717220b23a740bce801"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 7 : Fugacity Ideal Solutions Activity Activity Coefficient"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 7.1  Page: 134"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "from scipy.integrate import quad \n",
      "\n",
      "\n",
      "T = 220+459.67          #[R] Temperature in Rankine\n",
      "P = 500.                #[psia] Pressure\n",
      "R = 10.73               #[(psi*ft**(3)/(lbmol*R))] Gas consmath.tant\n",
      "\n",
      "\n",
      "a = 4.256           #[ft**(3)/lbmol]\n",
      "\n",
      "def f6(p): \n",
      "\t return a*p**(0)\n",
      "\n",
      "I =  quad(f6,0,P)[0]\n",
      "\n",
      "\n",
      "f = P*math.exp((-1/(R*T))*I)            #[psia]\n",
      "\n",
      "print \"Fugacity of propane gas at the given condition is %.0f psia\"%(round(f,1))\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Fugacity of propane gas at the given condition is 374 psia\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 7.2  Page: 138\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "import math \n",
      "\n",
      "T = 100. + 460          #[R] Temperature of the system in Rankine\n",
      "P = 1.                  # [psia]\n",
      "R = 10.73               #[(psi*ft**(3)/(lbmol*R))] Gas consmath.tant\n",
      "\n",
      "v = 0.016136*18         #[ft**(3)/lbmol]\n",
      "z = round((P*v)/(R*T),5)\n",
      "\n",
      "a = int(((R*T)/P))*(1-z)     #[ft**(3)/lbmol]\n",
      "\n",
      "print \" Compresssibility factor the liquid water at the given condition is %.5f \"%(z)\n",
      "print \"Volume residual for the liquid water at the given condition is     %0.1f cubic feet/lbmol\"%(a)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Compresssibility factor the liquid water at the given condition is 0.00005 \n",
        "Volume residual for the liquid water at the given condition is     6007.7 cubic feet/lbmol\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 7.3  Page: 138\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "from scipy.integrate import quad \n",
      "\n",
      "T = 100+460.            #[R] Temperature\n",
      "P = 1000.               #[psia] Pressure\n",
      "R = 10.73               #[(psi*ft**(3)/(lbmol*R))] Gas consmath.tant\n",
      "\n",
      "f_b = 0.95              #[psia]\n",
      "f_c = f_b               #[psia]\n",
      "v = 0.016136*18         #[ft**(3)/lbmol]\n",
      "\n",
      "P_d = 1000.             #[psia]\n",
      "P_c = 1.                #[psia]\n",
      "\n",
      "def f4(p): \n",
      "\t return p**(0)\n",
      "\n",
      "f_d = f_c*math.exp((v/(R*T))* (quad(f4,P_c,P_d))[0])\n",
      "\n",
      "print \"Fugacity of the pure liquid water at the given condition is %0.1f psia\"%(f_d)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Fugacity of the pure liquid water at the given condition is 1.0 psia\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 7.4  Page: 145\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "T = 78.15           #[C]\n",
      "P = 1.0             #[atm]\n",
      "p_a_0 = 0.993       #[atm] Pure ethanol vapor pressure at 78.15C\n",
      "p_b_0 = 0.434       #[atm] Pure water vapor pressure at 78.15C\n",
      "\n",
      "x_a = 0.8943        # Amount of ethanol in the liquid phase \n",
      "x_b = 0.1057        # Amount of water in liquid phase \n",
      "\n",
      "y_a = x_a           # Amount of ethanol in vapor phase \n",
      "y_b = x_b           # Amount of water in the vapor phase \n",
      "\n",
      "\n",
      "\n",
      "Y_a_1 = 1.0\n",
      "Y_b_1 = 1.0\n",
      "\n",
      "Y_a_2 = ((y_a*P)/(x_a*p_a_0))\n",
      "Y_b_2 = ((y_b*P)/(x_b*p_b_0))\n",
      "\n",
      "f_a_1 = (y_a*Y_a_1*P)           #[atm]\n",
      "f_b_1 = (y_b*Y_b_1*P)           #[atm]\n",
      "f_a_2 = f_a_1                   #[atm]\n",
      "f_b_2 = f_b_1                   #[atm]\n",
      "\n",
      "f_a_1_0 = P                     #[atm]\n",
      "f_b_1_0 = P                     #[atm]\n",
      "\n",
      "f_a_2_0 = p_a_0                 #[atm]\n",
      "f_b_2_0 = p_b_0                 #[atm]\n",
      "\n",
      "print \" The results are summarized in the following table: \\n\\tPhase\\t\\t\\t\\t Etahnol(i=a)\\t\\t\\t\\t Water,i=b\"\n",
      "print \" \\tVAPOR PHASE 1\"\n",
      "print \"  \\t  f_i_1 atm   \\t\\t\\t %.4f \\t\\t\\t\\t %.4f\"%(f_a_1,f_b_1)\n",
      "print \"  \\t  f_i_1_0 atm \\t\\t\\t %.4f \\t\\t\\t\\t %.4f\"%(f_a_1,f_b_1)\n",
      "print \"  \\t  Y_i_1 assumed  \\t\\t %f \\t\\t\\t\\t %f\"%(Y_a_1,Y_b_1)\n",
      "print \" \\tLIQUID PHASE 2\"\n",
      "print \"  \\t  f_i_2 atm   \\t\\t\\t %.4f \\t\\t\\t\\t %.4f\"%(f_a_2,f_b_2)\n",
      "print \"  \\t  f_i_2_0 atm \\t\\t\\t %.4f \\t\\t\\t\\t %.4f\"%(f_a_2,f_b_2)\n",
      "print \"  \\t  Y_i_2assumed  \\t\\t %.4f \\t\\t\\t\\t %.4f\"%(Y_a_2,Y_b_2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The results are summarized in the following table: \n",
        "\tPhase\t\t\t\t Etahnol(i=a)\t\t\t\t Water,i=b\n",
        " \tVAPOR PHASE 1\n",
        "  \t  f_i_1 atm   \t\t\t 0.8943 \t\t\t\t 0.1057\n",
        "  \t  f_i_1_0 atm \t\t\t 0.8943 \t\t\t\t 0.1057\n",
        "  \t  Y_i_1 assumed  \t\t 1.000000 \t\t\t\t 1.000000\n",
        " \tLIQUID PHASE 2\n",
        "  \t  f_i_2 atm   \t\t\t 0.8943 \t\t\t\t 0.1057\n",
        "  \t  f_i_2_0 atm \t\t\t 0.8943 \t\t\t\t 0.1057\n",
        "  \t  Y_i_2assumed  \t\t 1.0070 \t\t\t\t 2.3041\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 7.5  Page: 149\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "T = 220+460.            #[R] Temperature in rankine\n",
      "P = 1000.               #[psia] Pressure\n",
      "y_methane = 0.784       # Mol fraction of methane in the given mixture\n",
      "y_butane = (1-y_methane)       # Mol fraction of n-bumath.tane in the given mixture\n",
      "R = 10.73               #[(psia*ft**(3)/(lbmol*R))] gas consmath.tant\n",
      "\n",
      "\n",
      "Im = 290.               #[ft**(3)/lbmol]\n",
      "\n",
      "Jm = math.exp((-1/(R*T))*Im)\n",
      "\n",
      "f_methane = Jm*P*y_methane          #[psia] fugacity of methane\n",
      "\n",
      "Ib = 5859.                          #[ft**(3)/lbmol]\n",
      "Jb = math.exp((-1/(R*T))*Ib)\n",
      "f_butane = Jb*P*y_butane          #[psia] fugacity of bumath.tane\n",
      "\n",
      "print \" Fugacity of the methane in the gaseous mixture is %0.0f psia\"%(f_methane)\n",
      "print \" Fugacity of the butane in the gaseous mixture is  %0.1f psia\"%(f_butane)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Fugacity of the methane in the gaseous mixture is 753 psia\n",
        " Fugacity of the butane in the gaseous mixture is  96.8 psia\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 7.6  Page: 153\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "import math \n",
      "\n",
      "T = 220+460.            #[R] Temperature in rankine\n",
      "P = 1000.               #[psia] Pressure\n",
      "x_methane = 0.784       # Mol fraction of methane in the given mixture\n",
      "x_bumath_tane = (1-x_methane)       # Mol fraction of n-bumath_tane in the given mixture\n",
      "\n",
      "v_i_into_Y_i = 0.961\n",
      "phi_cap_i = 0.961\n",
      "\n",
      "v_i = 0.954\n",
      "phi_i = v_i\n",
      "Y_i = phi_cap_i/v_i\n",
      "\n",
      "print \" The value of v_i is %f\"%(v_i)\n",
      "print \" The value of Y_i is %f\"%(Y_i)\n",
      "print \" The value of phi_cap_i is %f\"%(phi_cap_i)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The value of v_i is 0.954000\n",
        " The value of Y_i is 1.007338\n",
        " The value of phi_cap_i is 0.961000\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 7.7  Page: 154\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "T_r = 0.889\n",
      "P_r = 1.815\n",
      "\n",
      "f_f = -0.48553\n",
      "\n",
      "v = math.exp((P_r/T_r)*f_f)\n",
      "phi = v\n",
      "\n",
      "print \" The value of v=phi for n-bumath.tane at given condition is %f\"%(v)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The value of v=phi for n-bumath.tane at given condition is 0.371106\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}