Skip to content

Commit

Permalink
Add options_inpgen input to SCF workchain (#211)
Browse files Browse the repository at this point in the history
* Add input port to SCF for providing options to inpgen overriding
the options of the fleur code

* Fixed test

Result changed in pymatgen v2023.5.10
  • Loading branch information
janssenhenning authored May 12, 2023
1 parent 21f7a10 commit c8ef565
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 24 deletions.
28 changes: 6 additions & 22 deletions aiida_fleur/workflows/scf.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class FleurScfWorkChain(WorkChain):
like Success, last result node, list with convergence behavior
"""

_workflowversion = '0.6.3'
_workflowversion = '0.6.4'
_default_wf_para = {
'fleur_runmax': 4,
'density_converged': 0.00002,
Expand Down Expand Up @@ -118,6 +118,7 @@ def define(cls, spec):
spec.input('fleurinp', valid_type=FleurinpData, required=False)
spec.input('remote_data', valid_type=RemoteData, required=False)
spec.input('options', valid_type=Dict, required=False)
spec.input('options_inpgen', valid_type=Dict, required=False)
spec.input('settings', valid_type=Dict, required=False)
spec.input('settings_inpgen', valid_type=Dict, required=False)
spec.outline(cls.start, cls.validate_input,
Expand Down Expand Up @@ -170,29 +171,10 @@ def start(self):
wf_dict[key] = wf_dict.get(key, val)
self.ctx.wf_dict = wf_dict

# fleur = self.inputs.fleur
# fleur_extras = fleur.extras
# inpgen_extras = None
# if 'inpgen' in self.inputs:
# inpgen = self.inputs.inpgen
# inpgen_extras = inpgen.extras

defaultoptions = self._default_options.copy()
user_options = {}
if 'options' in self.inputs:
user_options = self.inputs.options.get_dict()
'''
# extend options by code defaults given in code extras
# Maybe do full recursive merge
if 'queue_defaults' in fleur_extras:
qd = fleur_extras['queue_defaults']
queue = user_options.get('queue', 'default')
defaults_queue = qd.get(queue, {})
for key, val in defaultoptions.items():
defaultoptions[key] = defaults_queue.get(key, val)
'''

if 'options' in self.inputs:
options = user_options
options = self.inputs.options.get_dict()
else:
options = defaultoptions
# we use the same options for both codes, inpgen resources get overridden
Expand Down Expand Up @@ -399,6 +381,8 @@ def run_fleurinpgen(self):
'resources': self.ctx.options.get('resources'),
'queue_name': self.ctx.options.get('queue_name', '')
}
if 'options_inpgen' in self.inputs:
options = {**options, **self.inputs.options_inpgen.get_dict()}

inputs_build = get_inputs_inpgen(structure,
inpgencode,
Expand Down
4 changes: 2 additions & 2 deletions tests/tools/test_StructureData_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1009,8 +1009,8 @@ def test_create_all_slabs(generate_structure):
film_strucs = create_all_slabs(structure, 2, 5)

assert len(film_strucs.keys()) == 9
assert list(film_strucs.keys()) == [(1, 1, 1), (2, 2, 1), (1, 1, 0), (2, 2, -1), (2, 1, 1), (2, 1, -1), (2, 1, -2),
(2, 0, -1), (2, -1, -1)]
assert list(film_strucs.keys()) == [(1, 1, 1), (1, 1, 0), (1, 1, -1), (1, 0, -1), (2, 2, -1), (2, 1, -1),
(2, 1, -2), (2, 0, -1), (2, -1, -1)]
for key, film_struc in film_strucs.items():
assert isinstance(film_struc, StructureData)

Expand Down

0 comments on commit c8ef565

Please sign in to comment.