|
15 | 15 |
|
16 | 16 | """Utilities for crystals."""
|
17 | 17 |
|
18 |
| -def crystalToDiffpyStructure(crystal): |
19 |
| - """Create a diffpy.Structure.Structure from a crystal. |
20 |
| -
|
21 |
| - This requires diffpy.Structure to be installed. This uses file IO transfer |
22 |
| - data, so there is some inherent precision loss. |
23 |
| -
|
24 |
| - Note that the resulting structure will be in P1 symmetry. |
25 |
| -
|
26 |
| - """ |
27 |
| - |
28 |
| - # Write the crystal to string and load it into a diffpy Structure |
29 |
| - |
30 |
| - from io import StringIO |
31 |
| - buf = StringIO() |
32 |
| - crystal.CIFOutput(buf) |
33 |
| - |
34 |
| - from diffpy.Structure import Structure |
35 |
| - stru = Structure() |
36 |
| - |
37 |
| - s = buf.getvalue() |
38 |
| - stru.readStr(s) |
39 |
| - buf.close() |
40 |
| - |
41 |
| - return stru |
42 |
| - |
43 |
| -def expandSymmetry(crystal): |
44 |
| - """Expand a crystal to P1 symmetry. |
45 |
| -
|
46 |
| - This requires diffpy.Structure to be installed. This uses file IO transfer |
47 |
| - data, so there is some inherent precision loss. |
48 |
| -
|
49 |
| - This returns a new structure. |
50 |
| -
|
51 |
| - """ |
52 |
| - |
53 |
| - # Create a string from a diffpy Structure, which is in P1 symmetry, and |
54 |
| - # load this as a Crystal. |
55 |
| - stru = crystalToDiffpyStructure(crystal) |
56 |
| - |
57 |
| - cifstr = stru.writeStr(format = "cif") |
58 |
| - from io import StringIO |
59 |
| - buf = StringIO(cifstr) |
60 |
| - |
61 |
| - from pyobjcryst.crystal import CreateCrystalFromCIF |
62 |
| - p1 = CreateCrystalFromCIF(buf) |
63 |
| - return p1 |
64 |
| - |
65 | 18 |
|
66 | 19 | def putAtomsInMolecule(crystal, alist = None, name = None):
|
67 | 20 | """Place atoms from a crystal into a molecule inside the crystal.
|
|
0 commit comments