Quantum 3xplorer (Q3)
An AI-native quantum simulation engine
Loading...
Searching...
No Matches
factory.hpp
Go to the documentation of this file.
1#pragma once
2
3/**
4 * create_smearing — factory function for occupation smearing schemes.
5 *
6 * Supported schemes: "fixed"/"none" (insulating, step function),
7 * "gaussian"/"gauss" (metallic, erfc smearing with configurable width),
8 * "methfessel-paxton"/"m-p"/"mp" (Hermite correction of order
9 * `methfessel_paxton_order`, default 1; ignored by the other schemes),
10 * "marzari-vanderbilt"/"cold"/"m-v"/"mv" (cold smearing), and
11 * "fermi-dirac"/"f-d"/"fd" (physical finite-T occupation). Aliases match
12 * Quantum ESPRESSO's `smearing` namelist values so QE input files translate
13 * directly without a separate name-mapping layer.
14 */
15
16#include <memory>
17#include <stdexcept>
18#include <string>
19
25
26namespace q3 {
27
28/// Factory for smearing schemes.
29inline std::unique_ptr<SmearingScheme> create_smearing(const std::string& name,
30 Real smearing_width = 0.0,
31 int methfessel_paxton_order = 1) {
32 if (name == "fixed" || name == "none" || name.empty()) {
33 return std::make_unique<FixedOccupation>();
34 }
35 if (name == "gaussian" || name == "gauss") {
36 return std::make_unique<GaussianSmearing>(smearing_width);
37 }
38 if (name == "methfessel-paxton" || name == "m-p" || name == "mp") {
39 return std::make_unique<MethfesselPaxtonSmearing>(smearing_width, methfessel_paxton_order);
40 }
41 if (name == "marzari-vanderbilt" || name == "cold" || name == "m-v" || name == "mv") {
42 return std::make_unique<MarzariVanderbiltSmearing>(smearing_width);
43 }
44 if (name == "fermi-dirac" || name == "f-d" || name == "fd") {
45 return std::make_unique<FermiDiracSmearing>(smearing_width);
46 }
47 throw std::runtime_error(
48 "Unknown smearing: " + name +
49 ". Options: fixed, gaussian, methfessel-paxton, marzari-vanderbilt, fermi-dirac");
50}
51
52} // namespace q3
double Real
std::unique_ptr< SmearingScheme > create_smearing(const std::string &name, Real smearing_width=0.0, int methfessel_paxton_order=1)
Factory for smearing schemes.
Definition factory.hpp:29