Quantum 3xplorer (Q3)
An AI-native quantum simulation engine
Loading...
Searching...
No Matches
diagnostic.hpp
Go to the documentation of this file.
1#pragma once
2
3/**
4 * WannierDiagnostic — the failures of the Wannier construction that a
5 * driver can act on, as codes beside the prose.
6 *
7 * The retry ladder in q3.workflows.wannier decides what to try next from
8 * WHY an evaluation failed: a disentanglement that ran out of iterations
9 * wants a looser tolerance, a window that froze too many bands wants a
10 * lower one, a record that cannot be localised wants no retry at all.
11 * Reading that out of the error prose would tie a routing decision to the
12 * wording of a sentence, so the code is the contract and the prose is for
13 * the reader.
14 *
15 * Every enumerator is spelled exactly as the utility prints it on the
16 * `diagnostic:` line after `Error:`, and exactly as the Python side's enum
17 * names it; a test on each side reads this file to keep the two equal.
18 */
19
20#include <stdexcept>
21#include <string>
22
23namespace q3 {
24
26 /// The subspace iteration exhausted its budget; the error carries the spreads it reached.
28 /// The record lacks the overlaps or the projectabilities that disentanglement reads.
30 /// A k-point freezes more bands than there are Wannier functions.
32 /// A k-point keeps fewer bands than there are Wannier functions.
34 /// The trial orbitals do not span the chosen manifold at some k-point.
36 /// A diagonal overlap vanished, so a Berry phase -- a centre -- is undefined.
38 /// The gauge-invariant spread came out negative: the overlaps are not of orthonormal states.
40 /// The record lacks the overlaps that localisation minimises.
42 /// The k-mesh has an axis of two points, on which k+b and k-b coincide.
44};
45
46/// The enumerator's own spelling, which is what the `diagnostic:` line prints.
47[[nodiscard]] inline std::string wannier_diagnostic_name(WannierDiagnostic diagnostic) {
48 switch (diagnostic) {
50 return "disentanglement_unconverged";
52 return "disentanglement_unsupported";
54 return "frozen_window_overfull";
56 return "kept_bands_underfull";
58 return "gauge_singular";
60 return "gauge_collapsed";
62 return "overlaps_not_orthonormal";
64 return "localization_unsupported";
66 return "two_point_axis";
67 }
68 throw std::logic_error("wannier_diagnostic_name: an enumerator without a name");
69}
70
71} // namespace q3
std::string wannier_diagnostic_name(WannierDiagnostic diagnostic)
The enumerator's own spelling, which is what the diagnostic: line prints.
WannierDiagnostic
@ two_point_axis
The k-mesh has an axis of two points, on which k+b and k-b coincide.
@ overlaps_not_orthonormal
The gauge-invariant spread came out negative: the overlaps are not of orthonormal states.
@ frozen_window_overfull
A k-point freezes more bands than there are Wannier functions.
@ gauge_singular
The trial orbitals do not span the chosen manifold at some k-point.
@ disentanglement_unsupported
The record lacks the overlaps or the projectabilities that disentanglement reads.
@ localization_unsupported
The record lacks the overlaps that localisation minimises.
@ kept_bands_underfull
A k-point keeps fewer bands than there are Wannier functions.
@ disentanglement_unconverged
The subspace iteration exhausted its budget; the error carries the spreads it reached.
@ gauge_collapsed
A diagonal overlap vanished, so a Berry phase – a centre – is undefined.