|
15 | 15 | "conventional": lambda s: mg.symmetry.analyzer.SpacegroupAnalyzer(s).get_conventional_standard_structure(), |
16 | 16 | } |
17 | 17 |
|
| 18 | +PRECISION_MAP = { |
| 19 | + # decimal places |
| 20 | + "coordinates_crystal": 6, |
| 21 | + ## Default values are used for the below |
| 22 | + # "coordinates_crystal": 4, |
| 23 | + # "angles": 4, |
| 24 | +} |
| 25 | + |
18 | 26 |
|
19 | 27 | class StructureParser(BaseParser, IonicDataMixin): |
20 | 28 | """ |
@@ -61,9 +69,9 @@ def lattice_vectors(self): |
61 | 69 | """ |
62 | 70 | return { |
63 | 71 | "vectors": { |
64 | | - "a": self.structure.lattice.matrix.tolist()[0], |
65 | | - "b": self.structure.lattice.matrix.tolist()[1], |
66 | | - "c": self.structure.lattice.matrix.tolist()[2], |
| 72 | + "a": self._round(self.structure.lattice.matrix.tolist()[0]), |
| 73 | + "b": self._round(self.structure.lattice.matrix.tolist()[1]), |
| 74 | + "c": self._round(self.structure.lattice.matrix.tolist()[2]), |
67 | 75 | "alat": 1.0, |
68 | 76 | } |
69 | 77 | } |
@@ -160,7 +168,8 @@ def basis(self): |
160 | 168 | "units": "crystal", |
161 | 169 | "elements": [{"id": i, "value": v.species_string} for i, v in enumerate(self.structure.sites)], |
162 | 170 | "coordinates": [ |
163 | | - {"id": i, "value": self._round(v.frac_coords.tolist())} for i, v in enumerate(self.structure.sites) |
| 171 | + {"id": i, "value": self._round(v.frac_coords.tolist(), PRECISION_MAP["coordinates_crystal"])} |
| 172 | + for i, v in enumerate(self.structure.sites) |
164 | 173 | ], |
165 | 174 | } |
166 | 175 |
|
|
0 commit comments