From 83eddb29531dbfc9d095578d81be5380a59ee045 Mon Sep 17 00:00:00 2001 From: AndresOrtegaGuerrero Date: Tue, 17 Oct 2023 14:05:03 +0200 Subject: [PATCH 1/5] adding logic to pw.base tot_magnetization --- src/aiida_quantumespresso/workflows/pw/base.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/aiida_quantumespresso/workflows/pw/base.py b/src/aiida_quantumespresso/workflows/pw/base.py index 8e53dfa6e..cd5ddcffe 100644 --- a/src/aiida_quantumespresso/workflows/pw/base.py +++ b/src/aiida_quantumespresso/workflows/pw/base.py @@ -198,6 +198,10 @@ def get_builder_from_protocol( if overrides: parameter_overrides = overrides.get('pw', {}).get('parameters', {}) parameters = recursive_merge(parameters, parameter_overrides) + + # if tot_magnetization in parameters , remove starting_magnetization + if overrides["pw"]["parameters"]["SYSTEM"]["tot_magnetization"]: + parameters['SYSTEM'].pop('starting_magnetization') pseudos_overrides = overrides.get('pw', {}).get('pseudos', {}) pseudos = recursive_merge(pseudos, pseudos_overrides) From 43ba3f2dc7610c14955f83fc4f6cb5510b186c59 Mon Sep 17 00:00:00 2001 From: AndresOrtegaGuerrero Date: Tue, 17 Oct 2023 14:08:26 +0200 Subject: [PATCH 2/5] adding logic for tot_magnetization --- src/aiida_quantumespresso/workflows/pw/base.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/aiida_quantumespresso/workflows/pw/base.py b/src/aiida_quantumespresso/workflows/pw/base.py index cd5ddcffe..abe41ae3d 100644 --- a/src/aiida_quantumespresso/workflows/pw/base.py +++ b/src/aiida_quantumespresso/workflows/pw/base.py @@ -198,9 +198,9 @@ def get_builder_from_protocol( if overrides: parameter_overrides = overrides.get('pw', {}).get('parameters', {}) parameters = recursive_merge(parameters, parameter_overrides) - - # if tot_magnetization in parameters , remove starting_magnetization - if overrides["pw"]["parameters"]["SYSTEM"]["tot_magnetization"]: + + # if tot_magnetization in overrides , remove starting_magnetization from parameters + if overrides['pw']['parameters']['SYSTEM']['tot_magnetization']: parameters['SYSTEM'].pop('starting_magnetization') pseudos_overrides = overrides.get('pw', {}).get('pseudos', {}) From da34a76039443f8ac14b1a840e519ae4b162bb22 Mon Sep 17 00:00:00 2001 From: AndresOrtegaGuerrero Date: Tue, 17 Oct 2023 14:26:02 +0200 Subject: [PATCH 3/5] fix logic --- src/aiida_quantumespresso/workflows/pw/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aiida_quantumespresso/workflows/pw/base.py b/src/aiida_quantumespresso/workflows/pw/base.py index abe41ae3d..d16c62e6a 100644 --- a/src/aiida_quantumespresso/workflows/pw/base.py +++ b/src/aiida_quantumespresso/workflows/pw/base.py @@ -200,7 +200,7 @@ def get_builder_from_protocol( parameters = recursive_merge(parameters, parameter_overrides) # if tot_magnetization in overrides , remove starting_magnetization from parameters - if overrides['pw']['parameters']['SYSTEM']['tot_magnetization']: + if overrides['pw']['parameters']['SYSTEM'].get('tot_magnetization') is not None: parameters['SYSTEM'].pop('starting_magnetization') pseudos_overrides = overrides.get('pw', {}).get('pseudos', {}) From 2cece17aaff8ccc9dfebc31dba7188d79c6286e1 Mon Sep 17 00:00:00 2001 From: AndresOrtegaGuerrero Date: Tue, 17 Oct 2023 14:57:29 +0200 Subject: [PATCH 4/5] fix logic --- src/aiida_quantumespresso/workflows/pw/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aiida_quantumespresso/workflows/pw/base.py b/src/aiida_quantumespresso/workflows/pw/base.py index d16c62e6a..318efb637 100644 --- a/src/aiida_quantumespresso/workflows/pw/base.py +++ b/src/aiida_quantumespresso/workflows/pw/base.py @@ -201,7 +201,7 @@ def get_builder_from_protocol( # if tot_magnetization in overrides , remove starting_magnetization from parameters if overrides['pw']['parameters']['SYSTEM'].get('tot_magnetization') is not None: - parameters['SYSTEM'].pop('starting_magnetization') + parameters['SYSTEM'].pop('starting_magnetization', None) pseudos_overrides = overrides.get('pw', {}).get('pseudos', {}) pseudos = recursive_merge(pseudos, pseudos_overrides) From 0fd373bb817fbf0167fbc4fabf016afcd9e860c0 Mon Sep 17 00:00:00 2001 From: AndresOrtegaGuerrero Date: Wed, 18 Oct 2023 16:32:33 +0200 Subject: [PATCH 5/5] adding sebastian mod --- src/aiida_quantumespresso/workflows/pw/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/aiida_quantumespresso/workflows/pw/base.py b/src/aiida_quantumespresso/workflows/pw/base.py index 1d5bc6d4e..cfea4d4a9 100644 --- a/src/aiida_quantumespresso/workflows/pw/base.py +++ b/src/aiida_quantumespresso/workflows/pw/base.py @@ -199,8 +199,8 @@ def get_builder_from_protocol( parameters = recursive_merge(parameters, parameter_overrides) # if tot_magnetization in overrides , remove starting_magnetization from parameters - if overrides['pw']['parameters']['SYSTEM'].get('tot_magnetization') is not None: - parameters['SYSTEM'].pop('starting_magnetization', None) + if parameters.get('SYSTEM', {}).get('tot_magnetization') is not None: + parameters.setdefault('SYSTEM', {}).pop('starting_magnetization', None) pseudos_overrides = overrides.get('pw', {}).get('pseudos', {}) pseudos = recursive_merge(pseudos, pseudos_overrides)