HPhi++  3.1.0
CalcSpectrumByFullDiag.cpp
Go to the documentation of this file.
1 /* HPhi - Quantum Lattice Model Simulator */
2 /* Copyright (C) 2015 Takahiro Misawa, Kazuyoshi Yoshimi, Mitsuaki Kawamura, Youhei Yamaji, Synge Todo, Naoki Kawashima */
3 
4 /* This program is free software: you can redistribute it and/or modify */
5 /* it under the terms of the GNU General Public License as published by */
6 /* the Free Software Foundation, either version 3 of the License, or */
7 /* (at your option) any later version. */
8 
9 /* This program is distributed in the hope that it will be useful, */
10 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
11 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
12 /* GNU General Public License for more details. */
13 
14 /* You should have received a copy of the GNU General Public License */
15 /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #include <complex>
21 #include "global.hpp"
22 #include <ctime>
23 #include "struct.hpp"
24 #include "lapack_diag.hpp"
25 #include "mltply.hpp"
26 #include "mltplyCommon.hpp"
27 #include "CalcTime.hpp"
28 #include "common/setmemory.hpp"
29 #include "CalcSpectrum.hpp"
38  struct EDMainCalStruct *X,
39  int Nomega,
40  int NdcSpectrum,
41  std::complex<double> **dcSpectrum,
42  std::complex<double> *dcomega,
43  std::complex<double> **v1Org
44 )
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*/
113 
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 .
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
Binded struct.
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