17 #include "CalcSpectrum.h" 18 #include "CalcSpectrumByLanczos.h" 19 #include "CalcSpectrumByBiCG.h" 20 #include "CalcSpectrumByTPQ.h" 21 #include "CalcSpectrumByFullDiag.h" 25 #include "wrapperMPI.h" 27 #include "./common/setmemory.h" 31 #include "diagonalcalc.h" 52 double complex *dcSpectrum,
53 double complex *dcomega)
65 for (i = 0; i < Nomega; i++) {
66 fprintf(fp,
"%.10lf %.10lf %.10lf %.10lf \n",
68 creal(dcSpectrum[i]), cimag(dcSpectrum[i]));
96 unsigned long int i_max = 0;
98 int iFlagListModified =
FALSE;
104 double complex OmegaMax, OmegaMin;
105 double complex *dcSpectrum;
106 double complex *dcomega;
111 fprintf(stderr,
"Error: Fail to set Omega.\n");
122 dcSpectrum = cd_1d_allocate(Nomega);
123 dcomega = cd_1d_allocate(Nomega);
126 for (i = 0; i < Nomega; i++) {
127 dcomega[i] = (OmegaMax - OmegaMin) / Nomega * i + OmegaMin;
130 fprintf(
stdoutMPI,
"\nFrequency range:\n");
131 fprintf(
stdoutMPI,
" Omega Max. : %15.5e %15.5e\n", creal(OmegaMax), cimag(OmegaMax));
132 fprintf(
stdoutMPI,
" Omega Min. : %15.5e %15.5e\n", creal(OmegaMin), cimag(OmegaMin));
133 fprintf(
stdoutMPI,
" Num. of Omega : %d\n", Nomega);
136 fprintf(stderr,
"Error: Any excitation operators are not defined.\n");
158 fprintf(
stdoutMPI,
" Start: An Eigenvector is inputted in CalcSpectrum.\n");
161 strcat(defname,
"_rank_%d.dat");
163 sprintf(sdt, defname,
myrank);
167 fprintf(stderr,
"Error: A file of Input vector does not exist.\n");
171 byte_size = fread(&i_stp,
sizeof(i_stp), 1, fp);
173 byte_size = fread(&i_max,
sizeof(i_max), 1, fp);
175 fprintf(stderr,
"Error: myrank=%d, i_max=%ld\n",
myrank, i_max);
176 fprintf(stderr,
"Error: A file of Input vector is incorrect.\n");
179 byte_size = fread(
v1Org,
sizeof(complex
double), i_max + 1, fp);
182 if (byte_size == 0) printf(
"byte_size: %d \n", (
int) byte_size);
187 fprintf(
stdoutMPI,
" End: An Input vector is inputted in CalcSpectrum.\n\n");
190 fprintf(
stdoutMPI,
" Start: Calculating an excited vector.\n");
199 if (fabs(dnorm) < pow(10.0, -15)) {
200 fprintf(stderr,
"Warning: Norm of an excited vector becomes 0.\n");
201 fprintf(
stdoutMPI,
" End: Calculating an excited vector.\n\n");
203 fprintf(
stdoutMPI,
" End: Calculating a spectrum.\n\n");
205 for (i = 0; i < Nomega; i++) {
212 #pragma omp parallel for default(none) private(i) shared(v1, v0) firstprivate(i_max, dnorm, X) 214 v1[i] =
v0[i] / dnorm;
219 fprintf(
stdoutMPI,
" Start: Output an excited vector.\n\n");
226 fprintf(fp,
"%.10lf, %.10lf\n", creal(
v1[i]), cimag(
v1[i]));
229 fprintf(
stdoutMPI,
" End: Output an excited vector.\n\n");
232 fprintf(
stdoutMPI,
" End: Calculating an excited vector.\n\n");
237 if (iFlagListModified ==
TRUE) {
248 fprintf(
stdoutMPI,
" Start: Calculating a spectrum.\n\n");
275 fprintf(stderr,
" Error: TPQ is not supported for calculating spectrum mode.\n");
295 fprintf(stderr,
" Error: The selected calculation type is not supported for calculating spectrum mode.\n");
299 fprintf(
stdoutMPI,
" End: Calculating a spectrum.\n\n");
302 free_cd_1d_allocate(dcSpectrum);
303 free_cd_1d_allocate(dcomega);
318 double complex *tmp_v0,
319 double complex *tmp_v1
323 fprintf(stderr,
"Error: Both single and pair excitation operators exist.\n");
356 double E1, E2, E3, E4, Emax;
357 long unsigned int iline_countMax=2;
358 long unsigned int iline_count=2;
369 fprintf(
stdoutMPI,
"Error: xx_Lanczos_Step.dat does not exist.\n");
374 while (
fgetsMPI(ctmp, 256, fp) != NULL) {
377 iline_countMax = iline_count;
383 while (
fgetsMPI(ctmp, 256, fp) != NULL) {
384 sscanf(ctmp,
"stp=%d %lf %lf %lf %lf %lf\n",
392 if (iline_count == iline_countMax)
break;
396 fprintf(
stdoutMPI,
"Error: Lanczos step must be greater than 4 for using spectrum calculation.\n");
405 fprintf(
stdoutMPI,
"Error: xx_energy.dat does not exist.\n");
410 sscanf(ctmp,
" Energy %lf \n", &E1);
439 *iFlgListModifed =
FALSE;
453 case HubbardNConserved:
457 *iFlgListModifed =
TRUE;
467 case HubbardNConserved:
474 *iFlgListModifed =
TRUE;
482 if (*iFlgListModifed ==
TRUE) {
517 case HubbardNConserved:
558 case HubbardNConserved:
617 if (*iFlgListModifed ==
TRUE) {
623 fprintf(stdout,
"Debug2: myrank=%d, list_1[ %ld] = %ld\n",
myrank, j,
list_1[j]+
myrank* 64);
unsigned int NSingleExcitationOperator
Number of single excitaion operator for spectrum.
int childfopenALL(const char *_cPathChild, const char *_cmode, FILE **_fp)
All processes open file in output/ directory.
void exitMPI(int errorcode)
MPI Abortation wrapper.
struct DefineList Def
Definision of system (Hamiltonian) etc.
int iFlgSpecOmegaMin
Whether DefineList::dcOmegaMin is input or not.
int MakeExcitedList(struct BindStruct *X, int *iFlgListModifed)
Make the lists for the excited state; list_1, list_2_1 and list_2_2 (for canonical ensemble)...
void StartTimer(int n)
function for initializing elapse time [start]
long unsigned int * list_2_1_org
unsigned long int idim_max
The dimension of the Hilbert space of this process.
int CalcSpectrumByFullDiag(struct EDMainCalStruct *X, int Nomega, double complex *dcSpectrum, double complex *dcomega)
Compute the Green function with the Lehmann representation and FD .
int sz(struct BindStruct *X, long unsigned int *list_1_, long unsigned int *list_2_1_, long unsigned int *list_2_2_)
generating Hilbert space
void StopTimer(int n)
function for calculating elapse time [elapse time=StartTimer-StopTimer]
int Total2Sz
Total in this process.
const char * c_InputEigenVectorEnd
int iFlagListModified
When the Hilbert space of excited state differs from the original one.
double complex dcOmegaMax
Upper limit of the frequency for the spectrum.
const char * c_CalcSpectrumEnd
struct LargeList Large
Variables for Matrix-Vector product.
unsigned long int idim_maxMPIOrg
The global Hilbert-space dimention of original state for the spectrum.
int childfopenMPI(const char *_cPathChild, const char *_cmode, FILE **_fp)
Only the root process open file in output/ directory.
unsigned int Nup
Number of spin-up electrons in this process.
const char * cFileNameOutputExcitedVec
const char * c_CalcExcitedStateEnd
unsigned long int idim_maxMPI
The total dimension across process.
long int SizeOflist_2_1
Size of list_2_1.
const char * cFileNameLanczosStep
int check(struct BindStruct *X)
A program to check size of dimension for Hilbert-space.
int setmem_large(struct BindStruct *X)
Set size of memories for Hamiltonian (Ham, L_vec), vectors(vg, v0, v1, v2, vec, alpha, beta), lists (list_1, list_2_1, list_2_2, list_Diagonal) and Phys(BindStruct.PhysList) struct in the case of Full Diag mode.
long unsigned int * list_1buf_org
int GetPairExcitedState(struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Calculating the pair excited state by the pair operator; , where indicates a creation (anti-creat...
const char * c_CalcSpectrumStart
int GetExcitedState(struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Parent function to calculate the excited state.
double NormMPI_dc(unsigned long int idim, double complex *_v1)
Compute norm of process-distributed vector .
long unsigned int * OrgTpow
[2 * DefineList::NsiteMPI] malloc in setmem_def().
int iErrCodeMem
Error Message in HPhiMain.c.
unsigned int NupOrg
Number of spin-up electrons before exitation. Used only in the spectrum calculation. Read from modpara in readdef.h.
long unsigned int * list_2_2_org
unsigned int NeMPI
Total number of electrons across process. Differ from DefineList::Ne .
unsigned int Ndown
Number of spin-down electrons in this process.
const char * cFileNameCalcDynamicalGreen
int CalcSpectrumByBiCG(struct EDMainCalStruct *X, double complex *vrhs, double complex *v2, double complex *v4, int Nomega, double complex *dcSpectrum, double complex *dcomega)
A main function to calculate spectrum by BiCG method In this function, the library is used...
const char * c_InputEigenVectorStart
int diagonalcalc(struct BindStruct *X)
Calculate diagonal components and obtain the list, list_diagonal.
int CalcSpectrumByLanczos(struct EDMainCalStruct *X, double complex *tmp_v1, double dnorm, int Nomega, double complex *dcSpectrum, double complex *dcomega)
A main function to calculate spectrum by continued fraction expansions.
unsigned long int idim_maxOrg
The local Hilbert-space dimention of original state for the spectrum.
unsigned int Nsite
Number of sites in the INTRA process region.
int CalcSpectrumByTPQ(struct EDMainCalStruct *X, double complex *tmp_v1, double dnorm, int Nomega, double complex *dcSpectrum, double complex *dcomega)
A main function to calculate spectrum by TPQ (Note: This method is trial)
const char * c_CalcExcitedStateStart
long unsigned int * list_1_org
int ** SingleExcitationOperator
[DefineList::NSingleExcitationOperator][3] Indices of single excitaion operator for spectrum...
long unsigned int * list_2_1
int GetlistSize(struct BindStruct *X)
Set size of lists for the canonical ensemble.
void FinalizeMPI()
MPI Finitialization wrapper.
int CalcSpectrum(struct EDMainCalStruct *X)
A main function to calculate spectrum.
unsigned int NsiteMPI
Total number of sites, differ from DefineList::Nsite.
int iFlgGeneralSpin
Flag for the general (Sz/=1/2) spin.
int SetOmega(struct DefineList *X)
Set target frequencies.
int iNOmega
Number of frequencies for spectrum.
long unsigned int * list_1
int iFlgSpecOmegaOrg
Whether DefineList::dcOmegaOrg is input or not.
unsigned int NPairExcitationOperator
Number of pair excitaion operator for spectrum.
const char * cFileNameTimeKeep
long unsigned int * list_2_2
int ** PairExcitationOperator
[DefineList::NPairExcitationOperator][5] Indices of pair excitaion operator for spectrum. malloc in setmem_def().
unsigned int NdownOrg
Number of spin-down electrons before exitation. Used only in the spectrum calculation. Read from modpara in readdef.h.
unsigned int Ne
Number of electrons in this process.
double complex dcOmegaOrg
Origin limit of the frequency for the spectrum.
int iFlgSpecOmegaMax
Whether DefineList::dcOmegaMax is input or not.
int iCalcModel
Switch for model. 0:Hubbard, 1:Spin, 2:Kondo, 3:HubbardGC, 4:SpinGC, 5:KondoGC, 6:HubbardNConserved.
double complex dcOmegaMin
Lower limit of the frequency for the spectrum.
int GetSingleExcitedState(struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Calculation of single excited state Target System: Hubbard, Kondo.
int myrank
Process ID, defined in InitializeMPI()
int iFlgCalcSpec
Input parameter CalcSpec in teh CalcMod file.
int OutputSpectrum(struct EDMainCalStruct *X, int Nomega, double complex *dcSpectrum, double complex *dcomega)
Output spectrum.
int GetFileNameByKW(int iKWidx, char **FileName)
function of getting file name labeled by the keyword
char * fgetsMPI(char *InputString, int maxcount, FILE *fp)
MPI file I/O (get a line, fgets) wrapper. Only the root node (myrank = 0) reads and broadcast string...
const char * cFileNameEnergy_Lanczos
struct CheckList Check
Size of the Hilbert space.
char * CDataFileHead
Read from Calcmod in readdef.h. Header of output file such as Green's function.
long int SizeOflist_2_2
Size of list_2_2.
struct BindStruct Bind
Binded struct.
Definision of system (Hamiltonian) etc.
int TimeKeeper(struct BindStruct *X, const char *cFileName, const char *cTimeKeeper_Message, const char *cWriteType)
Functions for writing a time log.
int Total2SzMPI
Total across processes.
int iCalcType
Switch for calculation type. 0:Lanczos, 1:TPQCalc, 2:FullDiag.
FILE * stdoutMPI
File pointer to the standard output defined in InitializeMPI()