Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
corr2pt_Wilson_SF.cpp
Go to the documentation of this file.
1 
14 #include "corr2pt_Wilson_SF.h"
15 
16 //====================================================================
17 
64 const std::string Corr2pt_Wilson_SF::class_name = "Corr2pt_Wilson_SF";
65 
66 //====================================================================
67 double Corr2pt_Wilson_SF::fAfP(const std::vector<Field_F>& sq1,
68  const std::vector<Field_F>& sq2)
69 {
70  const int Lt = CommonParameters::Lt();
71 
72  const int Nvol = CommonParameters::Nvol();
73  const int NPE = CommonParameters::NPE();
74 
75  const double norm = (0.5 / Nvol / NPE) * Lt;
76 
77  std::vector<dcomplex> m_corr(Lt);
78 
79  // double norm=0.5/Lvol*Lt*(2*0.130*2*0.130);
80  // vout.general(m_vl,"norm=%lf\n",norm);
81 
82  vout.general(m_vl, "AO correlator:\n");
83 
86 
87  meson_corr(m_corr, qn_sink, qn_src, sq1, sq1);
88 
89  for (int t = 0; t < m_corr.size(); ++t) {
90  vout.general(m_vl, "fA %4d %20.12e %20.12e\n",
91  t, -norm * real(m_corr[t]), -norm * imag(m_corr[t]));
92  }
93 
94 
95  vout.general(m_vl, "PO correlator:\n");
96 
97  qn_src = m_gmset->get_GM(m_gmset->GAMMA5);
98  qn_sink = m_gmset->get_GM(m_gmset->GAMMA5);
99  // qn_src = m_gmset->get_GM(m_gmset->UNITY);
100  // qn_sink = m_gmset->get_GM(m_gmset->UNITY);
101 
102  meson_corr(m_corr, qn_sink, qn_src, sq1, sq1);
103 
104  for (int t = 0; t < m_corr.size(); ++t) {
105  vout.general(m_vl, "fP %4d %20.12e %20.12e\n",
106  t, norm * real(m_corr[t]), norm * imag(m_corr[t]));
107  }
108 
109 
110  vout.general(m_vl, "AO' correlator:\n");
111 
112  qn_src = m_gmset->get_GM(m_gmset->GAMMA5);
113  qn_sink = m_gmset->get_GM(m_gmset->GAMMA54);
114 
115  meson_corr(m_corr, qn_sink, qn_src, sq2, sq2);
116 
117  for (int t = 0; t < m_corr.size(); ++t) {
118  vout.general(m_vl, "fA' %4d %20.12e %20.12e\n",
119  t, norm * real(m_corr[Lt - 1 - t]), norm * imag(m_corr[Lt - 1 - t]));
120  }
121 
122 
123  vout.general(m_vl, "PO' correlator:\n");
124 
125  qn_src = m_gmset->get_GM(m_gmset->GAMMA5);
126  qn_sink = m_gmset->get_GM(m_gmset->GAMMA5);
127  // qn_src = m_gmset->get_GM(m_gmset->UNITY);
128  // qn_sink = m_gmset->get_GM(m_gmset->UNITY);
129 
130  meson_corr(m_corr, qn_sink, qn_src, sq2, sq2);
131 
132  for (int t = 0; t < m_corr.size(); ++t) {
133  vout.general(m_vl, "fP' %4d %20.12e %20.12e\n",
134  t, norm * real(m_corr[Lt - 1 - t]), norm * imag(m_corr[Lt - 1 - t]));
135  }
136 
137 
138  //- NB. use meson correlator at t=1 for a non-trivial check.
139  // double result = real(m_corr[0]);
140  const double result = real(m_corr[1]);
141 
142  return result;
143 }
144 
145 
146 //====================================================================
147 double Corr2pt_Wilson_SF::meson_corr(std::vector<dcomplex>& meson,
148  const GammaMatrix& qn_sink,
149  const GammaMatrix& qn_src,
150  const std::vector<Field_F>& sq1,
151  const std::vector<Field_F>& sq2)
152 {
153  const int Nc = CommonParameters::Nc();
154  const int Nd = CommonParameters::Nd();
155  const int Nvol = CommonParameters::Nvol();
156  const int Lt = CommonParameters::Lt();
157  const int Nx = CommonParameters::Nx();
158  const int Ny = CommonParameters::Ny();
159  const int Nz = CommonParameters::Nz();
160  const int Nt = CommonParameters::Nt();
161 
162  assert(meson.size() == Lt);
163 
164  const GammaMatrix gm5 = m_gmset->get_GM(m_gmset->GAMMA5);
165  const GammaMatrix gm_src = qn_src.mult(gm5);
166  const GammaMatrix gm_sink = gm5.mult(qn_sink);
167 
168  const Index_lex index;
169 
170  std::valarray<double> corr_r(Nd), corr_i(Nd);
171  // std::vector<int> s2(Nd);
172  Field corrF(2, Nvol, 2);
173 
174  std::valarray<dcomplex> corr_local(Nt);
175  corr_local = cmplx(0.0, 0.0);
176 
177  for (int c0 = 0; c0 < Nc; ++c0) {
178  for (int d0 = 0; d0 < Nd; ++d0) {
179  int d1 = gm_src.index(d0);
180  // int d1 = qn_src.index(d0);
181 
182  for (int t = 0; t < Nt; ++t) {
183  corr_r = 0.0;
184  corr_i = 0.0;
185  for (int z = 0; z < Nz; ++z) {
186  for (int y = 0; y < Ny; ++y) {
187  for (int x = 0; x < Nx; ++x) {
188  int site = index.site(x, y, z, t);
189 
190  for (int s0 = 0; s0 < Nd; ++s0) {
191  int s1 = gm_sink.index(s0);
192  //int s1 = qn_sink.index(s0);
193 
194  for (int c1 = 0; c1 < Nc; ++c1) {
195  corr_r[s0] += sq1[c0 + Nc * d0].cmp_r(c1, s1, site)
196  * sq2[c0 + Nc * d1].cmp_r(c1, s0, site)
197  + sq1[c0 + Nc * d0].cmp_i(c1, s1, site)
198  * sq2[c0 + Nc * d1].cmp_i(c1, s0, site);
199 
200  corr_i[s0] += sq1[c0 + Nc * d0].cmp_r(c1, s1, site)
201  * sq2[c0 + Nc * d1].cmp_i(c1, s0, site)
202  - sq1[c0 + Nc * d0].cmp_i(c1, s1, site)
203  * sq2[c0 + Nc * d1].cmp_r(c1, s0, site);
204  }
205  }
206  }
207  }
208  }
209  for (int s0 = 0; s0 < Nd; ++s0) {
210  dcomplex gmf = gm_src.value(d0) * gm_sink.value(s0);
211  //dcomplex gmf = qn_src.value(d0)*qn_sink.value(s0);
212  dcomplex corr = cmplx(corr_r[s0], corr_i[s0]);
213  corr_local[t] += gmf * corr;
214  //corr_local[t] += corr;
215  }
216  //vout.general(m_vl,"%d %lf %lf\n",t,real(corr_local[t]),imag(corr_local[t]));
217  }
218  }
219  }
220 
221 
222  const int ipe_t = Communicator::ipe(3);
223 
224  std::vector<dcomplex> corr_global(Lt);
225  for (int t_global = 0; t_global < Lt; ++t_global) {
226  corr_global[t_global] = cmplx(0.0, 0.0);
227  }
228  for (int t = 0; t < Nt; ++t) {
229  int t_global = t + ipe_t * Nt;
230  corr_global[t_global] = corr_local[t];
231  }
232  for (int t_global = 0; t_global < Lt; ++t_global) {
233  double cr_r = real(corr_global[t_global]);
234  double cr_i = imag(corr_global[t_global]);
235 
236  cr_r = Communicator::reduce_sum(cr_r);
237  cr_i = Communicator::reduce_sum(cr_i);
238 
239  meson[t_global] = cmplx(cr_r, cr_i);
240  // vout.general(m_vl,"%d %lf %lf\n",t,crr,cri);
241  }
242 
243 
244  //- NB. use meson correlator at t=1 for a non-trivial check.
245  // double result = real(m_corr[0]);
246  const double result = real(meson[1]);
247 
248 
249  return result;
250 }
251 
252 
253 //====================================================================
254 //============================================================END=====
Bridge::VerboseLevel m_vl
BridgeIO vout
Definition: bridgeIO.cpp:503
int site(const int &x, const int &y, const int &z, const int &t) const
Definition: index_lex.h:53
double meson_corr(std::vector< dcomplex > &meson, const GammaMatrix &gm_sink, const GammaMatrix &gm_src, const std::vector< Field_F > &sq1, const std::vector< Field_F > &sq2)
void general(const char *format,...)
Definition: bridgeIO.cpp:197
GammaMatrix get_GM(GMspecies spec)
Container of Field-type object.
Definition: field.h:45
static int ipe(const int dir)
logical coordinate of current proc.
Gamma Matrix class.
Definition: gammaMatrix.h:44
double fAfP(const std::vector< Field_F > &sq1, const std::vector< Field_F > &sq2)
Lexical site index.
Definition: index_lex.h:34
GammaMatrix mult(GammaMatrix) const
Definition: gammaMatrix.cpp:39
GammaMatrixSet * m_gmset
static int reduce_sum(int count, double *recv_buf, double *send_buf, int pattern=0)
make a global sum of an array of double over the communicator. pattern specifies the dimensions to be...
dcomplex value(int row) const
Definition: gammaMatrix.h:88
static const std::string class_name
int index(int row) const
Definition: gammaMatrix.h:83