HΦ  3.1.0
Multiply.c File Reference

File for giving multiplying functions to the wave vectors for TPQ and TE method. More...

#include "Common.h"
#include "diagonalcalc.h"
#include "Multiply.h"
#include "wrapperMPI.h"
#include "mltply.h"

Go to the source code of this file.

Functions

int Multiply (struct BindStruct *X)
 Function of calculating the i-th step norm as

\[ N^{(i)} = |L v_1^{(i)}-v_0^{(i)}/N_s | \]

and update the i+1-th wave vector as

\[ v_0^{(i+1)} = \frac{L v_1^{(i)}-v_0^{(i)}/N_s}{N^{(i)}} \]

for TPQ calculation. More...

 
int MultiplyForTEM (struct BindStruct *X)
 Function of multiplying Hamiltonian for Time Evolution. More...
 

Detailed Description

File for giving multiplying functions to the wave vectors for TPQ and TE method.

Author
Takahiro Misawa (The University of Tokyo)
Kazuyoshi Yoshimi (The University of Tokyo)
Kota Ido (The University of Tokyo)

Definition in file Multiply.c.

Function Documentation

◆ Multiply()

int Multiply ( struct BindStruct X)

Function of calculating the i-th step norm as

\[ N^{(i)} = |L v_1^{(i)}-v_0^{(i)}/N_s | \]

and update the i+1-th wave vector as

\[ v_0^{(i+1)} = \frac{L v_1^{(i)}-v_0^{(i)}/N_s}{N^{(i)}} \]

for TPQ calculation.

Parameters
X[in] data list for calculation (idim_max and NsiteMPI)
Return values
0normally finished
-1unnormally finished
Author
Takahiro Misawa (The University of Tokyo)
Kazuyoshi Yoshimi (The University of Tokyo)

Definition at line 43 of file Multiply.c.

References global_norm, LargeValue, SumMPI_dc(), v0, v1, and X.

Referenced by CalcByTPQ().

46 {
47  long int i,i_max;
48  double complex dnorm;
49  double Ns;
50 
51  i_max=X->Check.idim_max;
52  Ns = 1.0*X->Def.NsiteMPI;
53  // mltply is in expec_energy.c v0=H*v1
54  dnorm=0.0;
55 #pragma omp parallel for default(none) reduction(+: dnorm) private(i) shared(v0, v1) firstprivate(i_max, Ns, LargeValue)
56  for(i = 1; i <= i_max; i++){
57  v0[i]=LargeValue*v1[i]-v0[i]/Ns; //v0=(l-H/Ns)*v1
58  dnorm += conj(v0[i])*v0[i];
59  }
60  dnorm=SumMPI_dc(dnorm);
61  dnorm=sqrt(dnorm);
62  global_norm = dnorm;
63 #pragma omp parallel for default(none) private(i) shared(v0) firstprivate(i_max, dnorm)
64  for(i=1;i<=i_max;i++){
65  v0[i] = v0[i]/dnorm;
66  }
67  return 0;
68 }
double complex SumMPI_dc(double complex norm)
MPI wrapper function to obtain sum of Double complex across processes.
Definition: wrapperMPI.c:205
double complex * v1
Definition: global.h:35
double global_norm
Definition: global.h:67
struct EDMainCalStruct X
Definition: struct.h:431
double complex * v0
Definition: global.h:34
double LargeValue
Definition: global.h:64

◆ MultiplyForTEM()

int MultiplyForTEM ( struct BindStruct X)

Function of multiplying Hamiltonian for Time Evolution.

Make \( |v_0 \rangle = |\psi(t+dt) \rangle \) from \( |v_1 \rangle = | \psi(t) \rangle \) and \( |v_0 \rangle = H |\psi(t) \rangle \).

Parameters
X[in] data list for calculation (idim_max and TimeSlice)
Return values
0normally finished
-1unnormally finished

Definition at line 80 of file Multiply.c.

References global_norm, mltply(), SumMPI_dc(), v0, v1, v2, and X.

Referenced by CalcByTEM().

83 {
84 
85  long int i,i_max;
86  int coef;
87  double complex dnorm=0.0;
88  double complex tmp1 = 1.0;
89  double complex tmp2=0.0;
90  double dt=X->Def.Param.TimeSlice;
91 
92  //Make |v0> = |psi(t+dt)> from |v1> = |psi(t)> and |v0> = H |psi(t)>
93  i_max=X->Check.idim_max;
94  // mltply is in expec_energy.c v0=H*v1
95  if(dt <pow(10.0, -14)){
96 #pragma omp parallel for default(none) reduction(+: dnorm) private(i) shared(v0, v1, v2) firstprivate(i_max, dt, tmp2)
97  for(i = 1; i <= i_max; i++){
98  tmp2 = v0[i];
99  v0[i]=v1[i]; //v0=(1-i*dt*H)*v1
100  v1[i]=tmp2;
101  v2[i]= 0.0 + I*0.0;
102  }
103  mltply(X, v2, v1);
104  }
105  else {
106  tmp1 *= -I * dt;
107 #pragma omp parallel for default(none) reduction(+: dnorm) private(i) shared(v0, v1, v2) firstprivate(i_max, dt, tmp1, tmp2)
108  for (i = 1; i <= i_max; i++) {
109  tmp2 = v0[i];
110  v0[i] = v1[i] + tmp1 * tmp2; //v0=(1-i*dt*H)*v1
111  v1[i] = tmp2;
112  v2[i] = 0.0 + I * 0.0;
113  }
114  for (coef = 2; coef <= X->Def.Param.ExpandCoef; coef++) {
115  tmp1 *= -I * dt / (double complex) coef;
116  //v2 = H*v1 = H^coef |psi(t)>
117  mltply(X, v2, v1);
118 
119 #pragma omp parallel for default(none) private(i) shared(v0, v1, v2) firstprivate(i_max, tmp1, myrank)
120  for (i = 1; i <= i_max; i++) {
121  v0[i] += tmp1 * v2[i];
122  v1[i] = v2[i];
123  v2[i] = 0.0 + I * 0.0;
124  }
125  }
126  }
127  dnorm=0.0;
128 #pragma omp parallel for default(none) reduction(+: dnorm) private(i) shared(v0) firstprivate(i_max, dt)
129  for(i = 1; i <= i_max; i++){
130  dnorm += conj(v0[i])*v0[i];
131  }
132  dnorm=SumMPI_dc(dnorm);
133  dnorm=sqrt(dnorm);
134  global_norm = dnorm;
135 #pragma omp parallel for default(none) private(i) shared(v0) firstprivate(i_max, dnorm)
136  for(i=1;i<=i_max;i++){
137  v0[i] = v0[i]/dnorm;
138  }
139  return 0;
140 }
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...
Definition: mltply.c:56
double complex SumMPI_dc(double complex norm)
MPI wrapper function to obtain sum of Double complex across processes.
Definition: wrapperMPI.c:205
double complex * v1
Definition: global.h:35
double complex * v2
Definition: global.h:36
double global_norm
Definition: global.h:67
struct EDMainCalStruct X
Definition: struct.h:431
double complex * v0
Definition: global.h:34