Newer
Older
Laura Nervo
committed
function [symm_unique, symm_all] = gtCrystCalculateSymmetryOperators(phaseid, sg, crystal_system)
Laura Nervo
committed
% GTCRYSTCALCULATEREFLECTIONS Calculate the symmetry operators list using python
% from xfab library in fable (sg.py)
Laura Nervo
committed
% [symm_unique, symm_all] = gtCrystCalculateSymmetryOperators(phaseid, [sg], [crystal_system])
% --------------------------------------------------------------------------------------------
% If spacegroup and crystal_system are not provided, they are read from
% parameters.mat.
Laura Nervo
committed
%
% INPUT:
Laura Nervo
committed
% phaseid = <double> phase number {1}
% sg = <double> spacegroup number
% crystal_system = <string> crystal system
Laura Nervo
committed
%
% OUTPUT:
Laura Nervo
committed
% symm_unique = <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>
% symm_all = <struct 1xM> contains :
% .g3 = rotations (complete list using symmetry operators) <double 3x3>
% .trans = translation values from symmetry operators <double 1x3>
Laura Nervo
committed
%
Laura Nervo
committed
% Version 002 26-11-2013 by LNervo
% Changed output names to 'symm_unique' and 'symm_all'
% Changed symm_all.rot to symm_all.g3
% Removed default value for phaseid
Laura Nervo
committed
%
% Version 001 10-12-2012 by LNervo
if ~exist('sg','var') || isempty(sg)
parameters = [];
load('parameters.mat');
sg = parameters.cryst(phaseid).spacegroup;
Laura Nervo
committed
end
Laura Nervo
committed
if ~exist('crystal_system','var') || isempty(crystal_system)
parameters = [];
load('parameters.mat');
crystal_system = parameters.cryst(phaseid).crystal_system;
Laura Nervo
committed
end
global GT_MATLAB_HOME;
script_file = fullfile(GT_MATLAB_HOME, 'zUtil_Python', 'symmetry_operators_list.py');
Laura Nervo
committed
[~, msg] = gtPythonCommand([script_file ' ' num2str(sg) ' ' crystal_system], true);
Laura Nervo
committed
% read produced files
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','#');
Laura Nervo
committed
all_rotN = gtReadTextFile(['sg_rot_' crystal_system '.txt'],'%f %f %f',[3 3],true,'Delimiter',' ','CommentStyle','#');
all_transN = gtReadTextFile(['sg_trans_' crystal_system '.txt'],'%f %f %f',[1 3],true,'Delimiter',' ','CommentStyle','#');
Laura Nervo
committed
Laura Nervo
committed
symm_unique = struct('g3', rotN, 'perm', permN);
if nargout == 2
Laura Nervo
committed
symm_all = struct('g3', all_rotN, 'trans', all_transN);
Laura Nervo
committed
end
end % end of function