Skip to content

Commit

Permalink
mod CheckMPI.c
Browse files Browse the repository at this point in the history
  • Loading branch information
tmisawa committed Apr 17, 2024
1 parent 8faa525 commit f1e5a84
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 9 deletions.
44 changes: 41 additions & 3 deletions src/CheckMPI.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ int CheckMPI(struct BindStruct *X/**< [inout] */)
switch (X->Def.iCalcModel) /*2 (inner)*/ {

case Hubbard:
case tJ:
/**@brief
<li>For canonical Hubbard
DefineList::Nup, DefineList::Ndown, and DefineList::Ne should be
Expand All @@ -109,9 +108,33 @@ int CheckMPI(struct BindStruct *X/**< [inout] */)

break;/*case Hubbard:*/

case tJ:
/**@brief
<li>For canonical Hubbard
DefineList::Nup, DefineList::Ndown, and DefineList::Ne should be
differerent in each PE.</li>
*/
SmallDim = myrank;
for (isite = X->Def.Nsite; isite < X->Def.NsiteMPI; isite++) {
SpinNum = SmallDim % 4;
SmallDim /= 4;
if (SpinNum == 1 /*01*/) {
X->Def.Nup -= 1;
X->Def.Ne -= 1;
}
else if (SpinNum == 2 /*10*/) {
X->Def.Ndown -= 1;
X->Def.Ne -= 1;
}
/*else if (SpinNum == 3 //11){
X->Def.Nup -= 1;
X->Def.Ndown -= 1;
X->Def.Ne -= 2;
}*/
} /*for (isite = X->Def.Nsite; isite < X->Def.NsiteMPI; isite++)*/
break;/*case tJ:*/

case HubbardNConserved:
case tJNConserved:
case tJGC:/*is this correct?*/
/**@brief
<li>For N-conserved canonical Hubbard
DefineList::Ne should be differerent in each PE.</li>
Expand All @@ -126,6 +149,21 @@ int CheckMPI(struct BindStruct *X/**< [inout] */)

break; /*case HubbardNConserved:*/

case tJNConserved:
case tJGC:/*is this correct?*/
/**@brief
<li>For N-conserved canonical Hubbard
DefineList::Ne should be differerent in each PE.</li>
*/
SmallDim = myrank;
for (isite = X->Def.Nsite; isite < X->Def.NsiteMPI; isite++) {
SpinNum = SmallDim % 4;
SmallDim /= 4;
if (SpinNum == 1 /*01*/ || SpinNum == 2 /*10*/) X->Def.Ne -= 1;
//else if (SpinNum == 3 /*11*/) X->Def.Ne -= 2;
} /*for (isite = X->Def.Nsite; isite < X->Def.NsiteMPI; isite++)*/
break; /*case HubbardNConserved:*/

case KondoGC:
case Kondo:
/**@brief
Expand Down
9 changes: 7 additions & 2 deletions src/check.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ int check(struct BindStruct *X){
comb_down= Binomial(Ns, X->Def.Ne-i, comb, Ns);
comb_sum +=comb_up*comb_down;
}
//printf("Ns %ld iMinup %d iAllup %d Ne %d comb_sum %ld\n",Ns,iMinup,iAllup,X->Def.Ne,comb_sum);
break;

case tJ:
Expand All @@ -146,17 +147,18 @@ int check(struct BindStruct *X){

for(i=iMinup; i<= iAllup; i++){
comb_up = Binomial(Ns, i, comb, Ns);
comb_down = Binomial(Ns-i, X->Def.Ne-i, comb, Ns-i);
comb_down = Binomial(Ns-i, X->Def.Ne-i, comb, Ns);
comb_sum += comb_up*comb_down;
}
//printf("Ns %ld iMinup %d iAllup %d Ne %d comb_sum %ld\n",Ns,iMinup,iAllup,X->Def.Ne,comb_sum);
break;

case tJGC:
comb_sum=0;
for(i=0; i<= X->Def.Ne; i++){
comb_up = Binomial(Ns, i, comb, Ns);
for(j=0; j<= X->Def.Ne; j++){
comb_down = Binomial(Ns-i, j, comb, Ns-i);
comb_down = Binomial(Ns-i, j, comb, Ns);
comb_sum += comb_up*comb_down;
}
}
Expand Down Expand Up @@ -413,6 +415,9 @@ int check(struct BindStruct *X){
case Hubbard:
case Kondo:
case KondoNConserved:
case tJ:
case tJNConserved:
case tJGC:
//fprintf(stdoutMPI, "sdim=%ld =2^%d\n",X->Check.sdim,X->Def.Nsite);
fprintf(fp,"sdim=%ld =2^%d\n",X->Check.sdim,X->Def.Nsite);
break;
Expand Down
23 changes: 19 additions & 4 deletions src/sz.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ int sz(
fprintf(stdoutMPI, "%s", cProStartCalcSz);
TimeKeeper(X, cFileNameSzTimeKeep, cInitalSz, "w");
TimeKeeper(X, cFileNameTimeKeep, cInitalSz, "a");

if(X->Check.idim_max!=0){
/*[s] calculating the maximum size of Hilbert dimensions*/
switch(X->Def.iCalcModel){
Expand Down Expand Up @@ -344,7 +343,6 @@ int sz(
TimeKeeper(X, cFileNameTimeKeep, cOMPSzMid, "a");
icnt = 0;
for(ib=0;ib<X->Check.sdim;ib++){
//printf("ib=%lu jb=list_jb[ib]=%lu \n",ib,list_jb[ib]);
icnt += omp_sz_tJ(ib,ihfbit, X, list_1_, list_2_1_, list_2_2_, list_jb);
}
break;
Expand Down Expand Up @@ -424,6 +422,9 @@ int sz(
TimeKeeper(X, cFileNameTimeKeep, cOMPSzFinish, "a");
}
/* NConserved -> Normal */
// this part is move to the ene of sz.c so that this change is made even
// when idim_max=0
/*
if(X->Def.iFlgCalcSpec == CALCSPEC_NOT){
if(X->Def.iCalcModel == HubbardNConserved){
X->Def.iCalcModel = Hubbard;
Expand All @@ -435,7 +436,7 @@ int sz(
X->Def.iCalcModel = tJ;
}
}

*/
//Error message
if(i_max!=X->Check.idim_max){
//printf("DDD %lu %lu \n",i_max, X->Check.idim_max);
Expand All @@ -449,15 +450,29 @@ int sz(
fclose(fp_err);
exitMPI(-1);
}

free_li_2d_allocate(comb);
}
fprintf(stdoutMPI, "%s", cProEndCalcSz);
free(list_jb);

/* NConserved -> Normal */
if(X->Def.iFlgCalcSpec == CALCSPEC_NOT){
if(X->Def.iCalcModel == HubbardNConserved){
X->Def.iCalcModel = Hubbard;
}
if(X->Def.iCalcModel == KondoNConserved){
X->Def.iCalcModel = Kondo;
}
if(X->Def.iCalcModel == tJNConserved){
X->Def.iCalcModel = tJ;
}
}

if(X->Def.iFlgGeneralSpin==TRUE){
free(list_2_1_Sz);
free(list_2_2_Sz);
}
BarrierMPI();
return 0;
}

Expand Down

0 comments on commit f1e5a84

Please sign in to comment.