Skip to content
Snippets Groups Projects
gtSymmetricReflections.m 2.04 KiB
function results = gtSymmetricReflections(cryst,energy)
% GTSYMMETRICREFLECTIONS  Gets all the hkl signed reflections and calculate
%                         properly d-spacing and twotheta-type
%     results = gtSymmetricReflections(cryst,energy)
%     --------------------------------------------
%
%     INPUT 
%       cryst.hkl              - row vector of Miller indices;
%       cryst.crystal_system   - crystal system of lattice
%                                size nx3 or nx4 for hexagonal
%       cryst.latticepar       - lattice parameters
%       cryst.spacegroup       - spacegroup
%       cryst.hermann_mauguin  - Hermann-Mauguin symbol
%       energy                 - beam energy in keV 
%
%     MODIFICATIONS
%      08-03-2012 by PReischig
%       Changed input format: separated 'parameters' into 'cryst' and
%       'energy'.
%
%     FUNCTIONS CALLED:
%[use]- gtCrystSignedHKLs
%[use]- gtCalculateDist

hkltypes_used = cryst.hkl;
hkltypes_used = double(hkltypes_used);
% 4 columns needed for hexagonal

if strcmpi(cryst.crystal_system,'hexagonal') && size(hkltypes_used,2)==3
    hkltypes_used(:,4) = hkltypes_used(:,3);
    hkltypes_used(:,3) = -hkltypes_used(:,1)-hkltypes_used(:,2);
end

hklsp  = [];
hkl    = [];
thtype = [];
dsp    = [];
twoth  = [];
int    = [];


% 4 columns needed for hexagonal
for i = 1:size(hkltypes_used,1)
    allhkls_i = gtCrystSignedHKLs(hkltypes_used(i,:),cryst.spacegroup);
    nhkls     = size(allhkls_i,1)/2;
    hklsp     = [hklsp; allhkls_i(nhkls+1:end,:)];
    hkl       = [hkl; repmat(hkltypes_used(i,:),nhkls,1)];
    thtype    = [thtype; repmat(i,nhkls,1)];
    int       = [int; repmat(cryst.int(i),nhkls,1)];
end

for j=1:size(hklsp,1)
    % calculate d-spacing and twotheta for each reflection
    [dd,tmp,ttt] = gtCalculateDist(hklsp(j,:), cryst, energy);
    dsp(j)=dd;
    twoth(j)=ttt;
end

% simpler output (should ditch the hashtable)
results.hklsp       = hklsp;
results.thetasp     = twoth'/2;
results.dspacingsp  = dsp';
results.thetatypesp = thtype;
results.intsp       = int;

clear tmp dd ttt

end % end of function