KIDS  ver-0.0.1
KIDS : Kernel Integrated Dynamics Simulator
Loading...
Searching...
No Matches
Kernel_Elec_Switch.cpp
Go to the documentation of this file.
2
7#include "kids/hash_fnv1a.h"
8#include "kids/linalg.h"
9#include "kids/macro_utils.h"
10#include "kids/vars_list.h"
11
12inline bool isFileExists(const std::string& name) { return std::ifstream{name.c_str()}.good(); }
13
14extern double phi(double lambda, double N0_max, int F);
15
16namespace PROJECT_NS {
17
18extern double calc_alpha(kids_real* V, int i = 0, int k = 1, int F = 2);
19
20extern int calc_wrho(kids_complex* wrho, // distorted rho
21 kids_complex* rho, // rho_ele
22 double xi, // xi must be 1
23 double gamma, // gamma must be 0
24 double alpha);
25
26extern double calc_Ew(kids_real* E, kids_complex* wrho, int occ);
27
42extern int calc_distforce(kids_real* f1, // to be calculated
43 kids_real* E, // (input)
44 kids_real* dE, // (input)
45 kids_complex* wrho, // distorted rho
46 kids_complex* rho, // rho_ele
47 double alpha);
48
49extern int hopping_impulse(kids_real* direction, kids_real* np, kids_real* nm, //
50 kids_real Efrom, kids_real Eto, int from, int to, bool reflect);
51
52
53const std::string Kernel_Elec_Switch::getName() { return "Kernel_Elec_Switch"; }
54
56
57
58void Kernel_Elec_Switch::setInputParam_impl(std::shared_ptr<Param>& PM) {
59 cmsh_type = NADPolicy::_from(PM->get_string("cmsh_flag", LOC(), "CVSH"));
60
61 alpha0 = PM->get_double("alpha0", LOC(), 0.5);
62 gamma1 = PM->get_double("gamma", LOC(), elec_utils::gamma_wigner(Dimension::F));
63
66
67 gamma2 = (1 - gamma1) / (1.0f + Dimension::F * gamma1);
68 xi1 = (1 + Dimension::F * gamma1);
69 xi2 = (1 + Dimension::F * gamma2);
70 use_wmm = PM->get_bool("use_wmm", LOC(), false);
71 use_sqc = PM->get_bool("use_sqc", LOC(), false);
72 sqc_init = PM->get_int("sqc_init", LOC(), 0);
73 use_fssh = PM->get_bool("use_fssh", LOC(), false);
74 use_strange_win = PM->get_bool("use_strange_win", LOC(), false);
75 use_focus = PM->get_bool("use_focus", LOC(), false);
76 use_fall = PM->get_bool("use_fall", LOC(), false);
77 use_gdtwa = PM->get_bool("use_gdtwa", LOC(), false);
78 only_adjust = PM->get_bool("only_adjust", LOC(), false);
79 use_sum = PM->get_bool("use_sum", LOC(), false);
80 check_cxs = PM->get_bool("check_cxs", LOC(), false);
81 dt = PM->get_double("dt", LOC(), phys::time_d);
82
83 cread_from_ds = PM->get_bool("cread_from_ds", LOC(), false);
84
85 hopping_type1 = 0;
86 hopping_type2 = 0;
87 reflect = true;
88 use_cv = false;
89 dynamic_alpha = false;
90 switch (cmsh_type) {
91 case NADPolicy::EHR:
92 Kernel_NADForce::NADForce_type = NADForcePolicy::EHR;
93 break;
94 case NADPolicy::BOSH:
95 Kernel_NADForce::NADForce_type = NADForcePolicy::BO;
96 hopping_type1 = 0; // max(rho_ele)
97 hopping_type2 = 0; // MASH direction
98 reflect = true;
99 break;
100 case NADPolicy::CVSH:
101 Kernel_NADForce::NADForce_type = NADForcePolicy::CV;
102 hopping_type1 = 1; // max(rho_nuc)
103 hopping_type2 = 2; // P direction
104 reflect = false;
105 use_cv = true;
106 break;
107 case NADPolicy::BOSD:
108 Kernel_NADForce::NADForce_type = NADForcePolicy::BOSD;
109 dynamic_alpha = true;
110 break;
111 case NADPolicy::CVSD:
112 Kernel_NADForce::NADForce_type = NADForcePolicy::CVSD;
113 dynamic_alpha = true;
114 break;
115 }
116 hopping_type1 = PM->get_int("hopping_type1", LOC(), hopping_type1);
117 hopping_type2 = PM->get_int("hopping_type2", LOC(), hopping_type2);
118 use_cv = PM->get_bool("use_cv", LOC(), use_cv);
119 reflect = PM->get_bool("reflect", LOC(), reflect);
120 dynamic_alpha = PM->get_bool("dynamic_alpha", LOC(), dynamic_alpha);
121}
122
123void Kernel_Elec_Switch::setInputDataSet_impl(std::shared_ptr<DataSet>& DS) {
125 Epot = DS->def(DATA::integrator::Epot);
126 p = DS->def(DATA::integrator::p);
127 m = DS->def(DATA::integrator::m);
128 fadd = DS->def(DATA::integrator::fadd);
131 vpes = DS->def(DATA::model::vpes);
132 V = DS->def(DATA::model::V);
133 E = DS->def(DATA::model::rep::E);
134 dE = DS->def(DATA::model::rep::dE);
135 T = DS->def(DATA::model::rep::T);
136 H = DS->def(DATA::model::rep::H);
138 sqcw = DS->def(DATA::integrator::sqcw);
142}
143
145 for (int iP = 0; iP < Dimension::P; ++iP) {
147 kids_complex* wz_A = Kernel_Elec::wz_A + iP;
148 kids_complex* wz_D = Kernel_Elec::wz_D + iP;
149 kids_complex* ww_A = Kernel_Elec::ww_A + iP;
150 kids_complex* ww_D = Kernel_Elec::ww_D + iP;
156 int* occ_nuc = Kernel_Elec::occ_nuc + iP;
157 kids_real* alpha = this->alpha + iP;
158 kids_real* V = this->V + iP * Dimension::FF;
159
162
163 w[0] = kids_complex(Dimension::F);
164 int iocc;
165 Kernel_Random::rand_catalog(&iocc, 1, true, 0, Dimension::F - 1);
166 iocc = ((use_sum) ? iocc : Kernel_Elec::occ0);
167 *occ_nuc = iocc;
168 if (use_focus) {
170 } else if (use_sqc) {
171 switch (sqc_init) {
172 case 0: { // traditional SQC
173 elec_utils::c_window(c, iocc, SQCPolicy::TRI, Dimension::F);
174 break;
175 }
176 case 1: { // simplex SQC
178 for (int i = 0; i < Dimension::F; ++i) c[i] = std::abs(c[i] * c[i]);
179 c[iocc] += 1.0e0;
180 for (int i = 0; i < Dimension::F; ++i) {
181 kids_real randu;
183 randu *= phys::math::twopi;
184 c[i] = sqrt(c[i]);
185 c[i] *= (cos(randu) + phys::math::im * sin(randu));
186 }
187 break;
188 }
189 case 2: { // suggested by YHShang
191 break;
192 }
193 case 3: { // suggested by Liu
194 elec_utils::c_window(c, iocc, SQCPolicy::TRI, Dimension::F);
195 break;
196 }
197 case 4: { // suggested by Liu
198 elec_utils::c_window(c, iocc, SQCPolicy::TRI, Dimension::F);
199 double norm = 0.0e0;
200 for (int i = 0; i < Dimension::F; ++i) norm += std::abs(c[i] * c[i]);
201 xi1 = norm;
202 gamma1 = (xi1 - 1.0e0) / Dimension::F;
203 norm = sqrt(norm);
204 for (int i = 0; i < Dimension::F; ++i) c[i] /= norm;
205 break;
206 }
207 }
208 } else {
210 // for (int i = 0; i < Dimension::F; ++i) c[i] = 1.0e0 * i;
211 }
212 if (cread_from_ds) {
213 std::string init_nuclinp = _param->get_string("init_nuclinp", LOC());
214 std::string open_file = init_nuclinp;
215 if (!isFileExists(init_nuclinp)) open_file = utils::concat(init_nuclinp, stat.icalc, ".ds");
216
217 std::string stmp, eachline;
218 std::ifstream ifs(open_file);
219 while (getline(ifs, eachline)) {
220 if (eachline.find("init.c") != eachline.npos) {
221 getline(ifs, eachline);
222 for (int i = 0; i < Dimension::N; ++i) ifs >> c[i];
223 }
224 }
225 }
226
227 Kernel_Elec::ker_from_c(rho_ele, c, 1, 0, Dimension::F);
228
229 if (use_gdtwa) {
230 xi1 = 1.0e0;
231 gamma1 = 0.0e0;
232 use_cv = false;
233
234 double randu = 1.0e0;
235 double gamma_ou = phys::math::sqrthalf;
236 double gamma_uu = 0.0e0;
237 for (int j = 0; j < Dimension::F; ++j) {
238 if (j == iocc) {
239 rho_ele[j * Dimension::Fadd1] = 1.0e0;
240 continue;
241 }
243 randu = phys::math::halfpi * (int(randu / 0.25f) + 0.5);
244 rho_ele[iocc * Dimension::F + j] = cos(randu) + phys::math::im * sin(randu);
245 rho_ele[j * Dimension::F + iocc] = std::conj(rho_ele[iocc * Dimension::F + j]);
246 }
247 for (int i = 0, ij = 0; i < Dimension::F; ++i) {
248 for (int j = 0; j < Dimension::F; ++j, ++ij) {
249 if (i == iocc || j == iocc) continue;
250 rho_ele[ij] = rho_ele[iocc * Dimension::F + j] / rho_ele[iocc * Dimension::F + i];
251 }
252 }
253 for (int i = 0, ij = 0; i < Dimension::F; ++i) {
254 for (int j = 0; j < Dimension::F; ++j, ++ij) {
255 if (i == j) {
256 rho_ele[ij] = (i == iocc) ? phys::math::iu : phys::math::iz;
257 } else if (i == iocc || j == iocc) {
258 rho_ele[ij] *= gamma_ou;
259 } else {
260 rho_ele[ij] *= gamma_uu;
261 }
262 }
263 }
264 }
265
266 if (use_sqc) {
267 if (sqc_init == 0 || sqc_init == 1) {
268 Kernel_Elec::ker_from_rho(rho_nuc, rho_ele, 1.0, gamma1, Dimension::F, use_cv,
269 iocc);
270 } else if (sqc_init <= 3) { // by youhao shang / Liu scheme
271 double norm = 0.0;
272 for (int i = 0; i < Dimension::F; ++i) norm += std::abs(rho_ele[i * Dimension::Fadd1]);
273 Kernel_Elec::ker_from_rho(rho_nuc, rho_ele, xi1 / norm, gamma1, Dimension::F, use_cv,
274 iocc);
275 } else if (sqc_init <= 4) {
276 double norm = 0.0;
277 for (int i = 0; i < Dimension::F; ++i) norm += std::abs(rho_ele[i * Dimension::Fadd1]);
278 Kernel_Elec::ker_from_rho(rho_nuc, rho_ele, 1.0, (norm - 1.0) / Dimension::F, Dimension::F, use_cv,
279 iocc);
280 }
281 } else {
283 iocc);
284 }
286
287 // BO occupation in adiabatic representation
290 RepresentationPolicy::Adiabatic, //
291 SpacePolicy::L);
292 *occ_nuc = elec_utils::max_choose(rho_nuc);
293 if (use_fssh) *occ_nuc = elec_utils::pop_choose(rho_nuc);
295 RepresentationPolicy::Adiabatic, //
297 SpacePolicy::L);
298
299 // weight factor in tcf_repr
302 RepresentationPolicy::Adiabatic, //
303 SpacePolicy::L);
304 wz_A[0] = std::abs(rho_ele[0] - rho_ele[3]);
305 int max_pop = elec_utils::max_choose(rho_ele);
306 double max_val = std::abs(rho_ele[max_pop * Dimension::Fadd1]);
307 ww_A[0] = 4.0 - 1.0 / (max_val * max_val);
309 RepresentationPolicy::Adiabatic, //
310 RepresentationPolicy::Diabatic, //
311 SpacePolicy::L);
312 wz_D[0] = std::abs(rho_ele[0] - rho_ele[3]);
313 max_pop = elec_utils::max_choose(rho_ele);
314 max_val = std::abs(rho_ele[max_pop * Dimension::Fadd1]);
315 ww_D[0] = 4.0 - 1.0 / (max_val * max_val);
317 RepresentationPolicy::Diabatic, //
319 SpacePolicy::L);
320 }
321
322 _dataset->def_complex("init.wz_A", Kernel_Elec::wz_A, Dimension::P);
323 _dataset->def_complex("init.wz_D", Kernel_Elec::wz_D, Dimension::P);
326 Kernel_Elec::c_init = _dataset->def_complex("init.c", Kernel_Elec::c, Dimension::PF);
330
332 executeKernel(stat);
333 // for (int iP = 0; iP < Dimension::P; ++iP) { // @debug only for scattering problem
334 // kids_real* vpes = this->vpes + iP;
335 // kids_real* E = this->E + iP;
336 // kids_real* Epot = this->Epot + iP;
337 // kids_real* p = this->p + iP;
338 // kids_real* m = this->m + iP;
339 // double Ekin = 0.0e0;
340 // for (int j = 0; j < Dimension::N; ++j) Ekin += 0.5e0 * p[j] * p[j] / m[j];
341 // double Ekin2 = Ekin + E[Kernel_Elec::occ0] - Epot[0];
342 // double scale = sqrt(std::max({0.0e0, Ekin2 / Ekin}));
343 // for (int j = 0; j < Dimension::N; ++j) p[j] *= scale;
344 // }
345 return stat;
346}
347
349 for (int iP = 0; iP < Dimension::P; ++iP) {
350 int* occ_nuc = Kernel_Elec::occ_nuc + iP;
371 kids_complex* ww_A_init = Kernel_Elec::ww_A_init + iP;
372 kids_complex* ww_D_init = Kernel_Elec::ww_D_init + iP;
373 kids_complex* ww_A = Kernel_Elec::ww_A + iP;
374 kids_complex* ww_D = Kernel_Elec::ww_D + iP;
375
376 kids_real* alpha = this->alpha + iP;
377 kids_real* Epot = this->Epot + iP;
378 kids_real* vpes = this->vpes + iP;
379 kids_real* V = this->V + iP * Dimension::FF;
380 kids_real* E = this->E + iP * Dimension::F;
381 kids_real* dE = this->dE + iP * Dimension::NFF;
382 kids_real* p = this->p + iP * Dimension::N;
383 kids_real* m = this->m + iP * Dimension::N;
384 kids_real* fadd = this->fadd + iP * Dimension::N;
385 kids_complex* H = this->H + iP * Dimension::FF;
386
388
389 // * additional evolution can be appended here
390
391 // 1) transform from inp_repr => ele_repr
392 for (int i = 0; i < Dimension::F; ++i) c[i] = c_init[i]; // @debug
393 for (int ik = 0; ik < Dimension::FF; ++ik) rho_ele[ik] = rho_ele_init[ik];
394 for (int ik = 0; ik < Dimension::FF; ++ik) rho_nuc[ik] = rho_nuc_init[ik];
398 SpacePolicy::H);
402 SpacePolicy::L);
406 SpacePolicy::L);
407
408 // 2) propagte along ele_repr
412
413 // 3) hopping in adiabatic representation
416 RepresentationPolicy::Adiabatic, //
417 SpacePolicy::L);
420 RepresentationPolicy::Adiabatic, //
421 SpacePolicy::L);
422
423 // step 1: determine where to hop (BOSH & CVSH)
425 kids_real Efrom, Eto;
426 Efrom = calc_Ew(E, rho_nuc, *occ_nuc);
428 int to;
429 switch (hopping_type1) {
430 case 0: {
431 to = elec_utils::max_choose(rho_ele);
432 break;
433 }
434 case 1: {
435 to = elec_utils::max_choose(rho_nuc);
436 break;
437 }
438 case 2: {
439 to = elec_utils::pop_choose(rho_ele);
440 break;
441 }
442 case 3: {
443 to = elec_utils::hopping_choose(rho_ele, H, *occ_nuc, scale * dt);
444 break;
445 }
446 case 4: {
447 to = elec_utils::pop_choose(rho_nuc);
448 break;
449 }
450 case 5: {
451 to = elec_utils::pop_neg_choose(rho_nuc);
452 break;
453 }
454 }
455 Eto = calc_Ew(E, rho_nuc, to);
456 // step 2: determine direction to hop
457 switch (hopping_type2) {
458 case 0: {
459 elec_utils::hopping_direction(direction, E, dE, rho_ele, *occ_nuc, to);
460 break;
461 }
462 case 1: {
464 break;
465 }
466 case 2: {
467 for (int j = 0; j < Dimension::N; ++j) direction[j] = p[j];
468 break;
469 }
470 case 3: {
471 for (int j = 0; j < Dimension::N; ++j)
472 direction[j] = dE[j * Dimension::FF + to * Dimension::Fadd1] -
473 dE[j * Dimension::FF + (*occ_nuc) * Dimension::Fadd1];
474 break;
475 }
476 }
477 // step 3: try hop
478 *occ_nuc = hopping_impulse(direction, p, m, Efrom, Eto, *occ_nuc, to, reflect);
479 Epot[0] = vpes[0] + ((*occ_nuc == to) ? Eto : Efrom);
480
481 // if (*occ_nuc == to && Eto != Efrom) std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
482
483 // smooth dynamics (BOSD & CVSD)
484 if (cmsh_type == NADPolicy::BOSD || cmsh_type == NADPolicy::CVSD) {
486
487 // Win is for calculate energy
488 calc_wrho(wrho, rho_ele, xi1, gamma1, alpha[0]);
489 double Ew_old = calc_Ew(E, wrho, *occ_nuc);
490 calc_distforce(ftmp, E, dE, wrho, rho_ele, alpha[0]);
491
492 if (dynamic_alpha) alpha[0] = calc_alpha(V);
493 calc_wrho(wrho, rho_ele, xi1, gamma1, alpha[0]);
494 double Ew_new = calc_Ew(E, wrho, *occ_nuc);
495 calc_distforce(ftmp, E, dE, wrho, rho_ele, alpha[0]);
496 // non-linear force
497 for (int j = 0; j < Dimension::N; ++j) fadd[j] += ftmp[j];
498 Epot[0] = vpes[0] + Ew_new;
499
500 // region force
501 if (Ew_new != Ew_old) {
502 double vdotd = 0.0e0;
503 for (int j = 0; j < Dimension::N; ++j) vdotd += p[j] / m[j] * dE[j * Dimension::FF + 1];
504 double xsolve = (Ew_new - Ew_old) / (scale * dt) / vdotd;
505 for (int j = 0; j < Dimension::N; ++j) fadd[j] += xsolve * dE[j * Dimension::FF + 1];
506 }
507 for (int ik = 0; ik < Dimension::FF; ++ik) rho_nuc[ik] = wrho[ik];
508 }
509
511 RepresentationPolicy::Adiabatic, //
513 SpacePolicy::L);
514 if ((use_sqc && reflect) || (use_sqc && only_adjust)) { // only adjusted
516 RepresentationPolicy::Adiabatic, //
518 SpacePolicy::L);
519 double norm = 0.0e0;
520 for (int i = 0; i < Dimension::F; ++i) norm += std::abs(rho_ele[i * Dimension::Fadd1]);
521 // Kernel_Elec::ker_from_rho(rho_nuc, rho_ele, xi1/norm, gamma1, Dimension::F, use_cv,
522 // iocc); ///< initial rho_nuc /// adjust only support for sqc_init=0!!!
523 for (int i = 0; i < Dimension::FF; ++i) rho_nuc[i] = rho_ele[i] + (rho_nuc_init[i] - rho_ele_init[i]);
526 RepresentationPolicy::Adiabatic, //
527 SpacePolicy::L);
528 }
529
530 if (!at_samplingstep_finally_ptr[0]) continue;
531
532 // 4) calculated TCF in adiabatic rep & diabatic rep respectively
533 // 4-1) Adiabatic rep
534 int max_pop = elec_utils::max_choose(rho_ele);
535 double max_val = std::abs(rho_ele[max_pop * Dimension::Fadd1]);
536 ww_A[0] = 4.0 - 1.0 / (max_val * max_val);
537 ww_A[0] = std::min({abs(ww_A[0]), std::abs(ww_A_init[0])});
538
539 Kernel_Elec::ker_from_rho(K1QA, rho_ele, 1, 0, Dimension::F, true, ((use_fall) ? *occ_nuc : max_pop));
540 Kernel_Elec::ker_from_rho(K2QA, rho_ele, 1, 0, Dimension::F, true, ((use_fall) ? *occ_nuc : max_pop));
541 for (int i = 0; i < Dimension::F; ++i) {
542 K2QA[i * Dimension::Fadd1] = (abs(rho_ele[i * Dimension::Fadd1]) < 1 / xi1) ? 0.0e0 : 1.0e0;
543 }
544 if (use_fssh) { Kernel_Elec::ker_from_rho(K2QA, rho_ele, 1, 0, Dimension::F, true, *occ_nuc); }
545 if (use_sqc) {
546 elec_utils::ker_binning(K2QA, rho_ele, SQCPolicy::TRI);
547 sqcIA[0] = 0;
548 for (int i = 0; i < Dimension::F; ++i) sqcIA[0] += std::real(K2QA[i * Dimension::Fadd1]);
549 }
550
551 ARRAY_MAT_DIAG(K1DA, K1QA, Dimension::F);
552 ARRAY_MAT_DIAG(K2DA, K2QA, Dimension::F);
553
555 RepresentationPolicy::Adiabatic, //
557 SpacePolicy::L);
559 RepresentationPolicy::Adiabatic, //
561 SpacePolicy::L);
563 RepresentationPolicy::Adiabatic, //
565 SpacePolicy::L);
567 RepresentationPolicy::Adiabatic, //
569 SpacePolicy::L);
570 // 4-2) Diabatic rep
572 RepresentationPolicy::Adiabatic, //
573 RepresentationPolicy::Diabatic, //
574 SpacePolicy::L);
575
576 Kernel_Elec::ker_from_rho(K0, rho_ele, 1, 0, Dimension::F);
579
580 max_pop = elec_utils::max_choose(rho_ele); // (in dia rep)
581 max_val = std::abs(rho_ele[max_pop * Dimension::Fadd1]);
582
583 ww_D[0] = 4.0 - 1.0 / (max_val * max_val);
584 if (check_cxs) {
585 double y = max_val - 0.5e0;
586 ww_D[0] = (23.0e0 / 2 * y - 72.0e0 * y * y + 140.0e0 * y * y * y + 480.0e0 * y * y * y * y -
587 840.0e0 * y * y * y * y * y) +
588 (9.0e0 / 4.0 - 9.0e0 * y * y - 420.0e0 * y * y * y * y + 1680.0e0 * y * y * y * y * y * y) *
589 atan(2.0e0 * y);
590 }
591 ww_D[0] = std::min({abs(ww_D[0]), std::abs(ww_D_init[0])});
592 { // general squeezed sqc
593 Kernel_Representation::transform(rho_ele_init, T_init, Dimension::F, //
595 RepresentationPolicy::Diabatic, //
596 SpacePolicy::L);
597 double vmax0 = 0.0e0, vsec0 = 0.0e0;
598 double vmaxt = 0.0e0, vsect = 0.0e0;
599 for (int i = 0, ii = 0; i < Dimension::F; ++i, ii += Dimension::Fadd1) {
600 if (abs(rho_ele_init[ii]) > vmax0) {
601 vsec0 = vmax0;
602 vmax0 = std::abs(rho_ele_init[ii]);
603 } else if (abs(rho_ele_init[ii]) > vsec0) {
604 vsec0 = std::abs(rho_ele_init[ii]);
605 }
606 if (abs(rho_ele[ii]) > vmax0) {
607 vsect = vmaxt;
608 vmaxt = std::abs(rho_ele[ii]);
609 } else if (abs(rho_ele[ii]) > vsect) {
610 vsect = std::abs(rho_ele[ii]);
611 }
612 }
613
614 double lambda1 = std::min({1 / vsect, 2 / (vmax0 + vsec0)});
615 double lambda2 = std::max({1 / vmaxt, 1 / vmax0});
616 if (lambda1 > lambda2) {
617 ww_D[0] = phi(lambda1, vmax0, Dimension::F) - phi(lambda2, vmax0, Dimension::F);
618 } else {
619 ww_D[0] = 0.0e0;
620 }
621 Kernel_Representation::transform(rho_ele_init, T_init, Dimension::F, //
622 RepresentationPolicy::Diabatic, //
624 SpacePolicy::L);
625 }
626
627 Kernel_Elec::ker_from_rho(K1QD, rho_ele, 1, 0, Dimension::F, true, max_pop);
628 Kernel_Elec::ker_from_rho(K2QD, rho_ele, 1, 0, Dimension::F);
629 for (int i = 0; i < Dimension::F; ++i) {
630 K2QD[i * Dimension::Fadd1] = (abs(rho_ele[i * Dimension::Fadd1]) < 1 / xi1) ? 0.0e0 : 1.0e0;
631 }
632 if (use_strange_win) calc_wrho(K2QD, rho_ele, 1, 0, 0.2);
633 if (use_sqc) {
634 elec_utils::ker_binning(K2QD, rho_ele, SQCPolicy::TRI);
635 if (count_exec <= 0) { // only count at the beginning
636 for (int k = 0; k < Dimension::F; ++k) {
637 double radius =
638 std::abs(2.0e0 - rho_ele[Kernel_Elec::occ0 * Dimension::Fadd1] - rho_ele[k * Dimension::Fadd1]);
639 // radius = sqrt(radius * radius + 0.0025e0); // @bad soft radius
640 sqcw[k] = pow(radius, 3 - Dimension::F);
641 }
642 }
643
644 sqcID[0] = 0;
645 for (int i = 0; i < Dimension::F; ++i) sqcID[0] += std::real(K2QD[i * Dimension::Fadd1]);
646
647 if (sqc_init == 2) { // overload for K2QD
648 int imax = elec_utils::max_choose(rho_ele);
649 double vmax = std::abs(rho_ele[imax * Dimension::Fadd1]);
650 for (int ik = 0; ik < Dimension::FF; ++ik) K2QD[ik] = 0.0e0;
651 if (vmax * vmax * 8.0e0 / 7.0e0 * (Dimension::F + 0.5e0) > 1) K2QD[imax * Dimension::Fadd1] = 1.0e0;
652 }
653 }
654
655 ARRAY_MAT_DIAG(K1DD, K1QD, Dimension::F);
656 ARRAY_MAT_DIAG(K2DD, K2QD, Dimension::F);
657
658 // 5) transform back from tcf_repr => inp_repr
660 RepresentationPolicy::Diabatic, //
662 SpacePolicy::L);
664 RepresentationPolicy::Diabatic, //
666 SpacePolicy::L);
668 RepresentationPolicy::Diabatic, //
670 SpacePolicy::L);
672 RepresentationPolicy::Diabatic, //
674 SpacePolicy::L);
676 RepresentationPolicy::Diabatic, //
678 SpacePolicy::L);
680 RepresentationPolicy::Diabatic, //
682 SpacePolicy::L);
684 RepresentationPolicy::Diabatic, //
686 SpacePolicy::L);
688 RepresentationPolicy::Diabatic, //
690 SpacePolicy::L);
691 }
692 return stat;
693}
694}; // namespace PROJECT_NS
bool isFileExists(const std::string &name)
double phi(double lambda, double N0_max, int F)
bool isFileExists(const std::string &name)
double phi(double lambda, double N0_max, int F)
this file provides Kernel_NADForce class enabling force weighting from electronic properties.
#define ARRAY_MATMUL3_TRANS2(_A, _B, _C, _D, _n1, _n2, _n0, _n3)
#define ARRAY_MATMUL(_A, _B, _C, _n1, _n2, _n3)
#define ARRAY_EYE(_A, _n)
Definition array_macro.h:75
#define ARRAY_CLEAR(_A, _n)
Definition array_macro.h:36
virtual const std::string getName()
Get the name of the kernel.
virtual void setInputDataSet_impl(std::shared_ptr< DataSet > &DS)
Virtual function to set input data set for the kernel implementation.
virtual Status & initializeKernel_impl(Status &stat)
Virtual function to initialize the kernel implementation.
virtual int getType() const
Get the type of the kernel.
virtual void setInputParam_impl(std::shared_ptr< Param > &PM)
Virtual function to set input parameters for the kernel implementation.
virtual Status & executeKernel_impl(Status &stat)
Virtual function to execute the kernel implementation.
static kids_complex * U
dynamics variables for electronic DOFs
Definition Kernel_Elec.h:39
static int ker_from_rho(kids_complex *ker, kids_complex *rho, kids_real xi, kids_real gamma, int fdim, bool quantize=false, int occ=-1)
convert c (electonic amplititude) to kernel (affine map of the density)
static kids_complex * ww_A_init
Definition Kernel_Elec.h:59
static int * occ_nuc
weighting density for nuclear force
Definition Kernel_Elec.h:48
static kids_complex * K1QA
Simplex Quantization.
Definition Kernel_Elec.h:65
static kids_complex * ww_D_init
Definition Kernel_Elec.h:60
static kids_real * T_init
Definition Kernel_Elec.h:43
static kids_real * T
Definition Kernel_Elec.h:43
static kids_complex * rho_ele
Definition Kernel_Elec.h:41
static kids_complex * rho_nuc_init
Definition Kernel_Elec.h:49
static kids_complex * K1QD
Simplex Quantization.
Definition Kernel_Elec.h:69
static kids_complex * rho_nuc
Definition Kernel_Elec.h:49
static kids_complex * c
Definition Kernel_Elec.h:40
static kids_complex * K2QA
Heaviside Quantization.
Definition Kernel_Elec.h:66
static kids_complex * K2QD
Heaviside Quantization.
Definition Kernel_Elec.h:70
static int ker_from_c(kids_complex *ker, kids_complex *c, kids_real xi, kids_real gamma, int fdim)
convert c (electonic amplititude) to kernel (affine map of the density)
static kids_complex * ww_D
Definition Kernel_Elec.h:58
static kids_complex * c_init
electronic vector
Definition Kernel_Elec.h:40
static kids_complex * K2
partial version of K2
Definition Kernel_Elec.h:64
static kids_complex * ww_A
Definition Kernel_Elec.h:57
static int occ0
read parameters
Definition Kernel_Elec.h:31
static kids_complex * K1DD
Definition Kernel_Elec.h:71
static kids_complex * K2DD
Definition Kernel_Elec.h:72
static kids_complex * K1DA
Definition Kernel_Elec.h:67
static kids_complex * wz_A
Definition Kernel_Elec.h:55
static kids_complex * rho_ele_init
electronic density
Definition Kernel_Elec.h:41
static kids_complex * K1
partial version of K1
Definition Kernel_Elec.h:63
static kids_complex * K0
partial version of K0
Definition Kernel_Elec.h:62
static kids_complex * K2DA
Definition Kernel_Elec.h:68
static kids_complex * w
kernels for time correlation function
Definition Kernel_Elec.h:54
static kids_complex * wz_D
Definition Kernel_Elec.h:56
static NADForcePolicy::_type NADForce_type
static int rand_uniform(kids_real *res_arr, int N=1, kids_real sigma=1.0)
static int rand_catalog(int *res_arr, int N=1, bool reset=false, int begin=0, int end=1)
static RepresentationPolicy::_type ele_repr_type
representation for electronic dynamics
static int transform(kids_complex *A, kids_real *T, int fdim, RepresentationPolicy::_type from, RepresentationPolicy::_type to, SpacePolicy::_type Stype)
static RepresentationPolicy::_type inp_repr_type
representatioin for input (quantities)
std::shared_ptr< Param > _param
Shared pointer to the Param object associated with this kernel.
Definition Kernel.h:273
Status & executeKernel(Status &stat)
Execute the kernel's algorithm and those of its children.
Definition Kernel.cpp:48
std::shared_ptr< DataSet > _dataset
Shared pointer to the DataSet object associated with this kernel.
Definition Kernel.h:278
static int hopping_choose(kids_complex *rho, kids_complex *H, int from, kids_real dt)
static double gamma_wigner(int fdim)
static int pop_neg_choose(kids_complex *rho)
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)
#define LOC()
show the location information for debug
Definition fmt.h:49
int count_exec
Counter for the number of executions performed by this kernel.
Definition Kernel.h:258
Provide linalg APIs.
#define FUNCTION_NAME
Definition macro_utils.h:9
VARIABLE< kids_real > direction
VARIABLE< kids_complex > wrho
VARIABLE< kids_real > ftmp
VARIABLE< kids_real > sqcIA
VARIABLE< kids_real > p
VARIABLE< kids_real > Epot
VARIABLE< kids_real > alpha
VARIABLE< kids_real > fadd
VARIABLE< kids_real > m
VARIABLE< kids_real > sqcID
VARIABLE< kids_real > sqcw
VARIABLE< kids_bint > at_samplingstep_finally
VARIABLE< kids_real > dE
VARIABLE< kids_real > E
VARIABLE< kids_real > T
VARIABLE< kids_complex > H
VARIABLE< kids_real > vpes
VARIABLE< kids_real > V
std::size_t NFF
Product of N, F, and F (N * F * F).
Definition vars_list.cpp:22
std::size_t N
Number of nuclear degrees of freedom.
Definition vars_list.cpp:10
std::size_t PF
Product of P and F (P * F).
Definition vars_list.cpp:16
std::size_t PFF
Product of P, F, and F (P * F * F).
Definition vars_list.cpp:17
std::size_t P
Number of parallel trajectories (swarms of trajectories) in each Monte Carlo run.
Definition vars_list.cpp:9
std::size_t F
Number of electronic degrees of freedom.
Definition vars_list.cpp:11
std::size_t Fadd1
F plus 1 (F + 1).
Definition vars_list.cpp:24
std::size_t FF
Product of F and F (F * F).
Definition vars_list.cpp:21
< http://warp.povusers.org/FunctionParser/fparser.html
Definition Context.h:39
double calc_alpha(kids_real *V, int i=0, int k=1, int F=2)
void ARRAY_MAT_DIAG(kids_real *A, kids_real *B, size_t N1)
Copy the diagonal elements from matrix B to matrix A for real matrices.
Definition linalg.cpp:458
int calc_distforce(kids_real *f1, kids_real *E, kids_real *dE, kids_complex *wrho, kids_complex *rho, double alpha)
the force driven from the shape of distorted-density W(\rho)
double calc_Ew(kids_real *E, kids_complex *wrho, int occ)
double kids_real
Alias for real number type.
Definition Types.h:59
std::complex< double > kids_complex
Alias for complex number type.
Definition Types.h:60
int hopping_impulse(kids_real *direction, kids_real *np, kids_real *nm, kids_real Efrom, kids_real Eto, int from, int to, bool reflect)
int calc_wrho(kids_complex *wrho, kids_complex *rho, double xi, double gamma, double alpha)
constexpr real_precision halfpi
Definition phys.h:32
constexpr std::complex< real_precision > iu(1.0L, 0.0L)
constexpr real_precision sqrthalf
Definition phys.h:38
constexpr std::complex< real_precision > im(0.0L, 1.0L)
Imaginary Unit.
constexpr real_precision twopi
Definition phys.h:31
constexpr std::complex< real_precision > iz(0.0L, 0.0L)
constexpr dimension7 time_d
[T]
Definition phys.h:187
std::basic_string< CharT > concat(const separator_t< CharT > &sep, Args &&... seq)
Definition concat.h:242
constexpr uint32_t hash(const char *str)
Definition hash_fnv1a.h:12
declaration of variables used in the program.