Skip to content

Fix OT unoccupied eigenvalue bandgaps - #230

Open
cpignedoli wants to merge 9 commits into
mainfrom
fix-ot-unoccupied-bandgaps
Open

Fix OT unoccupied eigenvalue bandgaps#230
cpignedoli wants to merge 9 commits into
mainfrom
fix-ot-unoccupied-bandgaps

Conversation

@cpignedoli

@cpignedoli cpignedoli commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

This fixes OT HOMO-LUMO bandgap parsing for CP2K outputs where occupied and unoccupied eigenvalues are printed in separate blocks.

The parser now:

  • parses occupied eigenvalues into the existing eigen_spin*_au keys;
  • parses OT unoccupied eigenvalues into new unoccupied_eigen_spin*_au keys;
  • parses CP2K printed HOMO - LUMO gap [eV] values into printed_bandgap_spin*_ev;
  • stores bandgap_spin*_au from CP2K's printed gap when available;
  • computes electron-count frontier quantities separately as eigenvalue_homo_spin*_au, eigenvalue_lumo_spin*_au, and eigenvalue_bandgap_spin*_au when both frontier eigenvalues are available;
  • falls back to the electron-count gap for bandgap_spin*_au only if CP2K did not print a gap;
  • leaves bandgap_spin*_au absent if no real LUMO is available;
  • emits a non-fatal warning if the electron-count HOMO/LUMO gap disagrees with CP2K's printed gap.

Root Cause

After #184, eigen_spin*_au intentionally excluded the Lowest eigenvalues of the unoccupied subspace block. However, Cp2kAdvancedParser still assumed the LUMO was present in eigen_spin*_au, so for OT outputs it could silently report an occupied-occupied spacing as bandgap_spin*_au.

CI Maintenance Included

Small CI/doc maintenance changes are included because the existing checks were failing before reaching the relevant parser tests:

  • updated .github/workflows/ci.yml from actions/cache@v2 to actions/cache@v4, since GitHub now hard-fails workflows using cache v2;
  • added three exact AiiDA class references to docs/source/conf.py::nitpick_ignore, because the docs job runs Sphinx with -nW and was failing on unresolved external AiiDA references unrelated to this parser change;
  • pinned the pyupgrade pre-commit hook runtime to avoid a pre-commit.ci crash under Python 3.14. The hook still uses --py37-plus, so this does not change the package compatibility target.

Tests

Added regression coverage using:

  • the existing OT_v9.1.out fixture;
  • a UKS OT fixture based on a real CP2K output, with synthetic non-numeric warning/noise lines inserted into the occupied and unoccupied eigenvalue blocks.

Local validation performed in this environment:

  • direct parser check on OT_v9.1.out: stored printed gap 0.009679 eV;
  • direct parser check on OT_UKS_with_warnings.out: stored printed gaps 2.811670 eV and 2.798202 eV;
  • direct parser check on a real CP2K output from AiiDA calcjob 5897: stored printed gaps 2.811670 eV and 2.798202 eV;
  • python -m compileall /home/jovyan/opt/aiida-cp2k/aiida_cp2k;
  • pre-commit run --all-files.

Full pytest could not be run in this container because the repository conftest.py loads AiiDA PostgreSQL test fixtures and the environment is missing the locate command required by pgtest.

@cpignedoli
cpignedoli requested a review from yakutovicha June 23, 2026 08:09
@cpignedoli
cpignedoli marked this pull request as ready for review June 23, 2026 08:09
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.

1 participant