Changeset 57 for trunk/testinp/genselftest.py
 Timestamp:
 Apr 29, 2010 9:30:47 PM (12 years ago)
 Location:
 trunk/testinp
 Files:

 1 edited
 1 moved
Legend:
 Unmodified
 Added
 Removed

trunk/testinp/genselftest.py
r30 r57 1 1 ''' 2 this generates space group tables for ~all 230 space groups in 3 standard settings using the GSASIIspc.SpcGroup routine 4 (N.B. R space groups are set in both hex and rhomb. settings so there 5 are more than 230 tests generated). 6 7 Run this redirected to SGdat.py to create the input file. 2 this generates space group tables for all 230 space groups in 3 standard settings using the GSASIIspc.SpcGroup routine. A number 4 of redundant tests are computed, so more than 230 test cases are generated. 5 6 The output from this is placed in spctestinp.py which contains two dictionaries, 7 SGdat and SGlist that can be used for testing. 8 8 9 ''' 9 10 import sys … … 22 23 sglist[spc] = GSASIIspc.SGPrint(D) 23 24 24 #cubic 25 duplist = [] 26 ###################################################################### 27 #cubic (36) 28 ###################################################################### 25 29 GenSGdat('p 2 3') 26 30 GenSGdat('f 2 3') … … 31 35 GenSGdat('p n 3') 32 36 GenSGdat('f m 3') 33 GenSGdat('f d 3')34 GenSGdat('i m 3')37 GenSGdat('f d 3') 38 GenSGdat('i m 3') 35 39 GenSGdat('p a 3') 36 40 GenSGdat('i a 3') … … 59 63 GenSGdat('i m 3 m') 60 64 GenSGdat('i a 3 d') 61 # ortho 65 # duplicates (IT A naming) 66 GenSGdat('p m 3') # dup: as before 67 duplist.append(('p m 3', 'p m 3')) 68 GenSGdat('f m 3') # dup: as before 69 duplist.append(('f m 3','f m 3')) 70 GenSGdat('f d 3') # dup: as before 71 duplist.append(('f d 3','f d 3')) 72 GenSGdat('i m 3') # dup: as before 73 duplist.append(('i m 3','i m 3')) 74 GenSGdat('p a 3') # dup: as before 75 duplist.append(('p a 3','p a 3')) 76 GenSGdat('i a 3') # dup: as before 77 duplist.append(('i a 3','i a 3')) 78 ###################################################################### 79 # ortho (59) 80 ###################################################################### 62 81 GenSGdat('p 2 2 2') 63 82 GenSGdat('p 2 2 21') … … 119 138 GenSGdat('i b c a') 120 139 GenSGdat('i m m a') 121 # tetragonal 140 ###################################################################### 141 # tetragonal (68) 142 ###################################################################### 122 143 GenSGdat('p 4') 123 144 GenSGdat('p 41') … … 125 146 GenSGdat('p 43') 126 147 GenSGdat('i 4') 127 GenSGdat('i 41 1 1')148 GenSGdat('i 41') 128 149 GenSGdat('p 4') 129 150 GenSGdat('i 4') 130 151 GenSGdat('p 4/m') 131 152 GenSGdat('p 42/m') 132 #GenSGdat('p 4/n 1 ') # does not work133 153 GenSGdat('p 4/n') 134 154 GenSGdat('p 42/n') … … 141 161 GenSGdat('p 42 2 2') 142 162 GenSGdat('p 42 21 2') 143 GenSGdat('p 43 2 2 163 GenSGdat('p 43 2 2') 144 164 GenSGdat('p 43 21 2') 145 165 GenSGdat('i 4 2 2') … … 147 167 GenSGdat('p 4 m m') 148 168 GenSGdat('p 4 b m') 149 GenSGdat('p 2 c m')169 GenSGdat('p 42 c m') 150 170 GenSGdat('p 42 n m') 151 171 GenSGdat('p 4 c c') … … 189 209 GenSGdat('i 41/a m d') 190 210 GenSGdat('i 41/a c d') 191 # triclinic 211 # duplicate  note gives wrong Laue class 212 #GenSGdat('i 41 1 1') # dup: as before 213 #duplist.append(('i 41','i 41 1 1')) 214 #GenSGdat('p 4/n 1 ') # does not work 215 ###################################################################### 216 # triclinic (2) 217 ###################################################################### 192 218 GenSGdat('p 1') 193 219 GenSGdat('p 1') 194 # monoclinic 220 ###################################################################### 221 # monoclinic (13) 222 ###################################################################### 195 223 GenSGdat('p 2') 196 224 GenSGdat('p 21') 197 GenSGdat('c 2 1 1')225 GenSGdat('c 2') 198 226 GenSGdat('p m') 199 227 GenSGdat('p c') 200 228 GenSGdat('c m') 201 229 GenSGdat('c c') 202 GenSGdat('p 1 2/m 1')230 GenSGdat('p 2/m') 203 231 GenSGdat('p 21/m') 204 232 GenSGdat('c 2/m') 205 233 GenSGdat('p 2/c') 206 234 GenSGdat('p 21/c') 207 GenSGdat('c 1 2/c 1') 208 # trigonal 235 GenSGdat('c 2/c') 236 # duplicates 237 GenSGdat('c 1 2 1') # dup: as before 238 duplist.append(('c 2','c 1 2 1')) 239 GenSGdat('c 1 2/c 1') # dup: as before 240 duplist.append(('c 2/c','c 1 2/c 1')) 241 GenSGdat('p 1 2/m 1') # dup: as before 242 duplist.append(('p 2/m','p 1 2/m 1')) 243 ###################################################################### 244 # trigonal (25) 245 ###################################################################### 246 GenSGdat('p 3') 209 247 GenSGdat('p 31') 210 GenSGdat('p 32 1 1')248 GenSGdat('p 32') 211 249 GenSGdat('r 3') 212 GenSGdat('r 3 r')213 250 GenSGdat('p 3') 214 251 GenSGdat('r 3') 215 GenSGdat('r 3 r')216 252 GenSGdat('p 3 1 2') 217 253 GenSGdat('p 3 2 1') … … 220 256 GenSGdat('p 32 1 2') 221 257 GenSGdat('p 32 2 1') 222 GenSGdat('r 3 2 h') 223 GenSGdat('r 3 2 r') 258 GenSGdat('r 3 2') 224 259 GenSGdat('p 3 m 1') 225 260 GenSGdat('p 3 1 m') 226 261 GenSGdat('p 3 c 1') 227 262 GenSGdat('p 3 1 c') 228 GenSGdat('r 3 m h') 229 GenSGdat('r 3 m r') 263 GenSGdat('r 3 m') 230 264 GenSGdat('r 3 c') 231 GenSGdat('r 3 c r')232 265 GenSGdat('p 3 1 m') 233 266 GenSGdat('p 3 1 c') 234 267 GenSGdat('p 3 m 1') 235 268 GenSGdat('p 3 c 1') 236 GenSGdat('r 3 m') 237 GenSGdat('r 3 m r') 269 GenSGdat('r 3 m') 238 270 GenSGdat('r 3 c') 239 GenSGdat('r 3 c r') 240 # hexagonal 271 # duplicate 272 GenSGdat('r 3 r') # dup: rhomb setting 273 GenSGdat('r 3 r') # dup: rhomb setting 274 GenSGdat('r 3 2 r') # dup: rhomb setting 275 GenSGdat('r 3 c r') # dup: rhomb setting 276 GenSGdat('r 3 m r') # dup: rhomb setting 277 GenSGdat('r 3 c r') # dup: rhomb setting 278 GenSGdat('r 3 m r') # dup: rhomb setting 279 GenSGdat('p 32 1 1') # dup: as before 280 duplist.append(('p 32','p 32 1 1')) 281 GenSGdat('r 3 2 h') # dup: hex setting 282 duplist.append(('r 3 2','r 3 2 h')) 283 GenSGdat('r 3 m h') # dup: hex setting 284 duplist.append(('r 3 m','r 3 m h')) 285 ###################################################################### 286 # hexagonal (27) 287 ###################################################################### 241 288 GenSGdat('p 6') 242 289 GenSGdat('p 61') 243 GenSGdat('p 65 1 1')290 GenSGdat('p 65') 244 291 GenSGdat('p 62') 245 292 GenSGdat('p 64') 246 293 GenSGdat('p 63') 247 294 GenSGdat('p 6') 248 GenSGdat('p 6/m 1 1')295 GenSGdat('p 6/m') 249 296 GenSGdat('p 63/m') 250 297 GenSGdat('p 6 2 2') … … 266 313 GenSGdat('p 63/m c m') 267 314 GenSGdat('p 63/m m c') 268 # nonstandard space groups 269 GenSGdat('p 1 1 2/m') 270 GenSGdat('p 2/m 1 1') 271 GenSGdat('F 1') 272 GenSGdat('a 2 2 2') 273 274 275 print "# output from GSASIIspc computed on platform",sys.platform,"on",datetime.date.today() 276 print "import numpy as np" 277 print "array = np.array" 278 print "float32=np.float32" 279 print 'SGdat = {' 315 # duplicate 316 GenSGdat('p 65 1 1') # dup: as before 317 duplist.append(('p 65','p 65 1 1')) 318 GenSGdat('p 6/m 1 1') # dup: as before 319 duplist.append(('p 6/m','p 6/m 1 1')) 320 ###################################################################### 321 # nonstandard space group settings 322 ######################################################################G 323 GenSGdat('p 1 1 2/m') # dup: nonstandard 324 GenSGdat('p 2/m 1 1') # dup: nonstandard 325 GenSGdat('F 1') # dup: nonstandard 326 GenSGdat('a 2 2 2') # dup: nonstandard 327 328 # do a bit of internal consistency checking 329 import numpy as np 330 array = np.array 331 float32=np.float32 332 # check for internal agreement with duplicates 333 for key1,key2 in duplist: 334 msg = "checking %s against %s" % (key1, key2) 335 keys = sgdat[key1].keys() 336 assert len(keys) == len(sgdat[key2].keys()), msg 337 for key in keys: 338 if key == 'SGOps': 339 assert len(sgdat[key2][key]) == len(sgdat[key1][key]), msg 340 for i in range(len(sgdat[key2][key])): 341 assert np.allclose(sgdat[key1][key][i][0],sgdat[key2][key][i][0]), msg 342 assert np.allclose(sgdat[key1][key][i][1],sgdat[key2][key][i][1]), msg 343 elif key == 'SGCen': 344 assert len(sgdat[key2][key]) == len(sgdat[key1][key]), msg 345 for i in range(len(sgdat[key2][key])): 346 assert np.allclose(sgdat[key1][key][i][0],sgdat[key2][key][i][0]), msg 347 assert np.allclose(sgdat[key1][key][i][1],sgdat[key2][key][i][1]), msg 348 elif key == 'SpGrp': # expect this to differ 349 pass 350 else: 351 assert sgdat[key1][key] == sgdat[key2][key], msg+': key = '+key 352 353 354 fp = open('spctestinp.py','w') 355 fp.write("# output from GSASIIspc computed on platform %s on %s\n" % 356 (sys.platform, datetime.date.today()) ) 357 fp.write("import numpy as np\n") 358 fp.write("array = np.array\n") 359 fp.write("float32=np.float32\n") 360 fp.write('# testing %s space groups (25 dups/nonstandard)\n' % len(sgdat)) 361 fp.write('SGdat = {\n') 280 362 for spc in sgdat: 281 print ('"%s":' % spc),sgdat[spc],","282 print "}" 283 284 print 'SGlist = {' 363 fp.write('"%s": %s ,\n' % (spc,sgdat[spc],)) 364 fp.write("}\n") 365 366 fp.write('SGlist = {\n') 285 367 for spc in sgdat: 286 print ('"%s":' % spc),sglist[spc],"," 287 print "}" 368 fp.write('"%s": %s ,\n' % (spc,sglist[spc],)) 369 fp.write("}\n") 370 fp.close()
Note: See TracChangeset
for help on using the changeset viewer.