Loading...
Searching...
No Matches
factory.hpp
Go to the documentation of this file.
1#pragma once
2
3/**
4 * create_quantum_state_interpolator — the evaluation-side factory: an
5 * InterpolationRecord and the evaluation manifest's specification in, an
6 * interpolator of the electronic state and the report of its construction
7 * out.
8 *
9 * The record names its method, so the caller -- the utility that evaluates a
10 * saved model, or a test -- never branches on it, and the specification is
11 * the method-agnostic block every method reads its own knobs from. Adding a
12 * method is one payload member on the record, one construction function
13 * under method/, one report member on the construction, and one case here;
14 * every consumer of QuantumStateInterpolator then serves it unchanged. Mirrors
15 * create_mean_field_exporter(), minus the Null object: there is no "no interpolation" interpolator
16 * to hand out, since a record only exists when one was asked for.
17 *
18 * The two axes meet here and only here. The method builds a model from the
19 * record; the target evaluates that model. For every method that yields a
20 * local-orbital H(R) -- Wannier now, projected atomic orbitals and Shirley's
21 * basis later -- the evaluator is the same one, which is why it is selected
22 * here rather than owned by the method.
23 *
24 * Capture, the opposite direction, is deliberately not in this file: it needs
25 * the plane-wave SCF iterator, and evaluating a saved model must not. See
26 * capture.hpp.
27 */
28
29#include <memory>
30#include <stdexcept>
31#include <string>
32#include <utility>
33
42
43namespace q3 {
44
45/**
46 * A specification that says nothing builds the record as the manifest's
47 * defaults ask: an isolated manifold, localised where the record can support
48 * it.
49 */
50[[nodiscard]] inline QuantumStateInterpolatorConstruction
52 const InterpolationSpecification& specification = {}) {
53 if (record.method == "wannier") {
54 WannierConstruction construction =
55 WannierHamiltonianBuilder(WannierConstructionSettings::from(specification))
56 .build(record.wannier, record.real_lattice_bohr);
57 QuantumStateInterpolatorConstruction result;
58 result.interpolator = std::make_unique<LocalOrbitalQuantumStateInterpolator>(
59 std::move(construction.hamiltonian), construction.report.description());
60 result.wannier = std::move(construction.report);
61 return result;
62 }
63 throw std::runtime_error("create_quantum_state_interpolator: unknown interpolation method '" +
64 record.method + "'. Supported: wannier");
65}
66
67} // namespace q3
QuantumStateInterpolatorConstruction create_quantum_state_interpolator(const InterpolationRecord &record, const InterpolationSpecification &specification={})
Definition factory.hpp:51
WannierInputs wannier
Payload for method == "wannier": interface matrices on the full k-grid.
Definition record.hpp:46
Matrix3x3 real_lattice_bohr
Rows a1, a2, a3, Cartesian, in bohr.
Definition record.hpp:34
std::string method
The method that built the payload: "wannier".
Definition record.hpp:31
std::unique_ptr< QuantumStateInterpolator > interpolator
static WannierConstructionSettings from(const InterpolationSpecification &specification)
Definition init.hpp:56