Bridge++  Ver. 1.2.x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
corr2pt_4spinor.cpp
Go to the documentation of this file.
1 
14 #include <cassert>
15 #include "corr2pt_4spinor.h"
16 
17 using std::valarray;
18 using Bridge::vout;
19 
20 const std::string Corr2pt_4spinor::class_name = "Corr2pt_4spinor";
21 
22 //====================================================================
24 {
25  assert(CommonParameters::Nc() == 3);
26 
27  int Nc = 3;
28  int n;
29 
30  m_epsilon_index.resize(Nc * 6);
31 
32  n = 0;
33  m_epsilon_index[Nc * n] = 0;
34  m_epsilon_index[1 + Nc * n] = 1;
35  m_epsilon_index[2 + Nc * n] = 2;
36  n = 1;
37  m_epsilon_index[Nc * n] = 1;
38  m_epsilon_index[1 + Nc * n] = 2;
39  m_epsilon_index[2 + Nc * n] = 0;
40  n = 2;
41  m_epsilon_index[Nc * n] = 2;
42  m_epsilon_index[1 + Nc * n] = 0;
43  m_epsilon_index[2 + Nc * n] = 1;
44  n = 3;
45  m_epsilon_index[Nc * n] = 2;
46  m_epsilon_index[1 + Nc * n] = 1;
47  m_epsilon_index[2 + Nc * n] = 0;
48  n = 4;
49  m_epsilon_index[Nc * n] = 1;
50  m_epsilon_index[1 + Nc * n] = 0;
51  m_epsilon_index[2 + Nc * n] = 2;
52  n = 5;
53  m_epsilon_index[Nc * n] = 0;
54  m_epsilon_index[1 + Nc * n] = 2;
55  m_epsilon_index[2 + Nc * n] = 1;
56 }
57 
58 
59 //====================================================================
60 double Corr2pt_4spinor::meson_all(const valarray<Field_F>& sq1,
61  const valarray<Field_F>& sq2)
62 {
63  int Lt = CommonParameters::Lt();
64 
65  valarray<dcomplex> mcorr(Lt);
66  GammaMatrix qn_src, qn_sink;
67 
68  vout.general(m_vl, "PS <-- PS correlator:\n");
69  qn_src = m_gmset->get_GM(m_gmset->GAMMA5);
70  qn_sink = m_gmset->get_GM(m_gmset->GAMMA5);
71  meson_corr(mcorr, qn_sink, qn_src, sq1, sq2);
72  for (int t = 0; t < mcorr.size(); ++t) {
73  vout.general(m_vl, " %4d %20.12e %20.12e\n",
74  t, real(mcorr[t]), imag(mcorr[t]));
75  }
76  double result = real(mcorr[0]);
77 
78  vout.general(m_vl, "V1 <-- V1 correlator:\n");
79  qn_src = m_gmset->get_GM(m_gmset->GAMMA1);
80  qn_sink = m_gmset->get_GM(m_gmset->GAMMA1);
81  meson_corr(mcorr, qn_sink, qn_src, sq1, sq2);
82  for (int t = 0; t < mcorr.size(); ++t) {
83  vout.general(m_vl, " %4d %20.12e %20.12e\n",
84  t, real(mcorr[t]), imag(mcorr[t]));
85  }
86 
87  vout.general(m_vl, "V2 <-- V2 correlator:\n");
88  qn_src = m_gmset->get_GM(m_gmset->GAMMA2);
89  qn_sink = m_gmset->get_GM(m_gmset->GAMMA2);
90  meson_corr(mcorr, qn_sink, qn_src, sq1, sq2);
91  for (int t = 0; t < mcorr.size(); ++t) {
92  vout.general(m_vl, " %4d %20.12e %20.12e\n",
93  t, real(mcorr[t]), imag(mcorr[t]));
94  }
95 
96  vout.general(m_vl, "V3 <-- V3 correlator:\n");
97  qn_src = m_gmset->get_GM(m_gmset->GAMMA3);
98  qn_sink = m_gmset->get_GM(m_gmset->GAMMA3);
99  meson_corr(mcorr, qn_sink, qn_src, sq1, sq2);
100  for (int t = 0; t < mcorr.size(); ++t) {
101  vout.general(m_vl, " %4d %20.12e %20.12e\n",
102  t, real(mcorr[t]), imag(mcorr[t]));
103  }
104 
105  return result;
106 }
107 
108 
109 //====================================================================
110 void Corr2pt_4spinor::meson_corr(valarray<dcomplex>& meson,
111  const GammaMatrix& qn_sink,
112  const GammaMatrix& qn_src,
113  const valarray<Field_F>& sq1,
114  const valarray<Field_F>& sq2)
115 {
116  int Nc = CommonParameters::Nc();
117  int Nd = CommonParameters::Nd();
118  int Lt = CommonParameters::Lt();
119  int Nt = CommonParameters::Nt();
120 
121  assert(meson.size() == Lt);
122 
123  GammaMatrix gm_src, gm_sink, gm5;
124  gm5 = m_gmset->get_GM(m_gmset->GAMMA5);
125  gm_src = qn_src.mult(gm5);
126  gm_sink = gm5.mult(qn_sink);
127 
128  Index_lex index;
129  valarray<dcomplex> corr_local(Nt);
130  valarray<double> corr_r(Nd), corr_i(Nd);
131  valarray<int> s2(Nd);
132 
133  for (int c0 = 0; c0 < Nc; ++c0) {
134  for (int d0 = 0; d0 < Nd; ++d0) {
135  int d1 = gm_src.index(d0);
136 
137  dcomplex corr_t;
138  for (int t = 0; t < Nt; ++t) {
139  contract_at_t(corr_t, gm_sink,
140  sq1[c0 + Nc * d0], sq2[c0 + Nc * d1], t);
141 
142  dcomplex corr = cmplx(real(corr_t), imag(corr_t));
143  corr_local[t] += gm_src.value(d0) * corr;
144  }
145  }
146  }
147 
148  global_corr_t(meson, corr_local);
149 }
150 
151 
152 //====================================================================
153 double Corr2pt_4spinor::proton_test(const valarray<Field_F>& squ,
154  const valarray<Field_F>& sqd)
155 {
156  int Lt = CommonParameters::Lt();
157 
158  valarray<dcomplex> p_corr_unity(Lt), p_corr_gamm0(Lt), p_corr_upper(Lt);
159  GammaMatrix qn_unit, qn_gamm0;
160 
161 //#define DEBUG 0
162 
163 #if (DEBUG & 1)
164  vout.general(m_vl, "proton <-- proton correlator(UNITY):\n");
165 #endif
166 
167  qn_unit = m_gmset->get_GM(m_gmset->UNITY);
168  qn_gamm0 = m_gmset->get_GM(m_gmset->GAMMA4);
169 
170  proton_corr(p_corr_unity, qn_unit, squ, sqd);
171 
172 #if (DEBUG & 1)
173  for (int it = 0; it < p_corr_unity.size(); it++) {
174  vout.general(m_vl, " %4d %20.12e %20.12e\n",
175  it, real(p_corr_unity[it]), imag(p_corr_unity[it]));
176  }
177 #endif
178 
179  vout.general(m_vl, "proton <-- proton correlator(UPPER):\n");
180 
181  proton_corr(p_corr_gamm0, qn_gamm0, squ, sqd);
182  for (int it = 0; it < p_corr_upper.size(); it++) {
183  p_corr_upper[it] = (p_corr_unity[it] + p_corr_gamm0[it]) * 0.5;
184  vout.general(m_vl, " %4d %20.12e %20.12e\n",
185  it, real(p_corr_upper[it]), imag(p_corr_upper[it]));
186  }
187 
188 #if (DEBUG & 1)
189  vout.general(m_vl, "proton <-- proton correlator(GAMMA0):\n");
190 
191  for (int it = 0; it < p_corr_gamm0.size(); it++) {
192  vout.general(m_vl, " %4d %20.12e %20.12e\n",
193  it, real(p_corr_gamm0[it]), imag(p_corr_gamm0[it]));
194  }
195 #endif
196 
197  double result = real(p_corr_gamm0[0]);
198 
199  return result;
200 }
201 
202 
203 //====================================================================
204 void Corr2pt_4spinor::proton_corr(valarray<dcomplex>& proton,
205  const GammaMatrix& gm,
206  const valarray<Field_F>& squ,
207  const valarray<Field_F>& sqd)
208 {
209  int Nc = CommonParameters::Nc();
210  int Nd = CommonParameters::Nd();
211  int Lt = CommonParameters::Lt();
212  int Nt = CommonParameters::Nt();
213 
214  assert(Nc == 3);
215  assert(proton.size() == Lt);
216 
217  GammaMatrix cg5, c, gm5;
218  gm5 = m_gmset->get_GM(m_gmset->GAMMA5);
220  cg5 = c.mult(gm5);
221 
222 #if (DEBUG & 1)
223  vout.general(m_vl, "i:\tgm5\t\t\t\tc\t\t\t\tcg5\t\t\t\tgm\n");
224  for (int i = 0; i < Nd; i++) {
225  vout.general(m_vl, "%d:\t %d %e %e \t %d %e %e \t %d %e %e \t %d %e %e \n",
226  i,
227  gm5.index(i), real(gm5.value(i)), imag(gm5.value(i)),
228  c.index(i), real(c.value(i)), imag(c.value(i)),
229  cg5.index(i), real(cg5.value(i)), imag(cg5.value(i)),
230  gm.index(i), real(gm.value(i)), imag(gm.value(i))
231  );
232  }
233 #endif
234 
235  int FactNc = 6;
236  // This is valid only when Nc =3, which was already asserted.
237 
238  valarray<dcomplex> corr_local(Nt);
239  corr_local = cmplx(0.0, 0.0);
240 
241  for (int it = 0; it < Nt; it++) {
242 #if ((DEBUG & 65535) & 0)
243  vout.general(m_vl, "# it= %d\n", it);
244 #endif
245 
246  dcomplex sum = 0.0;
247  dcomplex sum1, sum2;
248 
249  for (int ialph = 0; ialph < Nd; ialph++) {
250  int ialphP = gm.index(ialph);
251  int ialph3 = ialph;
252  int ialph3P = ialphP;
253 
254  for (int ialph1P = 0; ialph1P < Nd; ialph1P++) {
255  int ialph2P = cg5.index(ialph1P);
256 
257  for (int ic123P = 0; ic123P < FactNc; ic123P++) {
258  int ic1P = epsilon_index(0, ic123P);
259  int ic2P = epsilon_index(1, ic123P);
260  int ic3P = epsilon_index(2, ic123P);
261  dcomplex factor = gm.value(ialph)
262  * cg5.value(ialph1P) * epsilon_value(ic123P);
263 
264  contract_at_t(sum1, cg5, ialph3,
265  squ[ic1P + Nc * ialph1P],
266  sqd[ic2P + Nc * ialph2P],
267  squ[ic3P + Nc * ialph3P], it);
268  contract_at_t(sum2, cg5, ialph3,
269  squ[ic3P + Nc * ialph3P],
270  sqd[ic2P + Nc * ialph2P],
271  squ[ic1P + Nc * ialph1P], it);
272  sum += factor * (sum1 - sum2);
273  }
274  }
275  }
276 
277  corr_local[it] = sum;
278  } // it loop end.
279 
280  global_corr_t(proton, corr_local);
281 }
282 
283 
284 //====================================================================
285 void Corr2pt_4spinor::global_corr_t(valarray<dcomplex>& corr_global,
286  valarray<dcomplex>& corr_local)
287 {
288  int Lt = CommonParameters::Lt();
289  int Nt = CommonParameters::Nt();
290 
291  assert(corr_global.size() == Lt);
292  assert(corr_local.size() == Nt);
293 
294  valarray<dcomplex> corr_tmp(Lt);
295 
296  int ipet = Communicator::ipe(3);
297 
298  for (int t = 0; t < Lt; ++t) {
299  corr_tmp[t] = cmplx(0.0, 0.0);
300  }
301 
302  for (int t = 0; t < Nt; ++t) {
303  int t2 = t + ipet * Nt;
304  corr_tmp[t2] = corr_local[t];
305  }
306 
307  for (int t = 0; t < Lt; ++t) {
308  double crr = real(corr_tmp[t]);
309  double cri = imag(corr_tmp[t]);
310  crr = Communicator::reduce_sum(crr);
311  cri = Communicator::reduce_sum(cri);
312  corr_global[t] = cmplx(crr, cri);
313  }
314 }
315 
316 
317 //====================================================================
318 //============================================================END=====
BridgeIO vout
Definition: bridgeIO.cpp:207
void general(const char *format,...)
Definition: bridgeIO.cpp:38
GammaMatrix get_GM(GMspecies spec)
void contract_at_t(dcomplex &corr, const GammaMatrix &gm, const Field_F &f1, const Field_F &f2, int time)
contraction for meson at a given time t.
Bridge::VerboseLevel m_vl
std::valarray< int > m_epsilon_index
index of totally antisymmetric tensor
GammaMatrixSet * m_gmset
static int ipe(const int dir)
logical coordinate of current proc.
Gamma Matrix class.
Definition: gammaMatrix.h:45
void meson_corr(std::valarray< dcomplex > &meson, const GammaMatrix &gm_sink, const GammaMatrix &gm_src, const std::valarray< Field_F > &sq1, const std::valarray< Field_F > &sq2)
static const std::string class_name
double proton_test(const std::valarray< Field_F > &squ, const std::valarray< Field_F > &sqd)
Lexical site index.
Definition: index_lex.h:34
GammaMatrix mult(GammaMatrix) const
Definition: gammaMatrix.cpp:39
void global_corr_t(std::valarray< dcomplex > &corr_global, std::valarray< dcomplex > &corr_local)
transform node-local correlator in t to global.
double epsilon_value(int n)
totally antisymmetric tensor: value.
double meson_all(const std::valarray< Field_F > &sq1, const std::valarray< Field_F > &sq2)
int epsilon_index(int i, int n)
totally antisymmetric tensor: index.
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:89
void proton_corr(std::valarray< dcomplex > &proton, const GammaMatrix &gm, const std::valarray< Field_F > &squ, const std::valarray< Field_F > &sqd)
int index(int row) const
Definition: gammaMatrix.h:84