aiidateam / aiida-cp2k

The CP2K plugin for the AiiDA workflow and provenance engine.
https://aiida-cp2k.readthedocs.io/en/latest/
MIT License
22 stars 28 forks source link

Wrong assumption for LUMO #182

Open cpignedoli opened 1 year ago

cpignedoli commented 1 year ago

In many cases a CP2K calculation will not have "ADDED_MOS" and the assumption LUMO = nel+1 is wrong https://github.com/aiidateam/aiida-cp2k/blob/380741873af59d3c3d199c36d7e16f19859b3fc1/aiida_cp2k/parsers/__init__.py#L148

One should check if nel-alpha < len(neig_spin1) if true we can assume LUMO_alpha as eig_alpha[nel_alpha] and the same for LUMO_beta (if UKS) if not the calculation did not have added_mos still a GAP could be available (e.g. if MO_CUBES with NLUMO>0 was specified) and one could parse:

patch for the wrong gap in the parser

gap =[]
for line in lines: # lines of aiida.out
    if line.startswith(' HOMO - LUMO gap'):
        gap.append(float(line.split()[-1]))
if dft_type == 'UKS':
  html +=  "<b>Gap spin1: </b> %s (eV)<br>" % round(gap[0],3)
  html +=  "<b>Gap spin2: </b> %s (eV)<br>" % round(gap[1],3)
else:
   html +=  "<b>Gap: </b> %s (eV)<br>" % round(gap[0],3)