HΦ  3.1.0
SingleExHubbard.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 "bitcalc.h"
17 #include "wrapperMPI.h"
18 #include "mfmemory.h"
19 #include "mltplyHubbardCore.h"
20 #include "mltplyMPIHubbardCore.h"
21 #ifdef MPI
22 #include "mpi.h"
23 #endif
24 
35  struct BindStruct *X,
36  double complex *tmp_v0,
37  double complex *tmp_v1
38 ) {
39  long int idim_max, idim_maxMPI;
40  long unsigned int i, j;
41  long unsigned int org_isite, ispin, itype;
42  long unsigned int is1_spin;
43  int isgn = 1;
44  double complex tmpphi;
45  long unsigned int tmp_off = 0;
46  //tmp_v0
47  if (X->Def.NSingleExcitationOperator == 0) {
48  return TRUE;
49  }
50  double complex *tmp_v1bufOrg;
51  //set size
52 #ifdef MPI
53  idim_maxMPI = MaxMPI_li(X->Check.idim_maxOrg);
54  c_malloc1(tmp_v1bufOrg, idim_maxMPI + 1);
55 #endif // MPI
56 
57  idim_max = X->Check.idim_maxOrg;
58  for (i = 0; i < X->Def.NSingleExcitationOperator; i++) {
59  org_isite = X->Def.SingleExcitationOperator[i][0];
60  ispin = X->Def.SingleExcitationOperator[i][1];
61  itype = X->Def.SingleExcitationOperator[i][2];
62  tmpphi = X->Def.ParaSingleExcitationOperator[i];
63  is1_spin = X->Def.Tpow[2 * org_isite + ispin];
64  if (itype == 1) {
65  if (org_isite >= X->Def.Nsite) {
66  X_Cis_MPI(org_isite, ispin, tmpphi, tmp_v0, tmp_v1, tmp_v1bufOrg, idim_max, \
67  X->Def.Tpow, list_1_org, list_1buf_org, list_2_1, list_2_2, \
68  X->Large.irght, X->Large.ilft, X->Large.ihfbit);
69  }
70  else {
71 #pragma omp parallel for default(none) shared(tmp_v0, tmp_v1, X, list_1_org) \
72  firstprivate(idim_max, tmpphi, org_isite, ispin, list_2_1, list_2_2, is1_spin) private(j, isgn,tmp_off)
73  for (j = 1; j <= idim_max; j++) {//idim_max -> original dimension
74  isgn = X_Cis(j, is1_spin, &tmp_off, list_1_org, list_2_1, list_2_2, X->Large.irght, X->Large.ilft, X->Large.ihfbit);
75  tmp_v0[tmp_off] += tmp_v1[j] * isgn*tmpphi;
76  }
77  }
78  }
79  else if (itype == 0) {
80  if (org_isite >= X->Def.Nsite) {
81  X_Ajt_MPI(org_isite, ispin, tmpphi, tmp_v0, tmp_v1, tmp_v1bufOrg, \
82  idim_max, X->Def.Tpow, list_1_org, list_1buf_org, \
83  list_2_1, list_2_2, X->Large.irght, X->Large.ilft, X->Large.ihfbit);
84  }
85  else {
86 #pragma omp parallel for default(none) shared(tmp_v0, tmp_v1, X, list_1_org, list_1) \
87  firstprivate(idim_max, tmpphi, org_isite, ispin, list_2_1, list_2_2, is1_spin, myrank) private(j, isgn, tmp_off)
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, X->Large.irght, X->Large.ilft, X->Large.ihfbit);
90  tmp_v0[tmp_off] += tmp_v1[j] * isgn*tmpphi;
91  }
92  }
93  }
94  }
95  return TRUE;
96 }/*int GetSingleExcitedStateHubbard*/
105  struct BindStruct *X,
106  double complex *tmp_v0,
107  double complex *tmp_v1
108 ){
109  long int idim_max, idim_maxMPI;
110  long unsigned int i, j;
111  long unsigned int org_isite, ispin, itype;
112  long unsigned int is1_spin;
113  double complex tmpphi;
114  long unsigned int tmp_off = 0;
115  //idim_max = X->Check.idim_max;
116  idim_max = X->Check.idim_maxOrg;
117  //tmp_v0
118  if (X->Def.NSingleExcitationOperator == 0) {
119  return TRUE;
120  }
121  double complex *tmp_v1bufOrg;
122  //set size
123 #ifdef MPI
124  idim_maxMPI = MaxMPI_li(X->Check.idim_maxOrg);
125  c_malloc1(tmp_v1bufOrg, idim_maxMPI + 1);
126 #endif // MPI
127 
128  // SingleEx
129  for (i = 0; i < X->Def.NSingleExcitationOperator; i++) {
130  org_isite = X->Def.SingleExcitationOperator[i][0];
131  ispin = X->Def.SingleExcitationOperator[i][1];
132  itype = X->Def.SingleExcitationOperator[i][2];
133  tmpphi = X->Def.ParaSingleExcitationOperator[i];
134  if (itype == 1) {
135  if (org_isite >= X->Def.Nsite) {
136  X_GC_Cis_MPI(org_isite, ispin, tmpphi, tmp_v0, tmp_v1, idim_max, tmp_v1bufOrg, X->Def.Tpow);
137  }
138  else {
139 #pragma omp parallel for default(none) shared(tmp_v0, tmp_v1, X) \
140  firstprivate(idim_max, tmpphi, org_isite, ispin) private(j, is1_spin, tmp_off)
141  for (j = 1; j <= idim_max; j++) {
142  is1_spin = X->Def.Tpow[2 * org_isite + ispin];
143  GC_Cis(j, tmp_v0, tmp_v1, is1_spin, tmpphi, &tmp_off);
144  }/*for (j = 1; j <= idim_max; j++)*/
145  }
146  }
147  else if (itype == 0) {
148  if (org_isite >= X->Def.Nsite) {
149  X_GC_Ajt_MPI(org_isite, ispin, tmpphi, tmp_v0, tmp_v1, idim_max, tmp_v1bufOrg, X->Def.Tpow);
150  }
151  else {
152 #pragma omp parallel for default(none) shared(tmp_v0, tmp_v1, X) \
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, 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*/
double complex X_GC_Cis_MPI(int org_isite, int org_ispin, double complex tmp_trans, double complex *tmp_v0, double complex *tmp_v1, unsigned long int idim_max, double complex *tmp_v1buf, unsigned long int *Tpow)
Single creation/annihilation operator in the inter process region for HubbardGC.
double complex X_Cis_MPI(int org_isite, unsigned int org_ispin, double complex tmp_trans, double complex *tmp_v0, double complex *tmp_v1, double complex *tmp_v1buf, unsigned long int idim_max, long unsigned int *Tpow, long unsigned int *list_1_org, long unsigned int *list_1buf_org, long unsigned int *list_2_1_target, long unsigned int *list_2_2_target, long unsigned int _irght, long unsigned int _ilft, long unsigned int _ihfbit)
Compute term of canonical Hubbard system.
#define TRUE
Definition: global.h:26
long unsigned int * list_1buf_org
Definition: global.h:54
double complex X_Ajt_MPI(int org_isite, unsigned int org_ispin, double complex tmp_trans, double complex *tmp_v0, double complex *tmp_v1, double complex *tmp_v1buf, unsigned long int idim_max, long unsigned int *Tpow, long unsigned int *list_1_org, long unsigned int *list_1buf_org, long unsigned int *list_2_1_target, long unsigned int *list_2_2_target, long unsigned int _irght, long unsigned int _ilft, long unsigned int _ihfbit)
Compute term of canonical Hubbard system.
Bind.
Definition: struct.h:408
int X_Cis(long unsigned int j, long unsigned int is1_spin, long unsigned int *tmp_off, long unsigned int *list_1_org, long unsigned int *list_2_1_target, long unsigned int *list_2_2_target, long unsigned int _irght, long unsigned int _ilft, long unsigned int _ihfbit)
Compute index of final wavefunction associatesd to term of canonical Hubbard system.
double complex GC_Ajt(long unsigned int j, double complex *tmp_v0, double complex *tmp_v1, long unsigned int is1_spin, double complex tmp_V, long unsigned int *tmp_off)
Compute term of grandcanonical Hubbard system.
long unsigned int * list_1_org
Definition: global.h:53
unsigned long int MaxMPI_li(unsigned long int idim)
MPI wrapper function to obtain maximum unsigned long integer across processes.
Definition: wrapperMPI.c:171
long unsigned int * list_2_1
Definition: global.h:49
int GetSingleExcitedStateHubbardGC(struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Calculation of Single excited state for Hubbard Grand canonical system.
double complex X_Ajt(long unsigned int j, long unsigned int is1_spin, long unsigned int *tmp_off, long unsigned int *list_1_org, long unsigned int *list_2_1_target, long unsigned int *list_2_2_target, long unsigned int _irght, long unsigned int _ilft, long unsigned int _ihfbit)
Compute index of final wavefunction associatesd to term of canonical Hubbard system.
double complex X_GC_Ajt_MPI(int org_isite, int org_ispin, double complex tmp_trans, double complex *tmp_v0, double complex *tmp_v1, unsigned long int idim_max, double complex *tmp_v1buf, unsigned long int *Tpow)
Single creation/annihilation operator in the inter process region for HubbardGC.
long unsigned int * list_2_2
Definition: global.h:50
int GetSingleExcitedStateHubbard(struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Calculation of Single excited state for Hubbard canonical system.
struct EDMainCalStruct X
Definition: struct.h:431
double complex GC_Cis(long unsigned int j, double complex *tmp_v0, double complex *tmp_v1, long unsigned int is1_spin, double complex tmp_V, long unsigned int *tmp_off)
Compute term of grandcanonical Hubbard system.