23 #include "Hamiltonian.h" 43 FCI(
CheMPS2::Hamiltonian * Ham,
const unsigned int Nel_up,
const unsigned int Nel_down,
const int TargetIrrep,
const double maxMemWorkMB=100.0,
const int FCIverbose=2);
52 unsigned int getL()
const{
return L; }
65 unsigned int getVecLength(
const int irrep_center)
const{
return irrep_center_jumps[ irrep_center ][ num_irreps ]; }
82 double getERI(
const int orb1,
const int orb2,
const int orb3,
const int orb4)
const{
return ERI[ orb1 + L * ( orb2 + L * ( orb3 + L * orb4 ) ) ]; }
88 double getGmat(
const int orb1,
const int orb2)
const{
return Gmat[ orb1 + L * orb2 ]; }
100 double GSDavidson(
double * inoutput=NULL,
const int DVDSN_NUM_VEC=CheMPS2::DAVIDSON_NUM_VEC)
const;
110 double Fill2RDM(
double * vector,
double * TwoRDM)
const;
115 void Fill3RDM(
double * vector,
double * ThreeRDM)
const;
120 void Fill4RDM(
double * vector,
double * FourRDM)
const;
127 void Fock4RDM(
double * vector,
double * ThreeRDM,
double * Fock,
double * output)
const;
134 void Diag4RDM(
double * vector,
double * three_rdm,
const unsigned int orbz,
double * output )
const;
144 static void FillRandom(
const unsigned int vecLength,
double * vec);
149 static void ClearVector(
const unsigned int vecLength,
double * vec);
164 void RetardedGF(
const double omega,
const double eta,
const unsigned int orb_alpha,
const unsigned int orb_beta,
const bool isUp,
const double GSenergy,
double * GSvector,
CheMPS2::Hamiltonian * Ham,
double * RePartGF,
double * ImPartGF)
const;
180 void RetardedGF_addition(
const double omega,
const double eta,
const unsigned int orb_alpha,
const unsigned int orb_beta,
const bool isUp,
const double GSenergy,
double * GSvector,
CheMPS2::Hamiltonian * Ham,
double * RePartGF,
double * ImPartGF,
double * TwoRDMreal=NULL,
double * TwoRDMimag=NULL,
double * TwoRDMadd=NULL)
const;
198 void GFmatrix_addition(
const double alpha,
const double beta,
const double eta,
int * orbsLeft,
const unsigned int numLeft,
int * orbsRight,
const unsigned int numRight,
const bool isUp,
double * GSvector,
CheMPS2::Hamiltonian * Ham,
double * RePartsGF,
double * ImPartsGF,
double ** TwoRDMreal=NULL,
double ** TwoRDMimag=NULL,
double ** TwoRDMadd=NULL)
const;
214 void RetardedGF_removal(
const double omega,
const double eta,
const unsigned int orb_alpha,
const unsigned int orb_beta,
const bool isUp,
const double GSenergy,
double * GSvector,
CheMPS2::Hamiltonian * Ham,
double * RePartGF,
double * ImPartGF,
double * TwoRDMreal=NULL,
double * TwoRDMimag=NULL,
double * TwoRDMrem=NULL)
const;
232 void GFmatrix_removal(
const double alpha,
const double beta,
const double eta,
int * orbsLeft,
const unsigned int numLeft,
int * orbsRight,
const unsigned int numRight,
const bool isUp,
double * GSvector,
CheMPS2::Hamiltonian * Ham,
double * RePartsGF,
double * ImPartsGF,
double ** TwoRDMreal=NULL,
double ** TwoRDMimag=NULL,
double ** TwoRDMrem=NULL)
const;
243 void DensityResponseGF(
const double omega,
const double eta,
const unsigned int orb_alpha,
const unsigned int orb_beta,
const double GSenergy,
double * GSvector,
double * RePartGF,
double * ImPartGF)
const;
257 void DensityResponseGF_forward(
const double omega,
const double eta,
const unsigned int orb_alpha,
const unsigned int orb_beta,
const double GSenergy,
double * GSvector,
double * RePartGF,
double * ImPartGF,
double * TwoRDMreal=NULL,
double * TwoRDMimag=NULL,
double * TwoRDMdens=NULL)
const;
271 void DensityResponseGF_backward(
const double omega,
const double eta,
const unsigned int orb_alpha,
const unsigned int orb_beta,
const double GSenergy,
double * GSvector,
double * RePartGF,
double * ImPartGF,
double * TwoRDMreal=NULL,
double * TwoRDMimag=NULL,
double * TwoRDMdens=NULL)
const;
281 void CGSolveSystem(
const double alpha,
const double beta,
const double eta,
double * RHS,
double * RealSol,
double * ImagSol,
const bool checkError=
true)
const;
290 double getFCIcoeff(
int * bits_up,
int * bits_down,
double * vector)
const;
298 void DiagHam(
double * diag)
const;
307 void matvec(
double * input,
double * output )
const;
316 double GetMatrixElement(
int * bits_bra_up,
int * bits_bra_down,
int * bits_ket_up,
int * bits_ket_down,
int * work)
const;
325 void getBitsOfCounter(
const int irrep_center,
const unsigned int counter,
int * bits_up,
int * bits_down)
const;
331 static void str2bits(
const unsigned int Lvalue,
const unsigned int bitstring,
int * bits);
337 static unsigned int bits2str(
const unsigned int Lvalue,
int * bits);
352 static double FCIddot(
const unsigned int vecLength,
double * vec1,
double * vec2);
358 static void FCIdcopy(
const unsigned int vecLength,
double * origin,
double * target);
371 static void FCIdaxpy(
const unsigned int vecLength,
const double alpha,
double * vec_x,
double * vec_y);
377 static void FCIdscal(
const unsigned int vecLength,
const double alpha,
double * vec);
388 void ActWithSecondQuantizedOperator(
const char whichOperator,
const bool isUp,
const unsigned int orbIndex,
double * thisVector,
const FCI * otherFCI,
double * otherVector)
const;
394 void ActWithNumberOperator(
const unsigned int orbIndex,
double * resultVector,
double * sourceVector)
const;
407 void CGCoreSolver(
const double alpha,
const double beta,
const double eta,
double * precon,
double * Sol,
double * RESID,
double * PVEC,
double * OxPVEC,
double * temp,
double * temp2)
const;
414 void CGAlphaPlusBetaHAM(
const double alpha,
const double beta,
double * in,
double * out)
const;
423 void CGoperator(
const double alpha,
const double beta,
const double eta,
double * in,
double * temp,
double * out)
const;
431 void CGdiagonal(
const double alpha,
const double beta,
const double eta,
double * diagonal,
double * workspace)
const;
441 void apply_excitation(
double * orig_vector,
double * result_vector,
const int crea,
const int anni,
const int orig_target_irrep )
const;
461 unsigned int num_irreps;
476 unsigned int Nel_down;
479 unsigned int * numPerIrrep_up;
482 unsigned int * numPerIrrep_down;
491 unsigned int ** cnt2str_up;
494 unsigned int ** cnt2str_down;
497 int *** lookup_cnt_alpha;
500 int *** lookup_cnt_beta;
503 int *** lookup_sign_alpha;
506 int *** lookup_sign_beta;
509 unsigned int * irrep_center_num;
512 unsigned int ** irrep_center_crea_orb;
515 unsigned int ** irrep_center_anni_orb;
518 unsigned int ** irrep_center_jumps;
521 unsigned long long HXVsizeWorkspace;
524 double * HXVworksmall;
527 double * HXVworkbig1;
530 double * HXVworkbig2;
533 void StartupCountersVsBitstrings();
536 void StartupLookupTables();
539 void StartupIrrepCenter();
542 double Driver3RDM(
double * vector,
double * output,
double * three_rdm,
double * fock,
const unsigned int orbz)
const;
545 static void excite_alpha_omp(
const unsigned int dim_new_up,
const unsigned int dim_old_up,
const unsigned int dim_down,
double * origin,
double * result,
int * signmap,
int * countmap );
546 static void excite_alpha_first(
const unsigned int dim_new_up,
const unsigned int dim_old_up,
const unsigned int start_down,
const unsigned int stop_down,
double * origin,
double * result,
int * signmap,
int * countmap );
547 static void excite_alpha_second_omp(
const unsigned int dim_new_up,
const unsigned int dim_old_up,
const unsigned int start_down,
const unsigned int stop_down,
double * origin,
double * result,
int * signmap,
int * countmap );
550 static void excite_beta_omp(
const unsigned int dim_up,
const unsigned int dim_new_down,
double * origin,
double * result,
int * signmap,
int * countmap );
551 static void excite_beta_first(
const unsigned int dim_up,
const unsigned int start_down,
const unsigned int stop_down,
double * origin,
double * result,
int * signmap,
int * countmap );
552 static void excite_beta_second_omp(
const unsigned int dim_up,
const unsigned int start_down,
const unsigned int stop_down,
double * origin,
double * result,
int * signmap,
int * countmap );
static double FCIddot(const unsigned int vecLength, double *vec1, double *vec2)
Take the inproduct of two vectors.
void Diag4RDM(double *vector, double *three_rdm, const unsigned int orbz, double *output) const
Construct part of the 4-RDM: output(i,j,k,p,q,r) = Gamma^4(i,j,k,z,p,q,r,z)
void apply_excitation(double *orig_vector, double *result_vector, const int crea, const int anni, const int orig_target_irrep) const
Apply E_{crea,anni} to |orig_vector> and store the result in |result_vector>
double getEconst() const
Function which returns the nuclear repulsion energy.
void DensityResponseGF(const double omega, const double eta, const unsigned int orb_alpha, const unsigned int orb_beta, const double GSenergy, double *GSvector, double *RePartGF, double *ImPartGF) const
Calculate the density response Green's function (= forward - backward propagating part) ...
void DensityResponseGF_backward(const double omega, const double eta, const unsigned int orb_alpha, const unsigned int orb_beta, const double GSenergy, double *GSvector, double *RePartGF, double *ImPartGF, double *TwoRDMreal=NULL, double *TwoRDMimag=NULL, double *TwoRDMdens=NULL) const
Calculate the backward propagating part of the density response Green's function: <GSvector| ( n_beta...
double getERI(const int orb1, const int orb2, const int orb3, const int orb4) const
Function which returns the electron repulsion integral (in chemists notation: integral dr1 dr2 orb1(r...
void DiagHam(double *diag) const
Function which returns the diagonal elements of the FCI Hamiltonian (without Econstant!!) = Slater de...
static void FCIdcopy(const unsigned int vecLength, double *origin, double *target)
Copy a vector.
void CGdiagonal(const double alpha, const double beta, const double eta, double *diagonal, double *workspace) const
Calculate (without approximation) diagonal = diag[ (alpha + beta * Hamiltonian)^2 + eta^2 ] (Econstan...
double GSDavidson(double *inoutput=NULL, const int DVDSN_NUM_VEC=CheMPS2::DAVIDSON_NUM_VEC) const
Calculates the FCI ground state with Davidson's algorithm.
void CGCoreSolver(const double alpha, const double beta, const double eta, double *precon, double *Sol, double *RESID, double *PVEC, double *OxPVEC, double *temp, double *temp2) const
Calculate the solution of the system Operator |Sol> = |RESID> with Operator = precon * [ ( alpha + be...
void ActWithSecondQuantizedOperator(const char whichOperator, const bool isUp, const unsigned int orbIndex, double *thisVector, const FCI *otherFCI, double *otherVector) const
Set thisVector to a creator/annihilator acting on otherVector.
void Fill4RDM(double *vector, double *FourRDM) const
Construct the (spin-summed) 4-RDM of a FCI vector: Gamma^4(i,j,k,l,p,q,r,t) = sum_sigma,tau,s,z < a^+_{i,sigma} a^+_{j,tau} a^+_{k,s} a^+_{l,z} a_{t,z} a_{r,s} a_{q,tau} a_{p,sigma} > = FourRDM[ i + L * ( j + L * ( k + L * ( l + L * ( p + L * ( q + L * ( r + L * t ) ) ) ) ) ) ].
static void FCIdaxpy(const unsigned int vecLength, const double alpha, double *vec_x, double *vec_y)
Do lapack's daxpy vec_y += alpha * vec_x.
void DensityResponseGF_forward(const double omega, const double eta, const unsigned int orb_alpha, const unsigned int orb_beta, const double GSenergy, double *GSvector, double *RePartGF, double *ImPartGF, double *TwoRDMreal=NULL, double *TwoRDMimag=NULL, double *TwoRDMdens=NULL) const
Calculate the forward propagating part of the density response Green's function: <GSvector| ( n_alpha...
void GFmatrix_removal(const double alpha, const double beta, const double eta, int *orbsLeft, const unsigned int numLeft, int *orbsRight, const unsigned int numRight, const bool isUp, double *GSvector, CheMPS2::Hamiltonian *Ham, double *RePartsGF, double *ImPartsGF, double **TwoRDMreal=NULL, double **TwoRDMimag=NULL, double **TwoRDMrem=NULL) const
Calculate the removal Green's function: GF[i+numLeft*j] = <GSvector| a^+_{orbsLeft[i], spin} [ alpha + beta * Ham + I*eta ]^{-1} a_{orbsRight[j], spin} |GSvector>
void DiagHamSquared(double *output) const
Function which returns the diagonal elements of the FCI Hamiltonian squared (without Econstant!!) ...
static void FillRandom(const unsigned int vecLength, double *vec)
Fill a vector with random numbers in the interval [-1,1[; used when output for GSDavidson is desired ...
void RetardedGF_removal(const double omega, const double eta, const unsigned int orb_alpha, const unsigned int orb_beta, const bool isUp, const double GSenergy, double *GSvector, CheMPS2::Hamiltonian *Ham, double *RePartGF, double *ImPartGF, double *TwoRDMreal=NULL, double *TwoRDMimag=NULL, double *TwoRDMrem=NULL) const
Calculate the removal part of the retarded Green's function: <GSvector| a^+_{beta, spin(isUp)} [ omega + Ham - GSenergy + I*eta ]^{-1} a_{alpha, spin(isUp)} |GSvector>
static void FCIdscal(const unsigned int vecLength, const double alpha, double *vec)
Do lapack's dscal vec *= alpha.
unsigned int LowestEnergyDeterminant() const
Return the global counter of the Slater determinant with the lowest energy.
void CGoperator(const double alpha, const double beta, const double eta, double *in, double *temp, double *out) const
Calculate out = [(alpha + beta * Hamiltonian)^2 + eta^2] * in (Econstant is taken into account!!) ...
unsigned int getNel_down() const
Getter for the number of down or beta electrons.
double getGmat(const int orb1, const int orb2) const
Function which returns the AUGMENTED one-body matrix elements ( G_{ij} = T_{ij} - 0...
void CGSolveSystem(const double alpha, const double beta, const double eta, double *RHS, double *RealSol, double *ImagSol, const bool checkError=true) const
Calculate the solution of the equation ( alpha + beta * Hamiltonian + I * eta ) Solution = RHS with c...
void RetardedGF(const double omega, const double eta, const unsigned int orb_alpha, const unsigned int orb_beta, const bool isUp, const double GSenergy, double *GSvector, CheMPS2::Hamiltonian *Ham, double *RePartGF, double *ImPartGF) const
Calculate the retarded Green's function (= addition + removal amplitude)
double getFCIcoeff(int *bits_up, int *bits_down, double *vector) const
Function which returns a FCI coefficient.
void GFmatrix_addition(const double alpha, const double beta, const double eta, int *orbsLeft, const unsigned int numLeft, int *orbsRight, const unsigned int numRight, const bool isUp, double *GSvector, CheMPS2::Hamiltonian *Ham, double *RePartsGF, double *ImPartsGF, double **TwoRDMreal=NULL, double **TwoRDMimag=NULL, double **TwoRDMadd=NULL) const
Calculate the addition Green's function: GF[i+numLeft*j] = <GSvector| a_{orbsLeft[i], spin} [ alpha + beta * Ham + I*eta ]^{-1} a^+_{orbsRight[j], spin} |GSvector>
virtual ~FCI()
Destructor.
unsigned int getVecLength(const int irrep_center) const
Getter for the number of variables in the vector " E_ij | FCI vector > " ; where irrep_center = I_i x...
void Fill3RDM(double *vector, double *ThreeRDM) const
Construct the (spin-summed) 3-RDM of a FCI vector: Gamma^3(i,j,k,l,m,n) = sum_sigma,tau,s < a^+_{i,sigma} a^+_{j,tau} a^+_{k,s} a_{n,s} a_{m,tau} a_{l,sigma} > = ThreeRDM[ i + L * ( j + L * ( k + L * ( l + L * ( m + L * n ) ) ) ) ].
void CGAlphaPlusBetaHAM(const double alpha, const double beta, double *in, double *out) const
Calculate out = (alpha + beta * Hamiltonian) * in (Econstant is taken into account!!) ...
double GetMatrixElement(int *bits_bra_up, int *bits_bra_down, int *bits_ket_up, int *bits_ket_down, int *work) const
Sandwich the Hamiltonian between two Slater determinants (return a specific element) (without Econsta...
static void ClearVector(const unsigned int vecLength, double *vec)
Set the entries of a vector to zero.
void ActWithNumberOperator(const unsigned int orbIndex, double *resultVector, double *sourceVector) const
Set resultVector to the number operator of a specific site acting on sourceVector.
void RetardedGF_addition(const double omega, const double eta, const unsigned int orb_alpha, const unsigned int orb_beta, const bool isUp, const double GSenergy, double *GSvector, CheMPS2::Hamiltonian *Ham, double *RePartGF, double *ImPartGF, double *TwoRDMreal=NULL, double *TwoRDMimag=NULL, double *TwoRDMadd=NULL) const
Calculate the addition part of the retarded Green's function: <GSvector| a_{alpha, spin(isUp)} [ omega - Ham + GSenergy + I*eta ]^{-1} a^+_{beta, spin(isUp)} |GSvector>
static void str2bits(const unsigned int Lvalue, const unsigned int bitstring, int *bits)
Convertor between two representations of a same spin-projection Slater determinant.
static unsigned int bits2str(const unsigned int Lvalue, int *bits)
Convertor between two representations of a same spin-projection Slater determinant.
unsigned int getNel_up() const
Getter for the number of up or alpha electrons.
void matvec(double *input, double *output) const
Function which performs the Hamiltonian times Vector product (without Econstant!!) making use of the ...
void getBitsOfCounter(const int irrep_center, const unsigned int counter, int *bits_up, int *bits_down) const
Find the bit representation of a global counter corresponding to " E_ij | FCI vector > " ; where irre...
double CalcSpinSquared(double *vector) const
Measure S(S+1) (spin squared)
int getUpIrrepOfCounter(const int irrep_center, const unsigned int counter) const
Find the irrep of the up Slater determinant of a global counter corresponding to " E_ij | FCI vector ...
unsigned int getL() const
Getter for the number of orbitals.
int getTargetIrrep() const
Get the target irrep.
static double FCIfrobeniusnorm(const unsigned int vecLength, double *vec)
Calculate the 2-norm of a vector.
double Fill2RDM(double *vector, double *TwoRDM) const
Construct the (spin-summed) 2-RDM of a FCI vector: Gamma^2(i,j,k,l) = sum_sigma,tau < a^+_i...
void Fock4RDM(double *vector, double *ThreeRDM, double *Fock, double *output) const
Construct the (spin-summed) contraction of the 4-RDM with the Fock operator: output(i,j,k,p,q,r) = sum_{l,t} Fock(l,t) * Gamma^4(i,j,k,l,p,q,r,t)
int getOrb2Irrep(const int orb) const
Get an orbital irrep.
FCI(CheMPS2::Hamiltonian *Ham, const unsigned int Nel_up, const unsigned int Nel_down, const int TargetIrrep, const double maxMemWorkMB=100.0, const int FCIverbose=2)
Constructor.