HPhi++  3.1.0
phys.cpp File Reference

File for giving a parent function to calculate physical quantities by full diagonalization method. More...

#include "phys.hpp"
#include "expec_energy_flct.hpp"
#include "expec_totalspin.hpp"
#include "expec_cisajs.hpp"
#include "expec_cisajscktaltdc.hpp"
#include "wrapperMPI.hpp"

Go to the source code of this file.

Functions

void phys (struct BindStruct *X, long int neig)
 A main function to calculate physical quantities by full diagonalization method. More...
 

Detailed Description

File for giving a parent function to calculate physical quantities by full diagonalization method.

Version
0.1, 0.2
Author
Takahiro Misawa (The University of Tokyo)
Kazuyoshi Yoshimi (The University of Tokyo)

Definition in file phys.cpp.

Function Documentation

◆ phys()

void phys ( struct BindStruct X,
long int  neig 
)

A main function to calculate physical quantities by full diagonalization method.

Parameters
[in,out]XCalcStruct list for getting and pushing calculation information
neignumber of eigenvalues
Version
0.2

add output process of calculation results for general spin

Version
0.1
Author
Takahiro Misawa (The University of Tokyo)
Kazuyoshi Yoshimi (The University of Tokyo)
Parameters
[in,out]X
[in]neig

Definition at line 48 of file phys.cpp.

References BindStruct::Check, BindStruct::Def, PhysList::doublon, PhysList::energy, exitMPI(), expec_cisajs(), expec_cisajscktaltdc(), expec_energy_flct(), expec_totalspin(), DefineList::iCalcModel, DefineList::iCalcType, CheckList::idim_max, myrank, DefineList::NsiteMPI, PhysList::num_down, PhysList::num_up, BindStruct::Phys, PhysList::s2, stdoutMPI, PhysList::Sz, v0, and v1.

Referenced by CalcByFullDiag(), and CalcByLOBPCG().

