17 #include "CalcSpectrum.hpp" 18 #include "CalcSpectrumByBiCG.hpp" 19 #include "CalcSpectrumByFullDiag.hpp" 20 #include "CalcTime.hpp" 21 #include "SingleEx.hpp" 23 #include "wrapperMPI.hpp" 25 #include "common/setmemory.hpp" 26 #include "readdef.hpp" 29 #include "diagonalcalc.hpp" 53 char sdt[D_FileNameMax], ctmp[256];
55 double E1, E2, E3, E4, Emax;
56 long int iline_countMax = 2;
57 long int iline_count = 2;
68 fprintf(
stdoutMPI,
"Error: xx_Lanczos_Step.dat does not exist.\n");
73 while (
fgetsMPI(ctmp, 256, fp) != NULL) {
76 iline_countMax = iline_count;
82 while (
fgetsMPI(ctmp, 256, fp) != NULL) {
83 sscanf(ctmp,
"stp=%d %lf %lf %lf %lf %lf\n",
91 if (iline_count == iline_countMax)
break;
95 fprintf(
stdoutMPI,
"Error: Lanczos step must be greater than 4 for using spectrum calculation.\n");
104 fprintf(
stdoutMPI,
"Error: xx_energy.dat does not exist.\n");
109 sscanf(ctmp,
" Energy %lf \n", &E1);
137 *iFlgListModifed = FALSE;
139 if (
check(X) == MPIFALSE) {
151 case HubbardNConserved:
155 *iFlgListModifed = TRUE;
166 case HubbardNConserved:
173 *iFlgListModifed = TRUE;
182 if (*iFlgListModifed == TRUE) {
186 long int MAXidim_max;
216 case HubbardNConserved:
261 case HubbardNConserved:
302 if (
check(X) == MPIFALSE) {
310 fprintf(
stdoutMPI,
"Error: Fail for memory allocation.\n");
317 long int MAXidim_max, MAXidim_maxOrg;
320 if (MAXidim_max < MAXidim_maxOrg) {
321 free_cd_2d_allocate(
v1buf);
322 v1buf = cd_2d_allocate(MAXidim_maxOrg + 1, 1);
331 if (*iFlgListModifed == TRUE) {
333 fprintf(stdout,
"Debug1: myrank=%d, list_1_org[ %ld] = %ld\n",
338 fprintf(stdout,
"Debug2: myrank=%d, list_1[ %ld] = %ld\n",
myrank, j,
list_1[j] +
myrank * 64);
355 std::complex<double> **dcSpectrum,
356 std::complex<double> *dcomega)
359 char sdt[D_FileNameMax];
360 int iomega, idcSpectrum;
368 for (idcSpectrum = 0; idcSpectrum < NdcSpectrum; idcSpectrum++) {
369 for (iomega = 0; iomega < Nomega; iomega++) {
370 fprintf(fp,
"%.10lf %.10lf %.10lf %.10lf \n",
372 real(dcSpectrum[iomega][idcSpectrum]), imag(dcSpectrum[iomega][idcSpectrum]));
390 std::complex<double> **tmp_v0,
391 std::complex<double> **tmp_v1,
425 char sdt[D_FileNameMax];
429 int i_stp, NdcSpectrum;
430 int iFlagListModified = FALSE;
432 std::complex<double> **v1Org;
436 std::complex<double> OmegaMax, OmegaMin;
437 std::complex<double> **dcSpectrum;
438 std::complex<double> *dcomega;
448 free_li_1d_allocate(
list_1);
453 free_cd_2d_allocate(
v0);
456 free_cd_2d_allocate(
v1);
459 free_cd_2d_allocate(
v1buf);
476 fprintf(stderr,
"Error: Fail to set Omega.\n");
488 dcomega = cd_1d_allocate(Nomega);
491 for (i = 0; i < Nomega; i++) {
492 dcomega[i] = OmegaMin
493 + (OmegaMax - OmegaMin) / (std::complex<double>)Nomega * (std::complex<double>)i;
496 fprintf(
stdoutMPI,
"\nFrequency range:\n");
497 fprintf(
stdoutMPI,
" Omega Max. : %15.5e %15.5e\n", real(OmegaMax), imag(OmegaMax));
498 fprintf(
stdoutMPI,
" Omega Min. : %15.5e %15.5e\n", real(OmegaMin), imag(OmegaMin));
499 fprintf(
stdoutMPI,
" Num. of Omega : %d\n", Nomega);
503 fprintf(stderr,
"Error: Any excitation operators are not defined.\n");
514 fprintf(stderr,
"Error: Both single and pair excitation operators exist.\n");
517 dcSpectrum = cd_2d_allocate(Nomega, NdcSpectrum);
533 fprintf(
stdoutMPI,
" Start: An Eigenvector is inputted in CalcSpectrum.\n");
534 TimeKeeper(&(X->
Bind),
"%s_TimeKeeper.dat",
"Reading an input Eigenvector starts: %s",
"a");
536 strcat(defname,
"_rank_%d.dat");
538 sprintf(sdt, defname,
myrank);
542 fprintf(stderr,
"Error: A file of Inputvector does not exist.\n");
546 byte_size = fread(&i_stp,
sizeof(i_stp), 1, fp);
548 byte_size = fread(&i_max,
sizeof(i_max), 1, fp);
550 fprintf(stderr,
"Error: myrank=%d, i_max=%ld\n",
myrank, i_max);
551 fprintf(stderr,
"Error: A file of Input vector is incorrect.\n");
554 byte_size = fread(&v1Org[0][0],
sizeof(std::complex<double>), i_max + 1, fp);
557 if (byte_size == 0) printf(
"byte_size: %d \n", (
int)byte_size);
564 fprintf(
stdoutMPI,
" Start: Calculating a spectrum.\n\n");
565 TimeKeeper(&(X->
Bind),
"%s_TimeKeeper.dat",
"Calculating a spectrum starts: %s",
"a");
583 fprintf(stderr,
" Error: The selected calculation type is not supported for calculating spectrum mode.\n");
587 fprintf(
stdoutMPI,
" End: Calculating a spectrum.\n\n");
588 TimeKeeper(&(X->
Bind),
"%s_TimeKeeper.dat",
"Calculating a spectrum finishes: %s",
"a");
589 iret =
OutputSpectrum(X, Nomega, NdcSpectrum, dcSpectrum, dcomega);
590 free_cd_2d_allocate(dcSpectrum);
591 free_cd_1d_allocate(dcomega);
double * doublon
Expectation value of the Doublon.
void exitMPI(int errorcode)
MPI Abortation wrapper.
int Nup
Number of spin-up electrons in this process.
long int idim_maxMPIOrg
The global Hilbert-space dimention of original state for the spectrum.
struct DefineList Def
Definision of system (Hamiltonian) etc.
int NeMPI
Total number of electrons across process. Differ from DefineList::Ne .
int iFlgSpecOmegaMin
Whether DefineList::dcOmegaMin is input or not.
double * num_down
Expectation value of the number of down-spin electtrons.
int CalcSpectrumByFullDiag(struct EDMainCalStruct *X, int Nomega, int NdcSpectrum, std::complex< double > **dcSpectrum, std::complex< double > *dcomega, std::complex< double > **v1Org)
Compute the Green function with the Lehmann representation and FD .
double * var
Expectation value of the Energy variance.
int GetExcitedState(struct BindStruct *X, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, int iEx)
Parent function to calculate the excited state.
FILE * stdoutMPI
File pointer to the standard output defined in InitializeMPI()
int NupMPI
Total number of spin-up electrons across processes. Deffer from DefineList::Nup. Read from modpara in...
int childfopenALL(const char *_cPathChild, const char *_cmode, FILE **_fp)
All processes open file in output/ directory.
long int * OrgTpow
[2 * DefineList::NsiteMPI] malloc in setmem_def().
std::complex< double > ** v1buf
int GetFileNameByKW(int iKWidx, char **FileName)
function of getting file name labeled by the keyword
void FinalizeMPI()
MPI Finitialization wrapper.
std::complex< double > ** v0
int Total2Sz
Total in this process.
int iFlagListModified
When the Hilbert space of excited state differs from the original one.
std::complex< double > dcOmegaMin
Lower limit of the frequency for the spectrum.
double * s2
Expectation value of the square of the total S.
int Nsite
Number of sites in the INTRA process region.
long int idim_maxOrg
The local Hilbert-space dimention of original state for the spectrum.
long int idim_maxMPI
The total dimension across process.
int GetPairExcitedState(struct BindStruct *X, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, int iEx)
Calculating the pair excited state by the pair operator; , where indicates a creation (anti-creat...
std::complex< double > I(0.0, 1.0)
struct LargeList Large
Variables for Matrix-Vector product.
double * num2
Expectation value of the quare of the number of electrons.
struct PhysList Phys
Physical quantities.
double * Sz2
Expectation value of the Square of total Sz.
long int SizeOflist_2_1
Size of list_2_1.
long int MaxMPI_li(long int idim)
MPI wrapper function to obtain maximum unsigned long integer across processes.
std::complex< double > ** v1
int SetOmega(struct DefineList *X)
Set target frequencies.
int diagonalcalc(struct BindStruct *X)
Calculate diagonal components and obtain the list, list_diagonal.
double * Sz
Expectation value of the Total Sz.
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)...
int sz(struct BindStruct *X, long int *list_1_, long int *list_2_1_, long int *list_2_2_)
generating Hilbert space
int NsiteMPI
Total number of sites, differ from DefineList::Nsite.
int NNSingleExcitationOperator
Number of single excitaion operator for spectrum.
std::complex< double > dcOmegaOrg
Origin limit of the frequency for the spectrum.
int Ne
Number of electrons in this process.
double * num
Expectation value of the Number of electrons.
int NdownOrg
Number of spin-down electrons before exitation. Used only in the spectrum calculation. Read from modpara in readdef.h.
int GetSingleExcitedState(struct BindStruct *X, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, int iEx)
Calculation of single excited state Target System: Hubbard, Kondo.
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...
double * energy
Expectation value of the total energy.
int myrank
Process ID, defined in InitializeMPI()
int iFlgGeneralSpin
Flag for the general (Sz/=1/2) spin.
int iNOmega
Number of frequencies for spectrum.
std::complex< double > dcOmegaMax
Upper limit of the frequency for the spectrum.
void StopTimer(int n)
function for calculating elapse time [elapse time=StartTimer-StopTimer]
int iFlgSpecOmegaOrg
Whether DefineList::dcOmegaOrg is input or not.
double * doublon2
Expectation value of the Square of doublon.
int CalcSpectrum(struct EDMainCalStruct *X)
A main function to calculate spectrum.
int check(struct BindStruct *X)
A program to check size of dimension for Hilbert-space.
int OutputSpectrum(struct EDMainCalStruct *X, int Nomega, int NdcSpectrum, std::complex< double > **dcSpectrum, std::complex< double > *dcomega)
Output spectrum.
int iFlgSpecOmegaMax
Whether DefineList::dcOmegaMax is input or not.
int setmem_large(struct BindStruct *X)
Set size of memories for 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.
int TimeKeeper(struct BindStruct *X, const char *cFileName, const char *cTimeKeeper_Message, const char *cWriteType)
Functions for writing a time log.
double * num_up
Expectation value of the number of up-spin electtrons.
int iCalcModel
Switch for model. 0:Hubbard, 1:Spin, 2:Kondo, 3:HubbardGC, 4:SpinGC, 5:KondoGC, 6:HubbardNConserved.
int GetlistSize(struct BindStruct *X)
Set size of lists for the canonical ensemble.
int NdownMPI
Total number of spin-down electrons across processes. Deffer from DefineList::Ndown. Read from modpara in readdef.h.
int iFlgCalcSpec
Input parameter CalcSpec in teh CalcMod file.
int Ndown
Number of spin-down electrons in this process.
int CalcSpectrumByBiCG(struct EDMainCalStruct *X, std::complex< double > **v2, std::complex< double > **v4, int Nomega, int NdcSpectrum, std::complex< double > **dcSpectrum, std::complex< double > *dcomega, std::complex< double > **v1Org)
A main function to calculate spectrum by BiCG method In this function, the library is used...
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.
int NupOrg
Number of spin-up electrons before exitation. Used only in the spectrum calculation. Read from modpara in readdef.h.
int NNPairExcitationOperator
Number of pair excitaion operator for spectrum.
int *** SingleExcitationOperator
[DefineList::NSingleExcitationOperator][3] Indices of single excitaion operator for spectrum...
long int idim_max
The dimension of the Hilbert space of this process.
long int SizeOflist_2_2
Size of list_2_2.
int *** PairExcitationOperator
[DefineList::NPairExcitationOperator][5] Indices of pair excitaion operator for spectrum. malloc in setmem_def().
struct BindStruct Bind
Binded struct.
Definision of system (Hamiltonian) etc.
int Total2SzMPI
Total across processes.
int iCalcType
Switch for calculation type. 0:Lanczos, 1:TPQCalc, 2:FullDiag.
void StartTimer(int n)
function for initializing elapse time [start]
int childfopenMPI(const char *_cPathChild, const char *_cmode, FILE **_fp)
Only the root process open file in output/ directory.