HPhi++  3.1.0
CalcByFullDiag.cpp
Go to the documentation of this file.
1 /* HPhi - Quantum Lattice Model Simulator */
2 /* Copyright (C) 2015 The University of Tokyo */
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/>. */
16 #include "CalcByFullDiag.hpp"
17 #include "input.hpp"
18 #include "wrapperMPI.hpp"
19 #include "CalcTime.hpp"
20 #include "mltplyCommon.hpp"
21 #include "mltply.hpp"
22 
28  struct EDMainCalStruct *X
29 )
30 {
31  int iret=0;
32  long int idim;
33 
34  fprintf(stdoutMPI, "%s", "###### Start: Setting Hamiltonian. ######\n\n");
35  StartTimer(5100);
36  if(X->Bind.Def.iInputHam==FALSE){
37  zclear((X->Bind.Check.idim_max + 1)*X->Bind.Check.idim_max, &v0[0][0]);
38  zclear((X->Bind.Check.idim_max + 1)*X->Bind.Check.idim_max, &v1[0][0]);
39  for (idim = 1; idim <= X->Bind.Check.idim_max; idim++) v1[idim][idim-1] = 1.0;
40  mltply(&(X->Bind), X->Bind.Check.idim_max, v0, v1);
41  }
42  else if(X->Bind.Def.iInputHam==TRUE){
43  fprintf(stdoutMPI, "%s", "###### Start: Input Hamiltonian. ######\n\n");
44  inputHam(&(X->Bind));
45  fprintf(stdoutMPI, "%s", "###### End : Input Hamiltonian. ######\n\n");
46  }
47  StopTimer(5100);
48  fprintf(stdoutMPI, "%s", "###### End : Setting Hamiltonian. ######\n\n");
49  if(iret != 0) return FALSE;
50 
51 
52  if(X->Bind.Def.iOutputHam == TRUE){
53  fprintf(stdoutMPI, "%s", "###### Start: Output Hamiltonian. ######\n\n");
54  StartTimer(5500);
55  iret=outputHam(&(X->Bind));
56  StopTimer(5500);
57  fprintf(stdoutMPI, "%s", "###### End : Output Hamiltonian. ######\n\n");
58  if(iret != 0) return FALSE;
59  return TRUE;
60  }
61 
62  fprintf(stdoutMPI, "%s", "###### Start: Diagonalization. ######\n\n");
63  StartTimer(5200);
64  iret=lapack_diag(&(X->Bind));
65  StopTimer(5200);
66  fprintf(stdoutMPI, "%s", "###### End : Diagonalization. ######\n\n");
67  if(iret != 0) return FALSE;
68 
69  X->Bind.Def.St=0;
70  fprintf(stdoutMPI, "%s", "###### Start: Calc Expected value. ######\n\n");
71  StartTimer(5300);
72  phys(&(X->Bind), X->Bind.Check.idim_max);
73  StopTimer(5300);
74  fprintf(stdoutMPI, "%s", "###### End : Calc Expected value. ######\n\n");
75 
76  StartTimer(5400);
77  iret=output(&(X->Bind));
78  StopTimer(5400);
79  fprintf(stdoutMPI, "%s", "###### Finish Calculation. ######\n");
80  if(iret != 0) return FALSE;
81 
82  return TRUE;
83 }
int iInputHam
Definition: struct.hpp:207
struct DefineList Def
Definision of system (Hamiltonian) etc.
Definition: struct.hpp:395
int St
0 or 1, but it affects nothing.
Definition: struct.hpp:80
FILE * stdoutMPI
File pointer to the standard output defined in InitializeMPI()
Definition: global.cpp:75
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
int inputHam(struct BindStruct *X)
Definition: input.cpp:20
std::complex< double > ** v1
Definition: global.cpp:21
int output(struct BindStruct *X)
output function for FullDiag mode
Definition: output.cpp:27
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
void StopTimer(int n)
function for calculating elapse time [elapse time=StartTimer-StopTimer]
Definition: time.cpp:83
int outputHam(struct BindStruct *X)
output Hamiltonian only used for FullDiag mode
Definition: output.cpp:73
void phys(struct BindStruct *X, long int neig)
A main function to calculate physical quantities by full diagonalization method.
Definition: phys.cpp:48
int iOutputHam
Definition: struct.hpp:206
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
int CalcByFullDiag(struct EDMainCalStruct *X)
Parent function for FullDiag mode.