diff --git a/HISTORY.rst b/HISTORY.rst index cd09668..e66cab3 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,6 +1,12 @@ ======= History ======= +2023.11.8 -- Bugfix: Fermi level being an array caused problems + * The Fermi level in DFTB+ is a vector with 1 or 2 elements, depending whether the + calculation is spin-polarized. DFTB+ can handle different Fermi levels, but it is + not clear how useful this is, so for the time being not allowing such calculations + and treating the Fermi level as a scalar. + 2023.11.7 -- Added structure to orbital and density plots * The Dashboard expects 'structure.sdf' in order to display the structure with the orbital or debsity plots from CUBE files. diff --git a/dftbplus_step/base.py b/dftbplus_step/base.py index edabc6a..a510da6 100644 --- a/dftbplus_step/base.py +++ b/dftbplus_step/base.py @@ -616,7 +616,12 @@ def parse_results(self, lines): if _type == "real": values = [float(x) for x in values] - property_data[key] = redimension(values, dims) + if key == "fermi_level": + # The Fermi level has one or two values if spin-polarized, but + # normally they are the same, so turn into a scalar. + property_data[key] = values[0] + else: + property_data[key] = redimension(values, dims) if key not in properties: self.logger.warning("Property '{}' not recognized.".format(key)) if key in properties and "units" in properties[key]: diff --git a/dftbplus_step/energy.py b/dftbplus_step/energy.py index 91c422d..74a56ed 100644 --- a/dftbplus_step/energy.py +++ b/dftbplus_step/energy.py @@ -618,7 +618,8 @@ def analyze(self, indent="", data={}, out=[]): # Prepare the DOS graph(s) if "fermi_level" in data: - Efermi = list(Q_(data["fermi_level"], "hartree").to("eV").magnitude) + # Efermi = list(Q_(data["fermi_level"], "hartree").to("eV").magnitude) + Efermi = [Q_(data["fermi_level"], "hartree").to("eV").magnitude] else: Efermi = [0.0] wd = Path(self.directory) diff --git a/dftbplus_step/metadata.py b/dftbplus_step/metadata.py index cdee993..5df552f 100644 --- a/dftbplus_step/metadata.py +++ b/dftbplus_step/metadata.py @@ -46,7 +46,7 @@ "optimization", ], "description": "The Fermi level", - "dimensionality": [2], + "dimensionality": "scalar", "property": "Fermi level#DFTB+#{model}", "type": "float", "units": "E_h",