HΦ  3.1.0
mltplySpinCore.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/>. */
19 #include <bitcalc.h>
20 #include "mfmemory.h"
21 #include "xsetmem.h"
22 #include "wrapperMPI.h"
23 #include "mltplyCommon.h"
24 #include "mltplySpinCore.h"
25 
26 /******************************************************************************/
27 //[s] GetInfo functions
28 /******************************************************************************/
29 
37  int iExchange,
38  struct BindStruct *X
39 ) {
40  int isite1 = X->Def.ExchangeCoupling[iExchange][0] + 1;
41  int isite2 = X->Def.ExchangeCoupling[iExchange][1] + 1;
45  X->Large.tmp_J = X->Def.ParaExchangeCoupling[iExchange];
50  X->Large.is1_up = X->Def.Tpow[isite1 - 1];
51  X->Large.is2_up = X->Def.Tpow[isite2 - 1];
55  X->Large.isA_spin = X->Large.is1_up + X->Large.is2_up;
56  return 0;
57 }/*int child_exchange_spin_GetInfo*/
65  int iPairLift,
66  struct BindStruct *X
67 ) {
68  int isite1 = X->Def.PairLiftCoupling[iPairLift][0] + 1;
69  int isite2 = X->Def.PairLiftCoupling[iPairLift][1] + 1;
73  X->Large.tmp_J = X->Def.ParaPairLiftCoupling[iPairLift];
78  X->Large.is1_up = X->Def.Tpow[isite1 - 1];
79  X->Large.is2_up = X->Def.Tpow[isite2 - 1];
83  X->Large.isA_spin = X->Large.is1_up + X->Large.is2_up;
84  return 0;
85 }/*int child_pairlift_spin_GetInfo*/
93  struct BindStruct *X,
94  long unsigned int isite1,
95  long unsigned int isite2,
96  long unsigned int sigma1,
97  long unsigned int sigma2,
98  long unsigned int sigma3,
99  long unsigned int sigma4,
100  double complex tmp_V
101 ) {
105  X->Large.tmp_V = tmp_V;
106  X->Large.isite1 = isite1;
107  X->Large.isite2 = isite2;
112  X->Large.is1_up = X->Def.Tpow[isite1 - 1];
113  X->Large.is2_up = X->Def.Tpow[isite2 - 1];
118  X->Large.is1_spin = sigma1;
119  X->Large.is2_spin = sigma2;
120  X->Large.is3_spin = sigma3;
121  X->Large.is4_spin = sigma4;
122  return 0;
123 }/*int child_general_int_spin_GetInfo*/
124 
125 /******************************************************************************/
126 //[e] GetInfo functions
127 /******************************************************************************/
128 
129 /******************************************************************************/
130 //[s] core routines
131 /******************************************************************************/
132 
140  long unsigned int j,
141  struct BindStruct *X,
142  long unsigned int is1_spin,
143  long unsigned int sigma2,
144  long unsigned int *list_1_Org_,
145  long unsigned int *list_2_1_,
146  long unsigned int *list_2_2_,
147  long unsigned int *tmp_off
148 ) {
149  long unsigned int list_1_j;
150  long unsigned int off;
151  list_1_j = list_1_Org_[j];
152  if (X_SpinGC_CisAit(list_1_j + 1, X, is1_spin, sigma2, &off) != 0) {
153  GetOffComp(list_2_1_, list_2_2_, off, X->Large.irght, X->Large.ilft, X->Large.ihfbit, tmp_off);
154  return 1;
155  }
156  else {
157  *tmp_off = 0;
158  return 0;
159  }
160 }/*int X_Spin_CisAit*/
168  long unsigned int j,
169  struct BindStruct *X,
170  long unsigned int is1_spin,
171  long unsigned int sigma1
172 ) {
173  int A_ibit_tmp;
174  // off = j
175  A_ibit_tmp = ((list_1[j] & is1_spin) / is1_spin) ^ (1 - sigma1);
176  return A_ibit_tmp;
177 }/*int X_Spin_CisAis*/
185  long unsigned int j,
186  struct BindStruct *X,
187  long unsigned int is1_spin,
188  long unsigned int sigma1
189 ) {
190  int A_ibit_tmp;
191  long unsigned int list_1_j;
192  // off = j
193  list_1_j = j - 1;
194  A_ibit_tmp = ((list_1_j & is1_spin) / is1_spin) ^ (1 - sigma1);
195  return A_ibit_tmp;
196 }/*int X_SpinGC_CisAis*/
205  long unsigned int j,
206  struct BindStruct *X,
207  long unsigned int is1_spin,
208  long unsigned int sigma2,
209  long unsigned int *tmp_off
210 ) {
211  long unsigned int list_1_j, ibit_tmp_1;
212 
213  list_1_j = j - 1;
214 
215  ibit_tmp_1 = list_1_j & is1_spin;
216  if (ibit_tmp_1 == 0 && sigma2 == 0) { // down -> up
217  *tmp_off = list_1_j + is1_spin;
218  return 1;
219  }
220  else if (ibit_tmp_1 != 0 && sigma2 == 1) { // up -> down
221  *tmp_off = list_1_j - is1_spin;
222  return 1;
223  }
224  else {
225  *tmp_off = 0;
226  return 0;
227  }
228 }/*int X_SpinGC_CisAit*/
229 
230 /******************************************************************************/
231 //[e] core routines
232 /******************************************************************************/
233 
241  long unsigned int j,
242  struct BindStruct *X,
243  long unsigned int isA_up,
244  long unsigned int isB_up,
245  long unsigned int sigmaA,
246  long unsigned int sigmaB,
247  long unsigned int *tmp_off
248 ) {
249  long unsigned int iexchg, off;
250  long unsigned int irght = X->Large.irght;
251  long unsigned int ilft = X->Large.ilft;
252  long unsigned int ihfbit = X->Large.ihfbit;
253  long unsigned int ibit_tmp_A, ibit_tmp_B;
254 
255  ibit_tmp_A = ((list_1[j] & isA_up) / isA_up);
256  ibit_tmp_B = ((list_1[j] & isB_up) / isB_up);
257  if (ibit_tmp_A == sigmaA && ibit_tmp_B == sigmaB) {
258  iexchg = list_1[j] ^ (isA_up + isB_up);
259  GetOffComp(list_2_1, list_2_2, iexchg, irght, ilft, ihfbit, &off);
260  *tmp_off = off;
261  return 1;
262  }
263  else {
264  *tmp_off = 0; // just tentative
265  return 0;
266  }
267 }/*int X_child_exchange_spin_element*/
275  long unsigned int j,
276  double complex *tmp_v0,
277  double complex *tmp_v1,
278  struct BindStruct *X,
279  long unsigned int *tmp_off
280 ) {
281  long unsigned int off;
282  double complex dmv;
283  long unsigned int iexchg;
284  long unsigned int is_up = X->Large.isA_spin;
285  long unsigned int irght = X->Large.irght;
286  long unsigned int ilft = X->Large.ilft;
287  long unsigned int ihfbit = X->Large.ihfbit;
288  double complex tmp_J = X->Large.tmp_J;
289  int mode = X->Large.mode;
290  double complex dam_pr = 0;
291  long unsigned int ibit_tmp;
292 
293  ibit_tmp = (list_1[j] & is_up);
294  if (ibit_tmp == 0 || ibit_tmp == is_up) {
295  return dam_pr;
296  }
297  else {
298  iexchg = list_1[j] ^ is_up;
299  GetOffComp(list_2_1, list_2_2, iexchg, irght, ilft, ihfbit, &off);
300  *tmp_off = off;
301  dmv = tmp_J * tmp_v1[j];
302  if (mode == M_MLTPLY) {
303  tmp_v0[off] += dmv;
304  }
305  dam_pr += dmv * conj(tmp_v1[off]);
306  return dam_pr;
307  }
308 }/*double complex child_exchange_spin_element*/
316  long unsigned int j,
317  double complex *tmp_v0,
318  double complex *tmp_v1,
319  struct BindStruct *X,
320  long unsigned int *tmp_off
321 ) {
322  double complex dmv;
323  long unsigned int is_up = X->Large.isA_spin;
324  double complex tmp_J = X->Large.tmp_J;
325  int mode = X->Large.mode;
326  long unsigned int list_1_j, list_1_off;
327 
328  double complex dam_pr = 0;
329  list_1_j = j - 1;
330 
331  long unsigned int ibit_tmp;
332  ibit_tmp = (list_1_j & is_up);
333  if (ibit_tmp == 0 || ibit_tmp == is_up) {
334  return dam_pr;
335  }
336  else {
337  list_1_off = list_1_j ^ is_up;
338  *tmp_off = list_1_off;
339  dmv = tmp_J * tmp_v1[j];
340  if (mode == M_MLTPLY) {
341  tmp_v0[list_1_off + 1] += dmv;
342  }
343  dam_pr += dmv * conj(tmp_v1[list_1_off + 1]);
344  return dam_pr;
345  }
346 }/*double complex GC_child_exchange_spin_element*/
354  long unsigned int j,
355  double complex *tmp_v0,
356  double complex *tmp_v1,
357  struct BindStruct *X,
358  long unsigned int *tmp_off
359 ) {
360  double complex dmv;
361  long unsigned int is_up = X->Large.isA_spin;
362  double complex tmp_J = X->Large.tmp_J;
363  int mode = X->Large.mode;
364  double complex dam_pr = 0;
365  long unsigned int list_1_off;
366  long unsigned int list_1_j = j - 1;
367  long unsigned int ibit_tmp;
368  //ibit_tmp = ((list_1_j & is1_up) / is1_up) ^ ((list_1_j & is2_up) / is2_up);
369  ibit_tmp = (list_1_j & is_up);
370  if (ibit_tmp == 0 || ibit_tmp == is_up) {
371  list_1_off = list_1_j ^ is_up; //Change: ++ -> -- or -- -> ++
372  *tmp_off = list_1_off;
373  dmv = tmp_J * tmp_v1[j];//* ibit_tmp;
374  if (mode == M_MLTPLY) {
375  tmp_v0[list_1_off + 1] += dmv;
376  }
377  dam_pr += dmv * conj(tmp_v1[list_1_off + 1]);
378  return dam_pr;
379  }
380  else {
381  return dam_pr;
382  }
383 }/*double complex GC_child_pairlift_spin_element*/
384 //[s]Spin
393  long unsigned int j,
394  long unsigned int isA_up,
395  long unsigned int isB_up,
396  long unsigned int org_sigma2,
397  long unsigned int org_sigma4,
398  double complex tmp_V,
399  double complex *tmp_v0,
400  double complex *tmp_v1,
401  struct BindStruct *X
402 ) {
403  int tmp_sgn;
404  double complex dmv;
405  double complex dam_pr = 0;
406 
407  tmp_sgn = X_Spin_CisAis(j, X, isB_up, org_sigma4);
408  tmp_sgn *= X_Spin_CisAis(j, X, isA_up, org_sigma2);
409  dmv = tmp_v1[j] * tmp_sgn * tmp_V;
410  if (X->Large.mode == M_MLTPLY || X->Large.mode == M_CALCSPEC) { // for multply
411  tmp_v0[j] += dmv;
412  }
413  dam_pr = conj(tmp_v1[j]) * dmv;
414  return dam_pr;
415 }/*double complex child_CisAisCisAis_spin_element*/
416 
417 //[e]Spin
418 
419 //[s]GC Spin
428  long unsigned int j,
429  long unsigned int isA_up,
430  long unsigned int isB_up,
431  long unsigned int org_sigma2,
432  long unsigned int org_sigma4,
433  double complex tmp_V,
434  double complex *tmp_v0,
435  double complex *tmp_v1,
436  struct BindStruct *X
437 ) {
438  int tmp_sgn;
439  double complex dmv = 0;
440  double complex dam_pr = 0;
441 
442  tmp_sgn = X_SpinGC_CisAis(j, X, isB_up, org_sigma4);
443  tmp_sgn *= X_SpinGC_CisAis(j, X, isA_up, org_sigma2);
444  if (tmp_sgn != 0) {
445  dmv = tmp_v1[j] * tmp_sgn * tmp_V;
446  if (X->Large.mode == M_MLTPLY || X->Large.mode == M_CALCSPEC) { // for multply
447  tmp_v0[j] += dmv;
448  }
449  dam_pr = conj(tmp_v1[j]) * dmv;
450  }
451  return dam_pr;
452 }/*double complex GC_child_CisAisCisAis_spin_element*/
461  long unsigned int j,
462  long unsigned int org_sigma2,
463  long unsigned int org_sigma4,
464  long unsigned int isA_up,
465  long unsigned int isB_up,
466  double complex tmp_V,
467  double complex *tmp_v0,
468  double complex *tmp_v1,
469  struct BindStruct *X,
470  long unsigned int *tmp_off
471 ) {
472  int tmp_sgn;
473  double complex dmv;
474  double complex dam_pr = 0 + 0 * I;
475  tmp_sgn = X_SpinGC_CisAit(j, X, isB_up, org_sigma4, tmp_off);
476  if (tmp_sgn != 0) {
477  tmp_sgn *= X_SpinGC_CisAis((*tmp_off + 1), X, isA_up, org_sigma2);
478  if (tmp_sgn != 0) {
479  dmv = tmp_v1[j] * tmp_sgn * tmp_V;
480  if (X->Large.mode == M_MLTPLY || X->Large.mode == M_CALCSPEC) { // for multply
481  tmp_v0[*tmp_off + 1] += dmv;
482  }
483  dam_pr = conj(tmp_v1[*tmp_off + 1]) * dmv;
484  }/*if (tmp_sgn != 0)*/
485  }/*if (tmp_sgn != 0)*/
486  return dam_pr;
487 }/*double complex GC_child_CisAisCitAiu_spin_element*/
496  long unsigned int j,
497  long unsigned int org_sigma2,
498  long unsigned int org_sigma4,
499  long unsigned int isA_up,
500  long unsigned int isB_up,
501  double complex tmp_V,
502  double complex *tmp_v0,
503  double complex *tmp_v1,
504  struct BindStruct *X,
505  long unsigned int *tmp_off
506 ) {
507  int tmp_sgn;
508  double complex dmv;
509  double complex dam_pr = 0 + 0 * I;
510  tmp_sgn = X_SpinGC_CisAis(j, X, isB_up, org_sigma4);
511  if (tmp_sgn != 0) {
512  tmp_sgn *= X_SpinGC_CisAit(j, X, isA_up, org_sigma2, tmp_off);
513  if (tmp_sgn != 0) {
514  dmv = tmp_v1[j] * tmp_sgn * tmp_V;
515  if (X->Large.mode == M_MLTPLY || X->Large.mode == M_CALCSPEC) { // for multply
516  tmp_v0[*tmp_off + 1] += dmv;
517  }
518  dam_pr = conj(tmp_v1[*tmp_off + 1]) * dmv;
519  }/*if (tmp_sgn != 0)*/
520  }/*if (tmp_sgn != 0)*/
521  return dam_pr;
522 }/*double complex GC_child_CisAitCiuAiu_spin_element*/
531  long unsigned int j,
532  long unsigned int org_sigma2,
533  long unsigned int org_sigma4,
534  long unsigned int isA_up,
535  long unsigned int isB_up,
536  double complex tmp_V,
537  double complex *tmp_v0,
538  double complex *tmp_v1,
539  struct BindStruct *X,
540  long unsigned int *tmp_off_2
541 ) {
542  int tmp_sgn;
543  long unsigned int tmp_off_1;
544  double complex dmv;
545  double complex dam_pr = 0 + 0 * I;
546  tmp_sgn = X_SpinGC_CisAit(j, X, isB_up, org_sigma4, &tmp_off_1);
547  if (tmp_sgn != 0) {
548  tmp_sgn *= X_SpinGC_CisAit((tmp_off_1 + 1), X, isA_up, org_sigma2, tmp_off_2);
549  if (tmp_sgn != 0) {
550  dmv = tmp_v1[j] * tmp_sgn * tmp_V;
551  if (X->Large.mode == M_MLTPLY || X->Large.mode == M_CALCSPEC) { // for multply
552  tmp_v0[*tmp_off_2 + 1] += dmv;
553  }
554  dam_pr = conj(tmp_v1[*tmp_off_2 + 1]) * dmv;
555  }/*if (tmp_sgn != 0)*/
556  }/*if (tmp_sgn != 0)*/
557  return dam_pr;
558 }/*double complex GC_child_CisAitCiuAiv_spin_element*/
559 //[e]GC Spin
double complex GC_child_exchange_spin_element(long unsigned int j, double complex *tmp_v0, double complex *tmp_v1, struct BindStruct *X, long unsigned int *tmp_off)
Multiply Hamiltonian of exchange term of grandcanonical spin system.
double complex GC_child_CisAitCiuAiu_spin_element(long unsigned int j, long unsigned int org_sigma2, long unsigned int org_sigma4, long unsigned int isA_up, long unsigned int isB_up, double complex tmp_V, double complex *tmp_v0, double complex *tmp_v1, struct BindStruct *X, long unsigned int *tmp_off)
Compute term of grandcanonical spsin system.
double complex GC_child_CisAisCitAiu_spin_element(long unsigned int j, long unsigned int org_sigma2, long unsigned int org_sigma4, long unsigned int isA_up, long unsigned int isB_up, double complex tmp_V, double complex *tmp_v0, double complex *tmp_v1, struct BindStruct *X, long unsigned int *tmp_off)
Compute term of grandcanonical spsin system.
int X_child_exchange_spin_element(long unsigned int j, struct BindStruct *X, long unsigned int isA_up, long unsigned int isB_up, long unsigned int sigmaA, long unsigned int sigmaB, long unsigned int *tmp_off)
Compute index of final wavefunction associated to spin-exchange term.
int X_SpinGC_CisAis(long unsigned int j, struct BindStruct *X, long unsigned int is1_spin, long unsigned int sigma1)
Compute the grandcanonical spin state with bit mask is1_spin.
double complex GC_child_CisAitCiuAiv_spin_element(long unsigned int j, long unsigned int org_sigma2, long unsigned int org_sigma4, long unsigned int isA_up, long unsigned int isB_up, 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 spsin system.
int X_Spin_CisAis(long unsigned int j, struct BindStruct *X, long unsigned int is1_spin, long unsigned int sigma1)
Compute the spin state with bit mask is1_spin.
int child_general_int_spin_GetInfo(struct BindStruct *X, long unsigned int isite1, long unsigned int isite2, long unsigned int sigma1, long unsigned int sigma2, long unsigned int sigma3, long unsigned int sigma4, double complex tmp_V)
Set parameters for the bit operation of spin-general interaction term.
int child_pairlift_spin_GetInfo(int iPairLift, struct BindStruct *X)
Set parameters for the bit operation of spin-pairlift term.
Bind.
Definition: struct.h:408
double complex GC_child_CisAisCisAis_spin_element(long unsigned int j, long unsigned int isA_up, long unsigned int isB_up, long unsigned int org_sigma2, long unsigned int org_sigma4, double complex tmp_V, double complex *tmp_v0, double complex *tmp_v1, struct BindStruct *X)
Compute term of grandcanonical spsin system.
int child_exchange_spin_GetInfo(int iExchange, struct BindStruct *X)
Set parameters for the bit operation of spin-exchange term.
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 child_CisAisCisAis_spin_element(long unsigned int j, long unsigned int isA_up, long unsigned int isB_up, long unsigned int org_sigma2, long unsigned int org_sigma4, double complex tmp_V, double complex *tmp_v0, double complex *tmp_v1, struct BindStruct *X)
Compute term of canonical spsin system.
int X_Spin_CisAit(long unsigned int j, struct BindStruct *X, long unsigned int is1_spin, long unsigned int sigma2, long unsigned int *list_1_Org_, long unsigned int *list_2_1_, long unsigned int *list_2_2_, long unsigned int *tmp_off)
Compute index of final wavefunction by term.
long unsigned int * list_1
Definition: global.h:47
long unsigned int * list_2_2
Definition: global.h:50
struct EDMainCalStruct X
Definition: struct.h:431
int X_SpinGC_CisAit(long unsigned int j, struct BindStruct *X, long unsigned int is1_spin, long unsigned int sigma2, long unsigned int *tmp_off)
Compute index of final wavefunction by term (grandcanonical).
double complex GC_child_pairlift_spin_element(long unsigned int j, double complex *tmp_v0, double complex *tmp_v1, struct BindStruct *X, long unsigned int *tmp_off)
Multiply Hamiltonian of pairlift term of grandcanonical spin system.
double complex child_exchange_spin_element(long unsigned int j, double complex *tmp_v0, double complex *tmp_v1, struct BindStruct *X, long unsigned int *tmp_off)
Multiply Hamiltonian of exchange term of canonical spin system.