From a2ff4744af4c0be97300a9ec795fcf1115096af5 Mon Sep 17 00:00:00 2001 From: JosePizarro3 Date: Thu, 19 Sep 2024 15:31:17 +0200 Subject: [PATCH] Added todo for testing overwrite_fermi_level once this is under control --- .../schema_packages/workflow/dft_plus_tb.py | 18 ++++++++++++++++-- tests/workflow/test_dft_plus_tb.py | 2 ++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/nomad_simulations/schema_packages/workflow/dft_plus_tb.py b/src/nomad_simulations/schema_packages/workflow/dft_plus_tb.py index 2b191a7d..b6ccb36e 100644 --- a/src/nomad_simulations/schema_packages/workflow/dft_plus_tb.py +++ b/src/nomad_simulations/schema_packages/workflow/dft_plus_tb.py @@ -147,12 +147,25 @@ def overwrite_fermi_level(self) -> None: """ Overwrites the Fermi level in the TB calculation with the Fermi level from the DFT calculation. """ - dft_output = self.tasks[0].outputs[-1] + # Check if the `outputs` of the DFT task exist + dft_task = self.tasks[0] + if not dft_task.outputs: + self.link_tasks() + + # Check if the `fermi_levels` exist in the DFT output + if not dft_task.m_xpath('outputs[-1].section'): + return None + dft_output = dft_task.outputs[-1].section if not dft_output.fermi_levels: return None fermi_level = dft_output.fermi_levels[-1] - tb_output = self.tasks[1].outputs[-1] + # Assign the Fermi level to the TB output + tb_task = self.tasks[1] + if not tb_task.m_xpath('outputs[-1].section'): + return None + tb_output = tb_task.outputs[-1].section + # ? Does appending like this work creating information in the TB entry? tb_output.fermi_levels.append(FermiLevel(value=fermi_level.value)) def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None: @@ -183,4 +196,5 @@ def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None: self.link_tasks() # Overwrite the Fermi level in the TB calculation + # ? test if overwritting works self.overwrite_fermi_level() diff --git a/tests/workflow/test_dft_plus_tb.py b/tests/workflow/test_dft_plus_tb.py index 40d54644..c9e68e68 100644 --- a/tests/workflow/test_dft_plus_tb.py +++ b/tests/workflow/test_dft_plus_tb.py @@ -188,10 +188,12 @@ def test_overwrite_fermi_level(self): """ Test the `overwrite_fermi_level` method of the `DFTPlusTB` section. """ + # TODO implement once testing in a real case is tested (Wannier90 parser) assert True def test_normalize(self): """ Test the `normalize` method of the `DFTPlusTB` section. """ + # TODO implement once testing in a real case is tested (Wannier90 parser) assert True