Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separating Direct and Indirect Measurement of Two Body Green Function #5

Closed
wants to merge 9 commits into from
2 changes: 1 addition & 1 deletion src/mVMC/average.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ void WeightAverageGreenFunc(MPI_Comm comm) {
}
if(NLanczosMode>1){
/* QCisAjsQ and QCisAjsCktAltQ */
n = NLSHam*NLSHam*NCisAjs + NLSHam*NLSHam*NCisAjsCktAltDC;
n = NLSHam*NLSHam*NCisAjs + NLSHam*NLSHam*(NCisAjsCktAltDC+NCisAjsCktAlt);
if(AllComplexFlag==0){
vec_real=QCisAjsQ_real;
weightAverageReduce_real(n,vec_real,comm);
Expand Down
7 changes: 6 additions & 1 deletion src/mVMC/calgrn.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void CalculateGreenFunc(const double w, const double complex ip, int *eleIdx, in

tmp = GreenFunc2(ri,rj,rk,rl,s,t,ip,myEleIdx,eleCfg,myEleNum,eleProjCnt,
myProjCntNew,myBuffer);
PhysCisAjsCktAltDC[idx] += w*tmp;
LocalCisAjsCktAltDC[idx] = tmp;
}

#pragma omp master
Expand All @@ -92,6 +92,11 @@ void CalculateGreenFunc(const double w, const double complex ip, int *eleIdx, in
PhysCisAjs[idx] += w*LocalCisAjs[idx];
}

#pragma omp for private(idx) nowait
for (idx=0;idx<NCisAjsCktAltDC;idx++) {
PhysCisAjsCktAltDC[idx] += w*LocalCisAjsCktAltDC[idx];
}

#pragma omp master
{StopTimer(52);StartTimer(53);}

Expand Down
11 changes: 8 additions & 3 deletions src/mVMC/include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,9 @@ double *ParaQPOptTrans;

/* for Green functions */
int NCisAjs, **CisAjsIdx; /* [NCisAjs][3] */
int NCisAjsCktAlt, **CisAjsCktAltIdx; /* [NCisAjsCktAlt][8] */
int NCisAjsCktAlt, **CisAjsCktAltIdx; /* [NCisAjsCktAlt][2] */
int NCisAjsCktAltDC, **CisAjsCktAltDCIdx; /* [NCisAjsCktAltDC][6] */
int NCisAjsLz, **CisAjsLzIdx, **iOneBodyGIdx; /* For Lanczos method only for rank 0*/
int NCisAjsCktAltLz, **CisAjsCktAltLzIdx;
int **iOneBodyGIdx; /* For GF2 indirect measurement */

/* Optimization flag */
int *OptFlag; /* [NPara] 1: optimized, 0 or 2: fixed */
Expand Down Expand Up @@ -268,6 +267,7 @@ double complex *PhysCisAjs; /* [NCisAjs] */
double complex *PhysCisAjsCktAlt; /* [NCisAjsCktAlt] */
double complex *PhysCisAjsCktAltDC; /* [NCisAjsCktAltDC] */
double complex *LocalCisAjs; /* [NCisAjs] */
double complex *LocalCisAjsCktAltDC; /* [NCisAjsCktAltDC] */

double complex Sztot,Sztot2; /* <Sz>,<Sz^2> */

Expand All @@ -285,10 +285,13 @@ double *LSLQ_real; /* [NLSHam][NLSHam]*/ //TBC

double complex *QCisAjsQ; /* QCisAjsQ[NLSHam][NLSHam][NCisAjs]*/ //TBC
double complex *QCisAjsCktAltQ; /* QCisAjsCktAltQ[NLSHam][NLSHam][NCisAjsCktAlt]*/ //TBC
double complex *QCisAjsCktAltQDC; /* QCisAjsCktAltQ[NLSHam][NLSHam][NCisAjsCktAlt]
DC Lanczos Calculation */
double complex *LSLCisAjs; /* [NLSHam][NCisAjs]*/ //TBC

double *QCisAjsQ_real; /* QCisAjsQ[NLSHam][NLSHam][NCisAjs]*/ //TBC
double *QCisAjsCktAltQ_real; /* QCisAjsCktAltQ[NLSHam][NLSHam][NCisAjsCktAlt]*/ //TBC
double *QCisAjsCktAltQDC_real; /* QCisAjsCktAltQ[NLSHam][NLSHam][NCisAjsCktAlt]*/
double *LSLCisAjs_real; /* [NLSHam][NCisAjs]*/ //TBC

/***** Output File *****/
Expand All @@ -304,8 +307,10 @@ FILE *FileLS;
FILE *FileLSQQQQ;
FILE *FileLSQCisAjsQ;
FILE *FileLSQCisAjsCktAltQ;
FILE *FileLSQCisAjsCktAltQ;
FILE *FileLSCisAjs;
FILE *FileLSCisAjsCktAlt;
FILE *FileLSCisAjsCktAltDC;


/* FILE *FileTimerList; */
Expand Down
14 changes: 10 additions & 4 deletions src/mVMC/include/physcal_lanczos.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,48 @@ int PhysCalLanczos_real(
double *_QQQQ_real,
double *_QCisAjsQ_real,
double *_QCisAjsCktAltQ_real,
double *_QCisAjsCktAltQDC_real,
const int _nLSHam,
const int _Ns,
const int _nCisAjs,
const int _nCisAjsLz,
int **_iOneBodyGIdx,
int **_CisAjsLzIdx,
const int _nCisAjsCktAlt,
int **_CisAjsCktAlt,
const int _nCisAjsCktAltDC,
int **_CisAjsCktAltDC,
const int _NLanczosmode,
FILE *_FileLS,
FILE *_FileLSQQQQ,
FILE *_FileLSQCisAjsQ,
FILE *_FileLSQCisAjsCktAltQ,
FILE *_FileLSCisAjs,
FILE *_FileLSCisAjsCktAlt
FILE *_FileLSCisAjsCktAlt,
FILE *_FileLSCisAjsCktAltDC
);

int PhysCalLanczos_fcmp(
double complex* _QQQQ,
double complex* _QCisAjsQ,
double complex* _QCisAjsCktAltQ,
double complex* _QCisAjsCktAltQDC,
const int _nLSHam,
const int _Ns,
const int _nCisAjs,
const int _nCisAjsLz,
int **_iOneBodyGIdx,
int **_CisAjsLzIdx,
const int _nCisAjsCktAlt,
int **_CisAjsCktAlt,
const int _nCisAjsCktAltDC,
int **_CisAjsCktAltDC,
const int _NLanczosmode,
FILE *_FileLS,
FILE *_FileLSQQQQ,
FILE *_FileLSQCisAjsQ,
FILE *_FileLSQCisAjsCktAltQ,
FILE *_FileLSCisAjs,
FILE *_FileLSCisAjsCktAlt
FILE *_FileLSCisAjsCktAlt,
FILE *_FileLSCisAjsCktAltDC
);
#endif

Expand Down
9 changes: 8 additions & 1 deletion src/mVMC/initfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,15 @@ void InitFilePhysCal(int i, int rank) {
CDataFileHead, idx);
FileLSCisAjs = fopen(fileName, "w");

sprintf(fileName, "%s_ls_cisajscktalt_%03d.dat",
// CACA
sprintf(fileName, "%s_ls_cisajscktaltex_%03d.dat",
CDataFileHead, idx);
FileLSCisAjsCktAlt = fopen(fileName, "w");

// CACADC
sprintf(fileName, "%s_ls_cisajscktalt_%03d.dat",
CDataFileHead, idx);
FileLSCisAjsCktAltDC = fopen(fileName, "w");
}
}

Expand Down Expand Up @@ -176,6 +182,7 @@ void CloseFilePhysCal(int rank) {
#endif
fclose(FileLSCisAjs);
fclose(FileLSCisAjsCktAlt);
fclose(FileLSCisAjsCktAltDC);
}
}

