16 #include "CalcSpectrumByTPQ.h"    17 #include "Lanczos_EigenValue.h"    19 #include "wrapperMPI.h"    51     double dene, dHvar, dn, ddoublon;
    56         fprintf(stderr, 
"  Error:  SS_rand%d.dat does not exist.\n", 
X->
Bind.
Def.
irand);
    61     while(
fgetsMPI(ctmp2, 256, fp) != NULL) {
    62         sscanf(ctmp2, 
"%lf %lf %lf %lf %lf %d\n",
    75     *temp = 1.0/dinv_temp;
    76     *specificHeat = (dHvar-dene*dene)*(dinv_temp*dinv_temp);
    94                        double ene, 
double *tmp_E, 
int Nsite, 
int idim_max, 
double complex * dc_tmpSpec)
    98     double factor, pre_factor;
    99     pre_factor=2.0*dtemp*dtemp*dspecificheat;
   100     factor=M_PI*pre_factor;
   101     factor=1.0/sqrt(factor);
   104     if(cimag(dcomega)>0) {
   105         for (l = 1; l <= idim_max; l++) {
   108             tmp_dcSpec += (double)(
vec[l][1] * conj(
vec[l][1])) * exp(-pow((creal(dcomega) - tmp_E[l] + ene),2)/(pre_factor));
   112         fprintf(stderr, 
" an imarginary part of omega must be positive.\n");
   116     *dc_tmpSpec = tmp_dcSpec;
   133               double complex *tmp_v1,
   136         double complex *dcSpectrum,
   137         double complex *dcomega
   141     unsigned long int i, i_max;
   145     unsigned long int liLanczosStp_vec=0;
   146     double dene, dtemp, dspecificHeat;
   148     double complex dctmp_Spectrum;
   159         fprintf(
stdoutMPI, 
"  Start: Input vectors for recalculation.\n");
   166         byte_size = fread(&liLanczosStp_vec, 
sizeof(liLanczosStp_vec),1,fp);
   167         byte_size = fread(&i_max, 
sizeof(
long int), 1, fp);
   169             fprintf(stderr, 
"Error: A size of Inputvector is incorrect.\n");
   175         fprintf(
stdoutMPI, 
"  End:   Input vectors for recalculation.\n");
   177         if (byte_size == 0) printf(
"byte_size: %d \n", (
int)byte_size);
   196             fprintf(
stdoutMPI, 
"  Error: Fail to read TMcomponents\n");
   205             if(liLanczosStp_vec !=liLanczosStp){
   206                 fprintf(
stdoutMPI, 
"  Error: Input files for vector and TMcomponents are incoorect.\n");
   207                 fprintf(
stdoutMPI, 
"  Error: Input vector %ld th stps, TMcomponents  %ld th stps.\n", liLanczosStp_vec, liLanczosStp);
   222         fprintf(
stdoutMPI, 
"    Start: Calculate tridiagonal matrix components.\n");
   230         fprintf(
stdoutMPI, 
"    End:   Calculate tridiagonal matrix components.\n\n");
   236     d_malloc1(tmp_E,stp+1);
   239     fprintf(
stdoutMPI, 
"    Start: Caclulate spectrum from tridiagonal matrix components.\n");
   241     for( i = 0 ; i < Nomega; i++) {
   248         dcSpectrum[i] = dnorm * dctmp_Spectrum;
   250     fprintf(
stdoutMPI, 
"    End:   Caclulate spectrum from tridiagonal matrix components.\n\n");
   253     d_free1(tmp_E,stp+1);
   257         fprintf(
stdoutMPI, 
"    Start: Output vectors for recalculation.\n");
   264         fwrite(&liLanczosStp, 
sizeof(liLanczosStp),1,fp);
   270         fprintf(
stdoutMPI, 
"    End:   Output vectors for recalculation.\n");
 int childfopenALL(const char *_cPathChild, const char *_cmode, FILE **_fp)
All processes open file in output/ directory. 
int irand
Input keyword TargetTPQRand ??? 
void exitMPI(int errorcode)
MPI Abortation wrapper. 
struct DefineList Def
Definision of system (Hamiltonian) etc. 
unsigned long int idim_max
The dimension of the Hilbert space of this process. 
int ReadTPQData(struct EDMainCalStruct *X, double *ene, double *temp, double *specificHeat)
Read TPQ data at "X->Bind.Large.itr" step in SS_rand file. 
struct LargeList Large
Variables for Matrix-Vector product. 
int Lanczos_GetTridiagonalMatrixComponents(struct BindStruct *X, double *_alpha, double *_beta, double complex *tmp_v1, unsigned long int *liLanczos_step)
Calculate tridiagonal matrix components by Lanczos method. 
int childfopenMPI(const char *_cPathChild, const char *_cmode, FILE **_fp)
Only the root process open file in output/ directory. 
const char * cFileNameOutputRestartVec
unsigned int nvec
Read from Calcmod in readdef.h. 
const char * c_OutputSpectrumRecalcvecEnd
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) 
int Lanczos_restart
Number of iterations performed in the restart computation. 
const char * c_InputSpectrumRecalcvecStart
const char * c_GetTridiagonalStart
const char * c_CalcSpectrumFromTridiagonalEnd
int GetCalcSpectrumTPQ(double complex dcomega, double dtemp, double dspecificheat, double ene, double *tmp_E, int Nsite, int idim_max, double complex *dc_tmpSpec)
Calculate spectrum function from the TPQ state. 
const char * cFileNameTimeKeep
const char * c_InputSpectrumRecalcvecEnd
void vec12(double alpha[], double beta[], unsigned int ndim, double tmp_E[], struct BindStruct *X)
Diagonalize a tri-diagonal matrix and store eigenvectors into vec. 
int OutputTMComponents(struct BindStruct *X, double *_alpha, double *_beta, double _dnorm, int liLanczosStp)
Output tridiagonal matrix components obtained by the Lanczos method. 
int myrank
Process ID, defined in InitializeMPI() 
int iFlgCalcSpec
Input parameter CalcSpec in teh CalcMod file. 
const char * cFileNameSSRand
const char * c_CalcSpectrumFromTridiagonalStart
const char * c_GetTridiagonalEnd
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...
int ReadTMComponents(struct BindStruct *X, double *_dnorm, unsigned long int *_i_max, int iFlg)
Read tridiagonal matrix components obtained by the Lanczos method. . 
const char * c_OutputSpectrumRecalcvecStart
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. 
struct BindStruct Bind
Binded struct. 
int TimeKeeper(struct BindStruct *X, const char *cFileName, const char *cTimeKeeper_Message, const char *cWriteType)
Functions for writing a time log. 
unsigned int Lanczos_max
Maximum number of iterations. 
FILE * stdoutMPI
File pointer to the standard output defined in InitializeMPI()