HPhi++  3.1.0
CalcByFullDiag.cpp File Reference
#include "CalcByFullDiag.hpp"
#include "input.hpp"
#include "wrapperMPI.hpp"
#include "CalcTime.hpp"
#include "mltplyCommon.hpp"
#include "mltply.hpp"

Go to the source code of this file.

Functions

int CalcByFullDiag (struct EDMainCalStruct *X)
 Parent function for FullDiag mode. More...
 

Function Documentation

◆ CalcByFullDiag()

int CalcByFullDiag ( struct EDMainCalStruct X)

Parent function for FullDiag mode.

Parameters
X[in,out] Struct to get information about file header names, dimension of hirbert space, calc type, physical quantities.
Return values
TRUE(=1)normally finished.
FALSE(=0)abnormally finished.

Definition at line 27 of file CalcByFullDiag.cpp.

References EDMainCalStruct::Bind, BindStruct::Check, BindStruct::Def, CheckList::idim_max, DefineList::iInputHam, inputHam(), DefineList::iOutputHam, lapack_diag(), mltply(), output(), outputHam(), phys(), DefineList::St, StartTimer(), stdoutMPI, StopTimer(), v0, v1, and zclear().

Referenced by main().

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