excgrid 0.1.0
Grid + XC-kernel + D3 library
Loading...
Searching...
No Matches
kernel.hpp
1#pragma once
2
3#include <span>
4#include <string_view>
5
6namespace excgrid {
7
16
25 double exc = 0.0;
26 double vrhoA = 0.0;
27 double vrhoB = 0.0;
28 double vsigmaAa = 0.0;
29 double vsigmaAb = 0.0;
30 double vsigmaBb = 0.0;
31 double vtauA = 0.0;
32 double vtauB = 0.0;
33};
34
40constexpr XcKernelValue operator+(const XcKernelValue& a, const XcKernelValue& b) noexcept {
41 return {a.exc + b.exc,
42 a.vrhoA + b.vrhoA,
43 a.vrhoB + b.vrhoB,
44 a.vsigmaAa + b.vsigmaAa,
45 a.vsigmaAb + b.vsigmaAb,
46 a.vsigmaBb + b.vsigmaBb,
47 a.vtauA + b.vtauA,
48 a.vtauB + b.vtauB};
49}
50
56constexpr XcKernelValue& operator+=(XcKernelValue& a, const XcKernelValue& b) noexcept {
57 a = a + b;
58
59 return a;
60}
61
67constexpr XcKernelValue operator*(double weight, const XcKernelValue& v) noexcept {
68 return {weight * v.exc,
69 weight * v.vrhoA,
70 weight * v.vrhoB,
71 weight * v.vsigmaAa,
72 weight * v.vsigmaAb,
73 weight * v.vsigmaBb,
74 weight * v.vtauA,
75 weight * v.vtauB};
76}
77
83constexpr XcKernelValue operator*(const XcKernelValue& v, double weight) noexcept {
84 return weight * v;
85}
86
89using LdaKernel = XcKernelValue (*)(double rhoA, double rhoB);
90
94using GgaKernel =
95 XcKernelValue (*)(double rhoA, double rhoB, double sigmaAa, double sigmaAb, double sigmaBb);
96
103public:
104 virtual ~XcFunctional() = default;
105
108 [[nodiscard]] virtual bool UsesGradient() const = 0;
109
113 [[nodiscard]] virtual double ExchangeFraction() const = 0;
114
123 double rhoA, double rhoB, double sigmaAa, double sigmaAb, double sigmaBb) const = 0;
124};
125
132const XcFunctional* FindFunctional(std::string_view name) noexcept;
133
137std::span<const std::string_view> FunctionalNames() noexcept;
138
139} // namespace excgrid
Definition kernel.hpp:102
virtual double ExchangeFraction() const =0
virtual bool UsesGradient() const =0
virtual XcKernelValue Evaluate(double rhoA, double rhoB, double sigmaAa, double sigmaAb, double sigmaBb) const =0
XcKernelValue(*)(double rhoA, double rhoB, double sigmaAa, double sigmaAb, double sigmaBb) GgaKernel
Definition kernel.hpp:94
constexpr XcKernelValue operator+(const XcKernelValue &a, const XcKernelValue &b) noexcept
Definition kernel.hpp:40
constexpr XcKernelValue operator*(double weight, const XcKernelValue &v) noexcept
Definition kernel.hpp:67
XcKernelValue(*)(double rhoA, double rhoB) LdaKernel
Definition kernel.hpp:89
std::span< const std::string_view > FunctionalNames() noexcept
constexpr XcKernelValue & operator+=(XcKernelValue &a, const XcKernelValue &b) noexcept
Definition kernel.hpp:56
const XcFunctional * FindFunctional(std::string_view name) noexcept
Definition kernel.hpp:24
double vsigmaBb
de/d sigmaBb.
Definition kernel.hpp:30
double vrhoB
de/d rhoB.
Definition kernel.hpp:27
double vsigmaAb
de/d sigmaAb.
Definition kernel.hpp:29
double exc
Energy density e(r).
Definition kernel.hpp:25
double vtauB
de/d tauB (reserved - zero from LDA/GGA).
Definition kernel.hpp:32
double vtauA
de/d tauA (reserved - zero from LDA/GGA).
Definition kernel.hpp:31
double vsigmaAa
de/d sigmaAa.
Definition kernel.hpp:28
double vrhoA
de/d rhoA.
Definition kernel.hpp:26