Skip to content

Fix: MatdynParser parsing logic for phonon frequencies with k-point weights#1228

Open
ValkScripter wants to merge 1 commit intoaiidateam:mainfrom
ValkScripter:wip/fix/matdyn_parser
Open

Fix: MatdynParser parsing logic for phonon frequencies with k-point weights#1228
ValkScripter wants to merge 1 commit intoaiidateam:mainfrom
ValkScripter:wip/fix/matdyn_parser

Conversation

@ValkScripter
Copy link
Contributor

This pull request fixes #1227 and improves the robustness and flexibility of the phonon frequencies parsing logic, allowing it to handle files with k-point weights and poorly formatted frequency lines (such as attached minus signs as before but with RE):

  • Refactored parse_raw_matdyn_phonon_file to use regular expressions to robustly parse k-point and frequency blocks, including cases with attached minus signs and k-point weights.
  • Added new regression tests (test_matdyn_k_weights and test_matdyn_k_weights_attached) to verify the parser correctly handles phonon frequencies files that include k-point weights and cases with attached minus signs in frequency values with more than only one k-point to check that different k-points are read correctly and that no gradual shift in phonon frequencies happens.
  • Added corresponding test fixtures for phonon frequencies and output files.

…weights and attached frequencies

Main changes in `src/aiida_quantumespresso/parsers/matdyn.py`:
- Rewrote `parse_raw_matdyn_phonon_file()` function with improved regex-based parsing for robustness
- Added support for k-point weights in the phonon frequencies file
- Enhanced handling of malformed frequencies with attached minus signs (e.g., `-148.70828-124.2696`)
- Improved error messages and validation for file format consistency

Supporting changes:
- Added test fixtures for k-point weights and attached frequencies cases
- Extended test suite with `test_matdyn_k_weights()` and `test_matdyn_k_weights_attached()`
- Updated regression data for all matdyn parser tests
- Refactored test helpers to support variable mesh parameters
@bastonero
Copy link
Collaborator

Many thanks @ValkScripter ! Is this PR also backward compatible with QE versions < 7.5 ?

@rikigigi
Copy link
Member

@pietrodelugas does an xml output for matdyn.x exist?

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.

MatdynParser incorrectly parses frequencies when kpoint weights are written after their coordinates (QE 7.5)

3 participants