Changeset 30
- Timestamp:
- Feb 18, 2010 9:34:17 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIspc.py
r13 r30 1 #GSASII - Space group intrepretion routines 2 # 3 # input string - space group symbol with spaces between axial fields 4 # returns [SGError,SGData] 5 # SGError = 0 for no errors; >0 for errors, see SGErrors below for details 6 # SGData dictionary entries are: 7 # 'SpGrp': space group symbol slightly cleaned up 8 # 'Laue': one of '-1','2/m','mmm','4/m','4/mmm','3R','3mR','3','3m1','31m','6/m','6/mmm','m3','m3m' 9 # 'SGInv': boolean; True if centrosymmetric, False if not 10 # 'SGLatt': one of 'P','A','B','C','I','F','R' 11 # 'SGUniq': one of 'a','b','c' if monoclinic, '' otherwise 12 # 'SGCen': cell centering vectors [0,0,0] at least 13 # 'SGOps': symmetry operations as [M,T] so that M*x+T = x' 14 # 1 "GSASII - Space group interpretion routines" 2 3 15 4 import numpy as np 5 import sys 6 import os.path 7 # determine a binary path pased on the host OS and the python version, path is relative to 8 # location of this file 9 if sys.platform == "win32": 10 bindir = '../binwin%d.%d' % sys.version_info[0:2] 11 elif sys.platform == "darwin": 12 bindir = '../binmac%d.%d' % sys.version_info[0:2] 13 else: 14 bindir = '../bin' 15 if os.path.exists(os.path.join(sys.path[0],bindir)): sys.path.insert(0,os.path.join(sys.path[0],bindir)) 16 17 import pypowder as pyd 16 18 17 19 def SpcGroup(SGSymbol): 18 import pypowder as pyd 20 ''' 21 input: space group symbol (string) with spaces between axial fields 22 returns [SGError,SGData] 23 SGError = 0 for no errors; >0 for errors (see SGErrors below for details) 24 returns dictionary SGData with entries: 25 'SpGrp': space group symbol slightly cleaned up 26 'Laue': one of '-1','2/m','mmm','4/m','4/mmm','3R','3mR','3', 27 '3m1','31m','6/m','6/mmm','m3','m3m' 28 'SGInv': boolean; True if centrosymmetric, False if not 29 'SGLatt': one of 'P','A','B','C','I','F','R' 30 'SGUniq': one of 'a','b','c' if monoclinic, '' otherwise 31 'SGCen': cell centering vectors [0,0,0] at least 32 'SGOps': symmetry operations as [M,T] so that M*x+T = x' 33 'SGSys': one of 'triclinic','monoclinic','orthorhombic','tetragonal','rhombohedral','trigonal','hexagonal','cubic' 34 ''' 19 35 LaueSym = ('-1','2/m','mmm','4/m','4/mmm','3R','3mR','3','3m1','31m','6/m','6/mmm','m3','m3m') 20 36 LattSym = ('P','A','B','C','I','F','R') … … 66 82 67 83 def SGErrors(IErr): 84 '''Interprets the error message code from SpcGroup. Used in SpaceGroup. 85 input: SGError, from SpcGroup 86 returns a string with the error message or "Unknown error" 87 ''' 88 68 89 ErrString = [' ', 69 90 'Less than 2 operator fields were found', … … 93 114 'Illegal character in the space group symbol', 94 115 ] 95 return ErrString[IErr] 116 try: 117 return ErrString[IErr] 118 except: 119 return "Unknown error" 96 120 97 121 def SGPrint(SGData): 122 ''' 123 Print the output of SpcGroup in a nicely formatted way. Used in SpaceGroup 124 input: SGData, from SpcGroup 125 returns a list of strings with the space group details 126 ''' 98 127 XYZ = ('-Z ','-Y ','-X ','X-Y','ERR','Y-X',' X ',' Y ',' Z ','+X ','+Y ','+Z ') 99 128 TRA = (' ','ERR','1/6','1/4','1/3','ERR','1/2','ERR','2/3','3/4','5/6','ERR') … … 159 188 160 189 def SpaceGroup(SgSym): 190 ''' 191 Print the output of SpcGroup in a nicely formatted way. 192 input: space group symbol (string) with spaces between axial fields 193 returns nothing 194 ''' 161 195 E,A = SpcGroup(SgSym) 162 196 if E > 0: 163 197 print SGErrors(E) 164 198 return 165 L = SGPrint(A) 166 for l in L: 199 for l in SGPrint(A): 167 200 print l 168 201 169 202 def MoveToUnitCell(XYZ): 203 ''' 204 Translates a set of coordinates so that all values are >=0 and < 1 205 input: a list or numpy array of any length. Note that the object is modified in place. 206 output: none 207 ''' 170 208 for i,x in enumerate(XYZ): 171 209 x = ((x % 1.0)+1.0) % 1.0 … … 174 212 175 213 def GenAtom(XYZ,SGData,ifAll=False): 214 ''' 215 Generates the equivalent positions for a specified coordinate and space group 216 input: 217 XYZ an array, tuple or list containing 3 elements: x, y & z 218 SGData, from SpcGroup 219 ifAll=True causes the return to provide the unique set of 220 equivalent positions 221 =False causes the input position to be repeated. This is the default, 222 but why someone would want this, I am not sure. 223 Returns a list of two element tuples: 224 The first element is the coordinate as a three-element array and 225 the second describes the symmetry used to generate the site, of form [-][C]SS 226 C indicates a centering operation was used (omitted if the 1st, [0,0,0]) 227 SS is the symmetry operator number (1-24) 228 - indicates the center of symmetry was used (omitted otherwise) 229 ''' 176 230 XYZEquiv = [] 177 231 Idup = [] … … 398 452 399 453 def SytSym(XYZ,SGData): 454 ''' 455 Generates the number of equivalent positions and a site symmetry code for a specified coordinate and space group 456 input: 457 XYZ: an array, tuple or list containing 3 elements: x, y & z 458 SGData: from SpcGroup 459 Returns a two element tuple: 460 The 1st element is a code for the site symmetry (see GetOprPtrName) 461 The 2nd element is the site multiplicity 462 ''' 400 463 def PackRot(SGOps): 401 464 IRT = []
Note: See TracChangeset
for help on using the changeset viewer.