From 5106e683d29f1c2cf52552d9b7a11910169e61e5 Mon Sep 17 00:00:00 2001 From: nscolonna Date: Wed, 12 Jun 2024 15:49:10 +0200 Subject: [PATCH] Bug fix in the setting of the number of electrons in kcp (and possibly also others). The general parameters given outside a specific calculator block were not properly used to set up the input files. --- src/koopmans/workflows/_workflow.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/koopmans/workflows/_workflow.py b/src/koopmans/workflows/_workflow.py index 8f27635d0..259a457e9 100644 --- a/src/koopmans/workflows/_workflow.py +++ b/src/koopmans/workflows/_workflow.py @@ -227,6 +227,19 @@ def __init__(self, atoms: Atoms, self.parameters.pseudo_directory = pseudo_dir.resolve() + # For any kwargs... + for key, value in kwargs.items(): + match = False + # if they correspond to any valid calculator parameter, set it + for calc_params in calculator_parameters.values(): + if calc_params.is_valid(key): + calc_params[key] = value + match = True + # if not a calculator, workflow, or plotting keyword, raise an error + if not match and not self.parameters.is_valid(key) and not self.plotting.is_valid(key) \ + and not self.ml.is_valid(key): + raise ValueError(f'{key} is not a valid setting') + # Before saving the calculator_parameters, automatically generate some keywords and perform some sanity checks if self.parameters.task != 'ui' and autogenerate_settings: # Automatically calculate nelec/nelup/neldw/etc using information contained in the pseudopotential files @@ -301,19 +314,6 @@ def __init__(self, atoms: Atoms, # Initialize self.parent self.parent: Optional[Workflow] = None - # For any kwargs... - for key, value in kwargs.items(): - match = False - # if they correspond to any valid calculator parameter, set it - for calc_params in self.calculator_parameters.values(): - if calc_params.is_valid(key): - calc_params[key] = value - match = True - # if not a calculator, workflow, or plotting keyword, raise an error - if not match and not self.parameters.is_valid(key) and not self.plotting.is_valid(key) \ - and not self.ml.is_valid(key): - raise ValueError(f'{key} is not a valid setting') - # Adding excluded_bands info to self.projections if self.projections: for spin in ['up', 'down', None]: