Changeset 57 for trunk/testinp


Ignore:
Timestamp:
Apr 29, 2010 9:30:47 PM (12 years ago)
Author:
toby
Message:

fixup unit test for GSASIIspg.py; provide files & Makefile for pyspg.for

Location:
trunk/testinp
Files:
2 added
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/testinp/genselftest.py

    r30 r57  
    11'''
    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
    89'''
    910import sys
     
    2223        sglist[spc] = GSASIIspc.SGPrint(D)
    2324
    24 #cubic
     25duplist = []
     26######################################################################
     27#cubic (36)
     28######################################################################
    2529GenSGdat('p 2 3')
    2630GenSGdat('f 2 3')
     
    3135GenSGdat('p n -3')
    3236GenSGdat('f m 3')
    33 GenSGdat('f d -3')
    34 GenSGdat('i m -3')
     37GenSGdat('f d 3')
     38GenSGdat('i m 3')
    3539GenSGdat('p a 3')
    3640GenSGdat('i a 3')
     
    5963GenSGdat('i m -3 m')
    6064GenSGdat('i a -3 d')
    61 # ortho
     65# duplicates (IT A naming)
     66GenSGdat('p m -3') # dup: as before
     67duplist.append(('p m 3', 'p m -3'))
     68GenSGdat('f m -3') # dup: as before
     69duplist.append(('f m 3','f m -3'))
     70GenSGdat('f d -3') # dup: as before
     71duplist.append(('f d 3','f d -3'))
     72GenSGdat('i m -3') # dup: as before
     73duplist.append(('i m 3','i m -3'))
     74GenSGdat('p a -3') # dup: as before
     75duplist.append(('p a 3','p a -3'))
     76GenSGdat('i a -3') # dup: as before
     77duplist.append(('i a 3','i a -3'))
     78######################################################################
     79# ortho (59)
     80######################################################################
    6281GenSGdat('p 2 2 2')
    6382GenSGdat('p 2 2 21')
     
    119138GenSGdat('i b c a')
    120139GenSGdat('i m m a')
    121 # tetragonal
     140######################################################################
     141# tetragonal (68)
     142######################################################################
    122143GenSGdat('p 4')
    123144GenSGdat('p 41')
     
    125146GenSGdat('p 43')
    126147GenSGdat('i 4')
    127 GenSGdat('i 41 1 1')
     148GenSGdat('i 41')
    128149GenSGdat('p -4')
    129150GenSGdat('i -4')
    130151GenSGdat('p 4/m')
    131152GenSGdat('p 42/m')
    132 #GenSGdat('p 4/n 1 ') # does not work
    133153GenSGdat('p 4/n')
    134154GenSGdat('p 42/n')
     
    141161GenSGdat('p 42 2 2')
    142162GenSGdat('p 42 21 2')
    143 GenSGdat('p 43 2 2 ')
     163GenSGdat('p 43 2 2')
    144164GenSGdat('p 43 21 2')
    145165GenSGdat('i 4 2 2')
     
    147167GenSGdat('p 4 m m')
    148168GenSGdat('p 4 b m')
    149 GenSGdat('p 2 c m')
     169GenSGdat('p 42 c m')
    150170GenSGdat('p 42 n m')
    151171GenSGdat('p 4 c c')
     
    189209GenSGdat('i 41/a m d')
    190210GenSGdat('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######################################################################
    192218GenSGdat('p 1')
    193219GenSGdat('p -1')
    194 # monoclinic
     220######################################################################
     221# monoclinic (13)
     222######################################################################
    195223GenSGdat('p 2')
    196224GenSGdat('p 21')
    197 GenSGdat('c 2 1 1')
     225GenSGdat('c 2')
    198226GenSGdat('p m')
    199227GenSGdat('p c')
    200228GenSGdat('c m')
    201229GenSGdat('c c')
    202 GenSGdat('p 1 2/m 1')
     230GenSGdat('p 2/m')
    203231GenSGdat('p 21/m')
    204232GenSGdat('c 2/m')
    205233GenSGdat('p 2/c')
    206234GenSGdat('p 21/c')
    207 GenSGdat('c 1 2/c 1')
    208 # trigonal
     235GenSGdat('c 2/c')
     236# duplicates
     237GenSGdat('c 1 2 1') # dup: as before
     238duplist.append(('c 2','c 1 2 1'))
     239GenSGdat('c 1 2/c 1') # dup: as before
     240duplist.append(('c 2/c','c 1 2/c 1'))
     241GenSGdat('p 1 2/m 1') # dup: as before
     242duplist.append(('p 2/m','p 1 2/m 1'))
     243######################################################################
     244# trigonal (25)
     245######################################################################
     246GenSGdat('p 3')
    209247GenSGdat('p 31')
    210 GenSGdat('p 32 1 1')
     248GenSGdat('p 32')
    211249GenSGdat('r 3')
    212 GenSGdat('r 3 r')
    213250GenSGdat('p -3')
    214251GenSGdat('r -3')
    215 GenSGdat('r -3 r')
    216252GenSGdat('p 3 1 2')
    217253GenSGdat('p 3 2 1')
     
    220256GenSGdat('p 32 1 2')
    221257GenSGdat('p 32 2 1')
    222 GenSGdat('r 3 2 h')
    223 GenSGdat('r 3 2 r')
     258GenSGdat('r 3 2')
    224259GenSGdat('p 3 m 1')
    225260GenSGdat('p 3 1 m')
    226261GenSGdat('p 3 c 1')
    227262GenSGdat('p 3 1 c')
    228 GenSGdat('r 3 m h')
    229 GenSGdat('r 3 m r')
     263GenSGdat('r 3 m')
    230264GenSGdat('r 3 c')
    231 GenSGdat('r 3 c r')
    232265GenSGdat('p -3 1 m')
    233266GenSGdat('p -3 1 c')
    234267GenSGdat('p -3 m 1')
    235268GenSGdat('p -3 c 1')
    236 GenSGdat('r -3 m')
    237 GenSGdat('r -3 m r')
     269GenSGdat('r -3 m')
    238270GenSGdat('r -3 c')
    239 GenSGdat('r -3 c r')
    240 # hexagonal
     271# duplicate
     272GenSGdat('r 3 r') # dup: rhomb setting
     273GenSGdat('r -3 r') # dup: rhomb setting
     274GenSGdat('r 3 2 r') # dup: rhomb setting
     275GenSGdat('r -3 c r') # dup: rhomb setting
     276GenSGdat('r 3 m r') # dup: rhomb setting
     277GenSGdat('r 3 c r') # dup: rhomb setting
     278GenSGdat('r -3 m r') # dup: rhomb setting
     279GenSGdat('p 32 1 1') # dup: as before
     280duplist.append(('p 32','p 32 1 1'))
     281GenSGdat('r 3 2 h') # dup: hex setting
     282duplist.append(('r 3 2','r 3 2 h'))
     283GenSGdat('r 3 m h') # dup: hex setting
     284duplist.append(('r 3 m','r 3 m h'))
     285######################################################################
     286# hexagonal (27)
     287######################################################################
    241288GenSGdat('p 6')
    242289GenSGdat('p 61')
    243 GenSGdat('p 65 1 1')
     290GenSGdat('p 65')
    244291GenSGdat('p 62')
    245292GenSGdat('p 64')
    246293GenSGdat('p 63')
    247294GenSGdat('p -6')
    248 GenSGdat('p 6/m 1 1')
     295GenSGdat('p 6/m')
    249296GenSGdat('p 63/m')
    250297GenSGdat('p 6 2 2')
     
    266313GenSGdat('p 63/m c m')
    267314GenSGdat('p 63/m m c')
    268 # non-standard 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
     316GenSGdat('p 65 1 1') # dup: as before
     317duplist.append(('p 65','p 65 1 1'))
     318GenSGdat('p 6/m 1 1') # dup: as before
     319duplist.append(('p 6/m','p 6/m 1 1'))
     320######################################################################
     321# non-standard space group settings
     322######################################################################G
     323GenSGdat('p 1 1 2/m') # dup: non-standard
     324GenSGdat('p 2/m 1 1') # dup: non-standard
     325GenSGdat('F -1')      # dup: non-standard
     326GenSGdat('a 2 2 2')   # dup: non-standard
     327
     328# do a bit of internal consistency checking
     329import numpy as np
     330array = np.array
     331float32=np.float32
     332# check for internal agreement with duplicates
     333for 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
     354fp = open('spctestinp.py','w')
     355fp.write("# output from GSASIIspc computed on platform %s on %s\n" %
     356         (sys.platform, datetime.date.today()) )
     357fp.write("import numpy as np\n")
     358fp.write("array = np.array\n")
     359fp.write("float32=np.float32\n")
     360fp.write('# testing %s space groups (25 dups/non-standard)\n' % len(sgdat))
     361fp.write('SGdat = {\n')
    280362for spc in sgdat:
    281     print ('"%s":' % spc),sgdat[spc],","
    282 print "}"
    283 
    284 print 'SGlist = {'
     363    fp.write('"%s": %s ,\n' % (spc,sgdat[spc],))
     364fp.write("}\n")
     365
     366fp.write('SGlist = {\n')
    285367for spc in sgdat:
    286     print ('"%s":' % spc),sglist[spc],","
    287 print "}"
     368    fp.write('"%s": %s ,\n' % (spc,sglist[spc],))
     369fp.write("}\n")
     370fp.close()
  • trunk/testinp/gensgtbx.py

    r30 r57  
    22'''
    33Generate symmetry operations in cctbx.sgtbx for use in testing the
    4 GSASII space group generation code. I think one of the 230 spacegroups
    5 is missing from the list below; but there are two settings included for the
    6 rhombohedral groups.
    7 
    8 Redirect output to sgtbxdat.py to create the input file for testing.
     4GSASII space group generation code. All 230 spacegroups are tested plus
     5rhombohedral settings of R space groups.
     6
     7 The output from this is placed in sgtbxtestinp.py which contains a dictionary
     8 sgtbx that can be used for testing.
     9
    910'''
    1011
    1112from cctbx import sgtbx
     13import sys
     14import datetime
    1215
    1316def GenSGdat(spc):
    14     print "'%s': [" % spc
     17    fp.write("'%s': [\n" % spc)
    1518    s=sgtbx.space_group_info(spc)
    1619    for s1 in s.group():
    17         print s1.as_double_array(),","
    18     print "],\n"
    19 print "sgtbx = {"
     20#        print s1.as_double_array()
     21        fp.write("%s ,\n" % (s1.as_double_array(),))
     22    fp.write("],\n\n")
     23
     24fp = open('sgtbxtestinp.py','w')
     25fp.write("# output from sgtbx computed on platform %s on %s\n" %
     26         (sys.platform, datetime.date.today()) )
     27fp.write("sgtbx = {\n")
    2028#cubic
    2129GenSGdat('p 2 3')
     
    121129GenSGdat('p 43')
    122130GenSGdat('i 4')
    123 #GenSGdat('i 41 1 1') # not accepted by cctbx
    124131GenSGdat('i 41')
    125132GenSGdat('p -4')
     
    127134GenSGdat('p 4/m')
    128135GenSGdat('p 42/m')
    129 #GenSGdat('p 4/n 1 ') # does not work
    130136GenSGdat('p 4/n')
    131137GenSGdat('p 42/n')
     
    138144GenSGdat('p 42 2 2')
    139145GenSGdat('p 42 21 2')
    140 GenSGdat('p 43 2 2 ')
     146GenSGdat('p 43 2 2')
    141147GenSGdat('p 43 21 2')
    142148GenSGdat('i 4 2 2')
     
    144150GenSGdat('p 4 m m')
    145151GenSGdat('p 4 b m')
    146 GenSGdat('p 2 c m')
     152GenSGdat('p 42 c m')
    147153GenSGdat('p 42 n m')
    148154GenSGdat('p 4 c c')
     
    183189GenSGdat('p 42/n c m')
    184190GenSGdat('i 4/m m m')
    185 GenSGdat('i 4/m c m ')
     191GenSGdat('i 4/m c m')
    186192GenSGdat('i 41/a m d')
    187193GenSGdat('i 41/a c d')
     
    192198GenSGdat('p 2')
    193199GenSGdat('p 21')
    194 GenSGdat('c 2 1 1')
     200GenSGdat('c 2')
    195201GenSGdat('p m')
    196202GenSGdat('p c')
    197203GenSGdat('c m')
    198204GenSGdat('c c')
    199 GenSGdat('p 1 2/m 1')
     205GenSGdat('p 2/m')
    200206GenSGdat('p 21/m')
    201207GenSGdat('c 2/m')
    202208GenSGdat('p 2/c')
    203209GenSGdat('p 21/c')
    204 GenSGdat('c 1 2/c 1')
     210GenSGdat('c 2/c')
    205211# trigonal
     212GenSGdat('p 3')
    206213GenSGdat('p 31')
    207 #GenSGdat('p 32 1 1')  # not accepted by cctbx
    208214GenSGdat('p 32')
    209215GenSGdat('r 3')
     
    239245GenSGdat('p 6')
    240246GenSGdat('p 61')
    241 #GenSGdat('p 65 1 1')  # not accepted by cctbx
    242247GenSGdat('p 65')
    243248GenSGdat('p 62')
     
    245250GenSGdat('p 63')
    246251GenSGdat('p -6')
    247 #GenSGdat('p 6/m 1 1')  # not accepted by cctbx
    248252GenSGdat('p 6/m')
    249253GenSGdat('p 63/m')
     
    266270GenSGdat('p 63/m c m')
    267271GenSGdat('p 63/m m c')
    268 
    269 print "}"
     272# non-standard
     273GenSGdat('p 21 1 1')
     274GenSGdat('p 1 21 1')
     275GenSGdat('p 1 1 21')
     276fp.write("}\n")
     277fp.close()
Note: See TracChangeset for help on using the changeset viewer.