Skip to content
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 CASTEP #258

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

zhubonan
Copy link
Collaborator

Adds implementation of the bands workchain for CASTEP plugin.

I made a custom protocol for the oxide work. Make relaxation input generator accepts, checks on the protocol choices should be removed. I think it would be a good thing to have it removed any way - so we don't limit ourselves to three protocols only?

@@ -32,7 +32,6 @@ def define(cls, spec):
)
spec.input(
'protocol',
valid_type=ChoiceType(('fast', 'moderate', 'precise')),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to discuss whether this should be limited, but this explicit definition did have the advantage that it made it discoverable exactly which protocols are available. If we remove this, we should reintroduce it in some other way.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an interesting point. The valid protocols can be always extended (actually changed) inside the code implementations of the CommonRelaxInputGenerator, am I right @sphuber? This is compatible also with the concept of creating code-agnostic workchains only if we remove the choice check in the inputs of the workchain. Foor instance this is what we do in the EOS wc: the valid types disappear (

spec.input('generator_inputs.protocol', valid_type=str, non_db=True,
). So in principle I do not see a drawback in maintaining this line.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point @bosonie. I should be able to just override it in CastepCommonRelaxInputGenerator. Will drop the changes to the base class.

"""Extract the Fermi energy from the BandsData output"""
efermi = bands.get_attribute('efermi')
if isinstance(efermi, list):
efermi = efermi[0]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good point. Should we discuss whether the fermi_energy output should be a Float or a List[float] depending on polarization? Think this would be a common "problem" across implementations

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will put in the list for discussion tomorrow

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An additional issue is that some code may not have a well defined single efermi energy if there are two spin channels (is such quantity itself well-defined at all?). Not sure if this is a limitation across the board or not. I know CASTEP always give two if there are two spin channels. VASP gives ones fermi energy with spin polarised calculation I think, but it may give a wrong value if spin is constrained.

else:
builder_common_bands_wc.structure = parent_castep_calc.inputs.structure

engb = engines['bands']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will except if engines was not specified in kwargs

engb = engines['bands']
builder_common_bands_wc.scf.calc.code = engines['bands']['code']
if 'options' in engb:
builder_common_bands_wc.scf.calc_options = orm.Dict(dict=engines['bands']['options'])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you may have just copied this from the Siesta implementation. Does the Castep implementation also expect the options as a Dict node as opposed to just a dictionary in the metadata namespace? If so, I would say that is suboptimal and we should think of improving that in aiida-castep at some point.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CASTEP actually work with metadata exposed from CalcJob previously, e.g. one pass the metadata.options as a dict not Dict, to an exposed calc.metadata port namespace.

I just updated the code to make it work with Dict...

Which way do you think is better? For the plain metadata.options approach the problem I had is that one cannot just do get_builder_restart from a WorkChainNode and have the builder fully populated and ready to go. This is because the exposed metadata.options namespace remains empty.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the problem with the options not being stored, but I am personally not a fan of closing of the original port and replacing it with a custom Dict analog. Rather, I think we should solve the root of the issue and see if there is a way that the options can be stored on the workflow node.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I will just keep both ways acceptable by aiida-castep for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants