From d8470cde56662a5b426a517f1ed991a683e9bce4 Mon Sep 17 00:00:00 2001 From: Yannick Schubert <43602823+schuyann@users.noreply.github.com> Date: Wed, 23 Aug 2023 11:04:48 +0200 Subject: [PATCH] new check_if_bin2xml_routine (#210) Co-authored-by: Yannick Schubert --- src/koopmans/workflows/_ml.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/koopmans/workflows/_ml.py b/src/koopmans/workflows/_ml.py index 0e12d418e..6f4737c1c 100644 --- a/src/koopmans/workflows/_ml.py +++ b/src/koopmans/workflows/_ml.py @@ -158,12 +158,20 @@ def convert_bin2xml(self): def check_if_bin2xml_is_complete(self) -> bool: """ - Checks if the bin2xml conversion was already performed + Checks if the bin2xml conversion was already performed. + + For this we first check if the next step is complete, i.e. the decomposition into spherical harmonics and + radial basis functions. If we haven't yet computed the decomposition, we check if this step, i.e. the + conversion to xml, was already performed. This way we can delete the (possibly large) binary and xml files + and only keep the expansion coefficients and still be able to restart the calculation. """ - # If there are as many xml files as there are bands to solve, the calculation was already completed - return len([name for name in os.listdir(self.dirs['xml']) if os.path.isfile(self.dirs['xml'] / name)]) \ - == (self.num_bands_to_extract[0] + self.num_bands_to_extract[1] + 1) + if self.check_if_compute_decomposition_is_complete(): + return True + else: + # If there are as many xml files as there are bands to solve, the calculation was already completed + return len([name for name in os.listdir(self.dirs['xml']) if os.path.isfile(self.dirs['xml'] / name)]) \ + == (self.num_bands_to_extract[0] + self.num_bands_to_extract[1] + 1) def compute_decomposition(self): """