Newer
Older
function [allshkls, allhklinds, mult, hklsp, thtype] = gtCrystSignedHKLs(hkl, symm)
% GTCRYSTSIGNEDHKLS Gives a complete list of signed hkl planes, by
% applying symmetry operators of the specified spacegroup to the input
% list of plane families.
% Should be revised for at least other than cubic lattices. Use of
% 'lattice_system' and 'crystal_system' instead of spacegroups should
% be considered.
%
% [allshkls, allhklinds, mult, hklsp, thtype] = gtCrystSignedHKLs(hkl, symm)
% --------------------------------------------------------------------------
%
% INPUT:
% hkl = <double> plane families (one in a row) as in
% (n,3) for cubic lattices
% (n,4) for hexagonal lattices
Laura Nervo
committed
% symm = <struct> structure containing .g3/.g with symmetry
% operators
%
% OUTPUT:
% allshkls = <double> complete list of signed hkl planes
Laura Nervo
committed
% (including Friedel pairs)
% allhklinds = <double> indices in allshkls according to input hkl
% mult = <double> multiplicity of hkl families (1,k)
% hklsp = <double> list of all the hkls (friedel not considered)
% thtype = <double> theta types among the given reflections
% according to input hkl
%
%
% Version 003 21-08-2013 by LNervo
% Added output hklsp and thtype to simplify calculation
Laura Nervo
committed
% Version 002 10-07-2013 by LNervo
% Added check of class for hkl list
if ~isa(hkl,'double')
hkl = double(hkl);
end
Wolfgang Ludwig
committed
Laura Nervo
committed
% reflections in rows
Wolfgang Ludwig
committed
if ~isrow(hkl)
hkl = hkl';
end
Laura Nervo
committed
if ~exist('symm','var') || isempty(symm)
load parameters
% Get symmetry operators
Laura Nervo
committed
symm = gtCrystGetSymmetryOperators(parameters.cryst.crystal_system, parameters.cryst.spacegroup);
Laura Nervo
committed
end
Laura Nervo
committed
ncols = size(hkl,2);
Laura Nervo
committed
if ncols > 4
gtError('gtCrystSignedHKLs:wrongSize','Something went wrong with the size of hkl list...Quitting')
end
Laura Nervo
committed
allshkls = [];
allhklinds = [];
mult = [];
hklsp = [];
thtype = [];
% Loop through input hkl types
Yoann Guilhem
committed
for ii = 1:size(hkl,1)
shkls = [];
Yoann Guilhem
committed
% Apply all symmmetry operators to the hkl type to get signed hkl-s
Yoann Guilhem
committed
for jj = 1:length(symm)
Laura Nervo
committed
shkls(2*jj-1,:) = hkl(ii,:)*symm{jj};
shkls(2*jj,:) = -shkls(2*jj-1,:); % Friedel pair of previous one
end
Laura Nervo
committed
% Remove duplicates and add to the complete list
newshkls = unique(shkls, 'rows');
Laura Nervo
committed
% sort according to h > k > l
newshkls = sortrows(newshkls, [-1 -2 -ncols]);
nhkls = size(newshkls,1)/2;
Laura Nervo
committed
allhklinds = [allhklinds; repmat(ii,nhkls*2,1)];
%newshkls = sortrows(newshkls, [ncols 1 2]);
hklsp = [hklsp; newshkls(nhkls+1:end,:)];
thtype = [thtype; repmat(ii,nhkls,1)];