aiidateam / aiida-common-workflows

A repository for the implementation of common workflow interfaces across materials-science codes and plugins
https://aiida-common-workflows.readthedocs.io
MIT License
52 stars 30 forks source link

Add structures with multiple kinds for AFM calculations #154

Closed mbercx closed 3 years ago

mbercx commented 3 years ago

So far I've been running AFM calculations for QE by first generating a new StructureData with the required kinds and then passing its identifier to the -S option. This is not very user friendly, however. 😅

Instead, it would be easier if we added structure files that immediately have the required kinds after being loaded. @yakutovicha sent me an example yesterday where tags are added to an .xyz file for BCC Fe:

2
Lattice="2.833509 0.0 0.0 0.0 2.833509 0.0 0.0 0.0 2.833509" Properties=species:S:1:pos:R:3:tags:I:1 spacegroup="I m -3 m" unit_cell=conventional pbc="T T T"
Fe       0.00000000       0.00000000       0.00000000        1
Fe       1.41675450       1.41675450       1.41675450        2

However, we might still switch to FCC iron for this structure (see #117). Another example would be the hydrogen molecule:

2
Lattice="15.0 0.0 0.0 0.0 15.0 0.0 0.0 0.0 15.0" Properties=species:S:1:pos:R:3:tags:I:1 pbc="F F F"
H        0.00000000       0.00000000      -0.40000000   1
H        0.00000000       0.00000000       0.40000000   2

When I adjust the common/data/h2.xyz file as above, the DissociationCurveWorkChain launch command work fine for Quantum ESPRESSO. However, running e.g. BigDFT result in error with the following final line:

aiida.common.exceptions.ValidationError: The following kinds are defined, but there are no sites with that kind: ['H2']

So maybe we should have two separate files (e.g. h2.xyz and h2-afm.xyz), and clearly indicate which ones to use for which code in the instructions? Not the cleanest solution, I admit. Alternatively we could look into loading the right structure in StructureDataParamType based on the code and provided magnetizations (which can be derived from the ctx?)? Pinging @sphuber for comments.

yakutovicha commented 3 years ago

Maybe consider also using something like this:

https://github.com/aiidateam/aiida-common-workflows/blob/master/aiida_common_workflows/workflows/relax/cp2k/generator.py#L62

mbercx commented 3 years ago

Sure, that also works for these simple cases :) (note that for complex systems with more than 10 magnetizations for one element this would fail due to the 3 char limit of Quantum ESPRESSO kinds). However, you would be creating a new duplicate StructureData each time the Cp2kRelaxInputGenerator.get_builder() method is called, right?

sphuber commented 3 years ago

Indeed, there are the usual two comments to the simple solution referenced:

  1. The provenance of the input structure is lost. If that is "fixed" by turning the function into a calcfunction, now the builder will mutate the database when being run, which is not desirable.
  2. This solution does not account for infinitesimal float differences, i.e., a magnetization of 0.99999, will be considered to be a different kind as 0.99999999999

@mbercx and I have written a calcfunction that takes the latter problem (and a lot more subtle details) but the further we advanced the more we were getting convinced the problem lay elsewhere. Really the CalcJob should probably just allow to specify quantities (such as starting magnetization) per site, instead of per kind.

mbercx commented 3 years ago

That said, it's probably better to have this simple solution for now than no solution at all? That or we add separate .xyz files with tags for the structures which we discuss in the paper. On that note, I don't seem to be able to obtain the click arguments from the context, i.e. ctx.params only seems to contain the options?