HΦ  3.2.0
phys.c File Reference

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

#include "phys.h"
#include "expec_energy_flct.h"
#include "expec_totalspin.h"
#include "expec_cisajs.h"
#include "expec_cisajscktaltdc.h"
#include "wrapperMPI.h"
+ Include dependency graph for phys.c:

Go to the source code of this file.

Functions

void phys (struct BindStruct *X, unsigned 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.c.

Function Documentation

◆ phys()

void phys ( struct BindStruct X,
unsigned 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.c.

References PhysList::all_doublon, PhysList::all_energy, PhysList::all_num_down, PhysList::all_num_up, PhysList::all_s2, PhysList::all_sz, BindStruct::Check, BindStruct::Def, PhysList::doublon, PhysList::eigen_num, PhysList::energy, exitMPI(), expec_cisajs(), expec_cisajscktaltdc(), expec_energy_flct(), expec_totalspin(), DefineList::iCalcModel, DefineList::iCalcType, CheckList::idim_max, L_vec, 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 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
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
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
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
+ Here is the call graph for this function:
+ Here is the caller graph for this function: