HΦ  3.2.0
mltply.c
Go to the documentation of this file.
1 /* HPhi - Quantum Lattice Model Simulator */
2 /* Copyright (C) 2015 The University of Tokyo */
3 /* This program is free software: you can redistribute it and/or modify */
4 /* it under the terms of the GNU General Public License as published by */
5 /* the Free Software Foundation, either version 3 of the License, or */
6 /* (at your option) any later version. */
7 
8 /* This program is distributed in the hope that it will be useful, */
9 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
10 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
11 /* GNU General Public License for more details. */
12 
13 /* You should have received a copy of the GNU General Public License */
14 /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
15 
16 // Define Mode for mltply
17 // complex version
18 #include <bitcalc.h>
19 #include "mltply.h"
20 #include "mltplySpin.h"
21 #include "mltplyHubbard.h"
22 #include "wrapperMPI.h"
23 #include "CalcTime.h"
24 #include "mltplyCommon.h"
25 #include "diagonalcalc.h"
26 
56 int mltply(struct BindStruct *X, double complex *tmp_v0,double complex *tmp_v1) {
57  long unsigned int j=0;
58  long unsigned int irght=0;
59  long unsigned int ilft=0;
60  long unsigned int ihfbit=0;
61 
62  double complex dam_pr;
63 
64  long unsigned int i_max;
65 
66  StartTimer(1);
67  i_max = X->Check.idim_max;
68  X->Large.prdct = 0.0;
69  dam_pr = 0.0;
70 
71  if(i_max!=0){
72  if (X->Def.iFlgGeneralSpin == FALSE) {
73  if (GetSplitBitByModel(X->Def.Nsite, X->Def.iCalcModel, &irght, &ilft, &ihfbit) != 0) {
74  return -1;
75  }
76  }
77  else{
78  if(X->Def.iCalcModel==Spin){
79  if (GetSplitBitForGeneralSpin(X->Def.Nsite, &ihfbit, X->Def.SiteToBit) != 0) {
80  return -1;
81  }
82  }
83  }
84  }
85  else{
86  irght=0;
87  ilft=0;
88  ihfbit=0;
89  }
90  X->Large.i_max = i_max;
91  X->Large.irght = irght;
92  X->Large.ilft = ilft;
93  X->Large.ihfbit = ihfbit;
94  X->Large.mode = M_MLTPLY;
95 
96  StartTimer(100);
97 #pragma omp parallel for default(none) reduction(+:dam_pr) firstprivate(i_max) shared(tmp_v0, tmp_v1, list_Diagonal)
98  for (j = 1; j <= i_max; j++) {
99  tmp_v0[j] += (list_Diagonal[j]) * tmp_v1[j];
100  dam_pr += (list_Diagonal[j]) * conj(tmp_v1[j]) * tmp_v1[j];
101  }
102  X->Large.prdct += dam_pr;
103  StopTimer(100);
104  if (X->Def.iCalcType == TimeEvolution) diagonalcalcForTE(step_i, X, tmp_v0, tmp_v1);
105 
106  switch (X->Def.iCalcModel) {
107  case HubbardGC:
108  mltplyHubbardGC(X, tmp_v0, tmp_v1);
109  break;
110 
111  case KondoGC:
112  case Hubbard:
113  case Kondo:
114  mltplyHubbard(X, tmp_v0, tmp_v1);
115  break;
116 
117  case Spin:
118  mltplySpin(X, tmp_v0, tmp_v1);
119  break;
120 
121  case SpinGC:
122  mltplySpinGC(X, tmp_v0, tmp_v1);
123  break;
124 
125  default:
126  return -1;
127  }
128 
129  X->Large.prdct = SumMPI_dc(X->Large.prdct);
130  StopTimer(1);
131  return 0;
132 }
struct DefineList Def
Definision of system (Hamiltonian) etc.
Definition: struct.h:410
int mltply(struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Parent function of multiplying the wavefunction by the Hamiltonian. . First, the calculation of diago...
Definition: mltply.c:56
void StartTimer(int n)
function for initializing elapse time [start]
Definition: time.c:71
int GetSplitBitForGeneralSpin(const int Nsite, long unsigned int *ihfbit, const long int *SiteToBit)
function of getting right, left and half bits corresponding to a original space.
Definition: bitcalc.c:124
double complex SumMPI_dc(double complex norm)
MPI wrapper function to obtain sum of Double complex across processes.
Definition: wrapperMPI.c:205
long unsigned int ihfbit
Used for Ogata-Lin ???
Definition: struct.h:345
unsigned long int idim_max
The dimension of the Hilbert space of this process.
Definition: struct.h:303
void StopTimer(int n)
function for calculating elapse time [elapse time=StartTimer-StopTimer]
Definition: time.c:83
int mltplySpinGC(struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Driver function for Spin hamiltonian.
Definition: mltplySpin.c:393
double complex prdct
The expectation value of the energy.
Definition: struct.h:314
struct LargeList Large
Variables for Matrix-Vector product.
Definition: struct.h:412
int mode
multiply or expectation value.
Definition: struct.h:330
Bind.
Definition: struct.h:409
unsigned int Nsite
Number of sites in the INTRA process region.
Definition: struct.h:56
long unsigned int ilft
Used for Ogata-Lin ???
Definition: struct.h:344
int GetSplitBitByModel(const int Nsite, const int iCalcModel, long unsigned int *irght, long unsigned int *ilft, long unsigned int *ihfbit)
function of splitting original bit into right and left spaces.
Definition: bitcalc.c:78
long int i_max
Length of eigenvector.
Definition: struct.h:317
int iFlgGeneralSpin
Flag for the general (Sz/=1/2) spin.
Definition: struct.h:86
#define FALSE
Definition: global.h:25
long int * SiteToBit
[DefineList::NsiteMPI] Similar to DefineList::Tpow. For general spin.
Definition: struct.h:94
int mltplyHubbardGC(struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
perform Hamiltonian vector product for (extended) Hubbard type model (Grandcanonical).
struct EDMainCalStruct X
Definition: struct.h:432
long unsigned int irght
Used for Ogata-Lin ???
Definition: struct.h:343
double * list_Diagonal
Definition: global.h:46
int iCalcModel
Switch for model. 0:Hubbard, 1:Spin, 2:Kondo, 3:HubbardGC, 4:SpinGC, 5:KondoGC, 6:HubbardNConserved.
Definition: struct.h:198
int diagonalcalcForTE(const int _istep, struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Definition: diagonalcalc.c:197
int mltplySpin(struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Driver function for Spin hamiltonian.
Definition: mltplySpin.c:175
struct CheckList Check
Size of the Hilbert space.
Definition: struct.h:411
int step_i
Definition: global.h:66
int mltplyHubbard(struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
perform Hamiltonian vector product for (extended) Hubbard type model.
int iCalcType
Switch for calculation type. 0:Lanczos, 1:TPQCalc, 2:FullDiag.
Definition: struct.h:192