HPhi++  3.1.0
phys.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 "phys.hpp"
17 #include "expec_energy_flct.hpp"
18 #include "expec_totalspin.hpp"
19 #include "expec_cisajs.hpp"
20 #include "expec_cisajscktaltdc.hpp"
21 #include "wrapperMPI.hpp"
22 #ifdef _SCALAPACK
23 #include "matrixscalapack.hpp"
24 #endif
25 
48 void phys(struct BindStruct *X,
49  long int neig
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
Bind.
Definition: struct.hpp:394
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
void phys(struct BindStruct *X, long int neig)
A main function to calculate physical quantities by full diagonalization method.
Definition: phys.cpp:48
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