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