Skip to content
Snippets Groups Projects
Commit 5ba14b50 authored by Laura Nervo's avatar Laura Nervo
Browse files

gtCrystCalculateSymmetryOperators : Changed output names to 'symm_unique' and...

gtCrystCalculateSymmetryOperators : Changed output names to 'symm_unique' and 'symm_all'; changed symm_all.rot to symm_all.g3; removed default value for phaseid
symmetry_operators_list.py        : added check for spacegroup number and added input argument #2 for the crystal system

Signed-off-by: default avatarLaura Nervo <laura.nervo@esrf.fr>
parent d8643219
No related branches found
No related tags found
No related merge requests found
function [symm, sg] = gtCrystCalculateSymmetryOperators(phaseid, sg, crystal_system)
function [symm_unique, symm_all] = 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])
% ----------------------------------------------------------------------------------
% [symm_unique, symm_all] = gtCrystCalculateSymmetryOperators(phaseid, [sg], [crystal_system])
% --------------------------------------------------------------------------------------------
% If spacegroup and crystal_system are not provided, they are read from
% parameters.mat.
%
% INPUT:
% phaseid = <double> phase number {1}
% sg = <double> spacegroup number
% crystal_system = <string> crystal system
% phaseid = <double> phase number {1}
% sg = <double> spacegroup number
% crystal_system = <string> crystal system
%
% OUTPUT:
% 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>
% 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>
%
% 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
%
% Version 001 10-12-2012 by LNervo
if ~exist('phaseid','var') || isempty(phaseid)
phaseid = 1;
end
if ~exist('sg','var') || isempty(sg)
parameters = [];
load('parameters.mat');
sg = parameters.cryst(phaseid).spacegroup;
if ~exist('crystal_system','var') || isempty(crystal_system)
crystal_system = parameters.cryst(phaseid).crystal_system;
end
end
if ~exist('crystal_system','var') || isempty(crystal_system)
parameters = [];
load('parameters.mat');
crystal_system = parameters.cryst(phaseid).crystal_system;
end
global GT_MATLAB_HOME;
script_file = fullfile(GT_MATLAB_HOME, 'zUtil_Python', 'symmetry_operators_list.py');
[~, msg] = gtPythonCommand([script_file ' ' num2str(sg)], true);
[~, msg] = gtPythonCommand([script_file ' ' num2str(sg) ' ' crystal_system], true);
disp(msg);
% 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','#');
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','#');
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','#');
symm = struct('g3', rotN, 'perm', permN);
symm_unique = struct('g3', rotN, 'perm', permN);
if nargout == 2
sg = struct('rot', sg_rotN, 'trans', sg_transN);
symm_all = struct('g3', all_rotN, 'trans', all_transN);
end
end % end of function
......@@ -20,21 +20,44 @@ from xfab.symmetry import tools
from xfab import sg
_sgno = int(sys.argv[1])
_crystalsystem = sys.argv[2]
print("")
print(" *** Input data ***")
print(" spacegroup: %s" % _sgno)
print(" spacegroup : %d" % _sgno)
if _sgno != None:
if (_sgno >= 0 and _sgno <= 230):
spg = sg.sg(sgno=_sgno)
# number of symmetry operators
nsymop = spg.nsymop
# crystal system
crystal_system = spg.crystal_system
if _crystalsystem is not None:
crystal_system = _crystalsystem
else:
crystal_system = spg.crystal_system
print(" crystal system: %s" % crystal_system)
print("")
if crystal_system == "triclinic":
nsystem = 1
elif crystal_system == "monoclinic":
nsystem = 2
elif crystal_system == "orthorhombic":
nsystem = 3
elif crystal_system == "tetragonal":
nsystem = 4
elif crystal_system == "trigonal":
nsystem = 5
elif crystal_system == "hexagonal":
nsystem = 6
elif crystal_system == "cubic":
nsystem = 7
else:
raise ValueError, 'The crystal system is not know'
print("Found %d symmetry operators for crystal system %s\n" % (nsymop, crystal_system))
# rotations list
......@@ -69,24 +92,6 @@ if _sgno != None:
print("...done!")
if crystal_system == "triclinic":
nsystem = 1
elif crystal_system == "monoclinic":
nsystem = 2
elif crystal_system == "orthorhombic":
nsystem = 3
elif crystal_system == "tetragonal":
nsystem = 4
elif crystal_system == "trigonal":
nsystem = 5
elif crystal_system == "hexagonal":
nsystem = 6
elif crystal_system == "cubic":
nsystem = 7
else:
print("Crystal system is not know")
# calculation of rotations
calc_rot = symmetry.rotations(nsystem)
# calc_rot_nf = calc_rot.reshape( calc_rot.shape[0]*calc_rot.shape[1], calc_rot.shape[2])
......@@ -119,4 +124,4 @@ if _sgno != None:
print("...done!")
else:
raise ValueError, 'No space group information given'
raise ValueError, 'Space group information is wrong'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment