summaryrefslogtreecommitdiff
path: root/Material_Science_by_S._L._Kakani_and_A._Kakani/ch3.ipynb
blob: e5b64fc1a284608d03c19573ecbc12b1f699ee52 (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
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 3 : Crystal Geometry Structure and Defects"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.10 Page No : 91"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "angle Between normals to the planes (111) and (121)(in degrees) = 19.47\n"
     ]
    }
   ],
   "source": [
    "\t\t\t\n",
    "from numpy import degrees, arccos\n",
    "\n",
    "# Variables\n",
    "#Miller indices of plane\n",
    "h_1 = 1.;\n",
    "k_1 = 1.;\n",
    "l_1 = 1.;\n",
    "h_2 = 1.;\n",
    "k_2 = 2.;\n",
    "l_2 = 1.;\n",
    "\n",
    "# Calculation\n",
    "angle = degrees(arccos((h_1*h_2+k_1*k_2+l_1*l_2)/(((h_1**2+k_1**2+l_1**2)**(1./2))*((h_2**2+k_2**2+l_2**2)**(1./2)))))\n",
    "\n",
    "# Results\n",
    "print 'angle Between normals to the planes (111) and (121)(in degrees) = %.2f'%angle\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.11 Page No : 91"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Packing efficiency of sodium chloride in = 66.3 %\n",
      "density of sodium chloride in = 2233 Kg/m3\n"
     ]
    }
   ],
   "source": [
    "\t\t\t\n",
    "\n",
    "import math \n",
    "\n",
    "# Variables\n",
    "r_Na = 0.98;\t\t\t#Radius of Na+(in A)\n",
    "r_Cl = 1.81;\t\t\t#Radius of Cl-(in A)\n",
    "a = 2*(r_Na+r_Cl);\t\t\t#Lattice parameter (in A)\n",
    "\n",
    "# Calculation\n",
    "pi = 22./7;\n",
    "V_i = 4*(4./3)*pi*((r_Na**3)+(r_Cl**3));\t\t\t#Volume of ions present in unit cell\n",
    "V_u = a**3;\t\t\t#Volume of unit cell\n",
    "Apf = V_i/V_u;\t\t\t#Atomic packing fraction\n",
    "Ef_p = (Apf)*100;\t\t\t#Packing efficiency(in %)\n",
    "AM_sodium = 22.99;\t\t\t#Atomic mass of sodium(in amu)\n",
    "AM_chlorine = 35.45;\t\t\t#Atomic mass of chlorine(in amu)\n",
    "M_1 = 4*(AM_sodium+AM_chlorine)*1.66*10**(-27);\t\t\t#Mass of the unit cell\n",
    "a_1 = a*10**(-10);\t\t\t#Lattice parameter (in meter)\n",
    "V_u1 = (a_1)**3;\n",
    "Density = M_1/V_u1;\n",
    "\n",
    "# Results\n",
    "print 'Packing efficiency of sodium chloride in = %.1f %%'%Ef_p\n",
    "print 'density of sodium chloride in = %.0f Kg/m3'%Density\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.12 Page No : 91"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "radius in = 4.049 A\n",
      "Diameter in 2.86 A\n"
     ]
    }
   ],
   "source": [
    "\t\t\t\n",
    "\n",
    "import math \n",
    "\n",
    "# Variables\n",
    "Density = 2.7;\t\t\t#(in g/cm**3)\n",
    "n = 4;\n",
    "m = 26.98;\t\t\t#atomic weight of Al\n",
    "\n",
    "# Calculation and Results\n",
    "N_a = 6.023*10**(23);\t\t\t            #avogadro number\n",
    "a = ((n*m/(Density*N_a))**(1./3));\t\t\t#Lattice parameter(in Cm)\n",
    "A = a*10**(8);\t\t\t                    #Lattice parameter(in A)\n",
    "print 'radius in = %.3f A'%A\n",
    "r = A/(2*1.414);\t\t\t#radius for fcp structure\n",
    "print 'Diameter in %.2f A'%(2*r)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.13 Page No : 92"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "interplaner distance of (200) plane of nickel crystal in = 1.76 A\n",
      "interplaner distance of (111) plane of nickel crystal in = 2.03 A\n"
     ]
    }
   ],
   "source": [
    "\t\t\t\n",
    "import math \n",
    "\n",
    "# Variables\n",
    "r = 1.245;\t\t\t#radius of nickel (in A)\n",
    "a = 4*r/(2)**(1./2);\t\t\t#Lattice consmath.tant(in A)\n",
    "#Miller indices of plane 200\n",
    "h_1 = 2;\n",
    "k_1 = 0;\n",
    "l_1 = 0;\n",
    "#Miller indices of plane 111\n",
    "h_2 = 1;\n",
    "k_2 = 1;\n",
    "l_2 = 1;\n",
    "\n",
    "# Calculation\n",
    "d_200 = a/((h_1**2)+(k_1**2)+(l_1**2))**(1./2);\n",
    "d_111 = a/((h_2**2)+(k_2**2)+(l_2**2))**(1./2);\n",
    "\n",
    "# Results\n",
    "print 'interplaner distance of (200) plane of nickel crystal in = %.2f A'%d_200\n",
    "print 'interplaner distance of (111) plane of nickel crystal in = %.2f A'%d_111\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.14 Page No : 92"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Number of atoms in the (100) plane of a simple cubic structure(in per mm**2) = 1.09e+13\n",
      "Number of atoms in the (110) plane of a simple cubic structure(in per mm**2) = 7.7e+12\n",
      "Number of atoms in the (111) plane of a simple cubic structure(in per mm**2) = 6.3e+12\n"
     ]
    }
   ],
   "source": [
    "\t\t\t\n",
    "import math \n",
    "\n",
    "# Variables\n",
    "a = 3.03*10**(-7);\t\t\t#lattice consmath.tant(in mm)\n",
    "\n",
    "# Calculation\n",
    "N_100 = 1/(a**2);\t\t\t#Number of atoms in the (100) plane of a simple cubic structure\n",
    "N_110 = 0.707/(a**2);\t\t\t#Number of atoms in the (110) plane of a simple cubic structure\n",
    "N_111 = 0.58/(a**2);\t\t\t#Number of atoms in the (111) plane of a simple cubic structure\n",
    "\n",
    "# Results\n",
    "print 'Number of atoms in the (100) plane of a simple cubic structure(in per mm**2) = %.2e'%N_100\n",
    "print 'Number of atoms in the (110) plane of a simple cubic structure(in per mm**2) = %.1e'%N_110\n",
    "print 'Number of atoms in the (111) plane of a simple cubic structure(in per mm**2) = %.1e'%N_111\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.15 Page No : 92"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the planer density of Ni (in atoms per mm**2) = 1.6e+13\n"
     ]
    }
   ],
   "source": [
    "\t\t\t\n",
    "import math \n",
    "\n",
    "# Variables\n",
    "r = 1.245*10**(-7);\t\t\t#Radius of the Ni atom(in mm)\n",
    "\n",
    "# Calculation\n",
    "NA_100 = 1+(1./4)*4;\t\t\t#Numbers of atom in (100) plane\n",
    "a = 4*r/(2)**(1./2);\t\t\t#Lattice consmath.tant(in mm)\n",
    "Area = a**2;\n",
    "P_density = NA_100/Area;\n",
    "\n",
    "# Results\n",
    "print 'the planer density of Ni (in atoms per mm**2) = %.1e'%P_density\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.16 Page No : 93"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Planar density of plane 100(in atoms/mm**2) = 8.2e+12\n",
      "Planar density of plane 110(in atoms/mm**2) = 5.8e+12\n",
      "Planar density of plane 111(in atoms/mm**2) = 9.4e+12\n"
     ]
    }
   ],
   "source": [
    "\t\t\t\n",
    "import math \n",
    "\n",
    "# Variables\n",
    "N_a1 = 4*(1./4)+1;\t\t\t#Number of atoms contained in (100) plane\n",
    "r = 1.75*10**(-7);\t\t\t#radius of lead atom (in mm)\n",
    "a_1 = 2*2**(1./2)*r;\t\t\t#edge of unit  cell in case of (100) plane\n",
    "PD_100 = N_a1/(a_1**2);\t\t\t#Planar density of plane (100)\n",
    "\n",
    "# Calculation\n",
    "N_a2 = 4*(1./4)+2*(1./2);\t\t\t#Number of atoms contained in (110) plane\n",
    "a_21 = 4*r;\t\t\t#top edge of the plane (110)\n",
    "a_22 = 2*2**(1./2)*r;\t\t\t#vertical edge of the plane (110)\n",
    "PD_110 = N_a2/(a_21*a_22);\t\t\t#Planar density of plane (110)\n",
    "N_a3 = 3*(1./6)+3./2;\t\t\t#Number of atom contained in (111) plane\n",
    "Ar_111 = 4*(3**(1./2))*r**2;\t\t\t#area of (111) plane\n",
    "PD_111 = N_a3/Ar_111;\t\t\t#Planar density of plane (111)\n",
    "\n",
    "# Results\n",
    "print 'Planar density of plane 100(in atoms/mm**2) = %.1e'%PD_100\n",
    "print 'Planar density of plane 110(in atoms/mm**2) = %.1e'%PD_110\n",
    "print 'Planar density of plane 111(in atoms/mm**2) = %.1e'%PD_111\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.17 Page No : 94"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "linear atomic density along (110) of copper crystal lattice in = 3.92e+06 atoms/mm\n",
      "linear atomic density along (111) of copper crystal lattice in = 1.60e+06 atoms/mm\n"
     ]
    }
   ],
   "source": [
    "\t\t\t\n",
    "import math \n",
    "\n",
    "# Variables\n",
    "N_a1 = (1./2)+1+(1./2);\t\t\t#Number of diameters of atom along (110) direction\n",
    "a = 3.61*10**(-7);\t\t\t#lattice consmath.tant of copper in mm\n",
    "\n",
    "# Calculation\n",
    "L_d1 = 2**(1./2)*a;\t\t\t#length of the face diagonal in case of (110) direction\n",
    "p_110 = N_a1/L_d1;\t\t\t#linear atomic density along (110) of copper crystal lattice(in atoms/mm)\n",
    "N_a2 = (1./2)+(1./2);\t\t\t#Number of diameters of atom along (111) direction\n",
    "L_d2 = 3**(1./2)*a;\t\t\t#length of the face diagonal in case of (111) direction\n",
    "p_111 = N_a2/L_d2;\t\t\t#linear atomic density along (110) of copper crystal lattice(in atoms/mm)\n",
    "\n",
    "# Results\n",
    "print 'linear atomic density along (110) of copper crystal lattice in = %.2e atoms/mm'%p_110\n",
    "print 'linear atomic density along (111) of copper crystal lattice in = %.2e atoms/mm'%p_111\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.18 Page No : 95"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Value of lattice constant in = 2.867 A\n"
     ]
    }
   ],
   "source": [
    "\t\t\t\n",
    "\n",
    "import math \n",
    "\n",
    "# Variables\n",
    "A = 55.8;\t\t\t#atomic weight of Fe\n",
    "n = 2;\t\t\t#number of atoms per unit cell\n",
    "\n",
    "# Calculation\n",
    "N = 6.02*10**(26);\t\t\t#Avogadro's number\n",
    "p = 7.87*10**3;\t\t\t#density of Fe(in kg/m**3)\n",
    "a = ((A*n/(N*p))**(1./3))*10**10;\t\t\t#Value of lattice consmath.tant\n",
    "\n",
    "# Results\n",
    "print 'Value of lattice constant in = %.3f A'%a\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.19 Page No : 95"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Numbers of atoms per unit cell =  2.0\n"
     ]
    }
   ],
   "source": [
    "\t\t\t\n",
    "import math \n",
    "\n",
    "\n",
    "# Variables\n",
    "a = 2.9*10**(-10);\t\t\t#lattice parameter(in m)\n",
    "A = 55.8;\t\t\t#atomic weight of Fe\n",
    "\n",
    "# Calculation\n",
    "N = 6.02*10**(26);\t\t\t#Avogadro's number\n",
    "p = 7.87*10**3;\t\t\t#density of Fe(in kg/m**3\n",
    "n = (a**3)*N*p/A;\t\t\t#Numbers of atoms per unit cell\n",
    "\n",
    "# Results\n",
    "print 'Numbers of atoms per unit cell = ',floor(n)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.20 Page No : 109"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "line energy of disslocation in = 2.47e-09 J/m\n"
     ]
    }
   ],
   "source": [
    "\t\t\t\n",
    "import math \n",
    "\n",
    "# Variables\n",
    "a = 2.87*10**(-10);\t\t\t#lattice parameter for bcc iron\n",
    "b = a*(3**(1./2))/2;\t\t\t#Magnitude of burgers vector\n",
    "\n",
    "# Calculation\n",
    "u = 80*10**9;\t\t\t#shear modulus\n",
    "E = (1./2)*u*b**2;\t\t\t#line energy of disslocation\n",
    "\n",
    "# Results\n",
    "print 'line energy of disslocation in = %.2e J/m'%E\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.22 Page No : 109"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "number of vacancies created during heating in = 6.54e+23 m**-3\n"
     ]
    }
   ],
   "source": [
    "\t\t\t\n",
    "import math \n",
    "\n",
    "# Variables\n",
    "N = 6.023*10**23;\t\t\t#avogadro number\n",
    "T = 1000.;\t\t\t#absolute temperature\n",
    "R = 8.314;\t\t\t#consmath.tant\n",
    "\n",
    "# Calculation\n",
    "H_f = 100*1000;\t\t\t#enthalpy of formation of vacancies(in J/mol)\n",
    "n = N*math.exp(-(H_f)/(R*T));\t\t\t#number of vacancies created during heating(in per mol)\n",
    "V = 5.5*10**(-6);\t\t\t#volume of 1 mole of the crystal in m**3\n",
    "n_1 = n/V;\t\t\t#number of vacancies created during heating(in per m**3)\n",
    "\n",
    "# Results\n",
    "print 'number of vacancies created during heating in = %.2e m**-3'%n_1\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.23 Page No : 109"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Surface energy (enthalpy) of copper in = 2.49 J/m**2\n"
     ]
    }
   ],
   "source": [
    "\t\t\t\n",
    "import math \n",
    "\n",
    "# Variables\n",
    "#bond energy per atom of copper = bond energy per bond*numbers of bond per atom*(1/2)\n",
    "A = 56.4*1000;\t\t\t#\n",
    "N = 6.023*10**23;\t\t\t#avogadro number\n",
    "n_1 = 12.;\t\t\t#numbers of bond per atom\n",
    "n_2 = 3.;\t\t\t#bonds broken at the surface\n",
    "\n",
    "# Calculation and Results\n",
    "E = A*n_1/(2*N);\t\t\t#Energy of total bonds\n",
    "E_b = E*(n_2/n_1);\t\t\t#Energy of broken bonds on surface\n",
    "n_a = 1.77*10**19;\t\t\t#no. of atoms on {111} planes in copper(in m**-2)\n",
    "E_c = n_a*E_b;\t\t\t#Surface energy (enthalpy) of copper\n",
    "print 'Surface energy (enthalpy) of copper in = %.2f J/m**2'%E_c\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.24 Page No : 110"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "equilibrium concentration of vacancies in aluminium at 300 K = 1.44e-12\n"
     ]
    }
   ],
   "source": [
    "\n",
    "import math \n",
    "\n",
    "# Variables\n",
    "H_f = 68.*1000;\t\t\t#enthalpy of formation of vacancies(in J/mol)\n",
    "T_1 = 0;\t\t\t#temp (in K)\n",
    "T_2 = 300.;\t\t\t#temp (in K)\n",
    "R = 8.314;\t\t\t#consmath.tant\n",
    "\n",
    "# Calculation\n",
    "\n",
    "n = math.exp(-H_f/(R*T_2));\t\t\t#equilibrium concentration of vacancies in aluminium at 300 K\n",
    "\n",
    "# Results\n",
    "print 'equilibrium concentration of vacancies in aluminium at 300 K = %.2e'%n\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.25 Page No : 113"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the interplanar spacing between atomic plane in = 2.22 A\n"
     ]
    }
   ],
   "source": [
    "\t\t\t\n",
    "import math \n",
    "\n",
    "# Variables\n",
    "Wavelength = 1.54*10**(-10);\t\t\t#in meter\n",
    "Angle = 20.3;\t\t\t#in degree\n",
    "n = 1;\t\t\t#First order\n",
    "\n",
    "# Calculation\n",
    "d = Wavelength*n/(2*math.sin(math.radians(Angle)));\t\t\t#the interplanar spacing(in Meter)\n",
    "\n",
    "# Results\n",
    "print 'the interplanar spacing between atomic plane in = %.2f A'%(d/(10**-10))\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.26 Page No : 113"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Size of unit cell in 3.51 Angstrom\n"
     ]
    }
   ],
   "source": [
    "\t\t\t\n",
    "import math \n",
    "\n",
    "# Variables\n",
    "wavelength = 0.58;\t\t\t#in Angstrom\n",
    "angle = 9.5;\t\t\t#in degree\n",
    "n = 1;\t\t\t#First order\n",
    "\n",
    "# Calculation\n",
    "#d_200 = wavelength*n/(2*math.sin(math.radians(angle)));\t\t\t#interplanar spacing(in Angstrom)\n",
    "d_200 = n/math.sqrt(2**2+0**2+0**2)\n",
    "#Miller indices of plane\n",
    "h = 2;\n",
    "k = 0;\n",
    "l = 0;\n",
    "a = 0.58/(math.sin(math.radians(angle))*2*d_200);\t\t\t#Size of unit cell(in Angstrom)\n",
    "# Results\n",
    "print 'Size of unit cell in %.2f Angstrom'%a\n",
    "\n",
    "# book answer is wrong."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.27 Page No : 114"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Bragg angle(in degree) = 7.527\n"
     ]
    }
   ],
   "source": [
    "\t\t\t\n",
    "import math \n",
    "\n",
    "# Variables\n",
    "#Miller indices of plane\n",
    "h = 1.;\n",
    "k = 1.;\n",
    "l = 1.;\n",
    "wavelength = 0.54;\t\t\t#in angstrom\n",
    "a = 3.57;\t\t\t#size of a cube\n",
    "n = 1;\n",
    "\n",
    "# Calculation\n",
    "d_111 = a/(h**2+k**2+l**2)**(1./2);\t\t\t#interplanar spacing(in Angstrom)\n",
    "sinangle = (n*wavelength)/(2*d_111)\n",
    "angle = math.degrees(math.asin(sinangle))\n",
    "\n",
    "# Results\n",
    "print 'Bragg angle(in degree) = %.3f'%angle\n",
    "\n",
    "# rounding off error"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.28 Page No : 114"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Bragg reflection index for BCC crystal = 1.53\n"
     ]
    }
   ],
   "source": [
    "\t\t\t\n",
    "import math \n",
    "\n",
    "# Variables\n",
    "d = 1.181;\t\t\t  #A\n",
    "wavelength = 1.540;\t  #in angstrom\n",
    "angle = 90;\t\t\t  #in degrees\n",
    "\n",
    "# Calculation\n",
    "n = 2*d*math.sin(math.radians(angle))/(wavelength);\t\t\t#the bragg reflection index\n",
    "\n",
    "# Results\n",
    "print 'Bragg reflection index for BCC crystal = %.2f'%n\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.29 Page No : 114"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3rd order reflection angle = 31.40\n"
     ]
    }
   ],
   "source": [
    "\t\t\t\n",
    "import math \n",
    "\n",
    "# Variables\n",
    "n_1 = 1;\t\t\t#1st order reflection index\n",
    "angle_1 = 10;\t\t\t#1st order reflection angle\n",
    "n_3 = 3;\t\t\t#3rd order reflection index\n",
    "\n",
    "# Calculation\n",
    "#math.math.sin(math.radians(angle_1)/math.math.sin(math.radians(angle_3) = n_1/n_3\n",
    "sinangle_3 = n_3 * math.sin(math.radians(angle_1)/n_1);\t\t\t#\n",
    "angle_3 = math.degrees(math.asin(sinangle_3))\n",
    "\n",
    "# Results\n",
    "print '3rd order reflection angle = %.2f'%angle_3\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.30 Page No : 115"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "interplanar spacing of reflection plane 2.22 A\n",
      "miller indices of the reflection plane 2.0\n",
      "((110),(101),(011))\n"
     ]
    }
   ],
   "source": [
    "\t\t\t\n",
    "import math \n",
    "\n",
    "# Variables\n",
    "angle = 20.3;\t\t\t#in degree\n",
    "wavelength = 1.54;\t\t\t#in angstrom\n",
    "n = 1;\n",
    "a = 3.16;\t\t\t#lattice parameter in angstrom\n",
    "\n",
    "# Calculation\n",
    "d = n*wavelength/(2*math.sin(math.radians(angle)));\t\t\t#interplanar spacing\n",
    "M_indices = a**2/(d**2);\n",
    "\n",
    "# Results\n",
    "print 'interplanar spacing of reflection plane %.2f A'%d\n",
    "print 'miller indices of the reflection plane',floor(M_indices)\n",
    "print \"((110),(101),(011))\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.31 Page No : 115"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "interatomic spacing(in angstrom) = 3.46\n"
     ]
    }
   ],
   "source": [
    "\t\t\t\n",
    "\n",
    "import math \n",
    "\n",
    "# Variables\n",
    "#Miller indices of plane\n",
    "n = 1;\n",
    "h = 1;\n",
    "k = 1;\n",
    "l = 1;\n",
    "angle = 30;\t\t\t#in degree\n",
    "wavelength = 2;\t\t\t#in angstrom\n",
    "\n",
    "# Calculation\n",
    "d = n*wavelength/(2*math.sin(math.radians(angle)));\t\t\t#interplanar spacing\n",
    "a = d*(h**2+k**2+l**2)**(1./2);\t\t\t#interatomic spacing\n",
    "\n",
    "# Results\n",
    "print 'interatomic spacing(in angstrom) = %.2f'%a\n"
   ]
  }
 ],
 "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.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}