10const double pi = 3.1415926535897932385;
12const double sqrt2 = std::sqrt(2.0);
15gaussian::delta(
double x__,
double width__)
17 double t = std::pow(x__ / width__, 2);
18 return std::exp(-t) / std::sqrt(
pi) / width__;
22gaussian::occupancy(
double x__,
double width__)
24 return 0.5 * (1 + std::erf(x__ / width__));
28gaussian::entropy(
double x__,
double width__)
30 double t = std::pow(x__ / width__, 2);
31 return -std::exp(-t) * width__ / 2.0 / std::sqrt(
pi);
35fermi_dirac::delta(
double x__,
double width__)
37 double t = x__ / 2.0 / width__;
38 return 1.0 / std::pow(std::exp(t) + std::exp(-t), 2) / width__;
42fermi_dirac::occupancy(
double x__,
double width__)
44 return 1.0 - 1.0 / (1.0 + std::exp(x__ / width__));
48fermi_dirac::entropy(
double x__,
double width__)
50 double t = x__ / width__;
51 double f = 1.0 / (1.0 + std::exp(t));
52 if (std::abs(f - 1.0) * std::abs(f) < 1e-16) {
55 return width__ * ((1 - f) * std::log(1 - f) + f * std::log(f));
66 double exw = std::exp(x__ / width__);
67 double w2 = width__ * width__;
68 return -exw * (exw - 1) / (std::pow(1 + exw, 3) * w2);
72cold::occupancy(
double x__,
double width__)
74 double x = x__ / width__ - 1.0 / sqrt2;
76 double f = std::erf(x) / 2.0 + 0.5;
82 return f + std::exp(-x2) / std::sqrt(2 * pi);
86cold::delta(
double x__,
double width__)
88 double x = x__ / width__ - 1.0 / sqrt2;
92 return std::exp(-x2) * (2 * width__ - sqrt2 * x__) / std::sqrt(pi) / width__ / width__;
103 double sqrt2 = std::sqrt(2.0);
104 double z = x__ / width__ - 1 / sqrt2;
108 double expmz2 = std::exp(-z2);
109 return expmz2 * (-sqrt2 - 2 * z + 2 * sqrt2 * z * z) / std::sqrt(
pi) / width__ / width__;
113cold::entropy(
double x__,
double width__)
115 double x = x__ / width__ - 1.0 / sqrt2;
119 return -std::exp(-x2) * (width__ - sqrt2 * x__) / 2 / std::sqrt(pi);
131 double sqrtpi = std::sqrt(
pi);
132 int sign = n % 2 == 0 ? 1 : -1;
133 return sign / tgamma(n + 1) / std::pow(4, n) / sqrtpi;
137methfessel_paxton::occupancy(
double x__,
double width__,
int n__)
139 double z = -x__ / width__;
141 result = 0.5 * (1 - std::erf(z));
143 for (
int i = 1; i <= n__; ++i) {
145 result += A * sf::hermiteh(2 * i - 1, z) * std::exp(-z * z);
151methfessel_paxton::delta(
double x__,
double width__,
int n__)
153 double z = -x__ / width__;
154 double result = -std::exp(-z * z) / std::sqrt(pi) / width__ * (-1);
155 for (
int i = 1; i <= n__; ++i) {
157 result += A * sf::hermiteh(2 * i, z) * std::exp(-z * z);
163methfessel_paxton::dxdelta(
double x__,
double width__,
int n__)
165 double z = -x__ / width__;
166 double result = 2 * std::exp(-z * z) * z / std::sqrt(pi) / (width__ * width__);
167 for (
int i = 1; i <= n__; ++i) {
169 result += A * sf::hermiteh(2 * i + 1, z) * std::exp(-z * z);
175methfessel_paxton::entropy(
double x__,
double width__,
int n__)
178 double x = x__ / width__;
179 double arg = std::min(200.0, x * x);
180 double S = -0.5 * std::exp(-arg) / std::sqrt(pi);
184 double hp = std::exp(-arg);
186 double a = 1 / std::sqrt(pi);
187 for (
int i = 1; i <= n__; ++i) {
188 hd = 2 * x * hp - 2 * ni * hd;
191 hp = 2 * x * hd - 2 * ni * hp;
194 S = S - a * (0.5 * hp + ni * hpm1);
double mp_coefficients(int n)
Namespace of the SIRIUS library.
int sign(T val)
Sign of the variable.
Smearing functions used in finding the band occupancies.
static double dxdelta(double x__, double width__)
static double dxdelta(double x__, double width__)