Loading...
Searching...
No Matches
factory.hpp
Go to the documentation of this file.
1#pragma once
2
3/**
4 * Pick the one-center convention a dataset's numbers were generated for.
5 *
6 * Looks up the dataset's own declared `one_center_convention` in the
7 * convention registry, not the file format and not some correlated
8 * capability. The thing that makes a reference subtraction correct is what
9 * the numbers mean, not where they were read from, and a capability test
10 * would silently do the wrong thing the first time some other reader produced
11 * either kind.
12 *
13 * A dataset declaring a convention this build does not provide is refused
14 * rather than computed in the default one, because the default would be wrong
15 * by a per-element constant while every reference-independent observable
16 * still agreed.
17 */
18
19#include <memory>
20#include <stdexcept>
21
25
26namespace q3 {
27namespace paw_one_center {
28
29inline std::unique_ptr<PawOneCenterConvention>
31 const auto& registry = one_center_convention_registry();
32 if (const auto* factory = registry.find(pseudopotential.one_center_convention))
33 return factory->create();
34 throw std::runtime_error("The PAW dataset for " + pseudopotential.element +
35 " is expressed in the one-center convention '" +
36 pseudopotential.one_center_convention +
37 "', which this build does not provide; the conventions it provides "
38 "are: " +
39 registry.canonical_names(", "));
40}
41
42} // namespace paw_one_center
43} // namespace q3
PAW pseudopotential — extends ultrasoft with one-center (on-site) data.
Definition init.hpp:33
std::string one_center_convention
Definition init.hpp:55
std::string element
Definition init.hpp:66
std::unique_ptr< PawOneCenterConvention > create_one_center_convention(const PawPseudopotential &pseudopotential)
Definition factory.hpp:30
Registry< NamedFactory< PawOneCenterConvention > > & one_center_convention_registry()
The registry create_one_center_convention() builds conventions from.
Definition registry.hpp:25