HΦ  3.2.0
phys.c
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.h"
17 #include "expec_energy_flct.h"
18 #include "expec_totalspin.h"
19 #include "expec_cisajs.h"
20 #include "expec_cisajscktaltdc.h"
21 #include "wrapperMPI.h"
22 #ifdef _SCALAPACK
23 #include "matrixscalapack.h"
24 #endif
25 
48 void phys(struct BindStruct *X,
49  unsigned long int neig
50 ) {
51  long unsigned int i, j, i_max;
52  double tmp_N;
53  i_max = X->Check.idim_max;
54 #ifdef _SCALAPACK
55  double complex *vec_tmp;
56  int ictxt, ierr, rank;
57  if(use_scalapack){
58  fprintf(stdoutMPI, "In scalapack fulldiag, total spin is not calculated !\n");
59  vec_tmp = malloc(i_max*sizeof(double complex));
60  }
61 #endif
62  for (i = 0; i < neig; i++) {
63 #ifdef _SCALAPACK
64  for (j = 0; j < i_max; j++) {
65  v0[j + 1] = 0.0;
66  }
67  if(use_scalapack){
68  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
69  GetEigenVector(i, i_max, Z_vec, descZ_vec, vec_tmp);
70  if(rank == 0) {
71  for (j = 0; j < i_max; j++) {
72  v0[j + 1] = vec_tmp[j];
73  }
74  }
75  else{
76  for (j = 0; j < i_max; j++) {
77  v0[j + 1] = 0.0;
78  }
79  }
80  } else {
81  if (X->Def.iCalcType == FullDiag) {
82  if (myrank == 0) {
83  for (j = 0; j < i_max; j++) {
84  v0[j + 1] = L_vec[i][j];
85  }
86  }
87  } else {
88  for (j = 0; j < i_max; j++) {
89  v0[j + 1] = L_vec[i][j];
90  }
91 
92  }
93  }
94 #else
95  for (j = 0; j < i_max; j++) {
96  v0[j + 1] = L_vec[i][j];
97  }
98 #endif
99 
100  X->Phys.eigen_num = i;
101  if (expec_energy_flct(X) != 0) {
102  fprintf(stderr, "Error: calc expec_energy.\n");
103  exitMPI(-1);
104  }
105  if (expec_cisajs(X, v1) != 0) {
106  fprintf(stderr, "Error: calc OneBodyG.\n");
107  exitMPI(-1);
108  }
109  if (expec_cisajscktaltdc(X, v1) != 0) {
110  fprintf(stderr, "Error: calc TwoBodyG.\n");
111  exitMPI(-1);
112  }
113 
114 #ifdef _SCALAPACK
115  if(use_scalapack){
116  if (X->Def.iCalcType == FullDiag) {
117  X->Phys.s2=0.0;
118  X->Phys.Sz=0.0;
119  }
120  }else{
121  if (X->Def.iCalcType == FullDiag) {
122  if (expec_totalspin(X, v1) != 0) {
123  fprintf(stderr, "Error: calc TotalSpin.\n");
124  exitMPI(-1);
125  }
126  }
127  }
128 #else
129  if (X->Def.iCalcType == FullDiag) {
130  if (expec_totalspin(X, v1) != 0) {
131  fprintf(stderr, "Error: calc TotalSpin.\n");
132  exitMPI(-1);
133  }
134  }
135 #endif
136 
137  if (X->Def.iCalcModel == Spin || X->Def.iCalcModel == SpinGC) {
138  tmp_N = X->Def.NsiteMPI;
139  } else {
140  tmp_N = X->Phys.num_up + X->Phys.num_down;
141  }
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", i, X->Phys.energy, tmp_N,
155  X->Phys.Sz, X->Phys.s2, X->Phys.doublon);
156 
157 #endif
158  }
159  else if (X->Def.iCalcType == CG)
160  fprintf(stdoutMPI, "i=%5ld Energy=%10lf N=%10lf Sz=%10lf Doublon=%10lf \n", i, X->Phys.energy, tmp_N,
161  X->Phys.Sz, X->Phys.doublon);
162  X->Phys.all_energy[i] = X->Phys.energy;
163  X->Phys.all_doublon[i] = X->Phys.doublon;
164  X->Phys.all_sz[i] = X->Phys.Sz;
165  X->Phys.all_s2[i] = X->Phys.s2;
166  X->Phys.all_num_up[i] = X->Phys.num_up;
167  X->Phys.all_num_down[i] = X->Phys.num_down;
168  }
169 #ifdef _SCALAPACK
170  if(use_scalapack) free(vec_tmp);
171 #endif
172 }
double * all_num_down
[CheckList::idim_max+1] Number of spin-down electrons for FullDiag and LOBPCG. malloc in setmem_large...
Definition: struct.h:381
double * all_s2
[CheckList::idim_max+1] for FullDiag and LOBPCG. malloc in setmem_large().
Definition: struct.h:377
void exitMPI(int errorcode)
MPI Abortation wrapper.
Definition: wrapperMPI.c:86
struct DefineList Def
Definision of system (Hamiltonian) etc.
Definition: struct.h:410
int expec_cisajscktaltdc(struct BindStruct *X, double complex *vec)
Parent function to calculate two-body green&#39;s functions.
int expec_totalspin(struct BindStruct *X, double complex *vec)
Parent function of calculation of total spin.
unsigned long int idim_max
The dimension of the Hilbert space of this process.
Definition: struct.h:303
double num_up
Expectation value of the number of up-spin electtrons.
Definition: struct.h:368
double complex * v1
Definition: global.h:35
void phys(struct BindStruct *X, unsigned long int neig)
A main function to calculate physical quantities by full diagonalization method.
Definition: phys.c:48
double num_down
Expectation value of the number of down-spin electtrons.
Definition: struct.h:369
struct PhysList Phys
Physical quantities.
Definition: struct.h:413
Bind.
Definition: struct.h:409
int expec_cisajs(struct BindStruct *X, double complex *vec)
function of calculation for one body green&#39;s function
Definition: expec_cisajs.c:69
double * all_doublon
[CheckList::idim_max+1] Doublon for FullDiag and LOBPCG. malloc in setmem_large().
Definition: struct.h:373
unsigned int NsiteMPI
Total number of sites, differ from DefineList::Nsite.
Definition: struct.h:57
double complex ** L_vec
Definition: global.h:74
double s2
Expectation value of the square of the total S.
Definition: struct.h:370
struct EDMainCalStruct X
Definition: struct.h:432
double doublon
Expectation value of the Doublon.
Definition: struct.h:356
double * all_sz
[CheckList::idim_max+1] for FullDiag and LOBPCG. malloc in setmem_large().
Definition: struct.h:375
int iCalcModel
Switch for model. 0:Hubbard, 1:Spin, 2:Kondo, 3:HubbardGC, 4:SpinGC, 5:KondoGC, 6:HubbardNConserved.
Definition: struct.h:198
double Sz
Expectation value of the Total Sz.
Definition: struct.h:360
int myrank
Process ID, defined in InitializeMPI()
Definition: global.h:163
int expec_energy_flct(struct BindStruct *X)
Parent function to calculate expected values of energy and physical quantities.
int eigen_num
Index of eigenstate used for the file name of the correlation function.
Definition: struct.h:367
double energy
Expectation value of the total energy.
Definition: struct.h:355
double complex * v0
Definition: global.h:34
struct CheckList Check
Size of the Hilbert space.
Definition: struct.h:411
double * all_num_up
[CheckList::idim_max+1] Number of spin-up electrons for FullDiag and LOBPCG. malloc in setmem_large()...
Definition: struct.h:379
int iCalcType
Switch for calculation type. 0:Lanczos, 1:TPQCalc, 2:FullDiag.
Definition: struct.h:192
FILE * stdoutMPI
File pointer to the standard output defined in InitializeMPI()
Definition: global.h:165
double * all_energy
[CheckList::idim_max+1] Energy for FullDiag and LOBPCG. malloc in setmem_large(). ...
Definition: struct.h:371