Extend parsing functionality#148
Merged
Merged
Conversation
Add 14 Specs covering band eigenvalues, magnetism, run-status flags, and HOMO/LUMO levels: - `eigenvalues` and `occupations_kpoint` as numpy arrays of shape `(n_kpoints, n_spin, n_bands)`, derived from `band_structure.ks_energies`. - Run-shape scalars from XML: `number_of_electrons`, `number_of_atoms`, `number_of_species`, `lsda`, `alat` (Å), `ibrav`. - Magnetism (μB/cell): `total_magnetization`, `absolute_magnetization`. - Run-status flags: `scf_converged` (from `convergence_info.scf_conv`) and `job_done` (presence of `<closed>`), each defaulting to `False` when the corresponding XML element is missing. - `highest_occupied_level` / `lowest_unoccupied_level` (eV) parsed from the pw.x stdout. `PwStdoutParser.parse` matches both the single-value `highest occupied level (ev): X` line and the paired `highest occupied, lowest unoccupied levels (ev): X Y` line.
The `bands.x` post-processor reorders the raw `pw.x` band eigenvalues into a plottable band-structure path and (optionally) labels each `(k, band)` with its symmetry representation. The qe-tools side had no parser for the `filband` family — users had to hand-roll text parsing and reshape arithmetic to lift an `(n_kpoints, n_bands)` array out of the gnuplot-flavoured output. Add a dedicated `BandsOutput` class plus three parsers: - `BandsDatParser` reads the `&plot nbnd=..., nks=... /` header and reshapes the body into `k_points` `(n_kpoints, 3)` and `eigenvalues` `(n_kpoints, n_bands)` arrays (eV). - `BandsRapParser` decodes the `*.dat.rap` symmetry-rep file when bands.x was run with `lsym=.true.`, exposing per-`(k, band)` representation indices and a `(n_kpoints,)` boolean flag for high-symmetry points. - `BandsStdoutParser` lifts the `high-symmetry point: kx ky kz x coordinate X` lines out of the bands.x stdout, so plot tick labels can be placed at the correct cumulative path-length.
`projwfc.x` writes projected-DOS data into one file per `(atom, wavefunction)` pair following the `<filpdos>.pdos_atm#N(El)_wfc#M(L)[_j#J]` naming scheme, plus a `<filpdos>.pdos_tot` summary. Decoding the filename, parsing the column-variable header, and reshaping the per-magnetic-quantum-number columns into a usable array is fiddly enough that callers were inevitably reinventing it. Add a dedicated `ProjwfcOutput` class plus two file parsers: - `PdosAtmWfcParser` reads a single `pdos_atm#N(El)_wfc#M(L)[_j#J]` file. It handles the spin-unpolarised, spin-polarised LSDA, and spin-orbit cases by counting `ldos`-prefixed columns and reshaping the trailing `pdos`-columns into `(n_energies, [spin,] 2*l + 1)`. - `PdosTotParser` reads `<filpdos>.pdos_tot` into the matching `dos_total` / `pdos_total` arrays. `ProjwfcOutput.from_dir` discovers every PDOS file in a directory via `collect_pdos_files`, sorts the resulting records numerically by `(atom, wfc, j)` so systems with more than nine atoms don't get scrambled by lexical order, and skips the consumed paths when sniffing for the projwfc.x stdout. The output exposes: - `pdos`: a flat list of records keyed by `(atom, element, wfc, l, l_label[, j])` with the parsed `energies`, `ldos`, and per-magnetic-quantum-number `pdos_m` arrays. Filtering by element or `l` is a one-line list comprehension on the caller side. - `pdos_total`: dict with `energies`, `dos_total`, `pdos_total`.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #148 +/- ##
==========================================
- Coverage 89.77% 88.08% -1.70%
==========================================
Files 11 23 +12
Lines 489 1032 +543
==========================================
+ Hits 439 909 +470
- Misses 50 123 +73 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.