Expand Down
59 changes: 44 additions & 15 deletions src/mVMC/physcal_lanczos.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,24 @@ int PhysCalLanczos_real
double *_QQQQ_real,
double *_QCisAjsQ_real,
double *_QCisAjsCktAltQ_real,
double *_QCisAjsCktAltQDC_real,
const int _nLSHam,
const int _Ns,
const int _nCisAjs,
const int _nCisAjsLz,
int **_iOneBodyGIdx,
int **_CisAjsLzIdx,
const int _nCisAjsCktAlt,
int **_CisAjsCktAlt,
const int _nCisAjsCktAltDC,
int **_CisAjsCktAltDC,
const int _NLanczosmode,
FILE *_FileLS,
FILE *_FileLSQQQQ,
FILE *_FileLSQCisAjsQ,
FILE *_FileLSQCisAjsCktAltQ,
FILE *_FileLSCisAjs,
FILE *_FileLSCisAjsCktAlt
FILE *_FileLSCisAjsCktAlt,
FILE *_FileLSCisAjsCktAltDC
)
{
int i=0;
Expand All @@ -53,8 +56,10 @@ int PhysCalLanczos_real
double alpha_m, ene_m, ene_vm;
double *LS_CisAjs_real;
double *LS_CisAjsCktAlt_real;
double *LS_CisAjsCktAltDC_real;
LS_CisAjs_real = (double*)malloc(sizeof(double)*_nCisAjs);
LS_CisAjsCktAlt_real = (double*)malloc(sizeof(double)*_nCisAjsCktAlt);
LS_CisAjsCktAltDC_real = (double*)malloc(sizeof(double)*_nCisAjsCktAltDC);

CalculateEne(_QQQQ_real[2], _QQQQ_real[3], _QQQQ_real[10], _QQQQ_real[11], _QQQQ_real[15],
&alpha_p, &ene_p, &ene_vp, &alpha_m, &ene_m, &ene_vm);
Expand Down Expand Up @@ -114,43 +119,55 @@ int PhysCalLanczos_real
fprintf(_FileLSQCisAjsCktAltQ, "\n");
#endif

CalculatePhysVal_real(_QQQQ_real[2], _QQQQ_real[3],
alpha, _QCisAjsCktAltQDC_real, _nCisAjsCktAltDC,
_nLSHam, LS_CisAjsCktAltDC_real);
/* zvo_ls_cisajscktalt.dat */
for (i = 0; i < _nCisAjsCktAltDC; i++) {
fprintf(_FileLSCisAjsCktAltDC, "%d %d %d %d %d %d %d %d % .18e 0.0\n",
_CisAjsCktAltDC[i][0], _CisAjsCktAltDC[i][1], _CisAjsCktAltDC[i][2], _CisAjsCktAltDC[i][3],
_CisAjsCktAltDC[i][4], _CisAjsCktAltDC[i][5], _CisAjsCktAltDC[i][6], _CisAjsCktAltDC[i][7],
LS_CisAjsCktAltDC_real[i]);
}
fprintf(_FileLSCisAjsCktAltDC, "\n");

CalculatePhysVal_real(_QQQQ_real[2], _QQQQ_real[3],
alpha, _QCisAjsCktAltQ_real, _nCisAjsCktAlt,
_nLSHam, LS_CisAjsCktAlt_real);
/* zvo_ls_cisajscktalt.dat */
/* zvo_ls_cisajscktaltex.dat */
for (i = 0; i < _nCisAjsCktAlt; i++) {
fprintf(_FileLSCisAjsCktAlt, "%d %d %d %d %d %d %d %d % .18e 0.0\n",
_CisAjsCktAlt[i][0], _CisAjsCktAlt[i][1], _CisAjsCktAlt[i][2], _CisAjsCktAlt[i][3],
_CisAjsCktAlt[i][4], _CisAjsCktAlt[i][5], _CisAjsCktAlt[i][6], _CisAjsCktAlt[i][7],
LS_CisAjsCktAlt_real[i]);

fprintf(_FileLSCisAjsCktAlt, "% .18e 0.0 ", LS_CisAjsCktAlt_real[i]); // LS_CisAjsCktAlt_real
}
fprintf(_FileLSCisAjsCktAlt, "\n");
}
free(LS_CisAjs_real);
free(LS_CisAjsCktAlt_real);
free(LS_CisAjsCktAltDC_real);
return 0;
}

