-
Notifications
You must be signed in to change notification settings - Fork 7
/
dspace.m
28 lines (20 loc) · 802 Bytes
/
dspace.m
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
function [ dspacing ] = dspace(hklvec,crystaltype, lattice_spacing)
%This function calculates the dspacing of an FCC or BCC crystal given
%the lattice parameter and hkl values. Input is given as
%dspace(latticeparameter,h,k,l). Units in Angstroms
dspacing=zeros(1,6);
if crystaltype==7
lattice_parametera=lattice_spacing(1);
lattice_parameterc=lattice_spacing(2);
for i=1:6
dspacing(i)=...
((4/3)*((hklvec{i}(1)^2 + hklvec{i}(1)*hklvec{i}(2) + hklvec{i}(2)^2)/lattice_parametera^2)+...
hklvec{i}(3)^2/lattice_parameterc^2)^-0.5;
end
else
lattice_parameter=lattice_spacing;
for i=1:6
dspacing(i)=(lattice_parameter/(sqrt((hklvec{i}(1)^2)+(hklvec{i}(2)^2)+(hklvec{i}(3)^2))));
end
end
end