-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement CommonBandsWorkChain for FLEUR #259
Open
janssenhenning
wants to merge
4
commits into
aiidateam:master
Choose a base branch
from
JuDFTteam:feature/common_bands_fleur
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6f9d522
Add implementation of workchain and generator of CommonBandsWorkchain…
janssenhenning 392fae6
Fix wrong code input names
janssenhenning ca56a39
Correct the fermi energy output. The bands output of fleur is shifted…
janssenhenning 401189b
Remove unused import
janssenhenning File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
# pylint: disable=undefined-variable | ||
"""Module with the implementations of the common bands workchain for Siesta.""" | ||
from .generator import * | ||
from .workchain import * | ||
|
||
__all__ = (generator.__all__ + workchain.__all__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Implementation of `aiida_common_workflows.common.bands.generator.CommonBandsInputGenerator` for Fleur.""" | ||
|
||
from aiida import engine, orm | ||
|
||
from aiida_common_workflows.generators import CodeType | ||
|
||
from ..generator import CommonBandsInputGenerator | ||
|
||
__all__ = ('FleurCommonBandsInputGenerator',) | ||
|
||
|
||
class FleurCommonBandsInputGenerator(CommonBandsInputGenerator): | ||
"""Generator of inputs for the FleurCommonBandsWorkChain""" | ||
|
||
@classmethod | ||
def define(cls, spec): | ||
"""Define the specification of the input generator. | ||
|
||
The ports defined on the specification are the inputs that will be accepted by the ``get_builder`` method. | ||
""" | ||
super().define(spec) | ||
spec.inputs['engines']['bands']['code'].valid_type = CodeType('fleur.fleur') | ||
|
||
def _construct_builder(self, **kwargs) -> engine.ProcessBuilder: | ||
"""Construct a process builder based on the provided keyword arguments. | ||
|
||
The keyword arguments will have been validated against the input generator specification. | ||
""" | ||
# pylint: disable=too-many-branches,too-many-statements,too-many-locals | ||
engines = kwargs.get('engines', None) | ||
parent_folder = kwargs['parent_folder'] | ||
bands_kpoints = kwargs['bands_kpoints'] | ||
|
||
# From the parent folder, we retrieve the calculation that created it. | ||
parent_calc = parent_folder.creator | ||
if parent_calc.process_type != 'aiida.calculations:fleur.fleur': | ||
raise ValueError('The `parent_folder` has not been created by a FleurCalculation') | ||
builder_parent = parent_folder.creator.get_builder_restart() | ||
|
||
#Transfer inputs from the parent calculation | ||
builder = self.process_class.get_builder() | ||
builder.options = orm.Dict(dict=builder_parent.metadata.options) | ||
builder.fleur = builder_parent.code | ||
|
||
wf_parameters = {'kpath': 'skip'} | ||
|
||
builder.wf_parameters = orm.Dict(dict=wf_parameters) | ||
builder.kpoints = bands_kpoints | ||
builder.remote = parent_folder | ||
|
||
#Add inputs from engines if given | ||
if engines: | ||
try: | ||
band_engines = engines['bands'] | ||
except KeyError: | ||
raise ValueError('The `engines` dictionary must contain `bands` as a top-level key') | ||
if 'code' in band_engines: | ||
builder.fleur = band_engines['code'] | ||
if 'options' in band_engines: | ||
builder.options = orm.Dict(dict=band_engines['options']) | ||
|
||
return builder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Implementation of `aiida_common_workflows.common.relax.workchain.CommonRelaxWorkChain` for Fleur.""" | ||
from aiida.orm import Float | ||
from aiida.plugins import WorkflowFactory | ||
|
||
from ..workchain import CommonBandsWorkChain | ||
from .generator import FleurCommonBandsInputGenerator | ||
|
||
__all__ = ('FleurCommonBandsWorkChain',) | ||
|
||
|
||
class FleurCommonBandsWorkChain(CommonBandsWorkChain): | ||
"""Implementation of `aiida_common_workflows.common.bands.workchain.CommonBandsWorkChain` for Fleur.""" | ||
|
||
_process_class = WorkflowFactory('fleur.banddos') | ||
_generator_class = FleurCommonBandsInputGenerator | ||
|
||
def convert_outputs(self): | ||
"""Convert the outputs of the sub workchain to the common output specification.""" | ||
self.report('Bands calculation concluded sucessfully, converting outputs') | ||
if 'output_banddos_wc_bands' not in self.ctx.workchain.outputs: | ||
self.report('FleurBandDOSWorkChain concluded without returning bands!') | ||
return self.exit_codes.ERROR_SUB_PROCESS_FAILED | ||
|
||
#The bands output of fleur is shifted to have the fermi energy at zero | ||
self.out('fermi_energy', Float(0.0)) | ||
|
||
self.out('bands', self.ctx.workchain.outputs['output_banddos_wc_bands']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really a point for this PR, but I don't think it is advisable to have the
Code
andoptions
inputs a separate ports. And especially exposing theoptions
as aDict
node instead of a normaldict
in the metadata of the calculation job is subideal. Is there a reason why you do this and you don't let the caller specify this information in the exposed inputs of theFleurScfWorkChain
?Taking a closer look, it seems that this is just a continuation problem of the fact that
FleurScfWorkChain
doesn't expose the inputs ofFleurBaseWorkChain
but manually creates input ports. If possible, I would recommend to properly useexpose_inputs
when wrapping subworkflows.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes you are right we have definitely underused exposing the inputs/outputs in the
aiida-fleur
plugin. I've been trying to expand the usage of this, where it leads to no breaking changes in the last months. One slight problem is that on the level of theFleurSCFWorkChain
we have two different codes that can potentially be used. Thefleur
code and theinpgen
code, which is used when we start a calculation from a structure input.We can probably move to exposing the inputs by exposing both the
FleurBaseWorkChain
and theFleurinputgenCalculation
, with one or both being in a namespace. But since the scf workchain is the main workchain that is then used throughout almost all higher level workchains this is quite a large breaking change, so we need to be careful with it.