From 964003cfd380545625fe309495117d2f091a599f Mon Sep 17 00:00:00 2001 From: VsevolodX <79542055+VsevolodX@users.noreply.github.com> Date: Tue, 20 Feb 2024 22:12:42 -0800 Subject: [PATCH] update: round materials coordinates, lattice params x 3 --- express/parsers/structure.py | 28 ++++++++++++----------- express/properties/non_scalar/bandgaps.py | 19 +++++++++++---- express/settings.py | 19 +++++---------- 3 files changed, 35 insertions(+), 31 deletions(-) diff --git a/express/parsers/structure.py b/express/parsers/structure.py index f3848ef7..5ea088ef 100644 --- a/express/parsers/structure.py +++ b/express/parsers/structure.py @@ -17,10 +17,9 @@ PRECISION_MAP = { # decimal places - "coordinates_crystal": 6, - ## Default values are used for the below - # "coordinates_crystal": 4, - # "angles": 4, + "coordinates_crystal": 9, + "coordinates_cartesian": 6, + "angles": 4, } @@ -67,11 +66,12 @@ def lattice_vectors(self): Reference: func: express.parsers.mixins.ionic.IonicDataMixin.lattice_vectors """ + precision = PRECISION_MAP["coordinates_cartesian"] return { "vectors": { - "a": self._round(self.structure.lattice.matrix.tolist()[0]), - "b": self._round(self.structure.lattice.matrix.tolist()[1]), - "c": self._round(self.structure.lattice.matrix.tolist()[2]), + "a": self._round(self.structure.lattice.matrix.tolist()[0], precision), + "b": self._round(self.structure.lattice.matrix.tolist()[1], precision), + "c": self._round(self.structure.lattice.matrix.tolist()[2], precision), "alat": 1.0, } } @@ -83,14 +83,16 @@ def lattice_bravais(self): Reference: func: express.parsers.mixins.ionic.IonicDataMixin.lattice_bravais """ + precision_coordinates = PRECISION_MAP["coordinates_cartesian"] + precision_angles = PRECISION_MAP["angles"] return { "type": self._lattice_type(), - "a": self._round(self.structure.lattice.a), - "b": self._round(self.structure.lattice.b), - "c": self._round(self.structure.lattice.c), - "alpha": self._round(self.structure.lattice.alpha), - "beta": self._round(self.structure.lattice.beta), - "gamma": self._round(self.structure.lattice.gamma), + "a": self._round(self.structure.lattice.a, precision_coordinates), + "b": self._round(self.structure.lattice.b, precision_coordinates), + "c": self._round(self.structure.lattice.c, precision_coordinates), + "alpha": self._round(self.structure.lattice.alpha, precision_angles), + "beta": self._round(self.structure.lattice.beta, precision_angles), + "gamma": self._round(self.structure.lattice.gamma, precision_angles), "units": {"length": "angstrom", "angle": "degree"}, } diff --git a/express/properties/non_scalar/bandgaps.py b/express/properties/non_scalar/bandgaps.py index d9ead891..69182d41 100644 --- a/express/properties/non_scalar/bandgaps.py +++ b/express/properties/non_scalar/bandgaps.py @@ -4,6 +4,12 @@ from express.properties.utils import eigenvalues from express.properties.non_scalar import NonScalarProperty +PRECISION_MAP = { + # decimal places + "ibz_kpts": 4, + "eigenvalues": 4, +} + class BandGaps(NonScalarProperty): """ @@ -96,11 +102,13 @@ def compute_on_mesh( # value for shifting back eigenvalues (see also _get_bands_info) e_fermi = self.fermi_energy if absolute_eigenvalues else 0 + precision = PRECISION_MAP["ibz_kpts"] + if k_val is not None and k_cond is not None: result.update( { - "kpointValence": self._round(self.ibz_k_points[k_val]), - "kpointConduction": self._round(self.ibz_k_points[k_cond]), + "kpointValence": self._round(self.ibz_k_points[k_val], precision), + "kpointConduction": self._round(self.ibz_k_points[k_cond], precision), "eigenvalueValence": ev_k[k_val] + e_fermi, "eigenvalueConduction": ec_k[k_cond] + e_fermi, } @@ -169,12 +177,13 @@ def _eigenvalues(self) -> list: Returns: dict """ + precision = PRECISION_MAP["eigenvalues"] eigens_at_kpoints = deepcopy(self.eigenvalues_at_kpoints) for eigens_at_kpoint in eigens_at_kpoints: - eigens_at_kpoint["kpoint"] = self._round(eigens_at_kpoint["kpoint"]) + eigens_at_kpoint["kpoint"] = self._round(eigens_at_kpoint["kpoint"], precision) for eigens_at_spin in eigens_at_kpoint["eigenvalues"]: - eigens_at_spin["energies"] = self._round(eigens_at_spin["energies"]) - eigens_at_spin["occupations"] = self._round(eigens_at_spin["occupations"]) + eigens_at_spin["energies"] = self._round(eigens_at_spin["energies"], precision) + eigens_at_spin["occupations"] = self._round(eigens_at_spin["occupations"], precision) # occupations are empty in case of QE GW, hence sending all values. if len(eigens_at_spin["occupations"]) == 0: continue diff --git a/express/settings.py b/express/settings.py index a1ef98f5..e8e20204 100644 --- a/express/settings.py +++ b/express/settings.py @@ -49,18 +49,10 @@ "average_potential_profile": { "reference": "express.properties.non_scalar.two_dimensional_plot.average_potential_profile.AveragePotentialProfile" # noqa: E501 }, - "dielectric_tensor": { - "reference": "express.properties.non_scalar.dielectric_tensor.DielectricTensor" - }, - "hubbard_u": { - "reference": "express.properties.non_scalar.hubbard_u.HubbardU" - }, - "hubbard_v": { - "reference": "express.properties.non_scalar.hubbard_v.HubbardV" - }, - "hubbard_v_nn": { - "reference": "express.properties.non_scalar.hubbard_v_nn.HubbardV_NN" - } + "dielectric_tensor": {"reference": "express.properties.non_scalar.dielectric_tensor.DielectricTensor"}, + "hubbard_u": {"reference": "express.properties.non_scalar.hubbard_u.HubbardU"}, + "hubbard_v": {"reference": "express.properties.non_scalar.hubbard_v.HubbardV"}, + "hubbard_v_nn": {"reference": "express.properties.non_scalar.hubbard_v_nn.HubbardV_NN"}, } CONVERGENCE_PROPERTIES = { @@ -81,4 +73,5 @@ "exabyteml": "express.parsers.exabyteml.ExabyteMLParser", } -PRECISION = 4 +# Used to round to zero by default +PRECISION = 9