summaryrefslogtreecommitdiff
path: root/Materials_science_and_engineering_an_introduction/CH5.ipynb
blob: caf36165ebbf9e5f1e6da70352b6e78de08e5288 (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
{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 5 : Diffusion"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.1 Page No. 114"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "Ca=1.2       #Concentration at A in  kg/m**3\n",
      "Cb=0.8       #Concentration at B in  kg/m**3\n",
      "xa=5*10**-3   #Position 1 in m\n",
      "xb=10*10**-3  #Position 2 in m\n",
      "\n",
      "D=3*10**-11   #Diffusion coefficient in m**2/s\n",
      "J=-D*(Ca-Cb)/(xa-xb)\n",
      "\n",
      "print\"Diffusion flux is \",J,\"kg/m**2-s\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Diffusion flux is  2.4e-09 kg/m**2-s\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.2 Page No. 117"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from scipy.optimize import fsolve\n",
      "Co=0.25        #Initial Conc. in wt%\n",
      "Cs=1.2         #Surface conc. in wt%\n",
      "Cx=0.8         #Conc. at any x  in wt%\n",
      "x=5*10**-4     #Position in m\n",
      "D=1.6*10**-11  #Diffusion coeff in m**2/s\n",
      "\n",
      "import math\n",
      "C=1-((Cx-Co)/(Cs-Co))\n",
      "\n",
      "def f(z):\n",
      "    return(0.4210-math.erf(z))\n",
      "z=fsolve(f,1)\n",
      "t=x**2/(4.0*D*z**2.0)\n",
      "\n",
      "print\"Time required is \",round(t/3600.0,1),\"h\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Time required is  7.0 h\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.3 Page No. 118"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "D500=4.8*10**-14     #Diffusion coefficient at 500 C\n",
      "D600=5.3*10**-13     #Diffusion coefficient at 600 C\n",
      "t600=10             #Time in hours to diffuse\n",
      "\n",
      "t500=D600*t600/D500\n",
      "\n",
      "print\"Time to diffuse at 500 C is \",round(t500,1),\"h\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Time to diffuse at 500 C is  110.4 h\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.4 Page No. 121"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "T=550+273            #in K\n",
      "D0=1.2*10**-4        #Temperature independent preexponential in m**2/s\n",
      "Qd=131000            #Activation energy in J/mol-K\n",
      "R=8.31               #Universal Gas constt\n",
      "\n",
      "import math\n",
      "D=D0*math.exp(-Qd/(R*T))\n",
      "\n",
      "print\"Diffusion coefficient is \",round(D,14),\"m**2/s\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Diffusion coefficient is  5.8e-13 m**2/s\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.5 Page No.121"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "inv_T1=0.8*10**-3          #Reciprocal of temp.  in K**-1\n",
      "inv_T2=1.1*10**-3          #Reciprocal of temp.  in K**-1\n",
      "logD1=-12.4\n",
      "logD2=-15.45\n",
      "R=8.31                   #Gas law Constant in J/mol-K\n",
      "\n",
      "Qd=-2.3*R*(logD1-logD2)/(inv_T1-inv_T2)\n",
      "print\"Activation energy is\",round(Qd/1000,0),\"KJ\"\n",
      "\n",
      "D0=10**(logD2+(Qd*inv_T2/(2.3*R)))\n",
      "print\"Preexponential factor is\",round(D0,6),\"m**2/s\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Activation energy is 194.0 KJ\n",
        "Preexponential factor is 5.4e-05 m**2/s\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Design Example 5.1, Page No.122"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "C0=0.2           #Initial concentration in wt%\n",
      "Cs=1             #Surface conc in wt%\n",
      "Cx=0.6           #Conc at any position X in wt%\n",
      "x=7.5*10**-4      #Position in m\n",
      "D0=2.3*10**-5     #Preexponential factor in m**2/s\n",
      "R=8.31           #Gas law constant in J/mol-K\n",
      "Qd=148000        #Activation energy in J/mol\n",
      "\n",
      "C=1-((Cx-C0)/(Cs-C0))\n",
      "z=0.4747\n",
      "Dt=(x/(2*z))**2\n",
      "\n",
      "D=Dt/D0\n",
      "\n",
      "T1=900.0\n",
      "T2=950.0\n",
      "T3=1000.0\n",
      "T4=1050.0\n",
      "t1=D/math.exp(-Qd/(R*(T1+273)))/3600.0\n",
      "t2=D/math.exp(-Qd/(R*(T2+273)))/3600.0\n",
      "t3=D/math.exp(-Qd/(R*(T3+273)))/3600.0\n",
      "t4=D/math.exp(-Qd/(R*(T4+273)))/3600.0\n",
      "\n",
      "print\"Temperature in Celcius  are\",T1,T2,T3,T4\n",
      "print\"Time is respectively \",round(t1,1),\"h,\",round(t2,1),\"h,\",round(t3,1),\"h,\",round(t4,1),\"h\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Temperature in Celcius  are 900.0 950.0 1000.0 1050.0\n",
        "Time is respectively  29.6 h, 15.9 h, 9.0 h, 5.3 h\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}