Skip to content

Commit 5ff26ad

Browse files
committed
PwOutput: Add parameters sub-mapping of run settings
Users inspecting a finished pw.x run often need to know *what the calculation actually ran with* — the cutoffs, k-point mesh, smearing, XC functional, spin/symmetry flags — without having to dig into the raw XML. Introduce a `_PwParametersMapping` exposed as `PwOutput.parameters`, collecting the settings the run used: `ecutwfc`/`ecutrho` (converted to eV), `fft_grid` and `smooth_fft_grid`, `xc_functional`, `monkhorst_pack_grid`/`_offset`, `smearing_type`, `degauss` (eV), `occupations`, `noncolin`, `lspinorb`, `noinv`, `no_t_rev`, and `assume_isolated`. The mapping deliberately mixes user inputs with values QE resolves at runtime (effective FFT grids, the functional inferred from pseudopotentials when `input_dft` is unset), since from the caller's perspective both describe parameters of the calculation.
1 parent a686eda commit 5ff26ad

File tree

8 files changed

+245
-1
lines changed

8 files changed

+245
-1
lines changed

src/qe_tools/outputs/pw.py

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,103 @@
1212
from qe_tools import CONSTANTS
1313

1414

15+
@output_mapping
16+
class _PwParametersMapping:
17+
"""Parameters the pw.x calculation ran with.
18+
19+
Includes both user-supplied inputs (cutoffs, k-points, smearing, ...) and values
20+
resolved by QE at runtime (effective FFT grids, functional from pseudopotentials
21+
when `input_dft` is unset).
22+
"""
23+
24+
ecutwfc: float = Spec(
25+
(
26+
"xml.input.basis.ecutwfc",
27+
lambda ecut: ecut * CONSTANTS.hartree_to_ev,
28+
)
29+
)
30+
"""Kinetic-energy cutoff for wavefunctions in eV."""
31+
32+
ecutrho: float = Spec(
33+
(
34+
"xml.input.basis.ecutrho",
35+
lambda ecut: ecut * CONSTANTS.hartree_to_ev,
36+
)
37+
)
38+
"""Kinetic-energy cutoff for the charge density and potential in eV."""
39+
40+
fft_grid: list = Spec(
41+
(
42+
"xml.output.basis_set.fft_grid",
43+
lambda grid: [grid["@nr1"], grid["@nr2"], grid["@nr3"]],
44+
)
45+
)
46+
"""Charge-density FFT grid dimensions `[nr1, nr2, nr3]` (used for the density and potentials)."""
47+
48+
smooth_fft_grid: list = Spec(
49+
(
50+
"xml.output.basis_set.fft_smooth",
51+
lambda grid: [grid["@nr1"], grid["@nr2"], grid["@nr3"]],
52+
)
53+
)
54+
"""Smooth FFT grid dimensions `[nr1, nr2, nr3]` (used for wavefunctions)."""
55+
56+
xc_functional: str = Spec("xml.output.dft.functional")
57+
"""Name of the exchange-correlation functional (e.g. `PBESOL`)."""
58+
59+
monkhorst_pack_grid: list = Spec(
60+
(
61+
"xml.input.k_points_IBZ.monkhorst_pack",
62+
lambda mp: [mp["@nk1"], mp["@nk2"], mp["@nk3"]],
63+
)
64+
)
65+
"""Monkhorst-Pack k-point mesh `[nk1, nk2, nk3]`."""
66+
67+
monkhorst_pack_offset: list = Spec(
68+
(
69+
"xml.input.k_points_IBZ.monkhorst_pack",
70+
lambda mp: [mp["@k1"], mp["@k2"], mp["@k3"]],
71+
)
72+
)
73+
"""Monkhorst-Pack k-point shift flags `[k1, k2, k3]` (each 0 or 1; `1` shifts by half a grid step along that axis)."""
74+
75+
smearing_type: str = Spec("xml.input.bands.smearing.$")
76+
"""Smearing function (e.g. `mv`, `gaussian`, `fd`, `mp`)."""
77+
78+
degauss: float = Spec(
79+
(
80+
"xml.input.bands.smearing.@degauss",
81+
lambda d: d * CONSTANTS.hartree_to_ev,
82+
)
83+
)
84+
"""Smearing width in eV."""
85+
86+
occupations: str = Spec("xml.input.bands.occupations")
87+
"""Occupations scheme (e.g. `smearing`, `tetrahedra`, `fixed`)."""
88+
89+
noncolin: bool = Spec("xml.input.spin.noncolin")
90+
"""Whether a non-collinear magnetic calculation was performed."""
91+
92+
lspinorb: bool = Spec("xml.input.spin.spinorbit")
93+
"""Whether spin-orbit coupling was included."""
94+
95+
noinv: bool = Spec("xml.input.symmetry_flags.noinv")
96+
"""Whether inversion symmetry was disabled (`noinv=.true.`)."""
97+
98+
no_t_rev: bool = Spec("xml.input.symmetry_flags.no_t_rev")
99+
"""Whether time-reversal symmetry was disabled (`no_t_rev=.true.`)."""
100+
101+
assume_isolated: str = Spec("xml.input.boundary_conditions.assume_isolated")
102+
"""Boundary-conditions / isolation scheme (e.g. `makov-payne`, `martyna-tuckerman`)."""
103+
104+
15105
@output_mapping
16106
class _PwMapping:
17107
"""Typed outputs of a pw.x calculation."""
18108

