Quantum 3xplorer (Q3)
Loading...
Searching...
No Matches
init.hpp
Go to the documentation of this file.
1
#pragma once
2
3
/**
4
* IsolatedSystemCorrectionCalculator — abstract interface for isolated-system
5
* (finite-size electrostatic) correction schemes.
6
*
7
* A charged or dipolar system computed in periodic boundary conditions
8
* carries a spurious electrostatic interaction with its own periodic images;
9
* a correction scheme estimates and removes it from the total energy after
10
* SCF convergence. Concrete schemes (Makov-Payne and Martyna-Tuckerman
11
* today; point-countercharge and slab/ESM-style corrections are the natural
12
* future additions, mirroring QE's assume_isolated options) implement this
13
* interface and are selected by name through
14
* create_isolated_system_correction_calculator() (factory.hpp), so
15
* orchestrators never branch on the scheme themselves -- "none" resolves to
16
* NullIsolatedSystemCorrectionCalculator (null.hpp), which reports "nothing
17
* applied", removing the need for any if/else at the call sites.
18
*
19
* The result is deliberately scheme-agnostic: a list of labeled additive
20
* energy terms rather than fixed fields, because the breakdown differs per
21
* scheme (Makov-Payne has a monopole and a dipole+quadrupole term;
22
* Martyna-Tuckerman reports a single reciprocal-space term, see
23
* MartynaTuckermanCorrectionCalculator -- its docstring also explains why
24
* this is the post-SCF evaluation of MT, distinct from QE's self-consistent
25
* assume_isolated='m-t'). Every term already carries the sign such that
26
* corrected_total_energy = total_energy + sum(terms).
27
*/
28
29
#include <string>
30
#include <utility>
31
#include <vector>
32
33
#include "
layer_0_core/types/init.hpp
"
34
#include "
layer_4_computation/state/kohn_sham/planewave/norm_conserving/init.hpp
"
35
36
namespace
q3
{
37
38
/**
39
* Outcome of one correction scheme's evaluation.
40
*
41
* `applied` is false only for the Null scheme ("none"); reporting code keys
42
* off it to decide whether to emit anything. `terms_in_ry` are the labeled
43
* additive contributions (labels are snake_case and become the
44
* `<label>_ry` keys in results.json).
45
*/
46
struct
IsolatedSystemCorrectionResult
{
47
bool
applied
=
false
;
48
std::string
method
=
"none"
;
49
std::vector<std::pair<std::string, Real>>
terms_in_ry
;
50
51
[[nodiscard]]
Real
total_in_ry
()
const
{
52
Real
total = 0.0;
53
for
(
const
auto
& [label, value] :
terms_in_ry
) {
54
total += value;
55
}
56
return
total;
57
}
58
};
59
60
class
IsolatedSystemCorrectionCalculator
{
61
public
:
62
virtual
~IsolatedSystemCorrectionCalculator
() =
default
;
63
64
/**
65
* Evaluate the correction on a converged SCF state. Schemes that have
66
* geometric preconditions (Makov-Payne: cubic lattice) throw
67
* std::runtime_error before touching any density data when violated.
68
*/
69
[[nodiscard]]
virtual
IsolatedSystemCorrectionResult
70
compute
(
const
NormConservingPlanewaveKohnShamSCFState
& scf_state)
const
= 0;
71
72
/// Scheme name as accepted by the input ("none", "makov-payne", ...).
73
[[nodiscard]]
virtual
std::string
name
()
const
= 0;
74
};
75
76
}
// namespace q3
q3::IsolatedSystemCorrectionCalculator
Definition
init.hpp:60
q3::IsolatedSystemCorrectionCalculator::name
virtual std::string name() const =0
Scheme name as accepted by the input ("none", "makov-payne", ...).
q3::IsolatedSystemCorrectionCalculator::compute
virtual IsolatedSystemCorrectionResult compute(const NormConservingPlanewaveKohnShamSCFState &scf_state) const =0
q3::IsolatedSystemCorrectionCalculator::~IsolatedSystemCorrectionCalculator
virtual ~IsolatedSystemCorrectionCalculator()=default
init.hpp
init.hpp
q3
Definition
q3_core_api.hpp:33
q3::Real
double Real
Definition
type_aliases.hpp:20
q3::IsolatedSystemCorrectionResult
Definition
init.hpp:46
q3::IsolatedSystemCorrectionResult::applied
bool applied
Definition
init.hpp:47
q3::IsolatedSystemCorrectionResult::terms_in_ry
std::vector< std::pair< std::string, Real > > terms_in_ry
Definition
init.hpp:49
q3::IsolatedSystemCorrectionResult::total_in_ry
Real total_in_ry() const
Definition
init.hpp:51
q3::IsolatedSystemCorrectionResult::method
std::string method
Definition
init.hpp:48
q3::NormConservingPlanewaveKohnShamSCFState
Definition
init.hpp:31
src
layer_5_properties
isolated_system_correction
planewave
init.hpp
Generated by
1.9.8