HPhi++  3.1.0
CalcSpectrumByFullDiag.cpp File Reference

Functions to perform spectrum calculations with the full-diagonalization method. More...

#include <complex>
#include "global.hpp"
#include <ctime>
#include "struct.hpp"
#include "lapack_diag.hpp"
#include "mltply.hpp"
#include "mltplyCommon.hpp"
#include "CalcTime.hpp"
#include "common/setmemory.hpp"
#include "CalcSpectrum.hpp"

Go to the source code of this file.

Functions

int CalcSpectrumByFullDiag (struct EDMainCalStruct *X, int Nomega, int NdcSpectrum, std::complex< double > **dcSpectrum, std::complex< double > *dcomega, std::complex< double > **v1Org)
 Compute the Green function with the Lehmann representation and FD

\[ G(z) = \sum_n \frac{|\langle n|c|0\rangle|^2}{z - E_n} \]

. More...

 

Detailed Description

Functions to perform spectrum calculations with the full-diagonalization method.

Definition in file CalcSpectrumByFullDiag.cpp.

Function Documentation

◆ CalcSpectrumByFullDiag()

int CalcSpectrumByFullDiag ( struct EDMainCalStruct X,
int  Nomega,
int  NdcSpectrum,
std::complex< double > **  dcSpectrum,
std::complex< double > *  dcomega,
std::complex< double > **  v1Org 
)

Compute the Green function with the Lehmann representation and FD

\[ G(z) = \sum_n \frac{|\langle n|c|0\rangle|^2}{z - E_n} \]

.

Author
Mitsuaki Kawamura (The University of Tokyo)
  • Generate fully stored Hamiltonian. Because v0 & v1 are overwritten, copy v0 into ::vg.

  • v0 becomes eigenvalues in lapack_diag(), and v1 becomes eigenvectors

  • Compute \(|\langle n|c|0\rangle|^2\) for all \(n\) and store them into v1, where \(c|0\rangle\) is ::vg.

  • Compute spectrum

    \[ \sum_n \frac{|\langle n|c|0\rangle|^2}{z - E_n} \]

Parameters
[in,out]X
[in]NomegaNumber of frequencies
[out]dcSpectrum[Nomega] Spectrum
[in]dcomega[Nomega] Frequency

Definition at line 37 of file CalcSpectrumByFullDiag.cpp.

References EDMainCalStruct::Bind, BindStruct::Check, PhysList::energy, GetExcitedState(), CheckList::idim_max, lapack_diag(), mltply(), BindStruct::Phys, StartTimer(), StopTimer(), v0, v1, and zclear().

Referenced by CalcSpectrum().

45 {
46  int idim, jdim, iomega, idim_max_int, idcSpectrum;
47  std::complex<double> **vR, **vL, vRv, vLv, *vLvvRv;
53  idim_max_int = (int)X->Bind.Check.idim_max;
54  vR = cd_2d_allocate(idim_max_int, 1);
55  vL = cd_2d_allocate(idim_max_int, 1);
56  vLvvRv = cd_1d_allocate(idim_max_int);
57 
58  StartTimer(6301);
59  zclear((X->Bind.Check.idim_max + 1)*(X->Bind.Check.idim_max + 1), &v0[0][0]);
60  zclear((X->Bind.Check.idim_max + 1)*(X->Bind.Check.idim_max + 1), &v1[0][0]);
61  for (idim = 1; idim <= X->Bind.Check.idim_max; idim++) v1[idim][idim] = 1.0;
62  mltply(&(X->Bind), X->Bind.Check.idim_max, v0, v1);
63  StopTimer(6301);
68  StartTimer(6302);
69  lapack_diag(&(X->Bind));
70  StopTimer(6302);
75  zclear(X->Bind.Check.idim_max, &vR[1][0]);
76  GetExcitedState(&(X->Bind), 1, vR, v1Org, 0);
77  for (idcSpectrum = 0; idcSpectrum < NdcSpectrum; idcSpectrum++) {
78  StartTimer(6303);
79  zclear(X->Bind.Check.idim_max, &vL[1][0]);
80  GetExcitedState(&(X->Bind), 1, vL, v1Org, idcSpectrum + 1);
81  for (idim = 0; idim < idim_max_int; idim++) {
82  vRv = 0.0;
83  vLv = 0.0;
84  for (jdim = 0; jdim < idim_max_int; jdim++) {
85  vRv += conj(v1[jdim][idim]) * vR[jdim][1];
86  vLv += conj(v1[jdim][idim]) * vL[jdim][1];
87  }
88  vLvvRv[idim] = conj(vLv) * vRv;
89  }/*for (idim = 0; idim < idim_max_int; idim++)*/
90  StopTimer(6303);
99  StartTimer(6304);
100  for (iomega = 0; iomega < Nomega; iomega++) {
101  dcSpectrum[iomega][idcSpectrum] = 0.0;
102  for (idim = 0; idim < idim_max_int; idim++) {
103  dcSpectrum[iomega][idcSpectrum] += vLvvRv[idim] / (dcomega[iomega] - X->Bind.Phys.energy[idim]);
104  }/*for (idim = 0; idim < idim_max_int; idim++)*/
105  }/*for (iomega = 0; iomega < Nomega; iomega++)*/
106  StopTimer(6304);
107  }/*for (idcSpectrum = 1; idcSpectrum < NdcSpectrum; idcSpectrum++)*/
108  free_cd_2d_allocate(vL);
109  free_cd_2d_allocate(vR);
110  free_cd_1d_allocate(vLvvRv);
111  return TRUE;
112 }/*CalcSpectrumByFullDiag*/
int GetExcitedState(struct BindStruct *X, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, int iEx)
Parent function to calculate the excited state.
std::complex< double > ** v0
Definition: global.cpp:20
int mltply(struct BindStruct *X, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1)
Parent function of multiplying the wavefunction by the Hamiltonian. . First, the calculation of diago...
Definition: mltply.cpp:56
struct PhysList Phys
Physical quantities.
Definition: struct.hpp:398
std::complex< double > ** v1
Definition: global.cpp:21
void zclear(long int n, std::complex< double > *x)
clear std::complex<double> array.
Definition: mltply.cpp:143
int lapack_diag(struct BindStruct *X)
performing full diagonalization using lapack
Definition: lapack_diag.cpp:35
double * energy
Expectation value of the total energy.
Definition: struct.hpp:356
void StopTimer(int n)
function for calculating elapse time [elapse time=StartTimer-StopTimer]
Definition: time.cpp:83
struct CheckList Check
Size of the Hilbert space.
Definition: struct.hpp:396
long int idim_max
The dimension of the Hilbert space of this process.
Definition: struct.hpp:305
struct BindStruct Bind
Binded struct.
Definition: struct.hpp:405
void StartTimer(int n)
function for initializing elapse time [start]
Definition: time.cpp:71