Quantum 3xplorer (Q3)
Loading...
Searching...
No Matches
base.hpp
Go to the documentation of this file.
1
#pragma once
2
3
/**
4
* Flavor — abstract interface for a Q3 calculation mode.
5
*
6
* A Flavor encapsulates a complete calculation workflow (SCF, NSCF, etc.)
7
* and returns its results as results.json's own struct, generated::Results.
8
*/
9
10
#include "
io/input/data.hpp
"
11
#include "
io/output/material/init.hpp
"
12
#include "
io/output/results.hpp
"
13
#include "
io/provenance/factory.hpp
"
14
#include "
layer_5_properties/band_structure/band_edges.hpp
"
15
16
namespace
q3
{
17
18
class
Flavor
{
19
public
:
20
virtual
~Flavor
() =
default
;
21
22
/**
23
* Execute the calculation described by the input and return results,
24
* stamped with the provenance of the run that produced them, the material
25
* it ran on, and the band edges and gap its eigenvalues give.
26
*
27
* Not virtual, and the reason is the stamp. Provenance attached at the call
28
* sites instead would mean every present and future caller had to remember
29
* to attach it, and the one that forgot would emit a results file
30
* indistinguishable from an unattributable one. Here it is structural: a
31
* flavor cannot run without being attributed.
32
*
33
* Re-reading the pseudopotential files to identify them costs milliseconds
34
* against a calculation that has already finished, which is the right trade
35
* for a subclass never having to carry provenance plumbing of its own.
36
*/
37
generated::Results
run
(
const
InputData
& input) {
38
generated::Results results =
run_calculation
(input);
39
if
(nlohmann::json provenance =
build_provenance_json
(input); !provenance.is_null()) {
40
results.provenance = std::move(provenance);
41
}
42
if
(nlohmann::json material =
build_material_json
(input); !material.is_null()) {
43
results.structure = generated::ResultsStructure{std::move(material)};
44
}
45
add_band_edge_records
(results);
46
return
results;
47
}
48
49
protected
:
50
/**
51
* Execute the calculation described by the input and return results.
52
*
53
* Implementations must be self-contained: they set up, run, and finalize
54
* the calculation entirely. The caller receives fully-populated results,
55
* minus what run() adds.
56
*/
57
virtual
generated::Results
run_calculation
(
const
InputData
& input) = 0;
58
};
59
60
}
// namespace q3
band_edges.hpp
q3::Flavor
Definition
base.hpp:18
q3::Flavor::run
generated::Results run(const InputData &input)
Definition
base.hpp:37
q3::Flavor::~Flavor
virtual ~Flavor()=default
q3::Flavor::run_calculation
virtual generated::Results run_calculation(const InputData &input)=0
data.hpp
init.hpp
factory.hpp
q3
Definition
q3_core_api.hpp:33
q3::build_material_json
nlohmann::json build_material_json(const InputData &input)
Definition
init.hpp:73
q3::add_band_edge_records
void add_band_edge_records(generated::Results &results)
Definition
band_edges.hpp:181
q3::build_provenance_json
nlohmann::json build_provenance_json(const InputData &input)
Build the provenance block for a completed run, from the input it consumed.
Definition
factory.hpp:44
results.hpp
q3::InputData
Parsed input data — holds raw values read from input files.
Definition
data.hpp:27
src
layer_4_computation
flavors
base.hpp
Generated by
1.9.8