1 | "GSASII - Space group interpretion routines" |
---|
2 | |
---|
3 | |
---|
4 | import numpy as np |
---|
5 | import sys |
---|
6 | import os.path as ospath |
---|
7 | |
---|
8 | # determine a binary path based on the host OS and the python version, path |
---|
9 | # is relative to the location of this file |
---|
10 | if sys.platform == "win32": |
---|
11 | bindir = 'binwin%d.%d' % sys.version_info[0:2] |
---|
12 | elif sys.platform == "darwin": |
---|
13 | bindir = 'binmac%d.%d' % sys.version_info[0:2] |
---|
14 | if sys.byteorder == 'big': |
---|
15 | bindir += 'PPC' |
---|
16 | elif sys.platform == "linux2": |
---|
17 | bindir = 'binlinux%d.%d' % sys.version_info[0:2] |
---|
18 | else: |
---|
19 | bindir = 'bin' |
---|
20 | mypath = ospath.split(ospath.abspath( __file__ ))[0] |
---|
21 | bindir = ospath.join(mypath,bindir) |
---|
22 | if ospath.exists(bindir): |
---|
23 | if bindir not in sys.path: sys.path.insert(0,bindir) |
---|
24 | else: |
---|
25 | print 'Expected binary directory (%s) for pyspg not found' % bindir |
---|
26 | # use local bin directory preferentially |
---|
27 | bindir = ospath.join(mypath,'bin') |
---|
28 | if ospath.exists(bindir): |
---|
29 | if bindir not in sys.path: sys.path.insert(0,bindir) |
---|
30 | |
---|
31 | import pyspg as pyd |
---|
32 | |
---|
33 | def SpcGroup(SGSymbol): |
---|
34 | ''' |
---|
35 | Determines cell and symmetry information from a short H-M space group name |
---|
36 | input: space group symbol (string) with spaces between axial fields |
---|
37 | returns [SGError,SGData] |
---|
38 | SGError = 0 for no errors; >0 for errors (see SGErrors below for details) |
---|
39 | returns dictionary SGData with entries: |
---|
40 | 'SpGrp': space group symbol slightly cleaned up |
---|
41 | 'Laue': one of '-1','2/m','mmm','4/m','4/mmm','3R','3mR','3', |
---|
42 | '3m1','31m','6/m','6/mmm','m3','m3m' |
---|
43 | 'SGInv': boolean; True if centrosymmetric, False if not |
---|
44 | 'SGLatt': one of 'P','A','B','C','I','F','R' |
---|
45 | 'SGUniq': one of 'a','b','c' if monoclinic, '' otherwise |
---|
46 | 'SGCen': cell centering vectors [0,0,0] at least |
---|
47 | 'SGOps': symmetry operations as [M,T] so that M*x+T = x' |
---|
48 | 'SGSys': one of 'triclinic','monoclinic','orthorhombic','tetragonal','rhombohedral','trigonal','hexagonal','cubic' |
---|
49 | ''' |
---|
50 | LaueSym = ('-1','2/m','mmm','4/m','4/mmm','3R','3mR','3','3m1','31m','6/m','6/mmm','m3','m3m') |
---|
51 | LattSym = ('P','A','B','C','I','F','R') |
---|
52 | UniqSym = ('','','a','b','c','',) |
---|
53 | SysSym = ('triclinic','monoclinic','orthorhombic','tetragonal','rhombohedral','trigonal','hexagonal','cubic') |
---|
54 | SGData = {} |
---|
55 | SGData['SpGrp'] = SGSymbol.strip().lower().capitalize() |
---|
56 | SGInfo = pyd.sgforpy(SGSymbol) |
---|
57 | SGData['SGLaue'] = LaueSym[SGInfo[0]-1] |
---|
58 | SGData['SGInv'] = bool(SGInfo[1]) |
---|
59 | SGData['SGLatt'] = LattSym[SGInfo[2]-1] |
---|
60 | SGData['SGUniq'] = UniqSym[SGInfo[3]+1] |
---|
61 | if SGData['SGLatt'] == 'P': |
---|
62 | SGData['SGCen'] = np.array(([0,0,0],)) |
---|
63 | elif SGData['SGLatt'] == 'A': |
---|
64 | SGData['SGCen'] = np.array(([0,0,0],[0,.5,.5])) |
---|
65 | elif SGData['SGLatt'] == 'B': |
---|
66 | SGData['SGCen'] = np.array(([0,0,0],[.5,0,.5])) |
---|
67 | elif SGData['SGLatt'] == 'C': |
---|
68 | SGData['SGCen'] = np.array(([0,0,0],[.5,.5,0,])) |
---|
69 | elif SGData['SGLatt'] == 'I': |
---|
70 | SGData['SGCen'] = np.array(([0,0,0],[.5,.5,.5])) |
---|
71 | elif SGData['SGLatt'] == 'F': |
---|
72 | SGData['SGCen'] = np.array(([0,0,0],[0,.5,.5],[.5,0,.5],[.5,.5,0,])) |
---|
73 | elif SGData['SGLatt'] == 'R': |
---|
74 | SGData['SGCen'] = np.array(([0,0,0],[1./3.,2./3.,2./3.],[2./3.,1./3.,1./3.])) |
---|
75 | SGData['SGOps'] = [] |
---|
76 | for i in range(SGInfo[5]): |
---|
77 | Mat = np.array(SGInfo[6][i]) |
---|
78 | Trns = np.array(SGInfo[7][i]) |
---|
79 | SGData['SGOps'].append([Mat,Trns]) |
---|
80 | if SGData['SGLaue'] in '-1': |
---|
81 | SGData['SGSys'] = SysSym[0] |
---|
82 | elif SGData['SGLaue'] in '2/m': |
---|
83 | SGData['SGSys'] = SysSym[1] |
---|
84 | elif SGData['SGLaue'] in 'mmm': |
---|
85 | SGData['SGSys'] = SysSym[2] |
---|
86 | elif SGData['SGLaue'] in ['4/m','4/mmm']: |
---|
87 | SGData['SGSys'] = SysSym[3] |
---|
88 | elif SGData['SGLaue'] in ['3R','3mR']: |
---|
89 | SGData['SGSys'] = SysSym[4] |
---|
90 | elif SGData['SGLaue'] in ['3','3m1','31m']: |
---|
91 | SGData['SGSys'] = SysSym[5] |
---|
92 | elif SGData['SGLaue'] in ['6/m','6/mmm']: |
---|
93 | SGData['SGSys'] = SysSym[6] |
---|
94 | elif SGData['SGLaue'] in ['m3','m3m']: |
---|
95 | SGData['SGSys'] = SysSym[7] |
---|
96 | return SGInfo[8],SGData |
---|
97 | |
---|
98 | def SGErrors(IErr): |
---|
99 | '''Interprets the error message code from SpcGroup. Used in SpaceGroup. |
---|
100 | input: SGError, from SpcGroup |
---|
101 | returns a string with the error message or "Unknown error" |
---|
102 | ''' |
---|
103 | |
---|
104 | ErrString = [' ', |
---|
105 | 'Less than 2 operator fields were found', |
---|
106 | 'Illegal Lattice type, not P, A, B, C, I, F or R', |
---|
107 | 'Rhombohedral lattice requires a 3-axis', |
---|
108 | 'Minus sign does not preceed 1, 2, 3, 4 or 6', |
---|
109 | 'Either a 5-axis anywhere or a 3-axis in field not allowed', |
---|
110 | ' ', |
---|
111 | 'I for COMPUTED GO TO out of range.', |
---|
112 | 'An a-glide mirror normal to A not allowed', |
---|
113 | 'A b-glide mirror normal to B not allowed', |
---|
114 | 'A c-glide mirror normal to C not allowed', |
---|
115 | 'D-glide in a primitive lattice not allowed', |
---|
116 | 'A 4-axis not allowed in the 2nd operator field', |
---|
117 | 'A 6-axis not allowed in the 2nd operator field', |
---|
118 | 'More than 24 matrices needed to define group', |
---|
119 | ' ', |
---|
120 | 'Improper construction of a rotation operator', |
---|
121 | 'Mirror following a / not allowed', |
---|
122 | 'A translation conflict between operators', |
---|
123 | 'The 2bar operator is not allowed', |
---|
124 | '3 fields are legal only in R & m3 cubic groups', |
---|
125 | 'Syntax error. Expected I -4 3 d at this point', |
---|
126 | ' ', |
---|
127 | 'A or B centered tetragonal not allowed', |
---|
128 | ' ','unknown error in sgroup',' ',' ',' ', |
---|
129 | 'Illegal character in the space group symbol', |
---|
130 | ] |
---|
131 | try: |
---|
132 | return ErrString[IErr] |
---|
133 | except: |
---|
134 | return "Unknown error" |
---|
135 | |
---|
136 | def SGPrint(SGData): |
---|
137 | ''' |
---|
138 | Print the output of SpcGroup in a nicely formatted way. Used in SpaceGroup |
---|
139 | input: SGData, from SpcGroup |
---|
140 | returns a list of strings with the space group details |
---|
141 | ''' |
---|
142 | XYZ = ('-Z ','-Y ','-X ','X-Y','ERR','Y-X',' X ',' Y ',' Z ','+X ','+Y ','+Z ') |
---|
143 | TRA = (' ','ERR','1/6','1/4','1/3','ERR','1/2','ERR','2/3','3/4','5/6','ERR') |
---|
144 | POL = (' ','x','y','x y','z','x z','y z','xyz','111') |
---|
145 | Mult = len(SGData['SGCen'])*len(SGData['SGOps'])*(int(SGData['SGInv'])+1) |
---|
146 | NP = [1,2,4] |
---|
147 | NPZ = [0,1] |
---|
148 | for M,T in SGData['SGOps']: |
---|
149 | for i in range(3): |
---|
150 | if M[i][i] <= 0.: NP[i] = 0 |
---|
151 | if M[0][2] > 0: NPZ[0] = 8 |
---|
152 | if M[1][2] > 0: NPZ[1] = 0 |
---|
153 | NPol = (NP[0]+NP[1]+NP[2]+NPZ[0]*NPZ[1])*(1-int(SGData['SGInv'])) |
---|
154 | SGText = [] |
---|
155 | SGText.append('Space Group '+SGData['SpGrp']) |
---|
156 | CentStr = 'centrosymmetric' |
---|
157 | if not SGData['SGInv']: |
---|
158 | CentStr = 'non'+CentStr |
---|
159 | if SGData['SGLatt'] in 'ABCIFR': |
---|
160 | SGText.append('The lattice is '+CentStr+' '+SGData['SGLatt']+'-centered '+SGData['SGSys'].lower()) |
---|
161 | else: |
---|
162 | SGText.append('The lattice is '+CentStr+' '+'primitive '+SGData['SGSys'].lower()) |
---|
163 | SGText.append('Multiplicity of a general site is '+str(Mult)) |
---|
164 | SGText.append('The Laue symmetry is '+SGData['SGLaue']) |
---|
165 | if SGData['SGUniq'] in ['a','b','c']: |
---|
166 | SGText.append('The unique monoclinic axis is '+SGData['SGUniq']) |
---|
167 | if SGData['SGInv']: |
---|
168 | SGText.append('The inversion center is located at 0,0,0') |
---|
169 | if NPol: |
---|
170 | SGText.append('The location of the origin is arbitrary in '+POL[NPol]) |
---|
171 | SGText.append('\n'+'The equivalent positions are:') |
---|
172 | if SGData['SGLatt'] in 'A': |
---|
173 | SGText.append('\n'+' (0,0,0; 0,1/2,1/2)+') |
---|
174 | elif SGData['SGLatt'] in 'B': |
---|
175 | SGText.append('\n'+' (0,0,0; 1/2,0,1/2)+') |
---|
176 | elif SGData['SGLatt'] in 'C': |
---|
177 | SGText.append('\n'+' (0,0,0; 1/2,1/2,0)+') |
---|
178 | elif SGData['SGLatt'] in 'I': |
---|
179 | SGText.append('\n'+' (0,0,0; 1/2,1/2,1/2)+') |
---|
180 | elif SGData['SGLatt'] in 'F': |
---|
181 | SGText.append('\n'+' (0,0,0; 0,1/2,1/2; 1/2,0,1/2; 1/2,1/2,0)+') |
---|
182 | elif SGData['SGLatt'] in 'R': |
---|
183 | SGText.append('\n'+' (0,0,0; 1/3,2/3,2/3; 2/3,1/3,1/3)+') |
---|
184 | if SGData['SGLaue'] in ['-1','2/m','mmm','4/m','4/mmm']: |
---|
185 | Ncol = 2 |
---|
186 | else: |
---|
187 | Ncol = 3 |
---|
188 | line = '' |
---|
189 | for iop,[M,T] in enumerate(SGData['SGOps']): |
---|
190 | if iop % Ncol == 0: |
---|
191 | SGText.append(line) |
---|
192 | line = '' |
---|
193 | Fld = '(%2i) ' % (iop+1) |
---|
194 | for j in range(3): |
---|
195 | IJ = int(round(2*M[j][0]+3*M[j][1]+4*M[j][2]+4)) % 12 |
---|
196 | IK = int(round(T[j]*12)) % 12 |
---|
197 | if IK > 0 and IJ > 4: IJ += 3 |
---|
198 | Fld += TRA[IK]+XYZ[IJ] |
---|
199 | if j != 2: Fld += ',' |
---|
200 | line += Fld |
---|
201 | SGText.append(line) |
---|
202 | return SGText |
---|
203 | |
---|
204 | def SpaceGroup(SgSym): |
---|
205 | ''' |
---|
206 | Print the output of SpcGroup in a nicely formatted way. |
---|
207 | input: space group symbol (string) with spaces between axial fields |
---|
208 | returns nothing |
---|
209 | ''' |
---|
210 | E,A = SpcGroup(SgSym) |
---|
211 | if E > 0: |
---|
212 | print SGErrors(E) |
---|
213 | return |
---|
214 | for l in SGPrint(A): |
---|
215 | print l |
---|
216 | |
---|
217 | def MoveToUnitCell(XYZ): |
---|
218 | ''' |
---|
219 | Translates a set of coordinates so that all values are >=0 and < 1 |
---|
220 | input: a list or numpy array of any length. Note that the object is modified in place. |
---|
221 | output: none |
---|
222 | ''' |
---|
223 | for i,x in enumerate(XYZ): |
---|
224 | x = ((x % 1.0)+1.0) % 1.0 |
---|
225 | if x > 0.9999: x = 0.0 |
---|
226 | XYZ[i] = x |
---|
227 | |
---|
228 | def GenAtom(XYZ,SGData,ifAll=False): |
---|
229 | ''' |
---|
230 | Generates the equivalent positions for a specified coordinate and space group |
---|
231 | input: |
---|
232 | XYZ an array, tuple or list containing 3 elements: x, y & z |
---|
233 | SGData, from SpcGroup |
---|
234 | ifAll=True causes the return to provide the unique set of |
---|
235 | equivalent positions |
---|
236 | =False causes the input position to be repeated. This is the default, |
---|
237 | but why someone would want this, I am not sure. |
---|
238 | Returns a list of two element tuples: |
---|
239 | The first element is the coordinate as a three-element array and |
---|
240 | the second describes the symmetry used to generate the site, of form [-][C]SS |
---|
241 | C indicates a centering operation was used (omitted if the 1st, [0,0,0]) |
---|
242 | SS is the symmetry operator number (1-24) |
---|
243 | - indicates the center of symmetry was used (omitted otherwise) |
---|
244 | ''' |
---|
245 | XYZEquiv = [] |
---|
246 | Idup = [] |
---|
247 | X = np.array(XYZ) |
---|
248 | MoveToUnitCell(X) |
---|
249 | XYZEquiv.append(np.array(X)) |
---|
250 | Idup.append(1) |
---|
251 | for ic,cen in enumerate(SGData['SGCen']): |
---|
252 | C = np.array(cen) |
---|
253 | for invers in range(int(SGData['SGInv']+1)): |
---|
254 | for io,ops in enumerate(SGData['SGOps']): |
---|
255 | idup = ((io+1)+100*ic)*(1-2*invers) |
---|
256 | T = np.array(ops[1]) |
---|
257 | M = np.array(ops[0]) |
---|
258 | newX = np.sum(M*X,axis=1)+T |
---|
259 | if invers: |
---|
260 | newX = -newX |
---|
261 | newX += C |
---|
262 | MoveToUnitCell(newX) |
---|
263 | New = True |
---|
264 | if ifAll: |
---|
265 | if np.allclose(newX,X,atol=0.0002): |
---|
266 | New = False |
---|
267 | idup = 0 |
---|
268 | XYZEquiv.append(newX) |
---|
269 | else: |
---|
270 | for oldX in XYZEquiv[:-1]: |
---|
271 | if np.allclose(newX,oldX,atol=0.0002): |
---|
272 | New = False |
---|
273 | idup = 0 |
---|
274 | if New or ifAll: |
---|
275 | XYZEquiv.append(newX) |
---|
276 | if ifAll and len(XYZEquiv) == 2: |
---|
277 | Idup.append(1) |
---|
278 | else: |
---|
279 | Idup.append(idup) |
---|
280 | if ifAll: |
---|
281 | return zip(XYZEquiv[1:],Idup[1:]) #eliminate duplicate initial entry |
---|
282 | else: |
---|
283 | return zip(XYZEquiv,Idup) |
---|
284 | |
---|
285 | def GetOprPtrName(key): |
---|
286 | OprPtrName = { |
---|
287 | '-6643':[ 2,' 1bar ', 1],'6479' :[ 10,' 2z ', 2],'-6479':[ 9,' mz ', 3], |
---|
288 | '6481' :[ 7,' my ', 4],'-6481':[ 6,' 2y ', 5],'6641' :[ 4,' mx ', 6], |
---|
289 | '-6641':[ 3,' 2x ', 7],'6591' :[ 28,' m+-0 ', 8],'-6591':[ 27,' 2+-0 ', 9], |
---|
290 | '6531' :[ 25,' m110 ',10],'-6531':[ 24,' 2110 ',11],'6537' :[ 61,' 4z ',12], |
---|
291 | '-6537':[ 62,' -4z ',13],'975' :[ 68,' 3+++1',14],'6456' :[ 114,' 3z1 ',15], |
---|
292 | '-489' :[ 73,' 3+-- ',16],'483' :[ 78,' 3-+- ',17],'-969' :[ 83,' 3--+ ',18], |
---|
293 | '819' :[ 22,' m+0- ',19],'-819' :[ 21,' 2+0- ',20],'2431' :[ 16,' m0+- ',21], |
---|
294 | '-2431':[ 15,' 20+- ',22],'-657' :[ 19,' m101 ',23],'657' :[ 18,' 2101 ',24], |
---|
295 | '1943' :[ 48,' -4x ',25],'-1943':[ 47,' 4x ',26],'-2429':[ 13,' m011 ',27], |
---|
296 | '2429' :[ 12,' 2011 ',28],'639' :[ 55,' -4y ',29],'-639' :[ 54,' 4y ',30], |
---|
297 | '-6484':[ 146,' 2010 ', 4],'6484' :[ 139,' m010 ', 5],'-6668':[ 145,' 2100 ', 6], |
---|
298 | '6668' :[ 138,' m100 ', 7],'-6454':[ 148,' 2120 ',18],'6454' :[ 141,' m120 ',19], |
---|
299 | '-6638':[ 149,' 2210 ',20],'6638' :[ 142,' m210 ',21], #search ends here |
---|
300 | '2223' :[ 68,' 3+++2',39], |
---|
301 | '6538' :[ 106,' 6z1 ',40],'-2169':[ 83,' 3--+2',41],'2151' :[ 73,' 3+--2',42], |
---|
302 | '2205' :[ 79,'-3-+-2',43],'-2205':[ 78,' 3-+-2',44],'489' :[ 74,'-3+--1',45], |
---|
303 | '801' :[ 53,' 4y1 ',46],'1945' :[ 47,' 4x3 ',47],'-6585':[ 62,' -4z3 ',48], |
---|
304 | '6585' :[ 61,' 4z3 ',49],'6584' :[ 114,' 3z2 ',50],'6666' :[ 106,' 6z5 ',51], |
---|
305 | '6643' :[ 1,' Iden ',52],'-801' :[ 55,' -4y1 ',53],'-1945':[ 48,' -4x3 ',54], |
---|
306 | '-6666':[ 105,' -6z5 ',55],'-6538':[ 105,' -6z1 ',56],'-2223':[ 69,'-3+++2',57], |
---|
307 | '-975' :[ 69,'-3+++1',58],'-6456':[ 113,' -3z1 ',59],'-483' :[ 79,'-3-+-1',60], |
---|
308 | '969' :[ 84,'-3--+1',61],'-6584':[ 113,' -3z2 ',62],'2169' :[ 84,'-3--+2',63], |
---|
309 | '-2151':[ 74,'-3+--2',64],'0':[0,' ????',0] |
---|
310 | } |
---|
311 | return OprPtrName[key] |
---|
312 | |
---|
313 | def GetKNsym(key): |
---|
314 | KNsym = { |
---|
315 | '0' :' 1 ','1' :' -1 ','64' :' 2(100)','32' :' m(100)', |
---|
316 | '97' :'2/m(100)','16' :' 2(010)','8' :' m(010)','25' :'2/m(010)', |
---|
317 | '2' :' 2(001)','4' :' m(001)','7' :'2/m(001)','134217728' :' 2(011)', |
---|
318 | '67108864' :' m(011)','201326593' :'2/m(011)','2097152' :' 2(0+-)','1048576' :' m(0+-)', |
---|
319 | '3145729' :'2/m(0+-)','8388608' :' 2(101)','4194304' :' m(101)','12582913' :'2/m(101)', |
---|
320 | '524288' :' 2(+0-)','262144' :' m(+0-)','796433' :'2/m(+0-)','1024' :' 2(110)', |
---|
321 | '512' :' m(110)','1537' :'2/m(110)','256' :' 2(+-0)','128' :' m(+-0)', |
---|
322 | '385' :'2/m(+-0)','76' :'mm2(100)','52' :'mm2(010)','42' :'mm2(001)', |
---|
323 | '135266336' :'mm2(011)','69206048' :'mm2(0+-)','8650760' :'mm2(101)','4718600' :'mm2(+0-)', |
---|
324 | '1156' :'mm2(110)','772' :'mm2(+-0)','82' :' 222 ','136314944' :'222(100)', |
---|
325 | '8912912' :'222(010)','1282' :'222(001)','127' :' mmm ','204472417' :'mmm(100)', |
---|
326 | '13369369' :'mmm(010)','1927' :'mmm(001)','33554496' :' 4(100)','16777280' :' -4(100)', |
---|
327 | '50331745' :'4/m(100)','169869394' :'422(100)','84934738' :'-42m 100','101711948' :'4mm(100)', |
---|
328 | '254804095' :'4/mmm100','536870928 ':' 4(010)','268435472' :' -4(010)','805306393' :'4/m (10)', |
---|
329 | '545783890' :'422(010)','272891986' :'-42m 010','541327412' :'4mm(010)','818675839' :'4/mmm010', |
---|
330 | '2050' :' 4(001)','4098' :' -4(001)','6151' :'4/m(001)','3410' :'422(001)', |
---|
331 | '4818' :'-42m 001','2730' :'4mm(001)','8191' :'4/mmm001','8192' :' 3(111)', |
---|
332 | '8193' :' -3(111)','2629888' :' 32(111)','1319040' :' 3m(111)','3940737' :'-3m(111)', |
---|
333 | '32768' :' 3(+--)','32769' :' -3(+--)','10519552' :' 32(+--)','5276160' :' 3m(+--)', |
---|
334 | '15762945' :'-3m(+--)','65536' :' 3(-+-)','65537' :' -3(-+-)','134808576' :' 32(-+-)', |
---|
335 | '67437056' :' 3m(-+-)','202180097' :'-3m(-+-)','131072' :' 3(--+)','131073' :' -3(--+)', |
---|
336 | '142737664' :' 32(--+)','71434368' :' 3m(--+)','214040961' :'-3m(--+)','237650' :' 23 ', |
---|
337 | '237695' :' m3 ','715894098' :' 432 ','358068946' :' -43m ','1073725439':' m3m ', |
---|
338 | '68157504' :' mm2d100','4456464' :' mm2d010','642' :' mm2d001','153092172' :'-4m2 100', |
---|
339 | '277348404' :'-4m2 010','5418' :'-4m2 001','1075726335':' 6/mmm ','1074414420':'-6m2 100', |
---|
340 | '1075070124':'-6m2 120','1075069650':' 6mm ','1074414890':' 622 ','1073758215':' 6/m ', |
---|
341 | '1073758212':' -6 ','1073758210':' 6 ','1073759865':'-3m(100)','1075724673':'-3m(120)', |
---|
342 | '1073758800':' 3m(100)','1075069056':' 3m(120)','1073759272':' 32(100)','1074413824':' 32(120)', |
---|
343 | '1073758209':' -3 ','1073758208':' 3 ','1074135143':'mmm(100)','1075314719':'mmm(010)', |
---|
344 | '1073743751':'mmm(110)','1074004034':' mm2z100','1074790418':' mm2z010','1073742466':' mm2z110', |
---|
345 | '1074004004':'mm2(100)','1074790412':'mm2(010)','1073742980':'mm2(110)','1073872964':'mm2(120)', |
---|
346 | '1074266132':'mm2(210)','1073742596':'mm2(+-0)','1073872930':'222(100)','1074266122':'222(010)', |
---|
347 | '1073743106':'222(110)','1073741831':'2/m(001)','1073741921':'2/m(100)','1073741849':'2/m(010)', |
---|
348 | '1073743361':'2/m(110)','1074135041':'2/m(120)','1075314689':'2/m(210)','1073742209':'2/m(+-0)', |
---|
349 | '1073741828':' m(001) ','1073741888':' m(100) ','1073741840':' m(010) ','1073742336':' m(110) ', |
---|
350 | '1074003968':' m(120) ','1074790400':' m(210) ','1073741952':' m(+-0) ','1073741826':' 2(001) ', |
---|
351 | '1073741856':' 2(100) ','1073741832':' 2(010) ','1073742848':' 2(110) ','1073872896':' 2(120) ', |
---|
352 | '1074266112':' 2(210) ','1073742080':' 2(+-0) ','1073741825':' -1 ' |
---|
353 | } |
---|
354 | return KNsym[key] |
---|
355 | |
---|
356 | def GetNXUPQsym(siteSym): |
---|
357 | NXUPQsym = { |
---|
358 | ' 1 ':(28,29,28,28),' -1 ':( 1,29,28, 0),' 2(100)':(12,18,12,25),' m(100)':(25,18,12,25), |
---|
359 | '2/m(100)':( 1,18, 0,-1),' 2(010)':(13,17,13,24),' m(010)':(24,17,13,24),'2/m(010)':( 1,17, 0,-1), |
---|
360 | ' 2(001)':(14,16,14,23),' m(001)':(23,16,14,23),'2/m(001)':( 1,16, 0,-1),' 2(011)':(10,23,10,22), |
---|
361 | ' m(011)':(22,23,10,22),'2/m(011)':( 1,23, 0,-1),' 2(0+-)':(11,24,11,21),' m(0+-)':(21,24,11,21), |
---|
362 | '2/m(0+-)':( 1,24, 0,-1),' 2(101)':( 8,21, 8,20),' m(101)':(20,21, 8,20),'2/m(101)':( 1,21, 0,-1), |
---|
363 | ' 2(+0-)':( 9,22, 9,19),' m(+0-)':(19,22, 9,19),'2/m(+0-)':( 1,22, 0,-1),' 2(110)':( 6,19, 6,18), |
---|
364 | ' m(110)':(18,19, 6,18),'2/m(110)':( 1,19, 0,-1),' 2(+-0)':( 7,20, 7,17),' m(+-0)':(17,20, 7,17), |
---|
365 | '2/m(+-0)':( 1,20, 0,-1),'mm2(100)':(12,10, 0,-1),'mm2(010)':(13,10, 0,-1),'mm2(001)':(14,10, 0,-1), |
---|
366 | 'mm2(011)':(10,13, 0,-1),'mm2(0+-)':(11,13, 0,-1),'mm2(101)':( 8,12, 0,-1),'mm2(+0-)':( 9,12, 0,-1), |
---|
367 | 'mm2(110)':( 6,11, 0,-1),'mm2(+-0)':( 7,11, 0,-1),' 222 ':( 1,10, 0,-1),'222(100)':( 1,13, 0,-1), |
---|
368 | '222(010)':( 1,12, 0,-1),'222(001)':( 1,11, 0,-1),' mmm ':( 1,10, 0,-1),'mmm(100)':( 1,13, 0,-1), |
---|
369 | 'mmm(010)':( 1,12, 0,-1),'mmm(001)':( 1,11, 0,-1),' 4(100)':(12, 4,12, 0),' -4(100)':( 1, 4,12, 0), |
---|
370 | '4/m(100)':( 1, 4,12,-1),'422(100)':( 1, 4, 0,-1),'-42m 100':( 1, 4, 0,-1),'4mm(100)':(12, 4, 0,-1), |
---|
371 | '4/mmm100':( 1, 4, 0,-1),' 4(010)':(13, 3,13, 0),' -4(010)':( 1, 3,13, 0),'4/m (10)':( 1, 3,13,-1), |
---|
372 | '422(010)':( 1, 3, 0,-1),'-42m 010':( 1, 3, 0,-1),'4mm(010)':(13, 3, 0,-1),'4/mmm010':(1, 3, 0,-1,), |
---|
373 | ' 4(001)':(14, 2,14, 0),' -4(001)':( 1, 2,14, 0),'4/m(001)':( 1, 2,14,-1),'422(001)':( 1, 2, 0,-1), |
---|
374 | '-42m 001':( 1, 2, 0,-1),'4mm(001)':(14, 2, 0,-1),'4/mmm001':( 1, 2, 0,-1),' 3(111)':( 2, 5, 2, 0), |
---|
375 | ' -3(111)':( 1, 5, 2, 0),' 32(111)':( 1, 5, 0, 2),' 3m(111)':( 2, 5, 0, 2),'-3m(111)':( 1, 5, 0,-1), |
---|
376 | ' 3(+--)':( 5, 8, 5, 0),' -3(+--)':( 1, 8, 5, 0),' 32(+--)':( 1, 8, 0, 5),' 3m(+--)':( 5, 8, 0, 5), |
---|
377 | '-3m(+--)':( 1, 8, 0,-1),' 3(-+-)':( 4, 7, 4, 0),' -3(-+-)':( 1, 7, 4, 0),' 32(-+-)':( 1, 7, 0, 4), |
---|
378 | ' 3m(-+-)':( 4, 7, 0, 4),'-3m(-+-)':( 1, 7, 0,-1),' 3(--+)':( 3, 6, 3, 0),' -3(--+)':( 1, 6, 3, 0), |
---|
379 | ' 32(--+)':( 1, 6, 0, 3),' 3m(--+)':( 3, 6, 0, 3),'-3m(--+)':( 1, 6, 0,-1),' 23 ':( 1, 1, 0, 0), |
---|
380 | ' m3 ':( 1, 1, 0, 0),' 432 ':( 1, 1, 0, 0),' -43m ':( 1, 1, 0, 0),' m3m ':( 1, 1, 0, 0), |
---|
381 | ' mm2d100':(12,13, 0,-1),' mm2d010':(13,12, 0,-1),' mm2d001':(14,11, 0,-1),'-4m2 100':( 1, 4, 0,-1), |
---|
382 | '-4m2 010':( 1, 3, 0,-1),'-4m2 001':( 1, 2, 0,-1),' 6/mmm ':( 1, 9, 0,-1),'-6m2 100':( 1, 9, 0,-1), |
---|
383 | '-6m2 120':( 1, 9, 0,-1),' 6mm ':(14, 9, 0,-1),' 622 ':( 1, 9, 0,-1),' 6/m ':( 1, 9,14,-1), |
---|
384 | ' -6 ':( 1, 9,14, 0),' 6 ':(14, 9,14, 0),'-3m(100)':( 1, 9, 0,-1),'-3m(120)':( 1, 9, 0,-1), |
---|
385 | ' 3m(100)':(14, 9, 0,14),' 3m(120)':(14, 9, 0,14),' 32(100)':( 1, 9, 0,14),' 32(120)':( 1, 9, 0,14), |
---|
386 | ' -3 ':( 1, 9,14, 0),' 3 ':(14, 9,14, 0),'mmm(100)':( 1,14, 0,-1),'mmm(010)':( 1,15, 0,-1), |
---|
387 | 'mmm(110)':( 1,11, 0,-1),' mm2z100':(14,14, 0,-1),' mm2z010':(14,15, 0,-1),' mm2z110':(14,11, 0,-1), |
---|
388 | 'mm2(100)':(12,14, 0,-1),'mm2(010)':(13,15, 0,-1),'mm2(110)':( 6,11, 0,-1),'mm2(120)':(15,14, 0,-1), |
---|
389 | 'mm2(210)':(16,15, 0,-1),'mm2(+-0)':( 7,11, 0,-1),'222(100)':( 1,14, 0,-1),'222(010)':( 1,15, 0,-1), |
---|
390 | '222(110)':( 1,11, 0,-1),'2/m(001)':( 1,16,14,-1),'2/m(100)':( 1,25,12,-1),'2/m(010)':( 1,28,13,-1), |
---|
391 | '2/m(110)':( 1,19, 6,-1),'2/m(120)':( 1,27,15,-1),'2/m(210)':( 1,26,16,-1),'2/m(+-0)':( 1,20,17,-1), |
---|
392 | ' m(001) ':(23,16,14,23),' m(100) ':(26,25,12,26),' m(010) ':(27,28,13,27),' m(110) ':(18,19, 6,18), |
---|
393 | ' m(120) ':(24,27,15,24),' m(210) ':(25,26,16,25),' m(+-0) ':(17,20, 7,17),' 2(001) ':(14,16,14,23), |
---|
394 | ' 2(100) ':(12,25,12,26),' 2(010) ':(13,28,13,27),' 2(110) ':( 6,19, 6,18),' 2(120) ':(15,27,15,24), |
---|
395 | ' 2(210) ':(16,26,16,25),' 2(+-0) ':( 7,20, 7,17),' -1 ':( 1,29,28, 0) |
---|
396 | } |
---|
397 | return NXUPQsym[siteSym] |
---|
398 | |
---|
399 | def GetCSxinel(siteSym): |
---|
400 | CSxinel = [[], # 0th empty - indices are Fortran style |
---|
401 | [[0,0,0],[ 0.0, 0.0, 0.0]], # 0 0 0 |
---|
402 | [[1,1,1],[ 1.0, 1.0, 1.0]], # X X X |
---|
403 | [[1,1,1],[ 1.0, 1.0,-1.0]], # X X -X |
---|
404 | [[1,1,1],[ 1.0,-1.0, 1.0]], # X -X X |
---|
405 | [[1,1,1],[ 1.0,-1.0,-1.0]], # -X X X |
---|
406 | [[1,1,0],[ 1.0, 1.0, 0.0]], # X X 0 |
---|
407 | [[1,1,0],[ 1.0,-1.0, 0.0]], # X -X 0 |
---|
408 | [[1,0,1],[ 1.0, 0.0, 1.0]], # X 0 X |
---|
409 | [[1,0,1],[ 1.0, 0.0,-1.0]], # X 0 -X |
---|
410 | [[0,1,1],[ 0.0, 1.0, 1.0]], # 0 Y Y |
---|
411 | [[0,1,1],[ 0.0, 1.0,-1.0]], # 0 Y -Y |
---|
412 | [[1,0,0],[ 1.0, 0.0, 0.0]], # X 0 0 |
---|
413 | [[0,1,0],[ 0.0, 1.0, 0.0]], # 0 Y 0 |
---|
414 | [[0,0,1],[ 0.0, 0.0, 1.0]], # 0 0 Z |
---|
415 | [[1,1,0],[ 1.0, 2.0, 0.0]], # X 2X 0 |
---|
416 | [[1,1,0],[ 2.0, 1.0, 0.0]], # 2X X 0 |
---|
417 | [[1,1,2],[ 1.0, 1.0, 1.0]], # X X Z |
---|
418 | [[1,1,2],[ 1.0,-1.0, 1.0]], # X -X Z |
---|
419 | [[1,2,1],[ 1.0, 1.0, 1.0]], # X Y X |
---|
420 | [[1,2,1],[ 1.0, 1.0,-1.0]], # X Y -X |
---|
421 | [[1,2,2],[ 1.0, 1.0, 1.0]], # X Y Y |
---|
422 | [[1,2,2],[ 1.0, 1.0,-1.0]], # X Y -Y |
---|
423 | [[1,2,0],[ 1.0, 1.0, 0.0]], # X Y 0 |
---|
424 | [[1,0,2],[ 1.0, 0.0, 1.0]], # X 0 Z |
---|
425 | [[0,1,2],[ 0.0, 1.0, 1.0]], # 0 Y Z |
---|
426 | [[1,1,2],[ 1.0, 2.0, 1.0]], # X 2X Z |
---|
427 | [[1,1,2],[ 2.0, 1.0, 1.0]], # 2X X Z |
---|
428 | [[1,2,3],[ 1.0, 1.0, 1.0]], # X Y Z |
---|
429 | ] |
---|
430 | indx = GetNXUPQsym(siteSym) |
---|
431 | return CSxinel[indx[0]] |
---|
432 | |
---|
433 | def GetCSuinel(siteSym): |
---|
434 | CSuinel = [[], # 0th empty - indices are Fortran style |
---|
435 | [[1,1,1,0,0,0],[ 1.0, 1.0, 1.0, 0.0, 0.0, 0.0]], # A A A 0 0 0 |
---|
436 | [[1,1,2,0,0,0],[ 1.0, 1.0, 1.0, 0.0, 0.0, 0.0]], # A A C 0 0 0 |
---|
437 | [[1,2,1,0,0,0],[ 1.0, 1.0, 1.0, 0.0, 0.0, 0.0]], # A B A 0 0 0 |
---|
438 | [[1,2,2,0,0,0],[ 1.0, 1.0, 1.0, 0.0, 0.0, 0.0]], # A B B 0 0 0 |
---|
439 | [[1,1,1,2,2,2],[ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]], # A A A D D D |
---|
440 | [[1,1,1,2,2,2],[ 1.0, 1.0, 1.0, 1.0,-1.0,-1.0]], # A A A D -D -D |
---|
441 | [[1,1,1,2,2,2],[ 1.0, 1.0, 1.0, 1.0,-1.0, 1.0]], # A A A D -D D |
---|
442 | [[1,1,1,2,2,2],[ 1.0, 1.0, 1.0, 1.0, 1.0,-1.0]], # A A A D D -D |
---|
443 | [[1,1,2,1,0,0],[ 1.0, 1.0, 1.0, 0.5, 0.0, 0.0]], # A A C A/2 0 0 |
---|
444 | [[1,2,3,0,0,],[ 1.0, 1.0, 1.0, 0.0, 0.0, 0.0]], # A B C 0 0 0 |
---|
445 | [[1,1,2,3,0,],[ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0]], # A A C D 0 0 |
---|
446 | [[1,2,1,0,3,],[ 1.0, 1.0, 1.0, 0.0, 1.0, 0.0]], # A B A 0 E 0 |
---|
447 | [[1,2,2,0,0,],[ 1.0, 1.0, 1.0, 0.0, 0.0, 1.0]], # A B B 0 0 F |
---|
448 | [[1,2,3,2,0,],[ 1.0, 1.0, 1.0, 0.5, 0.0, 0.0]], # A B C B/2 0 0 |
---|
449 | [[1,2,3,1,0,],[ 1.0, 1.0, 1.0, 0.5, 0.0, 0.0]], # A B C A/2 0 0 |
---|
450 | [[1,2,3,4,0,],[ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0]], # A B C D 0 0 |
---|
451 | [[1,2,3,0,4,],[ 1.0, 1.0, 1.0, 0.0, 1.0, 0.0]], # A B C 0 E 0 |
---|
452 | [[1,2,3,0,0,],[ 1.0, 1.0, 1.0, 0.0, 0.0, 1.0]], # A B C 0 0 F |
---|
453 | [[1,1,2,3,4,],[ 1.0, 1.0, 1.0, 1.0, 1.0,-1.0]], # A A C D E -E |
---|
454 | [[1,1,2,3,4,],[ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]], # A A C D E E |
---|
455 | [[1,2,1,3,4,],[ 1.0, 1.0, 1.0, 1.0, 1.0,-1.0]], # A B A D E -D |
---|
456 | [[1,2,1,3,4,],[ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]], # A B A D E D |
---|
457 | [[1,2,2,3,3,],[ 1.0, 1.0, 1.0, 1.0,-1.0, 1.0]], # A B B D -D F |
---|
458 | [[1,2,2,3,3,],[ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]], # A B B D D F |
---|
459 | [[1,2,3,2,4,],[ 1.0, 1.0, 1.0, 0.5, 0.5, 1.0]], # A B C B/2 F/2 F |
---|
460 | [[1,2,3,1,0,],[ 1.0, 1.0, 1.0, 0.5, 0.0, 1.0]], # A B C A/2 0 F |
---|
461 | [[1,2,3,2,4,],[ 1.0, 1.0, 1.0, 0.5, 1.0, 0.0]], # A B C B/2 E 0 |
---|
462 | [[1,2,3,1,4,],[ 1.0, 1.0, 1.0, 0.5, 1.0, 0.5]], # A B C A/2 E E/2 |
---|
463 | [[1,2,3,4,5,],[ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]], # A B C D E F |
---|
464 | ] |
---|
465 | indx = GetNXUPQsym(siteSym) |
---|
466 | return CSuinel[indx[1]] |
---|
467 | |
---|
468 | def SytSym(XYZ,SGData): |
---|
469 | ''' |
---|
470 | Generates the number of equivalent positions and a site symmetry code for a specified coordinate and space group |
---|
471 | input: |
---|
472 | XYZ: an array, tuple or list containing 3 elements: x, y & z |
---|
473 | SGData: from SpcGroup |
---|
474 | Returns a two element tuple: |
---|
475 | The 1st element is a code for the site symmetry (see GetOprPtrName) |
---|
476 | The 2nd element is the site multiplicity |
---|
477 | ''' |
---|
478 | def PackRot(SGOps): |
---|
479 | IRT = [] |
---|
480 | for ops in SGOps: |
---|
481 | M = ops[0] |
---|
482 | irt = 0 |
---|
483 | for j in range(2,-1,-1): |
---|
484 | for k in range(2,-1,-1): |
---|
485 | irt *= 3 |
---|
486 | irt += M[k][j] |
---|
487 | IRT.append(int(irt)) |
---|
488 | return IRT |
---|
489 | |
---|
490 | SymName = '' |
---|
491 | Mult = 1 |
---|
492 | Isym = 0 |
---|
493 | if SGData['SGLaue'] in ['3','3m1','31m','6/m','6/mmm']: |
---|
494 | Isym = 1073741824 |
---|
495 | Jdup = 1 |
---|
496 | Xeqv = GenAtom(XYZ,SGData,True) |
---|
497 | IRT = PackRot(SGData['SGOps']) |
---|
498 | L = -1 |
---|
499 | for ic,cen in enumerate(SGData['SGCen']): |
---|
500 | for invers in range(int(SGData['SGInv']+1)): |
---|
501 | for io,ops in enumerate(SGData['SGOps']): |
---|
502 | irtx = (1-2*invers)*IRT[io] |
---|
503 | L += 1 |
---|
504 | if not Xeqv[L][1]: |
---|
505 | Jdup += 1 |
---|
506 | jx = GetOprPtrName(str(irtx)) |
---|
507 | if jx[2] < 39: |
---|
508 | Isym += 2**(jx[2]-1) |
---|
509 | if Isym == 1073741824: Isym = 0 |
---|
510 | Mult = len(SGData['SGOps'])*len(SGData['SGCen'])*(int(SGData['SGInv'])+1)/Jdup |
---|
511 | |
---|
512 | return GetKNsym(str(Isym)),Mult |
---|
513 | |
---|
514 | # self-test materials follow. Requires files in directory testinp |
---|
515 | def test0(): |
---|
516 | '''test #0: exercise MoveToUnitCell''' |
---|
517 | msg = "MoveToUnitCell failed" |
---|
518 | v = [0,1,2,-1,-2]; MoveToUnitCell(v); assert v==[0,0,0,0,0], msg |
---|
519 | v = np.array([-.1]); MoveToUnitCell(v); assert abs(v-0.9) < 1e-6, msg |
---|
520 | v = np.array([.1]); MoveToUnitCell(v); assert abs(v-0.1) < 1e-6, msg |
---|
521 | |
---|
522 | def test1(): |
---|
523 | ''' test #1: SpcGroup and SGPrint against previous results''' |
---|
524 | testdir = ospath.join(mypath,'testinp') |
---|
525 | if ospath.exists(testdir): |
---|
526 | if testdir not in sys.path: sys.path.insert(0,testdir) |
---|
527 | import spctestinp |
---|
528 | def CompareSpcGroup(spc, referr, refdict, reflist): |
---|
529 | 'Compare output from GSASIIspc.SpcGroup with results from a previous run' |
---|
530 | # if an error is reported, the dictionary can be ignored |
---|
531 | msg = "failed on space group %s" % spc |
---|
532 | result = SpcGroup(spc) |
---|
533 | if result[0] == referr and referr > 0: return True |
---|
534 | keys = result[1].keys() |
---|
535 | #print result[1]['SpGrp'] |
---|
536 | assert len(keys) == len(refdict.keys()), msg |
---|
537 | for key in keys: |
---|
538 | #print key, type(refdict[key]) |
---|
539 | if key == 'SGOps' or key == 'SGCen': |
---|
540 | assert len(refdict[key]) == len(result[1][key]), msg |
---|
541 | for i in range(len(refdict[key])): |
---|
542 | assert np.allclose(result[1][key][i][0],refdict[key][i][0]), msg |
---|
543 | assert np.allclose(result[1][key][i][1],refdict[key][i][1]), msg |
---|
544 | else: |
---|
545 | assert result[1][key] == refdict[key], msg |
---|
546 | assert reflist == SGPrint(result[1]), 'SGPrint ' +msg |
---|
547 | for spc in spctestinp.SGdat: |
---|
548 | CompareSpcGroup(spc, 0, spctestinp.SGdat[spc], spctestinp.SGlist[spc] ) |
---|
549 | |
---|
550 | def test2(): |
---|
551 | ''' test #2: SpcGroup against cctbx (sgtbx) computations''' |
---|
552 | testdir = ospath.join(mypath,'testinp') |
---|
553 | if ospath.exists(testdir): |
---|
554 | if testdir not in sys.path: sys.path.insert(0,testdir) |
---|
555 | import sgtbxtestinp |
---|
556 | def CompareWcctbx(spcname, cctbx_in, debug=0): |
---|
557 | 'Compare output from GSASIIspc.SpcGroup with results from cctbx.sgtbx' |
---|
558 | cctbx = cctbx_in[:] # make copy so we don't delete from the original |
---|
559 | spc = (SpcGroup(spcname))[1] |
---|
560 | if debug: print spc['SpGrp'] |
---|
561 | if debug: print spc['SGCen'] |
---|
562 | latticetype = spcname.strip().upper()[0] |
---|
563 | # lattice type of R implies Hexagonal centering", fix the rhombohedral settings |
---|
564 | if latticetype == "R" and len(spc['SGCen']) == 1: latticetype = 'P' |
---|
565 | assert latticetype == spc['SGLatt'], "Failed: %s does not match Lattice: %s" % (spcname, spc['SGLatt']) |
---|
566 | onebar = [1] |
---|
567 | if spc['SGInv']: onebar.append(-1) |
---|
568 | for (op,off) in spc['SGOps']: |
---|
569 | for inv in onebar: |
---|
570 | for cen in spc['SGCen']: |
---|
571 | noff = off + cen |
---|
572 | MoveToUnitCell(noff) |
---|
573 | mult = tuple((op*inv).ravel().tolist()) |
---|
574 | if debug: print "\n%s: %s + %s" % (spcname,mult,noff) |
---|
575 | for refop in cctbx: |
---|
576 | if debug: print refop |
---|
577 | # check the transform |
---|
578 | if refop[:9] != mult: continue |
---|
579 | if debug: print "mult match" |
---|
580 | # check the translation |
---|
581 | reftrans = list(refop[-3:]) |
---|
582 | MoveToUnitCell(reftrans) |
---|
583 | if all(abs(noff - reftrans) < 1.e-5): |
---|
584 | cctbx.remove(refop) |
---|
585 | break |
---|
586 | else: |
---|
587 | assert False, "failed on %s:\n\t %s + %s" % (spcname,mult,noff) |
---|
588 | for key in sgtbxtestinp.sgtbx: |
---|
589 | CompareWcctbx(key, sgtbxtestinp.sgtbx[key]) |
---|
590 | |
---|
591 | def test3(): |
---|
592 | ''' test #3: exercise SytSym (includes GetOprPtrName, GenAtom, GetKNsym) |
---|
593 | for selected space groups against info in IT Volume A ''' |
---|
594 | def ExerciseSiteSym (spc, crdlist): |
---|
595 | 'compare site symmetries and multiplicities for a specified space group' |
---|
596 | msg = "failed on site sym test for %s" % spc |
---|
597 | (E,S) = SpcGroup(spc) |
---|
598 | assert not E, msg |
---|
599 | for t in crdlist: |
---|
600 | symb, m = SytSym(t[0],S) |
---|
601 | if symb.strip() != t[2].strip() or m != t[1]: |
---|
602 | print spc,t[0],m,symb |
---|
603 | assert m == t[1] |
---|
604 | #assert symb.strip() == t[2].strip() |
---|
605 | |
---|
606 | ExerciseSiteSym('p 1',[ |
---|
607 | ((0.13,0.22,0.31),1,'1'), |
---|
608 | ((0,0,0),1,'1'), |
---|
609 | ]) |
---|
610 | ExerciseSiteSym('p -1',[ |
---|
611 | ((0.13,0.22,0.31),2,'1'), |
---|
612 | ((0,0.5,0),1,'-1'), |
---|
613 | ]) |
---|
614 | ExerciseSiteSym('C 2/c',[ |
---|
615 | ((0.13,0.22,0.31),8,'1'), |
---|
616 | ((0.0,.31,0.25),4,'2(010)'), |
---|
617 | ((0.25,.25,0.5),4,'-1'), |
---|
618 | ((0,0.5,0),4,'-1'), |
---|
619 | ]) |
---|
620 | ExerciseSiteSym('p 2 2 2',[ |
---|
621 | ((0.13,0.22,0.31),4,'1'), |
---|
622 | ((0,0.5,.31),2,'2(001)'), |
---|
623 | ((0.5,.31,0.5),2,'2(010)'), |
---|
624 | ((.11,0,0),2,'2(100)'), |
---|
625 | ((0,0.5,0),1,'222'), |
---|
626 | ]) |
---|
627 | ExerciseSiteSym('p 4/n',[ |
---|
628 | ((0.13,0.22,0.31),8,'1'), |
---|
629 | ((0.25,0.75,.31),4,'2(001)'), |
---|
630 | ((0.5,0.5,0.5),4,'-1'), |
---|
631 | ((0,0.5,0),4,'-1'), |
---|
632 | ((0.25,0.25,.31),2,'4(001)'), |
---|
633 | ((0.25,.75,0.5),2,'-4(001)'), |
---|
634 | ((0.25,.75,0.0),2,'-4(001)'), |
---|
635 | ]) |
---|
636 | ExerciseSiteSym('p 31 2 1',[ |
---|
637 | ((0.13,0.22,0.31),6,'1'), |
---|
638 | ((0.13,0.0,0.833333333),3,'2(100)'), |
---|
639 | ((0.13,0.13,0.),3,'2(110)'), |
---|
640 | ]) |
---|
641 | ExerciseSiteSym('R 3 c',[ |
---|
642 | ((0.13,0.22,0.31),18,'1'), |
---|
643 | ((0.0,0.0,0.31),6,'3'), |
---|
644 | ]) |
---|
645 | ExerciseSiteSym('R 3 c R',[ |
---|
646 | ((0.13,0.22,0.31),6,'1'), |
---|
647 | ((0.31,0.31,0.31),2,'3(111)'), |
---|
648 | ]) |
---|
649 | ExerciseSiteSym('P 63 m c',[ |
---|
650 | ((0.13,0.22,0.31),12,'1'), |
---|
651 | ((0.11,0.22,0.31),6,'m(100)'), |
---|
652 | ((0.333333,0.6666667,0.31),2,'3m(100)'), |
---|
653 | ((0,0,0.31),2,'3m(100)'), |
---|
654 | ]) |
---|
655 | ExerciseSiteSym('I a -3',[ |
---|
656 | ((0.13,0.22,0.31),48,'1'), |
---|
657 | ((0.11,0,0.25),24,'2(100)'), |
---|
658 | ((0.11,0.11,0.11),16,'3(111)'), |
---|
659 | ((0,0,0),8,'-3(111)'), |
---|
660 | ]) |
---|
661 | |
---|
662 | if __name__ == '__main__': |
---|
663 | test0() |
---|
664 | test1() |
---|
665 | test2() |
---|
666 | test3() |
---|
667 | print "OK" |
---|