summaryrefslogtreecommitdiff
path: root/Engineering_Physics_by_P.K.Palanisamy/Chapter3_1.ipynb
blob: 5c886a5bc1cfbbb8d5303fec26aa7db1dbf63c45 (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
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#3: X-ray Diffraction"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.1, Page number 3.9"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "wavelength of X-rays is 0.08496 nm\n",
      "answer varies due to rounding off errors\n",
      "when theta=90, maximum order of diffraction possible is 7\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "d=0.313;     #lattice spacing(m)\n",
    "theta=7+(48/60);    #angle(degrees)\n",
    "n=1;\n",
    "\n",
    "#Calculation\n",
    "theta=theta*math.pi/180;    #angle(radian)\n",
    "lamda=2*d*math.sin(theta)/n;    #wavelength of X-rays(nm)\n",
    "#when theta=90\n",
    "n=2*d/lamda;       #maximum order of diffraction possible\n",
    "\n",
    "#Result\n",
    "print \"wavelength of X-rays is\",round(lamda,5),\"nm\"\n",
    "print \"answer varies due to rounding off errors\"\n",
    "print \"when theta=90, maximum order of diffraction possible is\",int(n)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.2, Page number 3.10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "interatomic spacing is 2.67 angstrom\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "lamda=1.5418;      #wavelength(angstrom)\n",
    "theta=30;      #angle(degrees)\n",
    "n=1;    #first order\n",
    "h=1;\n",
    "k=1;\n",
    "l=1;\n",
    "\n",
    "#Calculation\n",
    "theta=theta*math.pi/180;    #angle(radian)\n",
    "d=n*lamda/(2*math.sin(theta));     \n",
    "a=d*math.sqrt(h**2+k**2+l**2);    #interatomic spacing(angstrom)\n",
    "\n",
    "#Result\n",
    "print \"interatomic spacing is\",round(a,2),\"angstrom\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.3, Page number 3.10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "glancing angle is 21 degrees\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "d100=0.28;    #spacing(nm)\n",
    "lamda=0.071;    #wavelength of X rays(nm)\n",
    "n=2;    #second order\n",
    "\n",
    "#Calculation\n",
    "d110=round(d100/math.sqrt(2),3);     #spacing(nm)\n",
    "x=n*lamda/(2*d110);\n",
    "theta=math.asin(x);    #glancing angle(radian)\n",
    "theta=theta*180/math.pi;     #glancing angle(degrees)\n",
    "\n",
    "#Result\n",
    "print \"glancing angle is\",int(theta),\"degrees\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.4, Page number 3.11"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "distance between planes is 0.27 nm\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "a=0.38;     #lattice constant(nm)\n",
    "h=1;\n",
    "k=1;\n",
    "l=0;\n",
    "\n",
    "#Calculation\n",
    "d=a/math.sqrt(h**2+k**2+l**2);     #distance between planes(nm)\n",
    "\n",
    "#Result\n",
    "print \"distance between planes is\",round(d,2),\"nm\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.5, Page number 3.11"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "glancing angle is 32.0 degrees\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "a=0.19;     #lattice constant(nm)\n",
    "h=1;\n",
    "k=1;\n",
    "l=1;\n",
    "lamda=0.058;    #wavelength of X rays(nm)\n",
    "n=2;    #second order\n",
    "\n",
    "#Calculation\n",
    "d=a/math.sqrt(h**2+k**2+l**2);     #distance between planes(nm)\n",
    "x=n*lamda/(2*d);\n",
    "theta=math.asin(x);    #glancing angle(radian)\n",
    "theta=theta*180/math.pi;     #glancing angle(degrees)\n",
    "\n",
    "#Result\n",
    "print \"glancing angle is\",round(theta),\"degrees\""
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}