Skip to content

Commit 6bc9b64

Browse files
committed
update: round materials coordinates, lattice params x 2
1 parent 756af08 commit 6bc9b64

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

express/mixins.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33

44

55
class RoundNumericValuesMixin(object):
6-
def _round(self, array):
7-
return np.round(array, settings.PRECISION).tolist()
6+
7+
def _round(self, array, decimal_places=settings.PRECISION):
8+
return np.round(array, decimal_places).tolist()

express/parsers/structure.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
"conventional": lambda s: mg.symmetry.analyzer.SpacegroupAnalyzer(s).get_conventional_standard_structure(),
1616
}
1717

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+
1826

1927
class StructureParser(BaseParser, IonicDataMixin):
2028
"""
@@ -61,9 +69,9 @@ def lattice_vectors(self):
6169
"""
6270
return {
6371
"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]),
6775
"alat": 1.0,
6876
}
6977
}
@@ -160,7 +168,8 @@ def basis(self):
160168
"units": "crystal",
161169
"elements": [{"id": i, "value": v.species_string} for i, v in enumerate(self.structure.sites)],
162170
"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)
164173
],
165174
}
166175

0 commit comments

Comments
 (0)