aiidateam / aiida-quantumespresso

The official AiiDA plugin for Quantum ESPRESSO
https://aiida-quantumespresso.readthedocs.io
Other
53 stars 78 forks source link

Problematic translation in `HubbardStructureData` #991

Open t-reents opened 10 months ago

t-reents commented 10 months ago

I tried to run a PwCalculation calculation using a HubbardStructureData that was generated based on the following StructureData.

(output as pymatgen structure)
Structure Summary
Lattice
    abc : 5.1676899920824315 5.1676899920824315 5.167689992113305
 angles : 31.204203015989076 31.204203015989076 31.204203015105193
 volume : 32.87123329572289
      A : 1.3898768242032 0.80244575859357 4.9121627693234
      B : -1.3898768242032 0.80244575859357 4.9121627693234
      C : -8.7346701145945e-17 -1.6048915172871 4.9121627693235
    pbc : True True True
PeriodicSite: Co (0.0, 0.0, 0.0) [0.0, 0.0, 0.0]
PeriodicSite: O (1.39, 0.8024, 13.81) [1.604, 0.6041, 0.6041]
PeriodicSite: O (1.39, 0.8024, 10.75) [1.396, 0.3959, 0.3959]

Generating the HubbardStructureData:

hubbard_structure = HubbardStructureData.from_structure(structure)
hubbard_structure.initialize_onsites_hubbard("Co", "3d")
hubbard_structure.initialize_intersites_hubbard("Co", "3d", "O", "2p")

The calculation fails during the presubmit call, when calling HubbardUtils(structure).get_hubbard_card(). Inspecting the output of hubbard_structure.hubbard.parameters explains this failure:

[HubbardParameters(atom_index=0, atom_manifold='3d', neighbour_index=0, neighbour_manifold='3d', translation=(0, 0, 0), value=1e-08, hubbard_type='Ueff'),
 HubbardParameters(atom_index=0, atom_manifold='3d', neighbour_index=1, neighbour_manifold='2p', translation=(-2, -1, 0), value=1e-08, hubbard_type='V')]

The translation in the second entry is not part of the QE_TRANSLATIONS (https://github.com/aiidateam/aiida-quantumespresso/blob/main/src/aiida_quantumespresso/utils/hubbard.py#L21-L24), wherefore the following function call excepts (https://github.com/aiidateam/aiida-quantumespresso/blob/main/src/aiida_quantumespresso/utils/hubbard.py#L326).

If one would use the second O site, everything would work out. However, this method (https://github.com/aiidateam/aiida-quantumespresso/blob/main/src/aiida_quantumespresso/data/hubbard_structure.py#L214) selects the first occurring site that matches the kind_name. Apparently, this logic seems to work out in general, but in this case, it somehow breaks.

bastonero commented 9 months ago

Hi @t-reents , this is NOT a bug, but it is the intended way. This is because pw.x does NOT accept nearest neighbours outisde the 3x3x3 supercell. Thus, the (integer) values for the translations must be accordingly in {-1,0,1}.

You can in fact inspect that in you hubbard paramters one of the translations is (-2, -1, 0). This would make pw.x to crash. This is due to the fact that some atoms are outside the unitcell (e.g. in crystal coordinates they have some |x_i |> 1). You should fold in the unitcell such atoms. I recently worked on some utility functions for helping to do this. Please look at this branch: https://github.com/bastonero/aiida-quantumespresso/tree/feat/voronoi.

bastonero commented 9 months ago

Probably we should raise a WARNING when this happens, but the HubbardStructureData was thought not to be bounded to QE. So hopefully the upcoming utilities will solve this issue.

t-reents commented 9 months ago

Hi @bastonero thanks a lot for the explanation! This clarifies a lot.