Calculate eigenvectors by the Lanczos method.
The calculated tridiagonal matrix components \( \alpha_i, \beta_i\) are stored in each array \( \verb|alpha| \) and \(\verb|beta|\)
( \( i = 0\cdots N_c\), where \( N_c\) is the step where the calculated energy satisfies the convergence condition).
add an option to choose a type of initial vectors from complex or real types.
51 long int i,j,i_max,iv;
53 double beta1,alpha1,dnorm, dnorm_inv;
54 double complex temp1,temp2,cdnorm;
58 long unsigned int u_long_i, sum_i_max, i_max_tmp;
71 #pragma omp parallel for default(none) private(i) shared(v0, v1,vg) firstprivate(i_max) 72 for(i = 1; i <= i_max; i++){
79 for (iproc = 0; iproc <
nproc; iproc++) {
82 if (sum_i_max <= iv && iv < sum_i_max + i_max_tmp) {
85 v1[iv - sum_i_max+1] = 1.0;
87 v1[iv - sum_i_max+1] += 1.0*I;
88 v1[iv - sum_i_max+1] /= sqrt(2.0);
90 vg[iv - sum_i_max+1]=conj(
vec[k_exct][1])*
v1[iv - sum_i_max+1];
95 sum_i_max += i_max_tmp;
103 #pragma omp parallel default(none) private(i, u_long_i, mythread, dsfmt) \ 104 shared(v0, v1, iv, X, nthreads, myrank) firstprivate(i_max) 108 for (i = 1; i <= i_max; i++) {
115 mythread = omp_get_thread_num();
120 dsfmt_init_gen_rand(&dsfmt, u_long_i);
124 for (i = 1; i <= i_max; i++)
125 v1[i] = 2.0*(dsfmt_genrand_close_open(&dsfmt) - 0.5) + 2.0*(dsfmt_genrand_close_open(&dsfmt) - 0.5)*I;
129 for (i = 1; i <= i_max; i++)
130 v1[i] = 2.0*(dsfmt_genrand_close_open(&dsfmt) - 0.5);
137 #pragma omp parallel for default(none) private(i) shared(v1, i_max) reduction(+: cdnorm) 138 for(i=1;i<=i_max;i++){
139 cdnorm += conj(
v1[i])*
v1[i];
144 #pragma omp parallel for default(none) private(i) shared(v1, vec, vg) firstprivate(i_max, dnorm, k_exct) 145 for(i=1;i<=i_max;i++){
147 vg[i] =
v1[i]*conj(
vec[k_exct][1]);
157 #pragma omp parallel for default(none) private(j) shared(vec, v0, v1, vg) firstprivate(alpha1, beta1, i_max, k_exct) 158 for(j=1;j<=i_max;j++){
159 vg[j]+=conj(
vec[k_exct][2])*(
v0[j]-alpha1*
v1[j])/beta1;
169 #pragma omp parallel for default(none) private(j, temp1, temp2) shared(v0, v1) firstprivate(i_max, alpha1, beta1) 170 for (j = 1; j <= i_max; j++) {
172 temp2 = (
v0[j] - alpha1 *
v1[j]) / beta1;
173 v0[j] = -beta1 * temp1;
181 #pragma omp parallel for default(none) private(j) shared(vec, v0, v1, vg) firstprivate(alpha1, beta1, i_max, k_exct, i) 182 for (j = 1; j <= i_max; j++) {
183 vg[j] += conj(
vec[k_exct][i + 1]) * (
v0[j] - alpha1 *
v1[j]) / beta1;
187 #pragma omp parallel for default(none) private(j) shared(v0, vg) firstprivate(i_max) 188 for(j=1;j<=i_max;j++){
194 #pragma omp parallel for default(none) reduction(+:dnorm) private(j) shared(v0) firstprivate(i_max) 195 for(j=1;j<=i_max;j++){
196 dnorm += conj(
v0[j])*
v0[j];
201 #pragma omp parallel for default(none) private(j) shared(v0) firstprivate(i_max, dnorm_inv) 202 for(j=1;j<=i_max;j++){
203 v0[j] =
v0[j]*dnorm_inv;
struct DefineList Def
Definision of system (Hamiltonian) etc.
int mltply(struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Parent function of multiplying the wavefunction by the Hamiltonian. . First, the calculation of diago...
void StartTimer(int n)
function for initializing elapse time [start]
double complex SumMPI_dc(double complex norm)
MPI wrapper function to obtain sum of Double complex across processes.
unsigned long int idim_max
The dimension of the Hilbert space of this process.
unsigned long int BcastMPI_li(int root, unsigned long int idim)
MPI wrapper function to broadcast unsigned long integer across processes.
void StopTimer(int n)
function for calculating elapse time [elapse time=StartTimer-StopTimer]
struct LargeList Large
Variables for Matrix-Vector product.
double SumMPI_d(double norm)
MPI wrapper function to obtain sum of Double across processes.
int nthreads
Number of Threads, defined in InitializeMPI()
long int iv
Used for initializing vector.
const char * cLogLanczos_EigenVectorStart
int nproc
Number of processors, defined in InitializeMPI()
const char * cLanczos_EigenVectorFinish
const char * cLanczos_EigenVectorStart
const char * cFileNameTimeKeep
long int initial_iv
Seed of random number for initial guesss of wavefunctions.
int myrank
Process ID, defined in InitializeMPI()
int iInitialVecType
Switch for type of inital vectors. 0:complex type, 1: real type. default value is set as 0 in readdef...
struct CheckList Check
Size of the Hilbert space.
unsigned long int SumMPI_li(unsigned long int idim)
MPI wrapper function to obtain sum of unsigned long integer across processes.
int TimeKeeper(struct BindStruct *X, const char *cFileName, const char *cTimeKeeper_Message, const char *cWriteType)
Functions for writing a time log.
const char * cLogLanczos_EigenVectorEnd
FILE * stdoutMPI
File pointer to the standard output defined in InitializeMPI()
unsigned int k_exct
Read from Calcmod in readdef.h.