JuDFTteam / aiida-fleur

AiiDA plugin of the high-performance density functional theory code FLEUR (www.judft.de) for high-throughput electronic structure calculations.
https://aiida-fleur.readthedocs.io
Other
14 stars 7 forks source link

Easier `inpxml_changes` specification #171

Closed janssenhenning closed 2 years ago

janssenhenning commented 2 years ago

See #168

This PR implements a contextmanager inpxml_changes that can be used to simplify the syntax of the inpxml_changes in workflow inputs

#parameters is a dict, which can also already contain an inpxml_changes entry
with inpxml_changes(parameters) as fm: 
    fm.set_inpchanges({'l_noco': True, 'ctail': False})
    fm.set_species('all-Nd', {'electronConfig': {'flipspins': True}})

parameters afterwards

{
'inpxml_changes': [
    ('set_inpchanges', {'changes': {'l_noco': True, 'ctail': False}}'),
    ('set_species', {'species_name': 'all-Nd', 'changes': {'electronConfig': {'flipspins': True}}})
]}

Can also be used with a ProcessBuilder

from aiida import plugins

FleurBandDOS = plugins.WorkflowFactory('fleur.banddos')
inputs = FleurBandDOS.get_builder()

with inpxml_changes(inputs) as fm:
    fm.set_inpchanges({'l_noco': True, 'ctail': False})
    fm.set_species('all-Nd', {'electronConfig': {'flipspins': True}})

inputs.wf_parameters will look exactly like above

codecov[bot] commented 2 years ago

Codecov Report

Merging #171 (fa34312) into develop (8823487) will increase coverage by 1.78%. The diff coverage is 91.20%.

:exclamation: Current head fa34312 differs from pull request most recent head 062e60c. Consider uploading reports for the commit 062e60c to get more accurate results

@@             Coverage Diff             @@
##           develop     #171      +/-   ##
===========================================
+ Coverage    70.97%   72.75%   +1.78%     
===========================================
  Files          121      121              
  Lines        14766    16652    +1886     
===========================================
+ Hits         10480    12115    +1635     
- Misses        4286     4537     +251     
Impacted Files Coverage Δ
aiida_fleur/data/fleurinpmodifier.py 87.78% <84.00%> (+0.14%) :arrow_up:
aiida_fleur/data/__init__.py 100.00% <100.00%> (ø)
aiida_fleur/data/fleurinp.py 91.34% <100.00%> (+0.81%) :arrow_up:
tests/data/test_fleurinpmodifier.py 100.00% <100.00%> (ø)
aiida_fleur/workflows/base_relax.py 19.67% <0.00%> (-0.22%) :arrow_down:
aiida_fleur/calculation/fleur.py 72.70% <0.00%> (-0.09%) :arrow_down:
aiida_fleur/workflows/create_magnetic_film.py 16.30% <0.00%> (-0.06%) :arrow_down:
tests/tools/test_common_fleur_wf.py 100.00% <0.00%> (ø)
tests/tools/test_StructureData_util.py 99.26% <0.00%> (+0.07%) :arrow_up:
aiida_fleur/tools/common_fleur_wf_util.py 96.16% <0.00%> (+0.12%) :arrow_up:
... and 16 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 8823487...062e60c. Read the comment docs.