Skip to content
Snippets Groups Projects
gtCrystCalculateSymmetryOperators.m 2.34 KiB
Newer Older
function [symm, sg] = gtCrystCalculateSymmetryOperators(phaseid, sg, crystal_system)
% GTCRYSTCALCULATEREFLECTIONS  Calculate the symmetry operators list using python 
%                              from xfab library in fable (sg.py)
%     [symm, sg] = gtCrystCalculateSymmetryOperators(phaseid, [sg], [crystal_system])
%     ----------------------------------------------------------------------------------
%     If spacegroup and crystal_system are not provided, they are read from
%     parameters.mat.
%       phaseid        = <double>     phase number {1}
%       sg             = <double>     spacegroup number
%       crystal_system = <string>     crystal system
%       symm = <struct 1xN> contains :
%           .perm = set of indistinguishable lattice permutations <double 3x3>
%           .g3   = set of unitary rotation matrices corresponding to the
%                   indistinguishable lattice permutations <double 3x3>
%       sg = <struct 1xM> contains :
%            .rot   = rotations (complete list using symmetry operators) <double 3x3>
%            .trans = translation values from symmetry operators <double 1x3>
if ~exist('phaseid','var') || isempty(phaseid)
    phaseid = 1;
end
    parameters = [];
    load('parameters.mat');
    sg = parameters.cryst(phaseid).spacegroup;
    
    if ~exist('crystal_system','var') || isempty(crystal_system)
        crystal_system = parameters.cryst(phaseid).crystal_system;
global GT_MATLAB_HOME;
script_file = fullfile(GT_MATLAB_HOME, 'zUtil_Python', 'symmetry_operators_list.py');
[~, msg] = gtPythonCommand([script_file ' ' num2str(sg)], true);
disp(msg);
permN     = gtReadTextFile(['perm_' crystal_system '.txt'],'%f %f %f',[3 3],true,'Delimiter',' ','CommentStyle','#');
rotN      = gtReadTextFile(['rot_' crystal_system '.txt'],'%f %f %f',[3 3],true,'Delimiter',' ','CommentStyle','#');
sg_rotN   = gtReadTextFile(['sg_rot_' crystal_system '.txt'],'%f %f %f',[3 3],true,'Delimiter',' ','CommentStyle','#');
sg_transN = gtReadTextFile(['sg_trans_' crystal_system '.txt'],'%f %f %f',[1 3],true,'Delimiter',' ','CommentStyle','#');
symm = struct('g3', rotN, 'perm', permN);
    sg = struct('rot', sg_rotN, 'trans', sg_transN);