int PhysCalLanczos_fcmp(
double complex* _QQQQ,
double complex* _QCisAjsQ,
double complex* _QCisAjsCktAltQ,
double complex* _QCisAjsCktAltQDC,
const int _nLSHam,
const int _Ns,
const int _nCisAjs,
const int _nCisAjsLz,
int **_iOneBodyGIdx,
int **_CisAjsLzIdx,
const int _nCisAjsCktAlt,
int **_CisAjsCktAlt,
const int _nCisAjsCktAltDC,
int **_CisAjsCktAltDC,
const int _NLanczosmode,
FILE *_FileLS,
FILE *_FileLSQQQQ,
FILE *_FileLSQCisAjsQ,
FILE *_FileLSQCisAjsCktAltQ,
FILE *_FileLSCisAjs,
FILE *_FileLSCisAjsCktAlt
FILE *_FileLSCisAjsCktAlt,
FILE *_FileLSCisAjsCktAltDC
)
{
int i=0;
Expand All @@ -160,8 +177,10 @@ int PhysCalLanczos_fcmp(
double alpha_m, ene_m, ene_vm;
double complex*LS_CisAjs;
double complex*LS_CisAjsCktAlt;
double complex*LS_CisAjsCktAltDC;
LS_CisAjs = (double complex*)malloc(sizeof(double complex)*_nCisAjs);
LS_CisAjsCktAlt = (double complex*)malloc(sizeof(double complex)*_nCisAjsCktAlt);
LS_CisAjsCktAltDC = (double complex*)malloc(sizeof(double complex)*_nCisAjsCktAltDC);

/* zvo_ls.dat */
if(!CalculateEne(creal(_QQQQ[2]),creal(_QQQQ[3]),
Expand Down Expand Up @@ -221,20 +240,30 @@ int PhysCalLanczos_fcmp(
}
fprintf(_FileLSQCisAjsCktAltQ, "\n");
#endif
CalculatePhysVal_fcmp(_QQQQ[2], _QQQQ[3],
alpha, _QCisAjsCktAltQDC, _nCisAjsCktAltDC,
_nLSHam, LS_CisAjsCktAltDC);
/* zvo_ls_cisajscktalt.dat */
for (i = 0; i < _nCisAjsCktAltDC; i++) {
fprintf(_FileLSCisAjsCktAltDC, "%d %d %d %d %d %d %d %d % .18e % .18e\n",
_CisAjsCktAltDC[i][0], _CisAjsCktAltDC[i][1], _CisAjsCktAltDC[i][2], _CisAjsCktAltDC[i][3],
_CisAjsCktAltDC[i][4], _CisAjsCktAltDC[i][5], _CisAjsCktAltDC[i][6], _CisAjsCktAltDC[i][7],
creal(LS_CisAjsCktAltDC[i]), cimag(LS_CisAjsCktAltDC[i]));
}
fprintf(_FileLSCisAjsCktAltDC, "\n");

CalculatePhysVal_fcmp(_QQQQ[2], _QQQQ[3],
alpha, _QCisAjsCktAltQ, _nCisAjsCktAlt,
_nLSHam, LS_CisAjsCktAlt);
/* zvo_ls_cisajs.dat */
/* zvo_ls_cisajscktaltex.dat */
for (i = 0; i < _nCisAjsCktAlt; i++) {
fprintf(_FileLSCisAjsCktAlt, "%d %d %d %d %d %d %d %d % .18e % .18e\n",
_CisAjsCktAlt[i][0], _CisAjsCktAlt[i][1], _CisAjsCktAlt[i][2], _CisAjsCktAlt[i][3],
_CisAjsCktAlt[i][4], _CisAjsCktAlt[i][5], _CisAjsCktAlt[i][6], _CisAjsCktAlt[i][7],
creal(LS_CisAjsCktAlt[i]), cimag(LS_CisAjsCktAlt[i]));
fprintf(_FileLSCisAjsCktAlt, "% .18e % .18e ", creal(LS_CisAjsCktAlt[i]), cimag(LS_CisAjsCktAlt[i])); // LS_CisAjsCktAlt_real
}
fprintf(_FileLSCisAjsCktAlt, "\n");
}
free(LS_CisAjs);
free(LS_CisAjsCktAlt);
free(LS_CisAjsCktAltDC);
return 0;
}

Expand Down
Loading