HPhi++  3.1.0
SingleExHubbard.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 "bitcalc.hpp"
17 #include "wrapperMPI.hpp"
18 #include "common/setmemory.hpp"
19 #include "mltplyHubbardCore.hpp"
20 #include "mltplyMPIHubbardCore.hpp"
21 #include "mltplyCommon.hpp"
22 #ifdef __MPI
23 #include "mpi.h"
24 #endif
25 
36  struct BindStruct *X,
37  int nstate,
38  std::complex<double> **tmp_v0,
39  std::complex<double> **tmp_v1,
40  int iEx
41 ) {
42  long int idim_max;
43  long int i, j;
44  long int org_isite, ispin, itype;
45  long int is1_spin;
46  int isgn = 1, one = 1;
47  std::complex<double> tmpphi, dmv;
48  long int tmp_off = 0;
49  //tmp_v0
50  if (X->Def.NSingleExcitationOperator[iEx] == 0) {
51  return TRUE;
52  }
53 
54  idim_max = X->Check.idim_maxOrg;
55  for (i = 0; i < X->Def.NSingleExcitationOperator[iEx]; i++) {
56  org_isite = X->Def.SingleExcitationOperator[iEx][i][0];
57  ispin = X->Def.SingleExcitationOperator[iEx][i][1];
58  itype = X->Def.SingleExcitationOperator[iEx][i][2];
59  tmpphi = X->Def.ParaSingleExcitationOperator[iEx][i];
60  is1_spin = X->Def.Tpow[2 * org_isite + ispin];
61  if (itype == 1) {
62  if (org_isite >= X->Def.Nsite) {
63  X_Cis_MPI(org_isite, ispin, tmpphi, nstate, tmp_v0, tmp_v1, idim_max,
64  X->Def.Tpow,
65  X->Large.irght, X->Large.ilft, X->Large.ihfbit);
66  }
67  else {
68 #pragma omp parallel for default(none) shared(nstate,tmp_v0, tmp_v1, X, list_1_org,one) \
69 firstprivate(idim_max, tmpphi, org_isite, ispin, list_2_1, list_2_2, is1_spin) \
70 private(j, isgn,tmp_off,dmv)
71  for (j = 1; j <= idim_max; j++) {//idim_max -> original dimension
72  isgn = X_Cis(j, is1_spin, &tmp_off, list_1_org, list_2_1, list_2_2,
73  X->Large.irght, X->Large.ilft, X->Large.ihfbit);
74  dmv = (std::complex<double>)isgn * tmpphi;
75  zaxpy_(&nstate, &dmv, tmp_v1[j], &one, tmp_v0[tmp_off], &one);
76  }
77  }
78  }
79  else if (itype == 0) {
80  if (org_isite >= X->Def.Nsite) {
81  X_Ajt_MPI(org_isite, ispin, tmpphi, nstate, tmp_v0, tmp_v1,
82  idim_max, X->Def.Tpow, X->Large.irght, X->Large.ilft, X->Large.ihfbit);
83  }
84  else {
85 #pragma omp parallel for default(none) shared(tmp_v0,tmp_v1,X,list_1_org,list_1,one,nstate) \
86 firstprivate(idim_max,tmpphi,org_isite,ispin,list_2_1,list_2_2,is1_spin,myrank) \
87 private(j, isgn, tmp_off,dmv)
88  for (j = 1; j <= idim_max; j++) {//idim_max -> original dimension
89  isgn = X_Ajt(j, is1_spin, &tmp_off, list_1_org, list_2_1, list_2_2,
90  X->Large.irght, X->Large.ilft, X->Large.ihfbit);
91  dmv = (std::complex<double>)isgn * tmpphi;
92  zaxpy_(&nstate, &dmv, tmp_v1[j], &one, tmp_v0[tmp_off], &one);
93  }
94  }
95  }
96  }
97  return TRUE;
98 }/*int GetSingleExcitedStateHubbard*/
107  struct BindStruct *X,
108  int nstate,
109  std::complex<double> **tmp_v0,
110  std::complex<double> **tmp_v1,
111  int iEx
112 ) {
113  long int idim_max;
114  long int i, j;
115  long int org_isite, ispin, itype;
116  long int is1_spin;
117  std::complex<double> tmpphi;
118  long int tmp_off = 0;
119  //idim_max = X->Check.idim_max;
120  idim_max = X->Check.idim_maxOrg;
121  //tmp_v0
122  if (X->Def.NSingleExcitationOperator[iEx] == 0) {
123  return TRUE;
124  }
125 
126  // SingleEx
127  for (i = 0; i < X->Def.NSingleExcitationOperator[iEx]; i++) {
128  org_isite = X->Def.SingleExcitationOperator[iEx][i][0];
129  ispin = X->Def.SingleExcitationOperator[iEx][i][1];
130  itype = X->Def.SingleExcitationOperator[iEx][i][2];
131  tmpphi = X->Def.ParaSingleExcitationOperator[iEx][i];
132  if (itype == 1) {
133  if (org_isite >= X->Def.Nsite) {
134  X_GC_Cis_MPI(org_isite, ispin, tmpphi, nstate, tmp_v0, tmp_v1,
135  idim_max, X->Def.Tpow);
136  }
137  else {
138 #pragma omp parallel for default(none) shared(tmp_v0,tmp_v1,X,nstate) \
139 firstprivate(idim_max, tmpphi, org_isite, ispin) private(j, is1_spin, tmp_off)
140  for (j = 1; j <= idim_max; j++) {
141  is1_spin = X->Def.Tpow[2 * org_isite + ispin];
142  GC_Cis(j, nstate, tmp_v0, tmp_v1, is1_spin, tmpphi, &tmp_off);
143  }/*for (j = 1; j <= idim_max; j++)*/
144  }
145  }
146  else if (itype == 0) {
147  if (org_isite >= X->Def.Nsite) {
148  X_GC_Ajt_MPI(org_isite, ispin, tmpphi, nstate, tmp_v0, tmp_v1,
149  idim_max, X->Def.Tpow);
150  }
151  else {
152 #pragma omp parallel for default(none) shared(tmp_v0,tmp_v1,X,nstate) \
153 firstprivate(idim_max, tmpphi, org_isite, ispin) private(j, is1_spin, tmp_off)
154  for (j = 1; j <= idim_max; j++) {
155  is1_spin = X->Def.Tpow[2 * org_isite + ispin];
156  GC_Ajt(j, nstate, tmp_v0, tmp_v1, is1_spin, tmpphi, &tmp_off);
157  }/*for (j = 1; j <= idim_max; j++)*/
158  }
159  }
160  }
161  return TRUE;
162 }/*int GetSingleExcitedStateHubbardGC*/
struct DefineList Def
Definision of system (Hamiltonian) etc.
Definition: struct.hpp:395
long int * list_2_1
Definition: global.cpp:27
long int * list_2_2
Definition: global.cpp:28
void X_Cis_MPI(int org_isite, int org_ispin, std::complex< double > tmp_trans, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, long int idim_max, long int *Tpow, long int _irght, long int _ilft, long int _ihfbit)
Compute term of canonical Hubbard system.
void X_GC_Ajt_MPI(int org_isite, int org_ispin, std::complex< double > tmp_trans, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, long int idim_max, long int *Tpow)
Single creation/annihilation operator in the inter process region for HubbardGC.
std::complex< double > ** ParaSingleExcitationOperator
[DefineList::NSingleExcitationOperator] Coefficient of single excitaion operator for spectrum...
Definition: struct.hpp:184
int * NSingleExcitationOperator
Number of single excitaion operator for spectrum.
Definition: struct.hpp:183
int Nsite
Number of sites in the INTRA process region.
Definition: struct.hpp:56
int GetSingleExcitedStateHubbardGC(struct BindStruct *X, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, int iEx)
Calculation of Single excited state for Hubbard Grand canonical system.
long int idim_maxOrg
The local Hilbert-space dimention of original state for the spectrum.
Definition: struct.hpp:307
struct LargeList Large
Variables for Matrix-Vector product.
Definition: struct.hpp:397
long int * list_1_org
Definition: global.cpp:31
long int irght
Used for Ogata-Lin ???
Definition: struct.hpp:344
void GC_Ajt(long int j, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, long int is1_spin, std::complex< double > tmp_V, long int *tmp_off)
Compute term of grandcanonical Hubbard system.
int X_Cis(long int j, long int is1_spin, long int *tmp_off, long int *list_1_org, long int *list_2_1_target, long int *list_2_2_target, long int _irght, long int _ilft, long int _ihfbit)
Compute index of final wavefunction associatesd to term of canonical Hubbard system.
long int ilft
Used for Ogata-Lin ???
Definition: struct.hpp:345
Bind.
Definition: struct.hpp:394
int GetSingleExcitedStateHubbard(struct BindStruct *X, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, int iEx)
Calculation of Single excited state for Hubbard canonical system.
void X_GC_Cis_MPI(int org_isite, int org_ispin, std::complex< double > tmp_trans, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, long int idim_max, long int *Tpow)
Single creation/annihilation operator in the inter process region for HubbardGC.
long int ihfbit
Used for Ogata-Lin ???
Definition: struct.hpp:346
int X_Ajt(long int j, long int is1_spin, long int *tmp_off, long int *list_1_org, long int *list_2_1_target, long int *list_2_2_target, long int _irght, long int _ilft, long int _ihfbit)
Compute index of final wavefunction associatesd to term of canonical Hubbard system.
long int * Tpow
[2 * DefineList::NsiteMPI] malloc in setmem_def().
Definition: struct.hpp:90
void X_Ajt_MPI(int org_isite, int org_ispin, std::complex< double > tmp_trans, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, long int idim_max, long int *Tpow, long int _irght, long int _ilft, long int _ihfbit)
Compute term of canonical Hubbard system.
void GC_Cis(long int j, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, long int is1_spin, std::complex< double > tmp_V, long int *tmp_off)
Compute term of grandcanonical Hubbard system.
struct CheckList Check
Size of the Hilbert space.
Definition: struct.hpp:396
int *** SingleExcitationOperator
[DefineList::NSingleExcitationOperator][3] Indices of single excitaion operator for spectrum...
Definition: struct.hpp:180