HΦ  3.2.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"
+ Include dependency graph for Multiply.c:

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 BindStruct::Check, BindStruct::Def, global_norm, CheckList::idim_max, LargeValue, MultiplyForTEM(), DefineList::NsiteMPI, SumMPI_dc(), v0, and v1.

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 }
struct DefineList Def
Definision of system (Hamiltonian) etc.
Definition: struct.h:410
double complex SumMPI_dc(double complex norm)
MPI wrapper function to obtain sum of Double complex across processes.
Definition: wrapperMPI.c:205
unsigned long int idim_max
The dimension of the Hilbert space of this process.
Definition: struct.h:303
double complex * v1
Definition: global.h:35
double global_norm
Definition: global.h:67
unsigned int NsiteMPI
Total number of sites, differ from DefineList::Nsite.
Definition: struct.h:57
double complex * v0
Definition: global.h:34
struct CheckList Check
Size of the Hilbert space.
Definition: struct.h:411
double LargeValue
Definition: global.h:64
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 BindStruct::Check, BindStruct::Def, ParamList::ExpandCoef, global_norm, CheckList::idim_max, mltply(), DefineList::Param, SumMPI_dc(), ParamList::TimeSlice, v0, v1, and v2.

Referenced by CalcByTEM(), and Multiply().

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 }
struct DefineList Def
Definision of system (Hamiltonian) etc.
Definition: struct.h:410
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
unsigned long int idim_max
The dimension of the Hilbert space of this process.
Definition: struct.h:303
double complex * v1
Definition: global.h:35
double complex * v2
Definition: global.h:36
double global_norm
Definition: global.h:67
double TimeSlice
Definition: struct.h:33
struct ParamList Param
Definition: struct.h:241
int ExpandCoef
Definition: struct.h:35
double complex * v0
Definition: global.h:34
struct CheckList Check
Size of the Hilbert space.
Definition: struct.h:411
+ Here is the call graph for this function:
+ Here is the caller graph for this function: