Skip to content
Snippets Groups Projects
Commit 3c268494 authored by Laura Nervo's avatar Laura Nervo Committed by Nicola Vigano
Browse files

Updating and improving the generation of the lists with symmetry operators and...

Updating and improving the generation of the lists with symmetry operators and reflections for each space group.

Changes:
- gtCrystCalculateReflections : removed calculation of symmetry operators, done now in gtCrystCalculateSymmetryOperators; the function is needed to get the reflection list only, using script "reflections_list.py
- gtCrystCalculateSymmetryOperators : calculates symmetry operators given a space group (using python script "symmetry_operators_list.py"

Renamed create_reflections_list.py into reflections_list.py

Signed-off-by: default avatarLaura Nervo <laura.nervo@esrf.fr>

git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@955 4c865b51-4357-4376-afb4-474e03ccb993
parent 3eeb6bee
No related branches found
No related tags found
No related merge requests found
function [hkl, theta, hkil, sintheta] = gtCrystCalculateReflections(latticepar, mintheta, maxtheta, sg, typelist, filename)
% GTCRYSTCALCULATEREFLECTIONS Calculate the reflections list using python
% from fable library (genhkl_all or genhkl_unique
% scripts)
% from xfab library in fable
% [hkl, theta, hkil, sintheta] = gtCrystCalculateReflections(latticepar, mintheta, maxtheta, sg, typelist, filename)
% ------------------------------------------------------------------------------------------------------------------
%
......@@ -10,8 +9,8 @@ function [hkl, theta, hkil, sintheta] = gtCrystCalculateReflections(latticepar,
% mintheta = minimum sin(theta)/lambda allowed <double> {0.0001}
% maxtheta = maximum sin(theta)/lambda allowed <double>
% sg = spacegroup number <int>
% typelist = type of list <string> [{'all'}/'unique]
% filename = filename for output <string>
% typelist = type of list <string> [{'all'}/'unique']
% filename = filename for output <string>
%
% OUTPUT:
% hkl = reflection list <double>
......@@ -44,15 +43,13 @@ if ~exist('typelist','var') || isempty(typelist)
typelist = 'all';
end
if ~exist('filename','var') || isempty(filename)
filename = 'reflections';
filename = 'reflections_';
end
latticepar_str = sprintf('%f ', latticepar);
script_file = fullfile('/users/',getenv('USER'),'matlabDCT','zUtil_Python','create_reflections_list.py');
script_file = fullfile('/users/',getenv('USER'),'matlabDCT','zUtil_Python','reflections_list.py');
cmd = sprintf('python26 %s %s %f %f %d %s %s',...
script_file,latticepar_str,mintheta,maxtheta,sg,typelist,filename);
[~,msg]=unix(cmd);
disp(msg)
......@@ -83,7 +80,7 @@ else
disp(' h k l sin(theta)/lambda')
disp('---------------------------------')
for ii=1:size(hkl,1)
fprintf('%3d %3d %3d %7.3f\n',hkl(ii,:),sintheta(ii))
fprintf('%3d %3d %3d %7.3f\n',hkl(ii,:),sinth(ii))
end
end
......
function [perm, rot, sg_rot, sg_trans] = gtCrystCalculateSymmetryOperators(sg, crystal_system)
% GTCRYSTCALCULATEREFLECTIONS Calculate the symmetry operators list using python
% from xfab library in fable (sg.py)
% [perm, rot, sg_rot, sg_trans] = gtCrystCalculateSymmetryOperators(sg, crystal_system)
% -------------------------------------------------------------------------------------
%
% INPUT:
% sg = spacegroup number <int>
% crystal_system = crystal system <string>
%
% OUTPUT:
% perm = set of indistinguishable lattice permutations
% rot = set of unitary rotation matrices corresponding to the indistinguishable lattice permutations
% sg_rot = rotations (complete list using symmetry operators)
% sg_trans = transition values from symmetry operators
%
%
% Version 001 10-12-2012 by LNervo
if ~exist('sg','var') || isempty(sg)
load parameters;
sg = parameters.cryst(1).spacegroup;
end
if ~exist('crystal_system','var') || isempty(crystal_system)
load parameters;
crystal_system = parameters.cryst(1).crystal_system;
end
script_file = fullfile('/users/',getenv('USER'),'matlabDCT','zUtil_Python','symmetry_operators_list.py');
cmd = sprintf('python26 %s %d',script_file,sg);
[~,msg]=unix(cmd);
disp(msg)
% read produced files
perm = gtReadTextFile(['perm_' crystal_system '.txt'],'%f %f %f',' ','#',[3 3]);
rotN = gtReadTextFile(['rot_' crystal_system '.txt'],'%f %f %f',' ','#',[3 3]);
sg_rotN = gtReadTextFile(['sg_rot_' crystal_system '.txt'],'%f %f %f',' ','#',[3 3]);
sg_transN = gtReadTextFile(['sg_trans_' crystal_system '.txt'],'%f %f %f',' ','#',[1 3]);
if nargout > 1
rot = rotN;
if nargout > 2
sg_rot = sg_rotN;
if nargout > 3
sg_trans = sg_transN;
end
end
end
end % end of function
#!/usr/bin/python26
'''
Created on Dec 03, 2012
@author: lnervo
Based on the algorithm described in
Le Page and Gabe (1979) J. Appl. Cryst., 12, 464-466
and implemented in python by
Henning Osholm Sorensen, University of Copenhagen, July 22, 2010.
'''
import sys, os, numpy as np
from xfab import *
from xfab import symmetry
from xfab.symmetry import *
from xfab.symmetry import tools
_a = float(sys.argv[1])
_b = float(sys.argv[2])
_c = float(sys.argv[3])
_alpha = float(sys.argv[4])
_beta = float(sys.argv[5])
_gamma = float(sys.argv[6])
_mintheta = float(sys.argv[7])
_maxtheta = float(sys.argv[8])
_sgno = int(sys.argv[9])
_type = sys.argv[10]
_output = sys.argv[11]
print("")
print(" *** Input data ***")
print(" lattice parameters: (%f,%f,%f,%f,%f,%f)"
% (_a, _b, _c, _alpha, _beta, _gamma))
print(" sin(theta)/lambda range: %f,%f" % (_mintheta, _maxtheta))
print(" spacegroup: %s" % _sgno)
print(" type: %s" % _type)
print("")
print(" *** Reflections list calculation ***")
if _type == 'all':
list = symmetry.tools.genhkl_all([_a,_b,_c,_alpha,_beta,_gamma],
_mintheta,_maxtheta,sgno=_sgno,
output_stl=True)
elif _type == 'unique':
list = symmetry.tools.genhkl_unique([_a,_b,_c,_alpha,_beta,_gamma],
_mintheta,_maxtheta,sgno=_sgno,
output_stl=True)
else:
print("Type not known...Existing")
list = None
_outputfile = _output + _type
if list is not None:
print("Saving %d reflections generated for spacegroup %d - from symmetry.tools.genhkl_%s...\n"
% (len(list), _sgno, _type))
with file(_outputfile + '.txt','w') as outfile:
outfile.write('# Reflection list: {0}\n'.format(list.shape))
outfile.write('# h k l sin(theta)/lambda\n')
np.savetxt(outfile, list, fmt=('%d','%d','%d','%f'))
print("...done!")
#!/usr/bin/python26
'''
Created on Dec 03, 2012
Created on Dec 10, 2012
@author: lnervo
Based on the algorithm described in
......@@ -11,7 +11,7 @@ and implemented in python by
Henning Osholm Sorensen, University of Copenhagen, July 22, 2010.
'''
import sys, os, numpy as np
import sys, numpy as np
from xfab import *
from xfab import symmetry
......@@ -19,65 +19,25 @@ from xfab.symmetry import *
from xfab.symmetry import tools
from xfab import sg
_a = float(sys.argv[1])
_b = float(sys.argv[2])
_c = float(sys.argv[3])
_alpha = float(sys.argv[4])
_beta = float(sys.argv[5])
_gamma = float(sys.argv[6])
_mintheta = float(sys.argv[7])
_maxtheta = float(sys.argv[8])
_sgno = int(sys.argv[9])
_type = sys.argv[10]
_output = sys.argv[11]
_sgno = int(sys.argv[1])
print("")
print(" *** Input data ***")
print(" lattice parameters: (%f,%f,%f,%f,%f,%f)"
% (_a, _b, _c, _alpha, _beta, _gamma))
print(" sin(theta)/lambda range: %f,%f" % (_mintheta, _maxtheta))
print(" spacegroup: %s" % _sgno)
print(" type: %s" % _type)
print("")
print(" *** Reflections list calculation ***")
if _type == 'all':
list = symmetry.tools.genhkl_all([_a,_b,_c,_alpha,_beta,_gamma],
_mintheta,_maxtheta,sgno=_sgno,
output_stl=True)
elif _type == 'unique':
list = symmetry.tools.genhkl_unique([_a,_b,_c,_alpha,_beta,_gamma],
_mintheta,_maxtheta,sgno=_sgno,
output_stl=True)
else:
print("Type not known...Existing")
list = None
_outputfile = _output + _type
if list is not None:
print("Saving %d reflections generated for spacegroup %d - from symmetry.tools.genhkl_%s...\n"
% (len(list), _sgno, _type))
with file(_outputfile + '.txt','w') as outfile:
outfile.write('# Reflection list: {0}\n'.format(list.shape))
outfile.write('# h k l sin(theta)/lambda\n')
np.savetxt(outfile, list, fmt=('%d','%d','%d','%f'))
print("...done!")
# list of symmetry operators for crystal system
if _sgno != None:
spg = sg.sg(sgno=_sgno)
# number of symmetry operators
nsymop = spg.nsymop
# rotations list
rot = spg.rot
# crystal system
crystal_system = spg.crystal_system
print("Found %d symmetry operators for crystal system %s\n" % (nsymop, crystal_system))
# rotations list
rot = spg.rot
# trans info
trans = spg.trans
......
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