summaryrefslogtreecommitdiff
path: root/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch14.ipynb
blob: 335565d5d18d2d49e3dc768d1836ded3ccbd738f (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
{
 "metadata": {
  "name": "",
  "signature": "sha256:6d9acec694eaa6247956671e6c927c80e0d17b9873ff1364d6a6878fb63313c8"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 14 : Equilibrium With Gravity Or Centrifugal Force Osmotic Equilibrium Equilibrium With Surface Tension"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 14.1   Page: 379\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "T = 300.        #[K] Temperature of the natural gas well\n",
      "R = 8.314       #[J/(mol*K)] universal gas consmath.tant\n",
      "z_1 = 0         #[m]\n",
      "y_methane_surf = 85./100            #[mol%]\n",
      "y_ethane_surf = 10/100.             #[mol%]\n",
      "y_propane_surf = 5/100.             #[mol%]\n",
      "P = 2.                              #[MPa] Total equilibrium pressure \n",
      "z_2 = 1000.                         #[m] Depth of the well \n",
      "\n",
      "M_methane = 16./1000                #[kg/mol]\n",
      "M_ethane = 30./1000                 #[kg/mol]\n",
      "M_propane = 44./1000                #[kg/mol]\n",
      "\n",
      "g = 9.81                            #[m/s**(2)]\n",
      "\n",
      "f_methane_1 = y_methane_surf*P      #[MPa]\n",
      "f_ethane_1 = y_ethane_surf*P        #[MPa]\n",
      "f_propane_1 = y_propane_surf*P      #[MPa]\n",
      "\n",
      "f_methane_2 = f_methane_1*math.exp((-M_methane*g*(z_1-z_2))/(R*T))          #[MPa]\n",
      "f_ethane_2 = f_ethane_1*math.exp((-M_ethane*g*(z_1-z_2))/(R*T))             #[MPa]\n",
      "f_propane_2 = f_propane_1*math.exp((-M_propane*g*(z_1-z_2))/(R*T))          #[MPa]\n",
      "\n",
      "P_2 = (f_methane_2 + f_ethane_2 + f_propane_2 )                             #[MPa]\n",
      "\n",
      "y_methane_2 = f_methane_2/P_2\n",
      "y_ethane_2 = f_ethane_2/P_2\n",
      "y_propane_2 = f_propane_2/P_2\n",
      "\n",
      "print \"The mol fraction of the methane at the depth 1000m is %f\"%(y_methane_2)\n",
      "print \"The mol fraction of the ethane at the depth 1000m is %f\"%(y_ethane_2)\n",
      "print \"The mol fraction of the propane at the depth 1000m is %f\"%(y_propane_2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The mol fraction of the methane at the depth 1000m is 0.840351\n",
        "The mol fraction of the ethane at the depth 1000m is 0.104461\n",
        "The mol fraction of the propane at the depth 1000m is 0.055187\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 14.2   Page: 380\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "import math \n",
      "\n",
      "T = 288.                #[K] Atmospheric temperature \n",
      "R = 8.314               #[J/(mol*K)] universal gas consmath.tant\n",
      "z_2 = 15000.            #[m] Thickness of the atmosphere\n",
      "z_1 = 0.                #[m] Surface\n",
      "y_N2_1 = 0.79\n",
      "y_O2_1 = 0.21\n",
      "M_N2 = 28./1000         #[kg/mol]\n",
      "M_O2 = 32./1000          #[kg/mol]\n",
      "\n",
      "g = 9.81                #[m/s**(2)]\n",
      "\n",
      "a = math.exp(-(M_N2-M_O2)*g*(z_2-z_1)/(R*T))\n",
      "yi2_by_yi1 = 1/(y_N2_1 + y_O2_1/a)\n",
      "\n",
      "print \" Concentration of the nitrogen at the top of atmosphere with respect to the concentration of nitrogen \\\n",
      " at the surface of the earth is         yi2_by_yi1 = %0.2f\"%(yi2_by_yi1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Concentration of the nitrogen at the top of atmosphere with respect to the concentration of nitrogen  at the surface of the earth is         yi2_by_yi1 = 1.05\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 14.3   Page: 381\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "T = 288.                #[K] Atmospheric temperature \n",
      "R = 8.314               #[J/(mol*K)] Universal gas consmath.tant\n",
      "z_2 = 10.               #[m] Height of the reactor\n",
      "z_1 = 0.                #[m] Surface\n",
      "g = 9.81                #[m/s**(2)] Accelaration due to gravity\n",
      "\n",
      "y_N2_1 = 0.79\n",
      "y_O2_1 = 0.21\n",
      "M_N2 = 28./1000         #[kg/mol]\n",
      "M_O2 = 32./1000         #[kg/mol]\n",
      "\n",
      "a = math.exp(-(M_N2-M_O2)*g*(z_2-z_1)/(R*T))\n",
      "yi2_by_yi1 = 1/(y_N2_1 + y_O2_1/a)\n",
      "\n",
      "print \" Concentration of the nitrogen at the top of reactor with respect to the concentration of nitrogen \\\n",
      " at the bottom of reactor is         yi2_by_yi1 = %f\"%(yi2_by_yi1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Concentration of the nitrogen at the top of reactor with respect to the concentration of nitrogen  at the bottom of reactor is         yi2_by_yi1 = 1.000034\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 14.4   Page: 382\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "T = 300.                #[K] Temperature of the centrifuge\n",
      "R = 8.314               #[J/(mol*K)] Universal gas consmath.tant\n",
      "y_UF6_238_1 = 0.993     # Mole fraction of UF6 with 238 isotope of uranium in feed\n",
      "y_UF6_235_1 = 0.007     # Mole fraction of UF6 with 235 isotope of uranium in feed\n",
      "M_UF6_238 = 352./1000       #[kg/mol] Molecular weight of UF6 with 238 isotope of uranium\n",
      "M_UF6_235 = 349./1000       #[kg/mol] Molecular weight of UF6 with 235 isotope of uranium\n",
      "r_in = 2./100               #[m] Interanal raddi of the centrifuge\n",
      "r_out = 10./100             #[m] outer raddi of the centrifuge\n",
      "f = 800.                    #[revolution/second] Rotational frequency of centrifuge\n",
      "\n",
      "a = math.exp((M_UF6_235-M_UF6_238)*(2*3.141592*f)**(2)*(r_out**(2)-r_in**(2))/(2*R*T))\n",
      "\n",
      "A = 1./(y_UF6_235_1 + y_UF6_238_1/a)\n",
      "\n",
      "B = 1./A\n",
      "\n",
      "print \"The ratio of the mole fraction of UF6 with uranium 235 isotope) at the 2 cm radius to\\\n",
      " that at the 10 cm radius is %0.3f\"%(B)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The ratio of the mole fraction of UF6 with uranium 235 isotope) at the 2 cm radius to that at the 10 cm radius is 1.156\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 14.5   Page: 384\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "x_water_1 = 0.98            # mole fraction of water in phase 1 i.e. in seawater\n",
      "x_water_2 = 1.              # mole fraction of water in the phase 2 i.e. in water \n",
      "R = 10.73                   #[(psi*ft**(3))/(lbmol*R)] Universal gas consmath.tant\n",
      "T = 500.                    #[R] temperature\n",
      "v_water_1 = 18/62.4         # [ft**(3)/(lbmol)]\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "delta_P = (-(R*T)*math.log(x_water_1))/v_water_1#[psi]\n",
      "\n",
      "print \"The pressure difference between the two phases is %0.1f psi\"%(delta_P)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The pressure difference between the two phases is 375.7 psi\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 14.6   Page: 386\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "T = 100.            #[C] Temperature of the outside\n",
      "P_outside = 1.      #[atm]\n",
      "T = 0.05892         #[N/m] From metric steam table (7, page 267)\n",
      "\n",
      "\n",
      "d_1 = 0.001         #[m]\n",
      "\n",
      "delta_P_1 = (4*T)/d_1           #[Pa]\n",
      "\n",
      "d_2 = 10**(-6)                  #[m]\n",
      "\n",
      "delta_P_2 = (4*T)/d_2           #[Pa]\n",
      "\n",
      "d_3 = 0.01*10**(-6)             #[m]\n",
      "delta_P_3 = (4*T)/d_3           #[Pa]\n",
      "\n",
      "print \"Pressure difference with the change in radius of the drop of the water is given as in the following table\"\n",
      "print \"            Diameter of the droplet d_iin meter                   Pressure difference  P_inside - P_outside in atm\"\n",
      "print \"                     %0.2e                                                     %0.2e\"%(d_1,delta_P_1) \n",
      "print \"                     %0.2e                                                     %0.2e\"%(d_2,delta_P_2) \n",
      "print \"                     %0.2e                                                     %0.2e\"%(d_3,delta_P_3) \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure difference with the change in radius of the drop of the water is given as in the following table\n",
        "            Diameter of the droplet d_iin meter                   Pressure difference  P_inside - P_outside in atm\n",
        "                     1.00e-03                                                     2.36e+02\n",
        "                     1.00e-06                                                     2.36e+05\n",
        "                     1.00e-08                                                     2.36e+07\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 14.7   Page: 387\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "import math \n",
      "\n",
      "P_NBP = 1.                          #[atm]\n",
      "Temp =273.15+100                    #[C] Temperature\n",
      "D = 0.01*10**(-6)                   #[m] Diameter of the condensation nuclei( due to impurity )\n",
      "T = 0.05892                         #[N/m] Surface tension between water drops and gas\n",
      "R = 8.314                           #[J/(mol*K)]\n",
      "\n",
      "\n",
      "v_water_liquid = 1/958.39*0.018     #[m**(3)/mol]\n",
      "\n",
      "\n",
      "\n",
      "I = math.exp(v_water_liquid*(4*T/D)/(R*Temp))\n",
      "\n",
      "P_gas_minus_P_NBP = (I-1)*P_NBP         #[atm]\n",
      "delta_P = P_gas_minus_P_NBP*1.01325     #[bar]\n",
      "\n",
      "delta_P_1 = delta_P*100*0.1450377       #[psi]\n",
      "\n",
      "print \"The equilibrium pressure at which the steam begin to condence at this temperature on \\\n",
      " the nuclei is %f psi above the normal boiling point.\"%(delta_P_1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The equilibrium pressure at which the steam begin to condence at this temperature on  the nuclei is 2.253760 psi above the normal boiling point.\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 14.8   Page: 388\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "from scipy.integrate import quad \n",
      "\n",
      "Temp = 273.15+100                   #[K] Temperature of the water drop\n",
      "R = 8.314                           #[J/(mol*K)] Universal gas consmath.tant\n",
      "D = 0.01*10**(-6)                   #[m] Diameter of the water drop\n",
      "P_g = 0.15                          #[bar] guage pressure\n",
      "T = 0.05892                         #[N/m] Surface tension between water drop and gas\n",
      "\n",
      "\n",
      "v_water_liquid = 0.018/958.39       #[m**(3)/mol]\n",
      "P_NBP = 1.013                       #[bar]\n",
      "P_gas = 1.013+0.15                  #[bar]\n",
      "\n",
      "P_1 = P_gas + 4*T/D                 #[bar]\n",
      "\n",
      "def f2(P): \n",
      "\t return v_water_liquid*P**(0)\n",
      "\n",
      "delta_g_1 =  quad(f2,P_NBP,P_1)[0]\n",
      "\n",
      "\n",
      "\n",
      "def f3(P): \n",
      "\t return (R*Temp)/P\n",
      "\n",
      "delta_g_2 =  quad(f3,P_NBP,P_gas)[0]\n",
      "\n",
      "\n",
      "delta_g = (delta_g_1 - delta_g_2) \n",
      "\n",
      "\n",
      "print \"The liquid can lower its free energy %0.2f J/mol by Changing to gas,\"%(delta_g)\n",
      "print \"So that even at 0.15 bar above the normal boiling point, a drop of this small size is unstable and will quickly evaporate.\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The liquid can lower its free energy 14.25 J/mol by Changing to gas,\n",
        "So that even at 0.15 bar above the normal boiling point, a drop of this small size is unstable and will quickly evaporate.\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 14.9   Page: 390\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "from scipy.optimize import fsolve \n",
      "import math \n",
      "\n",
      "Temp = 904.7                #[R] Temperature of the pure liquid water \n",
      "P_NBP = 400.                #[psia] Saturation pressure of the pure liquid water at the given temperature\n",
      "T = 1.76*10**(-4)           #[lbf/inch] Surface tension of water\n",
      "R = 10.73                   #[(psi*ft**(3))/(lbmol*R)]\n",
      "\n",
      "v_water_liquid = 18*0.01934             #[ft**(3)/lbmol]\n",
      "D = 10**(-5.)                           #[inch]\n",
      "\n",
      "\n",
      "def f(p): \n",
      "\t return  v_water_liquid*(p - P_NBP)-(R*Temp)*math.log((p+4*T/D)/P_NBP)\n",
      "P_liquid = fsolve(f,300)\n",
      "\n",
      "P_inside = P_liquid + 4*T/D             #[psia]\n",
      "\n",
      "print \"The liquid pressure at which these boiling nuclei will begin to grow and intiate boiling is %0.1f psia\"%(P_liquid)\n",
      "print \"At this external pressure the pressure inside the bubble is %0.1f psia\"%(P_inside)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The liquid pressure at which these boiling nuclei will begin to grow and intiate boiling is 328.6 psia\n",
        "At this external pressure the pressure inside the bubble is 399.0 psia\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}