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