Skip to content

Commit 10a3759

Browse files
Merge pull request #145 from Exabyte-io/feature/SOF-7266-1-round-coordinates-update-precision-x2
feature/SOF-7266-1-round-coordinates-update-precision-x2
2 parents dde6feb + 964003c commit 10a3759

File tree

3 files changed

+35
-31
lines changed

3 files changed

+35
-31
lines changed

express/parsers/structure.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@
1717

1818
PRECISION_MAP = {
1919
# decimal places
20-
"coordinates_crystal": 6,
21-
## Default values are used for the below
22-
# "coordinates_crystal": 4,
23-
# "angles": 4,
20+
"coordinates_crystal": 9,
21+
"coordinates_cartesian": 6,
22+
"angles": 4,
2423
}
2524

2625

@@ -67,11 +66,12 @@ def lattice_vectors(self):
6766
Reference:
6867
func: express.parsers.mixins.ionic.IonicDataMixin.lattice_vectors
6968
"""
69+
precision = PRECISION_MAP["coordinates_cartesian"]
7070
return {
7171
"vectors": {
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]),
72+
"a": self._round(self.structure.lattice.matrix.tolist()[0], precision),
73+
"b": self._round(self.structure.lattice.matrix.tolist()[1], precision),
74+
"c": self._round(self.structure.lattice.matrix.tolist()[2], precision),
7575
"alat": 1.0,
7676
}
7777
}
@@ -83,14 +83,16 @@ def lattice_bravais(self):
8383
Reference:
8484
func: express.parsers.mixins.ionic.IonicDataMixin.lattice_bravais
8585
"""
86+
precision_coordinates = PRECISION_MAP["coordinates_cartesian"]
87+
precision_angles = PRECISION_MAP["angles"]
8688
return {
8789
"type": self._lattice_type(),
88-
"a": self._round(self.structure.lattice.a),
89-
"b": self._round(self.structure.lattice.b),
90-
"c": self._round(self.structure.lattice.c),
91-
"alpha": self._round(self.structure.lattice.alpha),
92-
"beta": self._round(self.structure.lattice.beta),
93-
"gamma": self._round(self.structure.lattice.gamma),
90+
"a": self._round(self.structure.lattice.a, precision_coordinates),
91+
"b": self._round(self.structure.lattice.b, precision_coordinates),
92+
"c": self._round(self.structure.lattice.c, precision_coordinates),
93+
"alpha": self._round(self.structure.lattice.alpha, precision_angles),
94+
"beta": self._round(self.structure.lattice.beta, precision_angles),
95+
"gamma": self._round(self.structure.lattice.gamma, precision_angles),
9496
"units": {"length": "angstrom", "angle": "degree"},
9597
}
9698

express/properties/non_scalar/bandgaps.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
from express.properties.utils import eigenvalues
55
from express.properties.non_scalar import NonScalarProperty
66

7+
PRECISION_MAP = {
8+
# decimal places
9+
"ibz_kpts": 4,
10+
"eigenvalues": 4,
11+
}
12+
713

814
class BandGaps(NonScalarProperty):
915
"""
@@ -96,11 +102,13 @@ def compute_on_mesh(
96102
# value for shifting back eigenvalues (see also _get_bands_info)
97103
e_fermi = self.fermi_energy if absolute_eigenvalues else 0
98104

105+
precision = PRECISION_MAP["ibz_kpts"]
106+
99107
if k_val is not None and k_cond is not None:
100108
result.update(
101109
{
102-
"kpointValence": self._round(self.ibz_k_points[k_val]),
103-
"kpointConduction": self._round(self.ibz_k_points[k_cond]),
110+
"kpointValence": self._round(self.ibz_k_points[k_val], precision),
111+
"kpointConduction": self._round(self.ibz_k_points[k_cond], precision),
104112
"eigenvalueValence": ev_k[k_val] + e_fermi,
105113
"eigenvalueConduction": ec_k[k_cond] + e_fermi,
106114
}
@@ -169,12 +177,13 @@ def _eigenvalues(self) -> list:
169177
Returns:
170178
dict
171179
"""
180+
precision = PRECISION_MAP["eigenvalues"]
172181
eigens_at_kpoints = deepcopy(self.eigenvalues_at_kpoints)
173182
for eigens_at_kpoint in eigens_at_kpoints:
174-
eigens_at_kpoint["kpoint"] = self._round(eigens_at_kpoint["kpoint"])
183+
eigens_at_kpoint["kpoint"] = self._round(eigens_at_kpoint["kpoint"], precision)
175184
for eigens_at_spin in eigens_at_kpoint["eigenvalues"]:
176-
eigens_at_spin["energies"] = self._round(eigens_at_spin["energies"])
177-
eigens_at_spin["occupations"] = self._round(eigens_at_spin["occupations"])
185+
eigens_at_spin["energies"] = self._round(eigens_at_spin["energies"], precision)
186+
eigens_at_spin["occupations"] = self._round(eigens_at_spin["occupations"], precision)
178187
# occupations are empty in case of QE GW, hence sending all values.
179188
if len(eigens_at_spin["occupations"]) == 0:
180189
continue

express/settings.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,10 @@
4949
"average_potential_profile": {
5050
"reference": "express.properties.non_scalar.two_dimensional_plot.average_potential_profile.AveragePotentialProfile" # noqa: E501
5151
},
52-
"dielectric_tensor": {
53-
"reference": "express.properties.non_scalar.dielectric_tensor.DielectricTensor"
54-
},
55-
"hubbard_u": {
56-
"reference": "express.properties.non_scalar.hubbard_u.HubbardU"
57-
},
58-
"hubbard_v": {
59-
"reference": "express.properties.non_scalar.hubbard_v.HubbardV"
60-
},
61-
"hubbard_v_nn": {
62-
"reference": "express.properties.non_scalar.hubbard_v_nn.HubbardV_NN"
63-
}
52+
"dielectric_tensor": {"reference": "express.properties.non_scalar.dielectric_tensor.DielectricTensor"},
53+
"hubbard_u": {"reference": "express.properties.non_scalar.hubbard_u.HubbardU"},
54+
"hubbard_v": {"reference": "express.properties.non_scalar.hubbard_v.HubbardV"},
55+
"hubbard_v_nn": {"reference": "express.properties.non_scalar.hubbard_v_nn.HubbardV_NN"},
6456
}
6557

6658
CONVERGENCE_PROPERTIES = {
@@ -81,4 +73,5 @@
8173
"exabyteml": "express.parsers.exabyteml.ExabyteMLParser",
8274
}
8375

84-
PRECISION = 4
76+
# Used to round to zero by default
77+
PRECISION = 9

0 commit comments

Comments
 (0)