summaryrefslogtreecommitdiff
path: root/635/CH8/EX8.13/Ch08Ex13.sci
blob: c79943c5f95aec690b4d282a1bf3757c2fc126dc (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
// Scilab code Ex8.13: Bragg angle and the indices of diffraction of Powder Lines Page 285 (2010)
n = 1;    // Cosider first order diffraction
a = 6e-010;    // First lattice parameter of direct lattice, m
lambda = 1.54e-010;    // Wavelength used in diffraction of X-rays by Powder Method, m
// Declare a function for converting angle into degrees and minutes
function [d,m] = degree_minute(n)    
         d = int(n);
         m = (n-int(n))*60;
endfunction  
// Calculate the hkl and hence interpalnar spacing 'd' for three lowest powder lines
printf("\nThe Bragg angles and the indices of diffraction for the three lowest powder lines are:");
for h = 0:1:2
    for k = 0:1:2
        for l = 0:1:1
            if (modulo(h,2) == 1 & modulo(k,2) == 1 & modulo (l,2) == 1) | (modulo(h,2) == 0 & modulo(k,2) == 0 & modulo (l,2) == 0) then
                if (h <> 0) then
                    N = h^2+k^2+l^2;
                    d = a/sqrt(N);    // Interplanar spacing, metre
                    theta = asind(n*lambda/(2*d));
                    [deg, mint] = degree_minute(theta);    // Call conversion function
                    printf("\nd[%d%d%d] = %4.2e and theta[%d%d%d] = %d deg %d min", h, k, l, d, h, k, l, deg, mint);
                end
            end
         end      
    end
end    
// Result
// The Bragg angles and the indices of diffraction for the three lowest powder lines are:
// d[111] = 3.46e-010 and theta[111] = 12 deg 50 min
// d[200] = 3.00e-010 and theta[200] = 14 deg 52 min
// d[220] = 2.12e-010 and theta[220] = 21 deg 17 min