From 1681c8a6433023e23c6801172851c59ed772124a Mon Sep 17 00:00:00 2001 From: k013600 Date: Thu, 21 Nov 2024 13:55:14 +0900 Subject: [PATCH] add "reweight" in modpara.def --- src/mVMC/include/global.h | 1 + src/mVMC/readdef.c | 4 ++++ src/mVMC/vmccal.c | 11 ++++++++--- src/mVMC/vmccal_fsz.c | 12 +++++++++--- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/mVMC/include/global.h b/src/mVMC/include/global.h index 40f312ba..956f939a 100644 --- a/src/mVMC/include/global.h +++ b/src/mVMC/include/global.h @@ -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 */ diff --git a/src/mVMC/readdef.c b/src/mVMC/readdef.c index d19c96e6..14d55da5 100644 --- a/src/mVMC/readdef.c +++ b/src/mVMC/readdef.c @@ -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); @@ -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) { @@ -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; diff --git a/src/mVMC/vmccal.c b/src/mVMC/vmccal.c index 50a3fb39..8ece4f6a 100644 --- a/src/mVMC/vmccal.c +++ b/src/mVMC/vmccal.c @@ -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; @@ -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 diff --git a/src/mVMC/vmccal_fsz.c b/src/mVMC/vmccal_fsz.c index 9996b42d..c85085cc 100644 --- a/src/mVMC/vmccal_fsz.c +++ b/src/mVMC/vmccal_fsz.c @@ -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; @@ -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