source: trunk/testinp/gencelltests.py @ 5036

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

Update orthogonalization routine w/unit-tests

  • Property svn:executable set to *
File size: 1.6 KB
Line 
1#!/Users/toby/build/cctbx_build/bin/python
2import sys
3import cctbx.uctbx as uc
4import numpy as np
5import datetime
6
7fp = sys.stdout
8fp.write("# output from uctbx (cctbx) computed on platform %s on %s\n" %
9         (sys.platform, datetime.date.today()) )
10fp.write("#import numpy as np\n")
11fp.write("array = np.array\n\n")
12fp.write("CellTestData = [\n")
13
14for cell in [
15    (4,4,4,90,90,90),
16    (4.1,5.2,6.3,100,80,130),
17    (3.5,3.5,6,90,90,120),
18    ]:
19    fp.write("# cell, g, G, cell*, V, V*\n")
20    result = []
21    result.append(cell)
22    mm = uc.unit_cell(cell).metrical_matrix()
23    result.append(
24        np.array([mm[i] for i in (0,3,4,3,1,5,4,5,2)]).reshape(3,3)
25        )
26    rmm = uc.unit_cell(cell).reciprocal_metrical_matrix()
27    result.append(
28        np.array([rmm[i] for i in (0,3,4,3,1,5,4,5,2)]).reshape(3,3)
29        )
30    result.append(
31        uc.unit_cell(cell).reciprocal().parameters()
32        )
33    result.append(
34        uc.unit_cell(cell).volume()
35        )
36    result.append(
37        uc.unit_cell(cell).reciprocal().volume()
38        )
39    fp.write(%s,\n" % result)
40fp.write("]\n")
41
42fp.write("CoordTestData = [\n")
43for cell in [
44    (4,4,4,90,90,90),
45    (4.1,5.2,6.3,100,80,130),
46    (3.5,3.5,6,90,90,120),
47    ]:
48    fp.write("# cell, ((frac, ortho),...)\n")
49    fp.write("  ((%s,%s,%s,%s,%s,%s,), [\n" % cell)
50    for frac in [
51        (0.1,0.,0.),
52        (0.,0.1,0.),
53        (0.,0.,0.1),
54        (0.1,0.2,0.3),
55        (0.2,0.3,0.1),
56        (0.3,0.2,0.1),
57        (0.5,0.5,0.5),
58        ]:
59        fp.write(" (%s,%s),\n" % (frac, uc.unit_cell(cell).orthogonalize(frac)))
60    fp.write("]),\n")
61fp.write("]\n")
62   
63sys.exit()
Note: See TracBrowser for help on using the repository browser.