From 339d3217857d0d891377ba949d200a41325949fb Mon Sep 17 00:00:00 2001 From: lllangWV Date: Wed, 28 Aug 2024 11:39:31 -0400 Subject: [PATCH] Made sure QE output results in angtrom to be consistent with VASP --- pyprocar/io/qe.py | 10 +++++++--- pyprocar/utils/units.py | 8 ++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 pyprocar/utils/units.py diff --git a/pyprocar/io/qe.py b/pyprocar/io/qe.py index 6c04883d..33153550 100644 --- a/pyprocar/io/qe.py +++ b/pyprocar/io/qe.py @@ -12,9 +12,8 @@ import numpy as np from pyprocar.core import DensityOfStates, Structure, ElectronicBandStructure, KPath +from pyprocar.utils.units import HARTREE_TO_EV, AU_TO_ANG - -HARTREE_TO_EV = 27.211386245988 #eV/Hartree class QEParser(): """The class is used to parse Quantum Expresso files. The most important objects that comes from this parser are the .ebs and .dos @@ -806,6 +805,7 @@ def _parse_structure(self,main_xml_root): self.species_list = list(self.composition.keys()) self.ionsCount = int(main_xml_root.findall(".//output/atomic_structure")[0].attrib['nat']) self.alat = float(main_xml_root.findall(".//output/atomic_structure")[0].attrib['alat']) + self.alat = self.alat * AU_TO_ANG self.ions = [] for ion in main_xml_root.findall(".//output/atomic_structure/atomic_positions")[0]: @@ -818,8 +818,12 @@ def _parse_structure(self,main_xml_root): # in a.u self.direct_lattice = np.array([ acell.text.split() for acell in main_xml_root.findall(".//output/atomic_structure/cell")[0] ],dtype = float) - + # in a.u self.reciprocal_lattice = (2 * np.pi /self.alat) * np.array([ acell.text.split() for acell in main_xml_root.findall(".//output/basis_set/reciprocal_lattice")[0] ],dtype = float) + + # Convert to angstrom + self.direct_lattice = self.direct_lattice * AU_TO_ANG + return None def _parse_symmetries(self,main_xml_root): diff --git a/pyprocar/utils/units.py b/pyprocar/utils/units.py new file mode 100644 index 00000000..c74c73c2 --- /dev/null +++ b/pyprocar/utils/units.py @@ -0,0 +1,8 @@ + + +AU_TO_ANG = 0.52917721067121 # bohr/ang +ANG_TO_AU = 1.0 / AU_TO_ANG # ang/bohr + + +HARTREE_TO_EV = 27.211386245988 #eV/Hartree +EV_TO_HARTREE = 1.0 / HARTREE_TO_EV #Hartree/eV \ No newline at end of file