18 #include "wrapperMPI.h"    19 #include "mltplyCommon.h"    20 #include "mltplyHubbard.h"    21 #include "mltplyHubbardCore.h"    22 #include "mltplyMPIHubbard.h"    23 #include "mltplyMPIHubbardCore.h"    39         double complex *tmp_v0, 
    40         double complex *tmp_v1 
    44     long unsigned int i,j;
    45     long unsigned int isite1;
    46     long unsigned int org_isite1,org_isite2,org_sigma1,org_sigma2;
    48     double complex tmp_trans=0;
    52     i_max = 
X->Check.idim_maxOrg;
    53     for(i=0;i<
X->Def.NPairExcitationOperator;i++) {
    54         org_isite1 = 
X->Def.PairExcitationOperator[i][0] + 1;
    55         org_isite2 = 
X->Def.PairExcitationOperator[i][2] + 1;
    56         org_sigma1 = 
X->Def.PairExcitationOperator[i][1];
    57         org_sigma2 = 
X->Def.PairExcitationOperator[i][3];
    58         tmp_trans = 
X->Def.ParaPairExcitationOperator[i];
    60         if (org_isite1 > 
X->Def.Nsite &&
    61             org_isite2 > 
X->Def.Nsite) {
    62             if (org_isite1 == org_isite2 && org_sigma1 == org_sigma2) {
    63                 if (
X->Def.PairExcitationOperator[i][4] == 0) {
    64                     if (org_sigma1 == 0) {
    65                         is = 
X->Def.Tpow[2 * org_isite1 - 2];
    68                         is = 
X->Def.Tpow[2 * org_isite1 - 1];
    70                     ibit = (
unsigned long int) 
myrank & is;
    72 #pragma omp parallel for default(none) shared(tmp_v0, tmp_v1)   \    73   firstprivate(i_max, tmp_trans) private(j)    74                         for (j = 1; j <= i_max; j++) tmp_v0[j] += tmp_trans * tmp_v1[j];
    78                     if (org_sigma1 == 0) {
    79                         is = 
X->Def.Tpow[2 * org_isite1 - 2];
    82                         is = 
X->Def.Tpow[2 * org_isite1 - 1];
    84                     ibit = (
unsigned long int) 
myrank & is;
    87 #pragma omp parallel for default(none) shared(tmp_v0, tmp_v1)   \    88   firstprivate(i_max, tmp_trans) private(j)    89                         for (j = 1; j <= i_max; j++) tmp_v0[j] += -tmp_trans * tmp_v1[j];
    98         else if (org_isite2 > 
X->Def.Nsite || org_isite1 > 
X->Def.Nsite) {
    99             if (org_isite1 < org_isite2) {
   105                                                   -conj(tmp_trans), 
X, tmp_v0, tmp_v1);
   110             if (org_isite1 == org_isite2 && org_sigma1 == org_sigma2 && 
X->Def.PairExcitationOperator[i][4] == 1) {
   111                 isite1=
X->Def.Tpow[2 * org_isite1 - 2 + org_sigma1];
   112 #pragma omp parallel for default(none) private(j) firstprivate(i_max,X,isite1, tmp_trans) shared(tmp_v0, tmp_v1)   113                 for(j=1;j<=i_max;j++){
   114                     GC_AisCis(j, tmp_v0, tmp_v1, 
X, isite1, -tmp_trans);
   139         double complex *tmp_v0, 
   140         double complex *tmp_v1 
   142     long unsigned int i,j, idim_maxMPI;
   143     long unsigned int irght,ilft,ihfbit;
   144     long unsigned int org_isite1,org_isite2,org_sigma1,org_sigma2;
   145     long unsigned int tmp_off=0;
   147     double complex tmp_trans=0;
   151     long unsigned int is, Asum, Adiff;
   152     long unsigned int ibitsite1, ibitsite2;
   155     i_max = 
X->Check.idim_maxOrg;
   159     X->Large.i_max    = i_max;
   160     X->Large.irght    = irght;
   161     X->Large.ilft     = ilft;
   162     X->Large.ihfbit   = ihfbit;
   163     X->Large.mode=M_CALCSPEC;
   166     double complex *tmp_v1bufOrg;
   169     idim_maxMPI = 
MaxMPI_li(
X->Check.idim_maxOrg);
   170     c_malloc1(tmp_v1bufOrg, idim_maxMPI + 1);
   173     for(i=0;i<
X->Def.NPairExcitationOperator;i++){
   174         org_isite1 = 
X->Def.PairExcitationOperator[i][0]+1;
   175         org_isite2 = 
X->Def.PairExcitationOperator[i][2]+1;
   176         org_sigma1 = 
X->Def.PairExcitationOperator[i][1];
   177         org_sigma2 = 
X->Def.PairExcitationOperator[i][3];
   178         tmp_trans = 
X->Def.ParaPairExcitationOperator[i];
   179         ibitsite1 = 
X->Def.OrgTpow[2*org_isite1-2+org_sigma1] ;
   180         ibitsite2 = 
X->Def.OrgTpow[2*org_isite2-2+org_sigma2] ;
   182         Asum = 
X->Large.isA_spin;
   183         Adiff = 
X->Large.A_spin;
   185         if(
X->Def.iFlagListModified == 
TRUE    186            && org_sigma1 != org_sigma2){
   187             if (org_isite1  > 
X->Def.Nsite &&
   188                 org_isite2  > 
X->Def.Nsite)
   190               X_child_CisAjt_MPIdouble(org_isite1-1, org_sigma1, org_isite2-1, org_sigma2, -tmp_trans, 
X, tmp_v0, tmp_v1, tmp_v1bufOrg, 
list_1_org, 
list_1buf_org, 
list_2_1, 
list_2_2);
   192             else if (org_isite2  > 
X->Def.Nsite
   193                      || org_isite1  > 
X->Def.Nsite)
   195                 if(org_isite1 < org_isite2) {
   203 #pragma omp parallel for default(none) shared(tmp_v0, tmp_v1,stdoutMPI) \   204   firstprivate(i_max, tmp_trans, Asum, Adiff, ibitsite1, ibitsite2, X, list_1_org, list_1, myrank) \   205   private(j, tmp_sgn, tmp_off)   206                 for (j = 1; j <= i_max; j++){
   208                   tmp_v0[tmp_off] += tmp_trans * tmp_sgn*tmp_v1[j];
   213             if (org_isite1  > 
X->Def.Nsite &&
   214                 org_isite2  > 
X->Def.Nsite) {
   215                 if(org_isite1==org_isite2 && org_sigma1==org_sigma2){
   216                     is = 
X->Def.Tpow[2 * org_isite1 - 2 + org_sigma1];
   217                     ibit = (
unsigned long int) 
myrank & is;
   218                     if( 
X->Def.PairExcitationOperator[i][4]==0) {
   220 #pragma omp parallel for default(none) shared(tmp_v0, tmp_v1)   \   221   firstprivate(i_max, tmp_trans) private(j)   222                             for (j = 1; j <= i_max; j++) tmp_v0[j] += tmp_trans * tmp_v1[j];
   227 #pragma omp parallel for default(none) shared(tmp_v0, tmp_v1)   \   228   firstprivate(i_max, tmp_trans) private(j)   229                             for (j = 1; j <= i_max; j++) tmp_v0[j] += -tmp_trans * tmp_v1[j];
   237             else if (org_isite2  > 
X->Def.Nsite || org_isite1  > 
X->Def.Nsite){
   238                 if(org_isite1 < org_isite2){
   249                 if(org_isite1==org_isite2 && org_sigma1==org_sigma2){
   250                     is = 
X->Def.Tpow[2 * org_isite1 - 2 + org_sigma1];
   251                     if( 
X->Def.PairExcitationOperator[i][4]==0) {
   252 #pragma omp parallel for default(none) shared(list_1, tmp_v0, tmp_v1) firstprivate(i_max, is, tmp_trans) private(num1, ibit)   253                         for (j = 1; j <= i_max; j++) {
   256                             tmp_v0[j] += tmp_trans * num1 * tmp_v1[j];
   260 #pragma omp parallel for default(none) shared(list_1, tmp_v0, tmp_v1) firstprivate(i_max, is, tmp_trans) private(num1, ibit)   261                         for (j = 1; j <= i_max; j++) {
   263                             num1 = (1-ibit / is);
   264                             tmp_v0[j] += -tmp_trans * num1 * tmp_v1[j];
 int GetPairExcitedStateHubbardGC(struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
double complex X_GC_child_general_hopp_MPIdouble(int org_isite1, int org_ispin1, int org_isite2, int org_ispin2, double complex tmp_trans, struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Hopping term in Hubbard + GC When both site1 and site2 are in the inter process region. 
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. 
long unsigned int * list_1buf_org
double complex X_GC_child_general_hopp_MPIsingle(int org_isite1, int org_ispin1, int org_isite2, int org_ispin2, double complex tmp_trans, struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Hopping term in Hubbard + GC When only site2 is in the inter process region. 
double complex X_child_CisAjt_MPIsingle(int org_isite1, int org_ispin1, int org_isite2, int org_ispin2, double complex tmp_trans, struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1, double complex *v1buf, long unsigned int *list_1_org, long unsigned int *list_1buf_org, long unsigned int *list_2_1_target, long unsigned int *list_2_2_target)
Hopping term in Hubbard (Kondo) + Canonical ensemble When only site2 is in the inter process region...
double complex child_general_hopp(double complex *tmp_v0, double complex *tmp_v1, struct BindStruct *X, double complex trans)
Compute hopping (canonical) 
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 GetSplitBitByModel(const int Nsite, const int iCalcModel, long unsigned int *irght, long unsigned int *ilft, long unsigned int *ihfbit)
function of splitting original bit into right and left spaces. 
long unsigned int * list_1_org
unsigned long int MaxMPI_li(unsigned long int idim)
MPI wrapper function to obtain maximum unsigned long integer across processes. 
long unsigned int * list_2_1
double complex X_child_general_hopp_MPIsingle(int org_isite1, int org_ispin1, int org_isite2, int org_ispin2, double complex tmp_trans, struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Hopping term in Hubbard (Kondo) + Canonical ensemble When only site2 is in the inter process region...
long unsigned int * list_1
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. 
long unsigned int * list_2_2
double complex X_child_CisAjt_MPIdouble(int org_isite1, int org_ispin1, int org_isite2, int org_ispin2, double complex tmp_trans, struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1, double complex *v1buf, long unsigned int *list_1_org, long unsigned int *list_1buf_org, long unsigned int *list_2_1_target, long unsigned int *list_2_2_target)
Hopping term in Hubbard + MPI When both site1 and site2 are in the inter process region. 
int GetPairExcitedStateHubbard(struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
double complex GC_child_general_hopp(double complex *tmp_v0, double complex *tmp_v1, struct BindStruct *X, double complex trans)
Commpute hopping term (grandcanonical) 
int myrank
Process ID, defined in InitializeMPI() 
double complex X_child_general_hopp_MPIdouble(int org_isite1, int org_ispin1, int org_isite2, int org_ispin2, double complex tmp_trans, struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Hopping term in Hubbard (Kondo) + Canonical ensemble When both site1 and site2 are in the inter proce...