12#ifndef Kernel_Elec_Utils_H
13#define Kernel_Elec_Utils_H
33 static inline double gamma_wigner(
int fdim) {
return (sqrt(fdim + 1.0e0) - 1) / fdim; }
37 for (
int i = 0; i < fdim; ++i) sum += 1.0e0 / (i + 1);
38 return ((fdim - sum) / (sum - 1.0e0)) / fdim;
46 if (std::real(rho[ii]) > vmax) {
47 vmax = std::real(rho[ii]);
59 sum += std::min({std::max({std::real(rho[ii]), 0.0e0}), 1.0e0});
60 if (rand_tmp < sum)
return i;
73 sum += std::abs(rho[ii]);
74 if (rand_tmp < sum)
return i;
89 prob = (prob > 1.0f) ? 1.0f : ((prob < 0.0f) ? 0.0f : prob);
91 if (rand_tmp < sumprob) {
100 if (to == from)
return;
106 if (to == from)
return;
124 int from,
int to,
bool reflect) {
125 if (to == from)
return from;
128 kids_real coeffa = 0.0f, coeffb = 0.0f, coeffc = E[to] - E[from];
130 coeffa += 0.5f * direction[i] * direction[i] / nm[i];
131 coeffb += np[i] / nm[i] * direction[i];
133 coeffb /= coeffa, coeffc /= coeffa;
135 kids_real coeffd = coeffb * coeffb - 4 * coeffc;
137 kids_real x1 = 0.5f * (-coeffb + sqrt(coeffd)), x2 = 0.5f * (-coeffb - sqrt(coeffd));
138 kids_real xx = (std::abs(x1) < std::abs(x2)) ? x1 : x2;
139 for (
int i = 0; i <
Dimension::N; ++i) np[i] += xx * direction[i];
141 }
else if (reflect) {
143 for (
int i = 0; i <
Dimension::N; ++i) np[i] += xx * direction[i];
157 for (
int i = 0; i < fdim; ++i) c[i] /= l;
162 for (
int i = 0; i < fdim; ++i) c[i] = ((i == occ ? 1.0e0 : 0.0e0) + gamma) / xi;
164 for (
int i = 0; i < fdim; ++i) {
167 c[i] = std::sqrt(std::abs(c[i])) * (cos(randu) +
phys::math::im * sin(randu));
173 bool pure_phase,
bool cont_phase) {
174 double randu = 1.0e0;
176 for (
int j = 0; j < fdim; ++j) {
178 rho[iocc * fdim + j] = 1.0e0;
184 rho[j * fdim + iocc] = std::conj(rho[iocc * fdim + j]);
186 for (
int i = 0, ij = 0; i < fdim; ++i) {
187 for (
int j = 0; j < fdim; ++j, ++ij) {
188 if (i == iocc || j == iocc)
continue;
189 rho[ij] = rho[iocc * fdim + j] / rho[iocc * fdim + i];
193 for (
int i = 0; i < fdim; ++i) {
194 for (
int j = i + 1; j < fdim; ++j) {
198 rho[j * fdim + i] = std::conj(rho[i * fdim + j]);
203 double occrand = (rand_act) ?
int(randu * fdim) : iocc;
204 for (
int i = 0, ij = 0; i < fdim; ++i) {
205 for (
int j = 0; j < fdim; ++j, ++ij) {
208 }
else if (i == occrand || j == occrand) {
220 case SQCPolicy::TRI: {
225 tmp2[1] = 1.0f - std::real(c[iocc]);
226 for (
int i = 0; i < fdim; ++i) {
229 c[i] = tmp2[0] * tmp2[1];
235 case SQCPolicy::SPX: {
237 for (
int i = 0; i <
Dimension::F; ++i) c[i] = std::abs(c[i] * c[i]);
241 case SQCPolicy::BIG: {
244 for (
int i = 0; i <
Dimension::F; ++i) c[i] = std::abs(cadd1[i] * cadd1[i]);
249 case SQCPolicy::SQR: {
251 for (
int i = 0; i < fdim; ++i) {
254 c[i] = 2.0 * gm0 * randu;
260 for (
int i = 0; i < fdim; ++i) {
274 for (
int i = 0; i <
Dimension::FF; ++i) ker[i] = rho[i] / std::abs(rho[i]);
280 double vk = std::abs(rho[kk]);
281 bool Outlier =
false;
286 Outlier = (i == j) ? ((k != i && vk > 1) || (k == i && vk < 1))
287 : ((k != i && k != j && vk > 1) || ((k == i || k == j) && vk < 0.5f));
289 if (i != j) Outlier =
false;
292 Outlier = (i == j) ? ((k != i && std::abs(vk - gm0) < gm0) ||
293 (k == i && std::abs(vk - gm1) < gm0))
294 : ((k != i && std::abs(vk - gm0) > gm0) ||
295 (k == i && std::abs(vk - gmh) > gm0) ||
296 (k == j && std::abs(vk - gmh) > gm0));
this file provide Kernel class
initialization kernels for electonic DOFs
#define DEFINE_POLICY(Policy,...)
static int rand_uniform(kids_real *res_arr, int N=1, kids_real sigma=1.0)
static int rand_gaussian(kids_real *res_arr, int N=1, kids_real sigma=1.0, kids_real mu=0.0)
static int hopping_choose(kids_complex *rho, kids_complex *H, int from, kids_real dt)
static void hopping_direction(kids_real *direction, kids_real *E, kids_real *dE, kids_complex *rho, int from, int to)
static double gamma_wigner(int fdim)
static int pop_neg_choose(kids_complex *rho)
static int rho_focus(kids_complex *rho, int iocc, double gamma_ou, double gamma_uu, int fdim, bool rand_act, bool pure_phase, bool cont_phase)
static int hopping_impulse(kids_real *direction, kids_real *np, kids_real *nm, kids_real *E, int from, int to, bool reflect)
static int pop_choose(kids_complex *rho)
static int c_window(kids_complex *c, int iocc, int type, int fdim)
static double gamma_opt(int fdim)
static int c_focus(kids_complex *c, double xi, double gamma, int occ, int fdim)
static void hopping_direction(kids_real *direction, kids_real *dE, int from, int to)
static int max_choose(kids_complex *rho)
static int c_sphere(kids_complex *c, int fdim)
sampling mapping variables from uniform sphere distribution (i.e.
static int ker_binning(kids_complex *ker, kids_complex *rho, int sqc_type)
std::size_t N
Number of nuclear degrees of freedom.
std::size_t F
Number of electronic degrees of freedom.
std::size_t Fadd1
F plus 1 (F + 1).
std::size_t FF
Product of F and F (F * F).
< http://warp.povusers.org/FunctionParser/fparser.html
kids_real ARRAY_INNER_TRANS1(kids_real *B, kids_real *C, size_t N1)
Compute the inner product of the transpose of B with C for real matrices.
double kids_real
Alias for real number type.
std::complex< double > kids_complex
Alias for complex number type.
constexpr real_precision halfpi
constexpr std::complex< real_precision > iu(1.0L, 0.0L)
constexpr std::complex< real_precision > im(0.0L, 1.0L)
Imaginary Unit.
constexpr real_precision twopi
constexpr std::complex< real_precision > iz(0.0L, 0.0L)
declaration of variables used in the program.