Skip to content

Commit

Permalink
add "reweight" in modpara.def
Browse files Browse the repository at this point in the history
  • Loading branch information
tmisawa committed Nov 21, 2024
1 parent d73d06b commit 1681c8a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/mVMC/include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ int NLanczosMode; /* mode of the single Lanczos step

int NStoreO; /* choice of store O: 0-> normal other-> store */
int NSRCG; /* choice of solver for Sx=g: 0-> (Sca)LAPACK other-> CG */
int reweight; /* 1: reweight in vmccal.c, vmccal_fsz.c, other: no reweight, default 0 */

int NDataIdxStart; /* starting value of the file index */
int NDataQtySmp; /* the number of output files */
Expand Down
4 changes: 4 additions & 0 deletions src/mVMC/readdef.c
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ int ReadDefFileNInt(char *xNameListFile, MPI_Comm comm) {
MPI_Bcast(&FlagRBM, 1, MPI_INT, 0, comm);
MPI_Bcast(&NStoreO, 1, MPI_INT, 0, comm); // for NStoreO
MPI_Bcast(&NSRCG, 1, MPI_INT, 0, comm); // for NCG
MPI_Bcast(&reweight, 1, MPI_INT, 0, comm); // for reweight
MPI_Bcast(&AllComplexFlag, 1, MPI_INT, 0, comm); // for Real
MPI_Bcast(&iFlgOrbitalGeneral, 1, MPI_INT, 0, comm); // for fsz
MPI_Bcast(bufDouble, nBufDouble, MPI_DOUBLE, 0, comm);
Expand Down Expand Up @@ -1820,6 +1821,7 @@ void SetDefaultValuesModPara(int *bufInt, double *bufDouble) {
bufDouble[IdxSROptCGTol] = 1.0e-10;
NStoreO = 1;
NSRCG = 0;
reweight = 0;
}

int GetInfoFromModPara(int *bufInt, double *bufDouble) {
Expand Down Expand Up @@ -1933,6 +1935,8 @@ int GetInfoFromModPara(int *bufInt, double *bufDouble) {
NStoreO = (int) dtmp;
} else if (CheckWords(ctmp, "NSRCG") == 0) {
NSRCG = (int) dtmp;
} else if (CheckWords(ctmp, "reweight") == 0) {
reweight = (int) dtmp;
//RBM
} else if (CheckWords(ctmp, "Nneuron") == 0) {
bufInt[IdxNneuron] = (int) dtmp;
Expand Down
11 changes: 8 additions & 3 deletions src/mVMC/vmccal.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void calculateQCACAQDC(double complex *qcacaq, const double complex *lslq, const
void VMCMainCal(MPI_Comm comm) {
int *eleIdx,*eleCfg,*eleNum,*eleProjCnt;
double complex e,ip;
double w;
double x,w;
double sqrtw;
double complex we;

Expand Down Expand Up @@ -148,9 +148,14 @@ void VMCMainCal(MPI_Comm comm) {
#ifdef _DEBUG_VMCCAL
printf(" Debug: sample=%d: LogProjVal \n",sample);
#endif
x = LogProjVal(eleProjCnt);
/* calculate reweight */
//w = exp(2.0*(log(fabs(ip))+x) - logSqPfFullSlater[sample]);
w =1.0;
if (reweight==1){
w = exp(2.0*(log(fabs(ip))+x) - logSqPfFullSlater[sample]);
}else{
w =1.0;
}

#ifdef _DEBUG_VMCCAL
printf(" Debug: sample=%d: isfinite \n",sample);
#endif
Expand Down
12 changes: 9 additions & 3 deletions src/mVMC/vmccal_fsz.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ along with this program. If not, see http://www.gnu.org/licenses/.
void VMCMainCal_fsz(MPI_Comm comm) {
int *eleIdx,*eleCfg,*eleNum,*eleProjCnt,*eleSpn; //fsz
double complex e,ip;
double w;
double w,x;
double sqrtw;
double complex we;
double Sz;
Expand Down Expand Up @@ -101,9 +101,15 @@ void VMCMainCal_fsz(MPI_Comm comm) {
#ifdef _DEBUG_DETAIL
printf(" Debug: sample=%d: LogProjVal \n",sample);
#endif
//LogProjVal(eleProjCnt);
/* calculate reweight */
w =1.0;
x = LogProjVal(eleProjCnt);
if (reweight==1){
w = exp(2.0*(log(fabs(ip))+x) - logSqPfFullSlater[sample]);
}else{
w =1.0;
}
//LogProjVal(eleProjCnt);
//w =1.0;
#ifdef _DEBUG_DETAIL
printf(" Debug: sample=%d: isfinite \n",sample);
#endif
Expand Down

0 comments on commit 1681c8a

Please sign in to comment.