HΦ  3.1.0
mltplyHubbardCore.c
Go to the documentation of this file.
1 /* HPhi - Quantum Lattice Model Simulator */
2 /* Copyright (C) 2015 The University of Tokyo */
3 /* This program is free software: you can redistribute it and/or modify */
4 /* it under the terms of the GNU General Public License as published by */
5 /* the Free Software Foundation, either version 3 of the License, or */
6 /* (at your option) any later version. */
7 
8 /* This program is distributed in the hope that it will be useful, */
9 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
10 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
11 /* GNU General Public License for more details. */
12 
13 /* You should have received a copy of the GNU General Public License */
14 /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 #include <bitcalc.h>
19 #include "mfmemory.h"
20 #include "xsetmem.h"
21 #include "wrapperMPI.h"
22 #include "mltplyCommon.h"
23 #include "mltplyHubbardCore.h"
24 
25 /******************************************************************************/
26 //[s] GetInfo functions
27 /******************************************************************************/
28 
36  struct BindStruct *X,
37  unsigned long int isite1,
38  unsigned long int isite2,
39  unsigned long int sigma1,
40  unsigned long int sigma2
41 ) {
46  X->Large.is1_spin = X->Def.Tpow[2 * isite1 - 2 + sigma1];
47  X->Large.is2_spin = X->Def.Tpow[2 * isite2 - 2 + sigma2];
51  if (isite1 > isite2) {
52  X->Large.A_spin = (X->Def.Tpow[2 * isite1 - 2 + sigma1] - X->Def.Tpow[2 * isite2 - 1 + sigma2]);
53  }
54  else if (isite1 < isite2) {
55  X->Large.A_spin = (X->Def.Tpow[2 * isite2 - 2 + sigma2] - X->Def.Tpow[2 * isite1 - 1 + sigma1]);
56  }
57  else {
58  if (sigma1 > sigma2) {
59  X->Large.A_spin = (X->Def.Tpow[2 * isite1 - 2 + sigma1] - X->Def.Tpow[2 * isite2 - 1 + sigma2]);
60  }
61  else {
62  X->Large.A_spin = (X->Def.Tpow[2 * isite2 - 2 + sigma2] - X->Def.Tpow[2 * isite1 - 1 + sigma1]);
63  }
64  }
68  X->Large.isA_spin = X->Large.is1_spin + X->Large.is2_spin;
69  return 0;
70 }/*int child_general_hopp_GetInfo*/
78  int iInterAll,
79  struct BindStruct *X,
80  long unsigned int isite1,
81  long unsigned int isite2,
82  long unsigned int isite3,
83  long unsigned int isite4,
84  long unsigned int sigma1,
85  long unsigned int sigma2,
86  long unsigned int sigma3,
87  long unsigned int sigma4,
88  double complex tmp_V
89 ) {
90  long unsigned int is1_spin, is2_spin, is3_spin, is4_spin;
91  long unsigned int A_spin, B_spin;
92  long unsigned int isA_spin, isB_spin;
97  is1_spin = X->Def.Tpow[2 * isite1 - 2 + sigma1];
98  is2_spin = X->Def.Tpow[2 * isite2 - 2 + sigma2];
102  if (isite1 > isite2) {
103  A_spin = (X->Def.Tpow[2 * isite1 - 2 + sigma1] - X->Def.Tpow[2 * isite2 - 1 + sigma2]);
104  }
105  else if (isite2 > isite1) {
106  A_spin = (X->Def.Tpow[2 * isite2 - 2 + sigma2] - X->Def.Tpow[2 * isite1 - 1 + sigma1]);
107  }
108  else {//isite1=isite2
109  if (sigma1 > sigma2) {
110  A_spin = (X->Def.Tpow[2 * isite1 - 2 + sigma1] - X->Def.Tpow[2 * isite2 - 1 + sigma2]);
111  }
112  else {
113  A_spin = (X->Def.Tpow[2 * isite2 - 2 + sigma2] - X->Def.Tpow[2 * isite1 - 1 + sigma1]);
114  }
115  }
120  is3_spin = X->Def.Tpow[2 * isite3 - 2 + sigma3];
121  is4_spin = X->Def.Tpow[2 * isite4 - 2 + sigma4];
125  if (isite3 > isite4) {
126  B_spin = (X->Def.Tpow[2 * isite3 - 2 + sigma3] - X->Def.Tpow[2 * isite4 - 1 + sigma4]);
127  }
128  else if (isite3 < isite4) {
129  B_spin = (X->Def.Tpow[2 * isite4 - 2 + sigma4] - X->Def.Tpow[2 * isite3 - 1 + sigma3]);
130  }
131  else {//isite3=isite4
132  if (sigma3 > sigma4) {
133  B_spin = (X->Def.Tpow[2 * isite3 - 2 + sigma3] - X->Def.Tpow[2 * isite4 - 1 + sigma4]);
134  }
135  else {
136  B_spin = (X->Def.Tpow[2 * isite4 - 2 + sigma4] - X->Def.Tpow[2 * isite3 - 1 + sigma3]);
137  }
138  }
142  isA_spin = is1_spin + is2_spin;
143  isB_spin = is3_spin + is4_spin;
144 
145  X->Large.is1_spin = is1_spin;
146  X->Large.is2_spin = is2_spin;
147  X->Large.is3_spin = is3_spin;
148  X->Large.is4_spin = is4_spin;
149  X->Large.isA_spin = isA_spin;
150  X->Large.isB_spin = isB_spin;
151  X->Large.A_spin = A_spin;
152  X->Large.B_spin = B_spin;
156  X->Large.tmp_V = tmp_V;
157  X->Large.isite1 = isite1;
158  X->Large.isite2 = isite2;
159  X->Large.isite3 = isite3;
160  X->Large.isite4 = isite4;
161 
162  return 0;
163 }/*int child_general_int_GetInfo*/
171  int iPairHopp,
172  struct BindStruct *X
173 ) {
174  int isite1 = X->Def.PairHopping[iPairHopp][0] + 1;
175  int isite2 = X->Def.PairHopping[iPairHopp][1] + 1;
179  X->Large.tmp_J = X->Def.ParaPairHopping[iPairHopp];
185  X->Large.is1_up = X->Def.Tpow[2 * isite1 - 2];
186  X->Large.is1_down = X->Def.Tpow[2 * isite1 - 1];
187  X->Large.is2_up = X->Def.Tpow[2 * isite2 - 2];
188  X->Large.is2_down = X->Def.Tpow[2 * isite2 - 1];
189 
190  return 0;
191 }/*int child_pairhopp_GetInfo*/
199  int iExchange,
200  struct BindStruct *X
201 ) {
202  int isite1 = X->Def.ExchangeCoupling[iExchange][0] + 1;
203  int isite2 = X->Def.ExchangeCoupling[iExchange][1] + 1;
207  X->Large.tmp_J = -X->Def.ParaExchangeCoupling[iExchange];
213  X->Large.is1_up = X->Def.Tpow[2 * isite1 - 2];
214  X->Large.is1_down = X->Def.Tpow[2 * isite1 - 1];
215  X->Large.is2_up = X->Def.Tpow[2 * isite2 - 2];
216  X->Large.is2_down = X->Def.Tpow[2 * isite2 - 1];
217 
218  return 0;
219 }/*int child_exchange_GetInfo*/
220 
221 /******************************************************************************/
222 //[e] GetInfo functions
223 /******************************************************************************/
224 
225 /******************************************************************************/
226 //[s] core routines
227 /******************************************************************************/
234 double complex GC_CisAis(
235  long unsigned int j,
236  double complex *tmp_v0,
237  double complex *tmp_v1,
238  struct BindStruct *X,
239  long unsigned int is1_spin,
240  double complex tmp_trans
241 ) {
242  long unsigned int A_ibit_tmp;
243  long unsigned int list_1_j;
244  double complex dmv;
245  double complex dam_pr;
246 
247  list_1_j = j - 1;
248  A_ibit_tmp = (list_1_j & is1_spin) / is1_spin;
249  dmv = tmp_v1[j] * A_ibit_tmp;
250  if (X->Large.mode == M_MLTPLY || X->Large.mode == M_CALCSPEC) {
251  tmp_v0[j] += dmv * tmp_trans;
252  }/*if (X->Large.mode == M_MLTPLY || X->Large.mode == M_CALCSPEC)*/
253  dam_pr = dmv * conj(tmp_v1[j]);
254  return dam_pr;
255 }/*double complex GC_CisAis*/
261 double complex GC_AisCis(
262  long unsigned int j,
263  double complex *tmp_v0,
264  double complex *tmp_v1,
265  struct BindStruct *X,
266  long unsigned int is1_spin,
267  double complex tmp_trans
268 ) {
269  long unsigned int A_ibit_tmp;
270  long unsigned int list_1_j;
271  double complex dmv;
272  double complex dam_pr;
273 
274  list_1_j = j - 1;
275  A_ibit_tmp = (list_1_j & is1_spin) / is1_spin;
276  dmv = tmp_v1[j] * (1 - A_ibit_tmp);
277  if (X->Large.mode == M_MLTPLY || X->Large.mode == M_CALCSPEC) {
278  tmp_v0[j] += dmv * tmp_trans;
279  }/*if (X->Large.mode == M_MLTPLY || X->Large.mode == M_CALCSPEC)*/
280  dam_pr = dmv * conj(tmp_v1[j]);
281  return dam_pr;
282 }/*double complex GC_AisCis*/
290  long unsigned int list_1_j,
291  struct BindStruct *X,
292  long unsigned int is1_spin
293 ) {
294  int A_ibit_tmp;
295 
296  // off = j
297  A_ibit_tmp = (list_1_j & is1_spin) / is1_spin;
298  return A_ibit_tmp;
299 }
306 double complex CisAjt(
307  long unsigned int j,
308  double complex *tmp_v0,
309  double complex *tmp_v1,
310  struct BindStruct *X,
311  long unsigned int is1_spin,
312  long unsigned int is2_spin,
313  long unsigned int sum_spin,
314  long unsigned int diff_spin,
315  double complex tmp_V
316 ) {
317  long unsigned int ibit_tmp_1, ibit_tmp_2;
318  long unsigned int bit, iexchg, off;
319  int sgn;
320  double complex dmv, dam_pr;
321 
322  ibit_tmp_1 = (list_1[j] & is1_spin);
323  ibit_tmp_2 = (list_1[j] & is2_spin);
324  if (ibit_tmp_1 == 0 && ibit_tmp_2 != 0) {
325  bit = list_1[j] & diff_spin;
326  SgnBit(bit, &sgn); // Fermion sign
327  iexchg = list_1[j] ^ sum_spin;
328 
329  if(GetOffComp(list_2_1, list_2_2, iexchg, X->Large.irght, X->Large.ilft, X->Large.ihfbit, &off)==FALSE){
330  return 0;
331  }
332 /*
333  if(X->Large.mode==M_CORR){
334  fprintf(stdout, "DEBUG-1: myrank=%d, org=%d, bit=%d, iexchg=%d, list_1[%d]=%d\n",
335  myrank, list_1[j], bit, iexchg, off, list_1[off]);
336  }
337 */
338  dmv = sgn * tmp_v1[j];
339  if (X->Large.mode == M_MLTPLY || X->Large.mode == M_CALCSPEC) { // for multply
340  tmp_v0[off] += tmp_V * dmv;
341  }
342  dam_pr = dmv * conj(tmp_v1[off]);
343  return dam_pr;
344  }
345  else {
346  return 0;
347  }
348 }
355 double complex GC_CisAjt(
356  long unsigned int j,
357  double complex *tmp_v0,
358  double complex *tmp_v1,
359  struct BindStruct *X,
360  long unsigned int is1_spin,
361  long unsigned int is2_spin,
362  long unsigned int sum_spin,
363  long unsigned int diff_spin,
364  double complex tmp_V,
365  long unsigned int *tmp_off
366 ) {
367  long unsigned int list_1_j, list_1_off;
368  long unsigned int ibit_tmp_1, ibit_tmp_2;
369  long unsigned int bit;
370  int sgn;
371  double complex dmv, dam_pr;
372 
373  list_1_j = j - 1;
374  ibit_tmp_1 = (list_1_j & is1_spin);
375  ibit_tmp_2 = (list_1_j & is2_spin);
376  *tmp_off = 0;
377 
378  if (ibit_tmp_1 == 0 && ibit_tmp_2 != 0) {
379  bit = list_1_j & diff_spin;
380  SgnBit(bit, &sgn); // Fermion sign
381  list_1_off = list_1_j ^ sum_spin;
382  *tmp_off = list_1_off;
383  dmv = sgn * tmp_v1[j];
384  if (X->Large.mode == M_MLTPLY || X->Large.mode == M_CALCSPEC) { // for multply
385  tmp_v0[list_1_off + 1] += dmv * tmp_V;
386  }
387  dam_pr = dmv * conj(tmp_v1[list_1_off + 1]);
388  return dam_pr;
389  }
390  else {
391  return 0;
392  }
393 }/*double complex GC_CisAjt*/
401  long unsigned int list_1_j,
402  struct BindStruct *X,
403  long unsigned int is1_spin,
404  long unsigned int is2_spin,
405  long unsigned int sum_spin,
406  long unsigned int diff_spin,
407  long unsigned int *tmp_off
408 ) {
409  long unsigned int off;
410  int sgn = 1;
411 
412  sgn = X_GC_CisAjt(list_1_j, X, is1_spin, is2_spin, sum_spin, diff_spin, tmp_off);
413  if (sgn != 0) {
414  if(GetOffComp(list_2_1, list_2_2, *tmp_off, X->Large.irght, X->Large.ilft, X->Large.ihfbit, &off)!=TRUE){
415  *tmp_off = 0;
416  return 0;
417  }
418  *tmp_off = off;
419  return sgn;
420  }
421  else {
422  *tmp_off = 0;
423  return 0;
424  }
425 }/*int X_CisAjt*/
433  long unsigned int list_1_j,
434  struct BindStruct *X,
435  long unsigned int is1_spin,
436  long unsigned int is2_spin,
437  long unsigned int sum_spin,
438  long unsigned int diff_spin,
439  long unsigned int *tmp_off
440 ) {
441  long unsigned int ibit_tmp_1, ibit_tmp_2;
442  long unsigned int bit, off;
443  int sgn = 1;
444 
445  ibit_tmp_1 = (list_1_j & is1_spin);
446  ibit_tmp_2 = (list_1_j & is2_spin);
447 
448  if (ibit_tmp_1 == 0 && ibit_tmp_2 != 0) {
449  bit = list_1_j & diff_spin;
450  SgnBit(bit, &sgn); // Fermion sign
451  off = list_1_j ^ sum_spin;
452  *tmp_off = off;
453  return sgn; // pm 1
454  }
455  else {
456  *tmp_off = 0;
457  return 0;
458  }
459 }
460 /******************************************************************************/
461 //[e] core routines
462 /******************************************************************************/
463 
464 /******************************************************************************/
465 //[s] child element functions
466 /******************************************************************************/
473 double complex child_exchange_element(
474  long unsigned int j,
475  double complex *tmp_v0,
476  double complex *tmp_v1,
477  struct BindStruct *X,
478  long unsigned int *tmp_off
479 ) {
480  long unsigned int off;
481  long unsigned int ibit1_up, ibit2_up, ibit1_down, ibit2_down;
482  double complex dmv;
483  long unsigned int iexchg;
484  long unsigned int is1_up = X->Large.is1_up;
485  long unsigned int is2_up = X->Large.is2_up;
486  long unsigned int is1_down = X->Large.is1_down;
487  long unsigned int is2_down = X->Large.is2_down;
488  long unsigned int irght = X->Large.irght;
489  long unsigned int ilft = X->Large.ilft;
490  long unsigned int ihfbit = X->Large.ihfbit;
491  double complex tmp_J = X->Large.tmp_J;
492  int mode = X->Large.mode;
493  double complex dam_pr = 0;
494 
495  ibit1_up = list_1[j] & is1_up;
496  ibit2_up = list_1[j] & is2_up;
497  ibit1_down = list_1[j] & is1_down;
498  ibit2_down = list_1[j] & is2_down;
499 
500  if (ibit1_up == 0 && ibit1_down != 0 && ibit2_up != 0 && ibit2_down == 0) {
501  iexchg = list_1[j] - (is1_down + is2_up);
502  iexchg += (is1_up + is2_down);
503  if(GetOffComp(list_2_1, list_2_2, iexchg, irght, ilft, ihfbit, &off)!=TRUE){
504  return 0;
505  }
506  *tmp_off = off;
507  dmv = tmp_J * tmp_v1[j];
508  if (mode == M_MLTPLY) {
509  tmp_v0[off] += dmv;
510  }
511  dam_pr += dmv * conj(tmp_v1[off]);
512  }
513  else if (ibit1_up != 0 && ibit1_down == 0 && ibit2_up == 0 && ibit2_down != 0) {
514  iexchg = list_1[j] - (is1_up + is2_down);
515  iexchg += (is1_down + is2_up);
516  if(GetOffComp(list_2_1, list_2_2, iexchg, irght, ilft, ihfbit, &off)!=TRUE){
517  return 0;
518  }
519  *tmp_off = off;
520  dmv = tmp_J * tmp_v1[j];
521  if (mode == M_MLTPLY) {
522  tmp_v0[off] += dmv;
523  }
524  dam_pr += dmv * conj(tmp_v1[off]);
525  }
526  return dam_pr;
527 }/*double complex child_exchange_element*/
534 double complex child_pairhopp_element(
535  long unsigned int j,
536  double complex *tmp_v0,
537  double complex *tmp_v1,
538  struct BindStruct *X,
539  long unsigned int *tmp_off
540 ) {
541  long unsigned int off;
542  long unsigned int ibit1_up, ibit2_up, ibit1_down, ibit2_down;
543  double complex dmv;
544  long unsigned int iexchg;
545  long unsigned int is1_up = X->Large.is1_up;
546  long unsigned int is2_up = X->Large.is2_up;
547  long unsigned int is1_down = X->Large.is1_down;
548  long unsigned int is2_down = X->Large.is2_down;
549  long unsigned int irght = X->Large.irght;
550  long unsigned int ilft = X->Large.ilft;
551  long unsigned int ihfbit = X->Large.ihfbit;
552  double complex tmp_J = X->Large.tmp_J;
553  int mode = X->Large.mode;
554  double complex dam_pr = 0;
555 
556  ibit1_up = list_1[j] & is1_up;
557  ibit2_up = list_1[j] & is2_up;
558  ibit1_down = list_1[j] & is1_down;
559  ibit2_down = list_1[j] & is2_down;
560 
561  if (ibit1_up == 0 && ibit1_down == 0 && ibit2_up != 0 && ibit2_down != 0) {
562  iexchg = list_1[j] - (is2_up + is2_down);
563  iexchg += (is1_up + is1_down);
564 
565  if(GetOffComp(list_2_1, list_2_2, iexchg, irght, ilft, ihfbit, &off)!=TRUE){
566  return 0;
567  }
568  *tmp_off = off;
569  dmv = tmp_J * tmp_v1[j];
570  if (mode == M_MLTPLY || X->Large.mode == M_CALCSPEC) {
571  tmp_v0[off] += dmv;
572  }
573  dam_pr += dmv * conj(tmp_v1[off]);
574  }
575  return dam_pr;
576 }/*double complex child_pairhopp_element*/
584  long unsigned int j,
585  double complex *tmp_v0,
586  double complex *tmp_v1,
587  struct BindStruct *X,
588  long unsigned int *tmp_off
589 ) {
590  long unsigned int ibit1_up, ibit2_up, ibit1_down, ibit2_down;
591  double complex dmv;
592  long unsigned int iexchg;
593  long unsigned int is1_up = X->Large.is1_up;
594  long unsigned int is2_up = X->Large.is2_up;
595  long unsigned int is1_down = X->Large.is1_down;
596  long unsigned int is2_down = X->Large.is2_down;
597  long unsigned int list_1_j, list_1_off;
598  double complex tmp_J = X->Large.tmp_J;
599  int mode = X->Large.mode;
600  double complex dam_pr = 0;
601 
602  list_1_j = j - 1;
603  ibit1_up = list_1_j & is1_up;
604  ibit2_up = list_1_j & is2_up;
605  ibit1_down = list_1_j & is1_down;
606  ibit2_down = list_1_j & is2_down;
607 
608  if (ibit1_up == 0 && ibit1_down != 0 && ibit2_up != 0 && ibit2_down == 0) {
609 
610  iexchg = list_1_j - (is1_down + is2_up);
611  iexchg += (is1_up + is2_down);
612  list_1_off = iexchg;
613  *tmp_off = list_1_off;
614 
615  dmv = tmp_J * tmp_v1[j];
616  if (mode == M_MLTPLY) {
617  tmp_v0[list_1_off + 1] += dmv;
618  }
619  dam_pr += dmv * conj(tmp_v1[list_1_off + 1]);
620  }
621  else if (ibit1_up != 0 && ibit1_down == 0 && ibit2_up == 0 && ibit2_down != 0) {
622  iexchg = list_1_j - (is1_up + is2_down);
623  iexchg += (is1_down + is2_up);
624  list_1_off = iexchg;
625  *tmp_off = list_1_off;
626 
627  dmv = tmp_J * tmp_v1[j];
628  if (mode == M_MLTPLY) {
629  tmp_v0[list_1_off + 1] += dmv;
630  }
631  dam_pr += dmv * conj(tmp_v1[list_1_off + 1]);
632  }
633  return dam_pr;
634 }/*double complex GC_child_exchange_element*/
642  long unsigned int j,
643  double complex *tmp_v0,
644  double complex *tmp_v1,
645  struct BindStruct *X,
646  long unsigned int *tmp_off
647 ) {
648  long unsigned int ibit1_up, ibit2_up, ibit1_down, ibit2_down;
649  double complex dmv;
650  long unsigned int iexchg;
651  long unsigned int is1_up = X->Large.is1_up;
652  long unsigned int is2_up = X->Large.is2_up;
653  long unsigned int is1_down = X->Large.is1_down;
654  long unsigned int is2_down = X->Large.is2_down;
655  long unsigned int list_1_j, list_1_off;
656  double complex tmp_J = X->Large.tmp_J;
657  int mode = X->Large.mode;
658 
659  double complex dam_pr = 0 + 0 * I;
660  list_1_j = j - 1;
661 
662  ibit1_up = list_1_j & is1_up;
663 
664  ibit2_up = list_1_j & is2_up;
665 
666  ibit1_down = list_1_j & is1_down;
667 
668  ibit2_down = list_1_j & is2_down;
669 
670  if (ibit1_up == 0 && ibit1_down == 0 && ibit2_up != 0 && ibit2_down != 0) {
671  iexchg = list_1_j - (is2_up + is2_down);
672  iexchg += (is1_up + is1_down);
673  list_1_off = iexchg;
674  *tmp_off = list_1_off;
675  dmv = tmp_J * tmp_v1[j];
676  if (mode == M_MLTPLY || X->Large.mode == M_CALCSPEC) {
677  tmp_v0[list_1_off + 1] += dmv;
678  }
679  dam_pr += dmv * conj(tmp_v1[list_1_off + 1]);
680  }
681  return dam_pr;
682 }
691  long unsigned int j,
692  long unsigned int isite1,
693  long unsigned int isite3,
694  double complex tmp_V,
695  double complex *tmp_v0,
696  double complex *tmp_v1,
697  struct BindStruct *X,
698  long unsigned int *tmp_off
699 ) {
700  int tmp_sgn;
701  double complex dmv;
702  double complex dam_pr = 0 + 0 * I;
703  tmp_sgn = X_CisAis(list_1[j], X, isite3);
704  tmp_sgn *= X_CisAis(list_1[j], X, isite1);
705  dmv = tmp_V * tmp_v1[j] * tmp_sgn;
706  if (X->Large.mode == M_MLTPLY || X->Large.mode == M_CALCSPEC) { // for multply
707  tmp_v0[j] += dmv;
708  }
709  dam_pr = conj(tmp_v1[j]) * dmv;
710  return dam_pr;
711 }/*double complex child_CisAisCisAis_element*/
720  long unsigned int j,
721  long unsigned int isite1,
722  long unsigned int isite3,
723  long unsigned int isite4,
724  long unsigned int Bsum,
725  long unsigned int Bdiff,
726  double complex tmp_V,
727  double complex *tmp_v0,
728  double complex *tmp_v1,
729  struct BindStruct *X,
730  long unsigned int *tmp_off
731 ) {
732  int tmp_sgn;
733  double complex dmv;
734  double complex dam_pr = 0 + 0 * I;
735  tmp_sgn = X_CisAjt(list_1[j], X, isite3, isite4, Bsum, Bdiff, tmp_off);
736  if (tmp_sgn != 0) {
737  tmp_sgn *= X_CisAis(list_1[*tmp_off], X, isite1);
738  if (tmp_sgn != 0) {
739  dmv = tmp_V * tmp_v1[j] * tmp_sgn;
740  if (X->Large.mode == M_MLTPLY || X->Large.mode == M_CALCSPEC) { // for multply
741  tmp_v0[*tmp_off] += dmv;
742  }
743  dam_pr = conj(tmp_v1[*tmp_off]) * dmv;
744  }
745  }
746  return dam_pr;
747 }/*double complex child_CisAisCjtAku_element*/
756  long unsigned int j,
757  long unsigned int isite1,
758  long unsigned int isite2,
759  long unsigned int isite3,
760  long unsigned int Asum,
761  long unsigned int Adiff,
762  double complex tmp_V,
763  double complex *tmp_v0,
764  double complex *tmp_v1,
765  struct BindStruct *X,
766  long unsigned int *tmp_off
767 ) {
768  int tmp_sgn;
769  double complex dmv;
770  double complex dam_pr;
771  dam_pr = 0;
772  tmp_sgn = X_CisAis(list_1[j], X, isite3);
773  if (tmp_sgn != 0) {
774  tmp_sgn *= X_CisAjt(list_1[j], X, isite1, isite2, Asum, Adiff, tmp_off);
775  if (tmp_sgn != 0) {
776  dmv = tmp_V * tmp_v1[j] * tmp_sgn;
777  if (X->Large.mode == M_MLTPLY || X->Large.mode == M_CALCSPEC) { // for multply
778  tmp_v0[*tmp_off] += dmv;
779  }
780  dam_pr = conj(tmp_v1[*tmp_off]) * dmv;
781  }
782  }
783  return dam_pr;
784 }/*double complex child_CisAjtCkuAku_element*/
793  long unsigned int j,
794  long unsigned int isite1,
795  long unsigned int isite2,
796  long unsigned int isite3,
797  long unsigned int isite4,
798  long unsigned int Asum,
799  long unsigned int Adiff,
800  long unsigned int Bsum,
801  long unsigned int Bdiff,
802  double complex tmp_V,
803  double complex *tmp_v0,
804  double complex *tmp_v1,
805  struct BindStruct *X,
806  long unsigned int *tmp_off_2
807 ) {
808  int tmp_sgn;
809  long unsigned int tmp_off_1;
810 
811  double complex dmv;
812  double complex dam_pr = 0;
813  tmp_sgn = X_GC_CisAjt(list_1[j], X, isite3, isite4, Bsum, Bdiff, &tmp_off_1);
814 
815  if (tmp_sgn != 0) {
816  tmp_sgn *= X_CisAjt(tmp_off_1, X, isite1, isite2, Asum, Adiff, tmp_off_2);
817  if (tmp_sgn != 0) {
818  dmv = tmp_V * tmp_v1[j] * tmp_sgn;
819  if (X->Large.mode == M_MLTPLY || X->Large.mode == M_CALCSPEC) { // for multply
820  tmp_v0[*tmp_off_2] += dmv;
821  }
822  dam_pr = conj(tmp_v1[*tmp_off_2]) * dmv;
823  }
824  }
825  return dam_pr;
826 }/*double complex child_CisAjtCkuAlv_element*/
827 //[s] Grand Canonical
836  long unsigned int j,
837  long unsigned int isite1,
838  long unsigned int isite3,
839  double complex tmp_V,
840  double complex *tmp_v0,
841  double complex *tmp_v1,
842  struct BindStruct *X,
843  long unsigned int *tmp_off
844 ) {
845  int tmp_sgn;
846  double complex dmv;
847  double complex dam_pr = 0;
848  tmp_sgn = X_CisAis(j - 1, X, isite3);
849  tmp_sgn *= X_CisAis(j - 1, X, isite1);
850  if (tmp_sgn != 0) {
851  dmv = tmp_V * tmp_v1[j] * tmp_sgn;
852  if (X->Large.mode == M_MLTPLY || X->Large.mode == M_CALCSPEC) { // for multply
853  tmp_v0[j] += dmv;
854  }
855  dam_pr = conj(tmp_v1[j]) * dmv;
856  }
857  return dam_pr;
858 }/*double complex GC_child_CisAisCisAis_element*/
867  long unsigned int j,
868  long unsigned int isite1,
869  long unsigned int isite3,
870  long unsigned int isite4,
871  long unsigned int Bsum,
872  long unsigned int Bdiff,
873  double complex tmp_V,
874  double complex *tmp_v0,
875  double complex *tmp_v1,
876  struct BindStruct *X,
877  long unsigned int *tmp_off
878 ) {
879  int tmp_sgn;
880  double complex dmv;
881  double complex dam_pr = 0 + 0 * I;
882  tmp_sgn = X_GC_CisAjt((j - 1), X, isite3, isite4, Bsum, Bdiff, tmp_off);
883  if (tmp_sgn != 0) {
884  tmp_sgn *= X_CisAis(*tmp_off, X, isite1);
885  if (tmp_sgn != 0) {
886  dmv = tmp_V * tmp_v1[j] * tmp_sgn;
887  if (X->Large.mode == M_MLTPLY || X->Large.mode == M_CALCSPEC) { // for multply
888  tmp_v0[*tmp_off + 1] += dmv;
889  }
890  dam_pr = conj(tmp_v1[*tmp_off + 1]) * dmv;
891  }
892  }
893  return dam_pr;
894 }/*double complex GC_child_CisAisCjtAku_element*/
903  long unsigned int j,
904  long unsigned int isite1,
905  long unsigned int isite2,
906  long unsigned int isite3,
907  long unsigned int Asum,
908  long unsigned int Adiff,
909  double complex tmp_V,
910  double complex *tmp_v0,
911  double complex *tmp_v1,
912  struct BindStruct *X,
913  long unsigned int *tmp_off
914 ) {
915  int tmp_sgn;
916  double complex dmv;
917  double complex dam_pr = 0 + 0 * I;
918  tmp_sgn = X_CisAis((j - 1), X, isite3);
919  if (tmp_sgn != 0) {
920  tmp_sgn *= X_GC_CisAjt((j - 1), X, isite1, isite2, Asum, Adiff, tmp_off);
921  if (tmp_sgn != 0) {
922  dmv = tmp_V * tmp_v1[j] * tmp_sgn;
923  if (X->Large.mode == M_MLTPLY || X->Large.mode == M_CALCSPEC) { // for multply
924  tmp_v0[*tmp_off + 1] += dmv;
925  }
926  dam_pr = conj(tmp_v1[*tmp_off + 1]) * dmv;
927  }/*if (tmp_sgn != 0)*/
928  }/*if (tmp_sgn != 0)*/
929  return dam_pr;
930 }/*double complex GC_child_CisAjtCkuAku_element*/
939  long unsigned int j,
940  long unsigned int isite1,
941  long unsigned int isite2,
942  long unsigned int isite3,
943  long unsigned int isite4,
944  long unsigned int Asum,
945  long unsigned int Adiff,
946  long unsigned int Bsum,
947  long unsigned int Bdiff,
948  double complex tmp_V,
949  double complex *tmp_v0,
950  double complex *tmp_v1,
951  struct BindStruct *X,
952  long unsigned int *tmp_off_2
953 ) {
954  int tmp_sgn;
955  long unsigned int tmp_off_1;
956  double complex dmv;
957  double complex dam_pr = 0 + 0 * I;
958 
959  tmp_sgn = X_GC_CisAjt((j - 1), X, isite3, isite4, Bsum, Bdiff, &tmp_off_1);
960  if (tmp_sgn != 0) {
961  tmp_sgn *= X_GC_CisAjt(tmp_off_1, X, isite1, isite2, Asum, Adiff, tmp_off_2);
962  if (tmp_sgn != 0) {
963  dmv = tmp_V * tmp_v1[j] * tmp_sgn;
964  if (X->Large.mode == M_MLTPLY || X->Large.mode == M_CALCSPEC) { // for multply
965  tmp_v0[*tmp_off_2 + 1] += dmv;
966  }
967  dam_pr = conj(tmp_v1[*tmp_off_2 + 1]) * dmv;
968  }
969  }
970  return dam_pr;
971 }/*double complex GC_child_CisAjtCkuAlv_element*/
972 //[e] Grand Canonical
981 double complex GC_Cis(
982  long unsigned int j,
983  double complex *tmp_v0,
984  double complex *tmp_v1,
985  long unsigned int is1_spin,
986  double complex tmp_V,
987  long unsigned int *tmp_off
988 ) {
989  long unsigned int list_1_j, list_1_off;
990  long unsigned int ibit_tmp_1;
991  long unsigned int bit;
992  int sgn, ipsgn;
993  double complex dmv, dam_pr;
994 
995  list_1_j = j - 1;
996 
997  ibit_tmp_1 = (list_1_j & is1_spin);
998  // is1_spin >= 1
999  // is1_spin = Tpow[2*isite + ispin]
1000 
1001  *tmp_off = 0;
1002 
1003  if (ibit_tmp_1 == 0) {
1004  // able to create an electron at the is1_spin state
1005  bit = list_1_j - (list_1_j & (2 * is1_spin - 1));
1006  SgnBit(bit, &sgn); // Fermion sign
1007  ipsgn = 1;
1008 #ifdef MPI
1009  SgnBit(myrank, &ipsgn); // Fermion sign
1010 #endif
1011  list_1_off = list_1_j | is1_spin; // OR
1012  *tmp_off = list_1_off;
1013  dmv = ipsgn * sgn * tmp_v1[j];
1014  //if (X->Large.mode == M_MLTPLY) { // for multply
1015  tmp_v0[list_1_off + 1] += dmv * tmp_V;
1016  //}
1017  dam_pr = dmv * conj(tmp_v1[list_1_off + 1]);
1018  return dam_pr;
1019  }
1020  else {
1021  return 0;
1022  }
1023 }/*double complex GC_Cis*/
1032 double complex GC_Ajt(
1033  long unsigned int j,
1034  double complex *tmp_v0,
1035  double complex *tmp_v1,
1036  long unsigned int is1_spin,
1037  double complex tmp_V,
1038  long unsigned int *tmp_off
1039 ) {
1040  long unsigned int list_1_j, list_1_off;
1041  long unsigned int ibit_tmp_1;
1042  long unsigned int bit;
1043  int sgn, ipsgn;
1044  double complex dmv, dam_pr;
1045 
1046  list_1_j = j - 1;
1047 
1048  ibit_tmp_1 = (list_1_j & is1_spin);
1049  // is1_spin >= 1
1050 
1051  *tmp_off = 0;
1052 
1053  if (ibit_tmp_1 == is1_spin) {
1054  // able to create an electron at the is1_spin state
1055  bit = list_1_j - (list_1_j & (2 * is1_spin - 1));
1056  SgnBit(bit, &sgn); // Fermion sign
1057  ipsgn = 1;
1058 #ifdef MPI
1059  SgnBit(myrank, &ipsgn); // Fermion sign
1060 #endif
1061  list_1_off = list_1_j ^ is1_spin;
1062  *tmp_off = list_1_off;
1063  dmv = ipsgn * sgn * tmp_v1[j];
1064  //if (X->Large.mode == M_MLTPLY) { // for multply
1065  tmp_v0[list_1_off + 1] += dmv * tmp_V;
1066  //}
1067  dam_pr = dmv * conj(tmp_v1[list_1_off + 1]);
1068  return dam_pr;
1069  }
1070  else {
1071  return 0;
1072  }
1073 }/*double complex GC_Ajt*/
1082 int X_Cis(
1083  long unsigned int j,
1084  long unsigned int is1_spin,
1085  long unsigned int *tmp_off,
1086  long unsigned int *list_1_org,
1087  long unsigned int *list_2_1_target,
1088  long unsigned int *list_2_2_target,
1089  long unsigned int _irght,
1090  long unsigned int _ilft,
1091  long unsigned int _ihfbit
1092 ) {
1093  long unsigned int list_1_j, list_1_off;
1094  long unsigned int ibit_tmp_1;
1095  long unsigned int bit;
1096  int sgn, ipsgn;
1097 
1098  list_1_j = list_1_org[j];
1099 
1100  ibit_tmp_1 = (list_1_j & is1_spin);
1101  // is1_spin >= 1
1102  // is1_spin = Tpow[2*isite + ispin]
1103 
1104  *tmp_off = 0;
1105 
1106  if (ibit_tmp_1 == 0) {
1107  // able to create an electron at the is1_spin state
1108  bit = list_1_j - (list_1_j & (2 * is1_spin - 1));
1109  SgnBit(bit, &sgn); // Fermion sign
1110  ipsgn = 1;
1111 #ifdef MPI
1112  SgnBit(myrank, &ipsgn); // Fermion sign
1113 #endif
1114  list_1_off = list_1_j | is1_spin; // OR
1115 
1116  if(GetOffComp(list_2_1_target, list_2_2_target, list_1_off, _irght, _ilft, _ihfbit, tmp_off)!=TRUE){
1117  *tmp_off=0;
1118  return 0;
1119  }
1120  sgn *= ipsgn;
1121  return (sgn);
1122  }
1123  else {
1124  *tmp_off = 0;
1125  return 0;
1126  }
1127 }/*int X_Cis*/
1136 double complex X_Ajt(
1137  long unsigned int j,
1138  long unsigned int is1_spin,
1139  long unsigned int *tmp_off,
1140  long unsigned int *list_1_org,
1141  long unsigned int *list_2_1_target,
1142  long unsigned int *list_2_2_target,
1143  long unsigned int _irght,
1144  long unsigned int _ilft,
1145  long unsigned int _ihfbit
1146 ) {
1147  long unsigned int list_1_j, list_1_off;
1148  long unsigned int ibit_tmp_1;
1149  long unsigned int bit;
1150  int sgn, ipsgn;
1151 
1152  list_1_j = list_1_org[j];
1153 
1154  ibit_tmp_1 = (list_1_j & is1_spin);
1155 // is1_spin >= 1
1156 // is1_spin = Tpow[2*isite + ispin]
1157 
1158  *tmp_off = 0;
1159  if (ibit_tmp_1 != 0) {
1160  // able to delete an electron at the is1_spin state
1161  bit = list_1_j - (list_1_j & (2 * is1_spin - 1));
1162  SgnBit(bit, &sgn); // Fermion sign
1163  ipsgn = 1;
1164 #ifdef MPI
1165  SgnBit(myrank, &ipsgn); // Fermion sign
1166 #endif
1167  list_1_off = list_1_j ^ is1_spin;
1168  if(GetOffComp(list_2_1_target, list_2_2_target, list_1_off, _irght, _ilft, _ihfbit, tmp_off)!=TRUE){
1169  *tmp_off=0;
1170  return 0;
1171  }
1172  sgn *= ipsgn;
1173  return(sgn);
1174  }
1175  else {
1176  *tmp_off = 0;
1177  return 0;
1178  }
1179 }/*double complex X_Ajt*/
1180 
1181 /******************************************************************************/
1182 //[e] child element functions
1183 /******************************************************************************/
int X_CisAis(long unsigned int list_1_j, struct BindStruct *X, long unsigned int is1_spin)
term in Hubbard (canonical)
int X_CisAjt(long unsigned int list_1_j, struct BindStruct *X, long unsigned int is1_spin, long unsigned int is2_spin, long unsigned int sum_spin, long unsigned int diff_spin, long unsigned int *tmp_off)
Compute index of wavefunction of final state.
int child_general_int_GetInfo(int iInterAll, struct BindStruct *X, long unsigned int isite1, long unsigned int isite2, long unsigned int isite3, long unsigned int isite4, long unsigned int sigma1, long unsigned int sigma2, long unsigned int sigma3, long unsigned int sigma4, double complex tmp_V)
Compute mask for bit operation of general interaction term.
double complex child_CisAjtCkuAku_element(long unsigned int j, long unsigned int isite1, long unsigned int isite2, long unsigned int isite3, long unsigned int Asum, long unsigned int Adiff, double complex tmp_V, double complex *tmp_v0, double complex *tmp_v1, struct BindStruct *X, long unsigned int *tmp_off)
Compute term of canonical Hubbard system.
double complex child_pairhopp_element(long unsigned int j, double complex *tmp_v0, double complex *tmp_v1, struct BindStruct *X, long unsigned int *tmp_off)
Compute pairhopp term of canonical Hubbard system.
double complex CisAjt(long unsigned int j, double complex *tmp_v0, double complex *tmp_v1, struct BindStruct *X, long unsigned int is1_spin, long unsigned int is2_spin, long unsigned int sum_spin, long unsigned int diff_spin, double complex tmp_V)
term for canonical Hubbard
double complex GC_child_pairhopp_element(long unsigned int j, double complex *tmp_v0, double complex *tmp_v1, struct BindStruct *X, long unsigned int *tmp_off)
Compute pairhopp term of grandcanonical Hubbard system.
#define TRUE
Definition: global.h:26
double complex GC_CisAjt(long unsigned int j, double complex *tmp_v0, double complex *tmp_v1, struct BindStruct *X, long unsigned int is1_spin, long unsigned int is2_spin, long unsigned int sum_spin, long unsigned int diff_spin, double complex tmp_V, long unsigned int *tmp_off)
term for grandcanonical Hubbard
double complex child_exchange_element(long unsigned int j, double complex *tmp_v0, double complex *tmp_v1, struct BindStruct *X, long unsigned int *tmp_off)
Compute exchange term of canonical-Hubbard.
double complex GC_child_exchange_element(long unsigned int j, double complex *tmp_v0, double complex *tmp_v1, struct BindStruct *X, long unsigned int *tmp_off)
Compute exchange term of grandcanonical Hubbard system.
Bind.
Definition: struct.h:408
int X_Cis(long unsigned int j, long unsigned int is1_spin, long unsigned int *tmp_off, long unsigned int *list_1_org, long unsigned int *list_2_1_target, long unsigned int *list_2_2_target, long unsigned int _irght, long unsigned int _ilft, long unsigned int _ihfbit)
Compute index of final wavefunction associatesd to term of canonical Hubbard system.
double complex GC_AisCis(long unsigned int j, double complex *tmp_v0, double complex *tmp_v1, struct BindStruct *X, long unsigned int is1_spin, double complex tmp_trans)
Operation of (Grandcanonical)
int child_pairhopp_GetInfo(int iPairHopp, struct BindStruct *X)
Compute mask for bit operation of pairhop term.
double complex GC_Ajt(long unsigned int j, double complex *tmp_v0, double complex *tmp_v1, long unsigned int is1_spin, double complex tmp_V, long unsigned int *tmp_off)
Compute term of grandcanonical Hubbard system.
long unsigned int * list_1_org
Definition: global.h:53
long unsigned int * list_2_1
Definition: global.h:49
int GetOffComp(long unsigned int *_list_2_1, long unsigned int *_list_2_2, long unsigned int _ibit, const long unsigned int _irght, const long unsigned int _ilft, const long unsigned int _ihfbit, long unsigned int *_ioffComp)
function of getting off-diagonal component
Definition: bitcalc.c:195
double complex GC_child_CisAisCisAis_element(long unsigned int j, long unsigned int isite1, long unsigned int isite3, double complex tmp_V, double complex *tmp_v0, double complex *tmp_v1, struct BindStruct *X, long unsigned int *tmp_off)
Compute term of grandcanonical Hubbard system.
double complex X_Ajt(long unsigned int j, long unsigned int is1_spin, long unsigned int *tmp_off, long unsigned int *list_1_org, long unsigned int *list_2_1_target, long unsigned int *list_2_2_target, long unsigned int _irght, long unsigned int _ilft, long unsigned int _ihfbit)
Compute index of final wavefunction associatesd to term of canonical Hubbard system.
#define FALSE
Definition: global.h:25
long unsigned int * list_1
Definition: global.h:47
int X_GC_CisAjt(long unsigned int list_1_j, struct BindStruct *X, long unsigned int is1_spin, long unsigned int is2_spin, long unsigned int sum_spin, long unsigned int diff_spin, long unsigned int *tmp_off)
Compute index of wavefunction of final state.
int child_general_hopp_GetInfo(struct BindStruct *X, unsigned long int isite1, unsigned long int isite2, unsigned long int sigma1, unsigned long int sigma2)
Compute mask for bit operation of hopping term.
double complex child_CisAisCisAis_element(long unsigned int j, long unsigned int isite1, long unsigned int isite3, double complex tmp_V, double complex *tmp_v0, double complex *tmp_v1, struct BindStruct *X, long unsigned int *tmp_off)
Compute term of canonical Hubbard system.
long unsigned int * list_2_2
Definition: global.h:50
struct EDMainCalStruct X
Definition: struct.h:431
int myrank
Process ID, defined in InitializeMPI()
Definition: global.h:162
double complex GC_Cis(long unsigned int j, double complex *tmp_v0, double complex *tmp_v1, long unsigned int is1_spin, double complex tmp_V, long unsigned int *tmp_off)
Compute term of grandcanonical Hubbard system.
int child_exchange_GetInfo(int iExchange, struct BindStruct *X)
Compute mask for bit operation of exchange term.
double complex GC_child_CisAisCjtAku_element(long unsigned int j, long unsigned int isite1, long unsigned int isite3, long unsigned int isite4, long unsigned int Bsum, long unsigned int Bdiff, double complex tmp_V, double complex *tmp_v0, double complex *tmp_v1, struct BindStruct *X, long unsigned int *tmp_off)
Compute term of grandcanonical Hubbard system.
void SgnBit(const long unsigned int org_bit, int *sgn)
function of getting fermion sign (64 bit)
Definition: bitcalc.c:339
double complex GC_child_CisAjtCkuAku_element(long unsigned int j, long unsigned int isite1, long unsigned int isite2, long unsigned int isite3, long unsigned int Asum, long unsigned int Adiff, double complex tmp_V, double complex *tmp_v0, double complex *tmp_v1, struct BindStruct *X, long unsigned int *tmp_off)
Compute term of grandcanonical Hubbard system.
double complex child_CisAjtCkuAlv_element(long unsigned int j, long unsigned int isite1, long unsigned int isite2, long unsigned int isite3, long unsigned int isite4, long unsigned int Asum, long unsigned int Adiff, long unsigned int Bsum, long unsigned int Bdiff, double complex tmp_V, double complex *tmp_v0, double complex *tmp_v1, struct BindStruct *X, long unsigned int *tmp_off_2)
Compute term of canonical Hubbard system.
double complex GC_CisAis(long unsigned int j, double complex *tmp_v0, double complex *tmp_v1, struct BindStruct *X, long unsigned int is1_spin, double complex tmp_trans)
Operation of (Grandcanonical)
double complex GC_child_CisAjtCkuAlv_element(long unsigned int j, long unsigned int isite1, long unsigned int isite2, long unsigned int isite3, long unsigned int isite4, long unsigned int Asum, long unsigned int Adiff, long unsigned int Bsum, long unsigned int Bdiff, double complex tmp_V, double complex *tmp_v0, double complex *tmp_v1, struct BindStruct *X, long unsigned int *tmp_off_2)
Compute term of grandcanonical Hubbard system.
double complex child_CisAisCjtAku_element(long unsigned int j, long unsigned int isite1, long unsigned int isite3, long unsigned int isite4, long unsigned int Bsum, long unsigned int Bdiff, double complex tmp_V, double complex *tmp_v0, double complex *tmp_v1, struct BindStruct *X, long unsigned int *tmp_off)
Compute term of canonical Hubbard system.