source: trunk/testinp/genhkltest.py @ 102

Last change on this file since 102 was 102, checked in by toby, 12 years ago

add space group list; fix minor bugs in GenHLaue & add unit test

  • Property svn:executable set to *
File size: 2.5 KB
RevLine 
[102]1#!/usr/bin/env /Users/toby/build/cctbx_build/bin/python
2import sys, datetime
3from cctbx import sgtbx
4
5# generate input for test 7 in GSASIIlattice
6dmin = 3
7fp = open('sgtbxlattinp.py','w')
8fp.write("# output from sgtbx computed on platform %s on %s\n" %
9         (sys.platform, datetime.date.today()) )
10fp.write("dmin = %s\n" % dmin)
11fp.write("sgtbx7 = {\n")
12for sg in ("P-1", # space groups for all 14 Bravais lattices
13           "P2/m",
14           "C2/m",
15           "Pmmm",
16           "Cmmm",
17           "Fmmm",
18           "Immm",
19           "P4/mmm",
20           "I4/mmm",
21           "R-3m",
22           "P6/mmm",
23           "Pm-3m",
24           "Im-3m",
25           "Fm-3m",
26           ):
27    sgi = sgtbx.space_group_info(symbol=sg)
28    cs = sgi.any_compatible_crystal_symmetry(volume=1000)
29    ms = cs.build_miller_set(anomalous_flag=False, d_min=dmin)
30    #ms.show_summary()
31    spcg = ("%s" %  ms.space_group_info()).split(':')[0]
32    print spcg
33    fp.write("'%s': [\n" % spcg)
34    fp.write("%s ,\n" % ms.unit_cell())
35    hkllist = {}
36    for hkl,d in ms.d_spacings():
37        if hkllist.has_key(d):
38            hkllist[d].append(hkl)
39            print hkllist[d]
40        else:
41            hkllist[d] = [hkl,]
42    fp.write("  (\n")
43    for d in sorted(hkllist.keys(),reverse=True):
44        fp.write("    (%s, %s),\n" % (hkllist[d],d))
45    fp.write("  )],\n\n")
46fp.write("}\n\n")
47
48# generate input for test 8 in GSASIIlattice
49spg = ("P -1", 
50       "P 2/m",
51       "C 2/m",
52       "B 1 1 2/m",
53       "B 2/m 1 1",
54       "I 2/m",
55       "P m m m",
56       "A m m m",
57       "B m m m",
58       "C m m m",
59       "F m m m",
60       "I m m m",
61       "P 4/m m m",
62       "I 4/m m m",
63       "R -3 m",
64       "P 6/m m m",
65       "P m -3 m",
66       "I m -3 m",
67       "F m -3 m",
68       ) # test w/space groups with only centering extinctions
69# N.B. (cctbx does not accept F -1, etc)
70
71fp.write("sgtbx8 = {\n")
72for sg in spg:
73    sgi = sgtbx.space_group_info(symbol=sg)
74    cs = sgi.any_compatible_crystal_symmetry(volume=1000)
75    ms = cs.build_miller_set(anomalous_flag=False, d_min=dmin)
76    #ms.show_summary()
77    spcg = ("%s" %  ms.space_group_info()).split(':')[0]
78    print spcg
79    #fp.write("'%s': [\n" % spcg)
80    fp.write("'%s': [\n" % sg)
81    fp.write("%s ,\n" % ms.unit_cell())
82    fp.write("  (\n")
83    for hkl,d in ms.d_spacings():
84        fp.write("    (%s, %s),\n" % (hkl,d))
85    fp.write("  )],\n\n")
86fp.write("}\n")
87
88#if __name__ == '__main__':
89#    from IPython.Shell import IPShellEmbed
90#    ipshell = IPShellEmbed()
91#    ipshell() # this call anywhere in your program will start IPython
Note: See TracBrowser for help on using the repository browser.