50  {
51  long int i;
52  double tmp_N;
53 #ifdef _SCALAPACK
54  std::complex<double> *vec_tmp;
55  int ictxt, ierr, rank;
56  long int j, i_max;
57 
58  i_max = X->Check.idim_max;
59 
60  if(use_scalapack){
61  fprintf(stdoutMPI, "In scalapack fulldiag, total spin is not calculated !\n");
62  vec_tmp = malloc(i_max*sizeof(std::complex<double>));
63  }
64  for (i = 0; i < neig; i++) {
65  for (j = 0; j < i_max; j++) {
66  v0[j + 1] = 0.0;
67  }
68  if (use_scalapack) {
69  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
70  GetEigenVector(i, i_max, Z_vec, descZ_vec, vec_tmp);
71  if (rank == 0) {
72  for (j = 0; j < i_max; j++) {
73  v0[j + 1] = vec_tmp[j];
74  }
75  }
76  else {
77  for (j = 0; j < i_max; j++) {
78  v0[j + 1] = 0.0;
79  }
80  }
81  }
82  else {
83  if (X->Def.iCalcType == FullDiag) {
84  if (myrank == 0) {
85  for (j = 0; j < i_max; j++) {
86  v0[j + 1] = v1[i][j];
87  }
88  }
89  }
90  else {
91  for (j = 0; j < i_max; j++) {
92  v0[j + 1] = v1[i][j];
93  }
94  }
95  }
96  }/*for (i = 0; i < neig; i++)*/
97 #endif
98 
99  if (expec_energy_flct(X, neig, v0, v1) != 0) {
100  fprintf(stderr, "Error: calc expec_energy.\n");
101  exitMPI(-1);
102  }
103  if (expec_cisajs(X, neig, v0, v1) != 0) {
104  fprintf(stderr, "Error: calc OneBodyG.\n");
105  exitMPI(-1);
106  }
107  if (expec_cisajscktaltdc(X, neig, v0, v1) != 0) {
108  fprintf(stderr, "Error: calc TwoBodyG.\n");
109  exitMPI(-1);
110  }
111 
112 #ifdef _SCALAPACK
113  if (use_scalapack) {
114  if (X->Def.iCalcType == FullDiag) {
115  X->Phys.s2 = 0.0;
116  X->Phys.Sz = 0.0;
117  }
118  }
119  else {
120  if (X->Def.iCalcType == FullDiag) {
121  if (expec_totalspin(X, v1) != 0) {
122  fprintf(stderr, "Error: calc TotalSpin.\n");
123  exitMPI(-1);
124  }
125  }
126  }
127 #else
128  if (X->Def.iCalcType == FullDiag) {
129  if (expec_totalspin(X, neig, v1) != 0) {
130  fprintf(stderr, "Error: calc TotalSpin.\n");
131  exitMPI(-1);
132  }
133  }
134 #endif
135 
136  for (i = 0; i < neig; i++) {
137  if (X->Def.iCalcModel == Spin || X->Def.iCalcModel == SpinGC) {
138  tmp_N = X->Def.NsiteMPI;
139  }
140  else {
141  tmp_N = X->Phys.num_up[i] + X->Phys.num_down[i];
142  }
143  if (X->Def.iCalcType == FullDiag) {
144 #ifdef _SCALAPACK
145  if (use_scalapack) {
146  fprintf(stdoutMPI, "i=%5ld Energy=%10lf N=%10lf Sz=%10lf Doublon=%10lf \n", i, X->Phys.energy, tmp_N,
147  X->Phys.Sz, X->Phys.doublon);
148  }
149  else {
150  fprintf(stdoutMPI, "i=%5ld Energy=%10lf N=%10lf Sz=%10lf S2=%10lf Doublon=%10lf \n", i, X->Phys.energy, tmp_N,
151  X->Phys.Sz, X->Phys.s2, X->Phys.doublon);
152  }
153 #else
154  fprintf(stdoutMPI, "i=%5ld Energy=%10lf N=%10lf Sz=%10lf S2=%10lf Doublon=%10lf \n",
155  i, X->Phys.energy[i], tmp_N, X->Phys.Sz[i], X->Phys.s2[i], X->Phys.doublon[i]);
156 #endif
157  }
158  else if (X->Def.iCalcType == CG)
159  fprintf(stdoutMPI, "i=%5ld Energy=%10lf N=%10lf Sz=%10lf Doublon=%10lf \n",
160  i, X->Phys.energy[i], tmp_N, X->Phys.Sz[i], X->Phys.doublon[i]);
161  }
162 #ifdef _SCALAPACK
163  if(use_scalapack) free(vec_tmp);
164 #endif
165 }
double * doublon
Expectation value of the Doublon.
Definition: struct.hpp:357
void exitMPI(int errorcode)
MPI Abortation wrapper.
Definition: wrapperMPI.cpp:86
struct DefineList Def
Definision of system (Hamiltonian) etc.
Definition: struct.hpp:395
double * num_down
Expectation value of the number of down-spin electtrons.
Definition: struct.hpp:364
FILE * stdoutMPI
File pointer to the standard output defined in InitializeMPI()
Definition: global.cpp:75
int expec_cisajscktaltdc(struct BindStruct *X, int nstate, std::complex< double > **Xvec, std::complex< double > **vec)
Parent function to calculate two-body green&#39;s functions.
int expec_energy_flct(struct BindStruct *X, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1)
Parent function to calculate expected values of energy and physical quantities.
std::complex< double > ** v0
Definition: global.cpp:20
double * s2
Expectation value of the square of the total S.
Definition: struct.hpp:365
struct PhysList Phys
Physical quantities.
Definition: struct.hpp:398
std::complex< double > ** v1
Definition: global.cpp:21
double * Sz
Expectation value of the Total Sz.
Definition: struct.hpp:361
int NsiteMPI
Total number of sites, differ from DefineList::Nsite.
Definition: struct.hpp:57
double * energy
Expectation value of the total energy.
Definition: struct.hpp:356
int expec_totalspin(struct BindStruct *X, int nstate, std::complex< double > **vec)
Parent function of calculation of total spin.
int myrank
Process ID, defined in InitializeMPI()
Definition: global.cpp:73
int expec_cisajs(struct BindStruct *X, int nstate, std::complex< double > **Xvec, std::complex< double > **vec)
function of calculation for one body green&#39;s function
double * num_up
Expectation value of the number of up-spin electtrons.
Definition: struct.hpp:363
int iCalcModel
Switch for model. 0:Hubbard, 1:Spin, 2:Kondo, 3:HubbardGC, 4:SpinGC, 5:KondoGC, 6:HubbardNConserved.
Definition: struct.hpp:200
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
int iCalcType
Switch for calculation type. 0:Lanczos, 1:TPQCalc, 2:FullDiag.
Definition: struct.hpp:194