109+
parameters: _PwParametersMapping
110+
"""Parameters the calculation ran with: cutoffs, grids, XC functional, k-points, spin/symmetry flags."""
111+
19112
structure: dict = Spec(
20113
{
21114
"atomic_species": (

tests/outputs/test_pw_output/test_default_xml_211101_.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,25 @@ base_outputs:
1919
- 1.0
2020
number_of_bands: 8
2121
number_of_k_points: 2
22+
parameters:
23+
degauss: 0.136056917253
24+
ecutrho: 3265.366014072
25+
ecutwfc: 408.170751759
26+
fft_grid:
27+
- 40
28+
- 40
29+
- 40
30+
lspinorb: false
31+
no_t_rev: false
32+
noinv: false
33+
noncolin: false
34+
occupations: smearing
35+
smearing_type: mv
36+
smooth_fft_grid:
37+
- 32
38+
- 32
39+
- 32
40+
xc_functional: PBE
2241
stress:
2342
- - 19.802407083925143
2443
- 3.18983295531761e-15

tests/outputs/test_pw_output/test_default_xml_220603_.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,33 @@ base_outputs:
2727
- 0.75
2828
number_of_bands: 8
2929
number_of_k_points: 4
30+
parameters:
31+
degauss: 0.136056917253
32+
ecutrho: 3265.366014072
33+
ecutwfc: 408.170751759
34+
fft_grid:
35+
- 40
36+
- 40
37+
- 40
38+
lspinorb: false
39+
monkhorst_pack_grid:
40+
- 2
41+
- 2
42+
- 2
43+
monkhorst_pack_offset:
44+
- 0
45+
- 0
46+
- 0
47+
no_t_rev: false
48+
noinv: false
49+
noncolin: false
50+
occupations: smearing
51+
smearing_type: mv
52+
smooth_fft_grid:
53+
- 32
54+
- 32
55+
- 32
56+
xc_functional: PBE
3057
stress:
3158
- - 7.558511471674453
3259
- 2.3923747164882088e-15

tests/outputs/test_pw_output/test_default_xml_230310_.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,31 @@ base_outputs:
6969
- 0.03125
7070
number_of_bands: 16
7171
number_of_k_points: 13
72+
parameters:
73+
ecutrho: 3265.366014072
74+
ecutwfc: 408.170751759
75+
fft_grid:
76+
- 48
77+
- 48
78+
- 48
79+
lspinorb: false
80+
monkhorst_pack_grid:
81+
- 4
82+
- 4
83+
- 4
84+
monkhorst_pack_offset:
85+
- 0
86+
- 0
87+
- 0
88+
no_t_rev: false
89+
noinv: false
90+
noncolin: false
91+
occupations: fixed
92+
smooth_fft_grid:
93+
- 36
94+
- 36
95+
- 36
96+
xc_functional: PBE
7297
stress:
7398
- - -62.88281405555692
7499
- -2.551866364254089e-14

tests/outputs/test_pw_output/test_default_xml_240411_.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,33 @@ base_outputs:
6363
- 0.1875
6464
number_of_bands: 8
6565
number_of_k_points: 13
66+
parameters:
67+
degauss: 0.136056917253
68+
ecutrho: 3265.366014072
69+
ecutwfc: 408.170751759
70+
fft_grid:
71+
- 36
72+
- 36
73+
- 36
74+
lspinorb: false
75+
monkhorst_pack_grid:
76+
- 4
77+
- 4
78+
- 4
79+
monkhorst_pack_offset:
80+
- 0
81+
- 0
82+
- 0
83+
no_t_rev: false
84+
noinv: false
85+
noncolin: false
86+
occupations: smearing
87+
smearing_type: mv
88+
smooth_fft_grid:
89+
- 32
90+
- 32
91+
- 32
92+
xc_functional: PBESOL
6693
stress:
6794
- - 0.00831212176267791
6895
- 5.84098538270437e-18

tests/outputs/test_pw_output/test_default_xml_250521_.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,33 @@ base_outputs:
3737
- 1.0
3838
number_of_bands: 24
3939
number_of_k_points: 2
40+
parameters:
41+
degauss: 0.37415652244575
42+
ecutrho: 4898.049021108
43+
ecutwfc: 612.2561276385
44+
fft_grid:
45+
- 45
46+
- 45
47+
- 45
48+
lspinorb: false
49+
monkhorst_pack_grid:
50+
- 2
51+
- 1
52+
- 1
53+
monkhorst_pack_offset:
54+
- 0
55+
- 0
56+
- 0
57+
no_t_rev: false
58+
noinv: false
59+
noncolin: false
60+
occupations: smearing
61+
smearing_type: mv
62+
smooth_fft_grid:
63+
- 36
64+
- 36
65+
- 36
66+
xc_functional: PBESOL
4067
stress:
4168
- - 3.345625870189871
4269
- 0.6180019560502391
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
base_outputs: {}
1+
base_outputs:
2+
parameters: {}
23
raw_outputs:
34
stdout:
45
code_version: '7.5'

tests/outputs/test_pw_output/test_success_base_collinear_.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,31 @@ base_outputs:
1212
- 0.5
1313
number_of_bands: 24
1414
number_of_k_points: 2
15+
parameters:
16+
ecutrho: 4898.049021108
17+
ecutwfc: 612.2561276385
18+
fft_grid:
19+
- 45
20+
- 45
21+
- 45
22+
lspinorb: false
23+
monkhorst_pack_grid:
24+
- 2
25+
- 1
26+
- 1
27+
monkhorst_pack_offset:
28+
- 0
29+
- 0
30+
- 0
31+
no_t_rev: false
32+
noinv: false
33+
noncolin: false
34+
occupations: tetrahedra_opt
35+
smooth_fft_grid:
36+
- 36
37+
- 36
38+
- 36
39+
xc_functional: PBESOL
1540
structure:
1641
atomic_species:
1742
- F

0 commit comments

Comments
 (0)