HPhi++  3.1.0
mltplySpinCore.cpp
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.hpp>
20 #include "xsetmem.hpp"
21 #include "wrapperMPI.hpp"
22 #include "mltplyCommon.hpp"
23 #include "mltplySpinCore.hpp"
24 
25 /******************************************************************************/
26 //[s] GetInfo functions
27 /******************************************************************************/
28 
36  int iExchange,
37  struct BindStruct *X
38 ) {
39  int isite1 = X->Def.ExchangeCoupling[iExchange][0] + 1;
40  int isite2 = X->Def.ExchangeCoupling[iExchange][1] + 1;
44  X->Large.tmp_J = X->Def.ParaExchangeCoupling[iExchange];
49  X->Large.is1_up = X->Def.Tpow[isite1 - 1];
50  X->Large.is2_up = X->Def.Tpow[isite2 - 1];
54  X->Large.isA_spin = X->Large.is1_up + X->Large.is2_up;
55  return 0;
56 }/*int child_exchange_spin_GetInfo*/
64  int iPairLift,
65  struct BindStruct *X
66 ) {
67  int isite1 = X->Def.PairLiftCoupling[iPairLift][0] + 1;
68  int isite2 = X->Def.PairLiftCoupling[iPairLift][1] + 1;
72  X->Large.tmp_J = X->Def.ParaPairLiftCoupling[iPairLift];
77  X->Large.is1_up = X->Def.Tpow[isite1 - 1];
78  X->Large.is2_up = X->Def.Tpow[isite2 - 1];
82  X->Large.isA_spin = X->Large.is1_up + X->Large.is2_up;
83  return 0;
84 }/*int child_pairlift_spin_GetInfo*/
92  struct BindStruct *X,
93  long int isite1,
94  long int isite2,
95  long int sigma1,
96  long int sigma2,
97  long int sigma3,
98  long int sigma4,
99  std::complex<double> tmp_V
100 ) {
104  X->Large.tmp_V = tmp_V;
105  X->Large.isite1 = isite1;
106  X->Large.isite2 = isite2;
111  X->Large.is1_up = X->Def.Tpow[isite1 - 1];
112  X->Large.is2_up = X->Def.Tpow[isite2 - 1];
117  X->Large.is1_spin = sigma1;
118  X->Large.is2_spin = sigma2;
119  X->Large.is3_spin = sigma3;
120  X->Large.is4_spin = sigma4;
121  return 0;
122 }/*int child_general_int_spin_GetInfo*/
123 
124 /******************************************************************************/
125 //[e] GetInfo functions
126 /******************************************************************************/
127 
128 /******************************************************************************/
129 //[s] core routines
130 /******************************************************************************/
131 
139  long int j,
140  struct BindStruct *X,
141  long int is1_spin,
142  long int sigma2,
143  long int *tmp_off
144 ) {
145  long int list_1_j;
146  long int off;
147  list_1_j = list_1_org[j];
148  if (X_SpinGC_CisAit(list_1_j + 1, is1_spin, sigma2, &off) != 0) {
149  GetOffComp(list_2_1, list_2_2, off, X->Large.irght, X->Large.ilft, X->Large.ihfbit, tmp_off);
150  return 1;
151  }
152  else {
153  *tmp_off = 0;
154  return 0;
155  }
156 }/*int X_Spin_CisAit*/
164  long int j,
165  long int is1_spin,
166  long int sigma1
167 ) {
168  int A_ibit_tmp;
169  // off = j
170  A_ibit_tmp = ((list_1[j] & is1_spin) / is1_spin) ^ (1 - sigma1);
171  return A_ibit_tmp;
172 }/*int X_Spin_CisAis*/
180  long int j,
181  long int is1_spin,
182  long int sigma1
183 ) {
184  int A_ibit_tmp;
185  long int list_1_j;
186  // off = j
187  list_1_j = j - 1;
188  A_ibit_tmp = ((list_1_j & is1_spin) / is1_spin) ^ (1 - sigma1);
189  return A_ibit_tmp;
190 }/*int X_SpinGC_CisAis*/
199  long int j,
200  long int is1_spin,
201  long int sigma2,
202  long int *tmp_off
203 ) {
204  long int list_1_j, ibit_tmp_1;
205 
206  list_1_j = j - 1;
207 
208  ibit_tmp_1 = list_1_j & is1_spin;
209  if (ibit_tmp_1 == 0 && sigma2 == 0) { // down -> up
210  *tmp_off = list_1_j + is1_spin;
211  return 1;
212  }
213  else if (ibit_tmp_1 != 0 && sigma2 == 1) { // up -> down
214  *tmp_off = list_1_j - is1_spin;
215  return 1;
216  }
217  else {
218  *tmp_off = 0;
219  return 0;
220  }
221 }/*int X_SpinGC_CisAit*/
222 
223 /******************************************************************************/
224 //[e] core routines
225 /******************************************************************************/
226 
234  long int j,
235  struct BindStruct *X,
236  long int isA_up,
237  long int isB_up,
238  long int sigmaA,
239  long int sigmaB,
240  long int *tmp_off
241 ) {
242  long int iexchg, off;
243  long int irght = X->Large.irght;
244  long int ilft = X->Large.ilft;
245  long int ihfbit = X->Large.ihfbit;
246  long int ibit_tmp_A, ibit_tmp_B;
247 
248  ibit_tmp_A = ((list_1[j] & isA_up) / isA_up);
249  ibit_tmp_B = ((list_1[j] & isB_up) / isB_up);
250  if (ibit_tmp_A == sigmaA && ibit_tmp_B == sigmaB) {
251  iexchg = list_1[j] ^ (isA_up + isB_up);
252  GetOffComp(list_2_1, list_2_2, iexchg, irght, ilft, ihfbit, &off);
253  *tmp_off = off;
254  return 1;
255  }
256  else {
257  *tmp_off = 0; // just tentative
258  return 0;
259  }
260 }/*int X_child_exchange_spin_element*/
267  long int j,
268  int nstate, std::complex<double> **tmp_v0,
269  std::complex<double> **tmp_v1,
270  struct BindStruct *X,
271  long int *tmp_off
272 ) {
273  long int off;
274  long int iexchg;
275  long int is_up = X->Large.isA_spin;
276  long int irght = X->Large.irght;
277  long int ilft = X->Large.ilft;
278  long int ihfbit = X->Large.ihfbit;
279  std::complex<double> tmp_J = X->Large.tmp_J;
280  long int ibit_tmp;
281  int one = 1;
282 
283  ibit_tmp = (list_1[j] & is_up);
284  if (ibit_tmp == 0 || ibit_tmp == is_up) {
285  return;
286  }
287  else {
288  iexchg = list_1[j] ^ is_up;
289  GetOffComp(list_2_1, list_2_2, iexchg, irght, ilft, ihfbit, &off);
290  *tmp_off = off;
291  zaxpy_(&nstate, &tmp_J, &tmp_v1[j][0], &one, &tmp_v0[off][0], &one);
292  }
293 }/*std::complex<double> child_exchange_spin_element*/
300  long int j,
301  int nstate, std::complex<double> **tmp_v0,
302  std::complex<double> **tmp_v1,
303  struct BindStruct *X,
304  long int *tmp_off
305 ) {
306  long int is_up = X->Large.isA_spin;
307  std::complex<double> tmp_J = X->Large.tmp_J;
308  long int list_1_j, list_1_off;
309  int one = 1;
310 
311  list_1_j = j - 1;
312 
313  long int ibit_tmp;
314  ibit_tmp = (list_1_j & is_up);
315  if (ibit_tmp == 0 || ibit_tmp == is_up) {
316  return;
317  }
318  else {
319  list_1_off = list_1_j ^ is_up;
320  *tmp_off = list_1_off;
321  zaxpy_(&nstate, &tmp_J, &tmp_v1[j][0], &one, &tmp_v0[list_1_off + 1][0], &one);
322  }
323 }/*std::complex<double> GC_child_exchange_spin_element*/
330  long int j,
331  int nstate, std::complex<double> **tmp_v0,
332  std::complex<double> **tmp_v1,
333  struct BindStruct *X,
334  long int *tmp_off
335 ) {
336  long int is_up = X->Large.isA_spin;
337  std::complex<double> tmp_J = X->Large.tmp_J;
338  int one = 1;
339  long int list_1_off;
340  long int list_1_j = j - 1;
341  long int ibit_tmp;
342  //ibit_tmp = ((list_1_j & is1_up) / is1_up) ^ ((list_1_j & is2_up) / is2_up);
343  ibit_tmp = (list_1_j & is_up);
344  if (ibit_tmp == 0 || ibit_tmp == is_up) {
345  list_1_off = list_1_j ^ is_up; //Change: ++ -> -- or -- -> ++
346  *tmp_off = list_1_off;
347  zaxpy_(&nstate, &tmp_J, &tmp_v1[j][0], &one, &tmp_v0[list_1_off + 1][0], &one);
348  }
349 }/*std::complex<double> GC_child_pairlift_spin_element*/
350 //[s]Spin
358  long int j,
359  long int isA_up,
360  long int isB_up,
361  long int org_sigma2,
362  long int org_sigma4,
363  std::complex<double> tmp_V,
364  int nstate, std::complex<double> **tmp_v0,
365  std::complex<double> **tmp_v1
366 ) {
367  int tmp_sgn;
368  std::complex<double> dmv;
369  int one = 1;
370 
371  tmp_sgn = X_Spin_CisAis(j, isB_up, org_sigma4);
372  tmp_sgn *= X_Spin_CisAis(j, isA_up, org_sigma2);
373  dmv = (std::complex<double>)tmp_sgn * tmp_V;
374  zaxpy_(&nstate, &dmv, &tmp_v1[j][0], &one, &tmp_v0[j][0], &one);
375 }/*std::complex<double> child_CisAisCisAis_spin_element*/
376 
377 //[e]Spin
378 
379 //[s]GC Spin
387  long int j,
388  long int isA_up,
389  long int isB_up,
390  long int org_sigma2,
391  long int org_sigma4,
392  std::complex<double> tmp_V,
393  int nstate, std::complex<double> **tmp_v0,
394  std::complex<double> **tmp_v1
395 ) {
396  int tmp_sgn;
397  std::complex<double> dmv = 0;
398  int one = 1;
399 
400  tmp_sgn = X_SpinGC_CisAis(j, isB_up, org_sigma4);
401  tmp_sgn *= X_SpinGC_CisAis(j, isA_up, org_sigma2);
402  if (tmp_sgn != 0) {
403  dmv = (std::complex<double>)tmp_sgn * tmp_V;
404  zaxpy_(&nstate, &dmv, &tmp_v1[j][0], &one, &tmp_v0[j][0], &one);
405  }
406 }/*std::complex<double> GC_child_CisAisCisAis_spin_element*/
414  long int j,
415  long int org_sigma2,
416  long int org_sigma4,
417  long int isA_up,
418  long int isB_up,
419  std::complex<double> tmp_V,
420  int nstate, std::complex<double> **tmp_v0,
421  std::complex<double> **tmp_v1,
422  long int *tmp_off
423 ) {
424  int tmp_sgn;
425  std::complex<double> dmv;
426  int one = 1;
427  tmp_sgn = X_SpinGC_CisAit(j, isB_up, org_sigma4, tmp_off);
428  if (tmp_sgn != 0) {
429  tmp_sgn *= X_SpinGC_CisAis((*tmp_off + 1), isA_up, org_sigma2);
430  if (tmp_sgn != 0) {
431  dmv = (std::complex<double>)tmp_sgn * tmp_V;
432  zaxpy_(&nstate, &dmv, &tmp_v1[j][0], &one, &tmp_v0[*tmp_off + 1][0], &one);
433  }/*if (tmp_sgn != 0)*/
434  }/*if (tmp_sgn != 0)*/
435 }/*std::complex<double> GC_child_CisAisCitAiu_spin_element*/
443  long int j,
444  long int org_sigma2,
445  long int org_sigma4,
446  long int isA_up,
447  long int isB_up,
448  std::complex<double> tmp_V,
449  int nstate, std::complex<double> **tmp_v0,
450  std::complex<double> **tmp_v1,
451  long int *tmp_off
452 ) {
453  int tmp_sgn;
454  std::complex<double> dmv;
455  int one = 1;
456  tmp_sgn = X_SpinGC_CisAis(j, isB_up, org_sigma4);
457  if (tmp_sgn != 0) {
458  tmp_sgn *= X_SpinGC_CisAit(j, isA_up, org_sigma2, tmp_off);
459  if (tmp_sgn != 0) {
460  dmv = (std::complex<double>)tmp_sgn * tmp_V;
461  zaxpy_(&nstate, &dmv, &tmp_v1[j][0], &one, &tmp_v0[*tmp_off + 1][0], &one);
462  }/*if (tmp_sgn != 0)*/
463  }/*if (tmp_sgn != 0)*/
464 }/*std::complex<double> GC_child_CisAitCiuAiu_spin_element*/
472  long int j,
473  long int org_sigma2,
474  long int org_sigma4,
475  long int isA_up,
476  long int isB_up,
477  std::complex<double> tmp_V,
478  int nstate, std::complex<double> **tmp_v0,
479  std::complex<double> **tmp_v1,
480  long int *tmp_off_2
481 ) {
482  int tmp_sgn;
483  long int tmp_off_1;
484  std::complex<double> dmv;
485  int one = 1;
486  tmp_sgn = X_SpinGC_CisAit(j, isB_up, org_sigma4, &tmp_off_1);
487  if (tmp_sgn != 0) {
488  tmp_sgn *= X_SpinGC_CisAit((tmp_off_1 + 1), isA_up, org_sigma2, tmp_off_2);
489  if (tmp_sgn != 0) {
490  dmv = (std::complex<double>)tmp_sgn * tmp_V;
491  zaxpy_(&nstate, &dmv, &tmp_v1[j][0], &one, &tmp_v0[*tmp_off_2 + 1][0], &one);
492  }/*if (tmp_sgn != 0)*/
493  }/*if (tmp_sgn != 0)*/
494 }/*std::complex<double> GC_child_CisAitCiuAiv_spin_element*/
495 //[e]GC Spin
struct DefineList Def
Definision of system (Hamiltonian) etc.
Definition: struct.hpp:395
void GC_child_CisAisCisAis_spin_element(long int j, long int isA_up, long int isB_up, long int org_sigma2, long int org_sigma4, std::complex< double > tmp_V, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1)
Compute term of grandcanonical spsin system.
long int is2_spin
Mask used in the bit oeration.
Definition: struct.hpp:334
long int * list_2_1
Definition: global.cpp:27
void GC_child_pairlift_spin_element(long int j, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, struct BindStruct *X, long int *tmp_off)
Multiply Hamiltonian of pairlift term of grandcanonical spin system.
long int * list_2_2
Definition: global.cpp:28
int X_Spin_CisAis(long int j, long int is1_spin, long int sigma1)
Compute the spin state with bit mask is1_spin.
void GC_child_CisAisCitAiu_spin_element(long int j, long int org_sigma2, long int org_sigma4, long int isA_up, long int isB_up, std::complex< double > tmp_V, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, long int *tmp_off)
Compute term of grandcanonical spsin system.
int ** ExchangeCoupling
[DefineList::NExchangeCoupling][2] Index of exchange term. malloc in setmem_def().
Definition: struct.hpp:146
int X_child_exchange_spin_element(long int j, struct BindStruct *X, long int isA_up, long int isB_up, long int sigmaA, long int sigmaB, long int *tmp_off)
Compute index of final wavefunction associated to spin-exchange term.
int child_general_int_spin_GetInfo(struct BindStruct *X, long int isite1, long int isite2, long int sigma1, long int sigma2, long int sigma3, long int sigma4, std::complex< double > tmp_V)
Set parameters for the bit operation of spin-general interaction term.
long int is1_up
Mask used in the bit oeration.
Definition: struct.hpp:326
int X_SpinGC_CisAis(long int j, long int is1_spin, long int sigma1)
Compute the grandcanonical spin state with bit mask is1_spin.
struct LargeList Large
Variables for Matrix-Vector product.
Definition: struct.hpp:397
std::complex< double > tmp_J
Coupling constant.
Definition: struct.hpp:324
long int * list_1_org
Definition: global.cpp:31
int isite2
Is it realy used ???
Definition: struct.hpp:338
long int is4_spin
Mask used in the bit oeration.
Definition: struct.hpp:336
long int irght
Used for Ogata-Lin ???
Definition: struct.hpp:344
int ** PairLiftCoupling
[DefineList::NPairHopping][2] Index of pair-lift term. malloc in setmem_def().
Definition: struct.hpp:154
long int ilft
Used for Ogata-Lin ???
Definition: struct.hpp:345
Bind.
Definition: struct.hpp:394
double * ParaExchangeCoupling
[DefineList::NExchangeCoupling] Coupling constant of exchange term. malloc in setmem_def().
Definition: struct.hpp:148
double * ParaPairLiftCoupling
[DefineList::NPairHopping] Coupling constant of pair-lift term. malloc in setmem_def().
Definition: struct.hpp:156
int GetOffComp(long int *_list_2_1, long int *_list_2_2, long int _ibit, const long int _irght, const long int _ilft, const long int _ihfbit, long int *_ioffComp)
function of getting off-diagonal component
Definition: bitcalc.cpp:195
long int ihfbit
Used for Ogata-Lin ???
Definition: struct.hpp:346
int child_exchange_spin_GetInfo(int iExchange, struct BindStruct *X)
Set parameters for the bit operation of spin-exchange term.
int child_pairlift_spin_GetInfo(int iPairLift, struct BindStruct *X)
Set parameters for the bit operation of spin-pairlift term.
void GC_child_exchange_spin_element(long int j, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, struct BindStruct *X, long int *tmp_off)
Multiply Hamiltonian of exchange term of grandcanonical spin system.
void child_exchange_spin_element(long int j, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, struct BindStruct *X, long int *tmp_off)
Multiply Hamiltonian of exchange term of canonical spin system.
long int * Tpow
[2 * DefineList::NsiteMPI] malloc in setmem_def().
Definition: struct.hpp:90
int X_SpinGC_CisAit(long int j, long int is1_spin, long int sigma2, long int *tmp_off)
Compute index of final wavefunction by term (grandcanonical).
void child_CisAisCisAis_spin_element(long int j, long int isA_up, long int isB_up, long int org_sigma2, long int org_sigma4, std::complex< double > tmp_V, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1)
Compute term of canonical spsin system.
long int is3_spin
Mask used in the bit oeration.
Definition: struct.hpp:335
long int is1_spin
Mask used in the bit oeration.
Definition: struct.hpp:333
int X_Spin_CisAit(long int j, struct BindStruct *X, long int is1_spin, long int sigma2, long int *tmp_off)
Compute index of final wavefunction by term.
long int isA_spin
Mask used in the bit oeration.
Definition: struct.hpp:347
void GC_child_CisAitCiuAiu_spin_element(long int j, long int org_sigma2, long int org_sigma4, long int isA_up, long int isB_up, std::complex< double > tmp_V, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, long int *tmp_off)
Compute term of grandcanonical spsin system.
int isite1
Is it realy used ???
Definition: struct.hpp:337
long int * list_1
Definition: global.cpp:25
long int is2_up
Mask used in the bit oeration.
Definition: struct.hpp:328
void GC_child_CisAitCiuAiv_spin_element(long int j, long int org_sigma2, long int org_sigma4, long int isA_up, long int isB_up, std::complex< double > tmp_V, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, long int *tmp_off_2)
Compute term of grandcanonical spsin system.
std::complex< double > tmp_V
Coupling constant.
Definition: struct.hpp:349