Grid 0.7.0
BaryonUtils.h
Go to the documentation of this file.
1/*************************************************************************************
2
3 Grid physics library, www.github.com/paboyle/Grid
4
5 Source file: ./lib/qcd/utils/BaryonUtils.h
6
7 Copyright (C) 2019
8
9 Author: Felix Erben <felix.erben@ed.ac.uk>
10 Author: Raoul Hodgson <raoul.hodgson@ed.ac.uk>
11
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License along
23 with this program; if not, write to the Free Software Foundation, Inc.,
24 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25
26 See the full license in the file "LICENSE" in the top level distribution directory
27 *************************************************************************************/
28/* END LEGAL */
29#pragma once
30#include <Grid/Eigen/unsupported/CXX11/Tensor>
31
33
34template <typename FImpl>
36{
37public:
38 typedef typename FImpl::ComplexField ComplexField;
39 typedef typename FImpl::FermionField FermionField;
40 typedef typename FImpl::PropagatorField PropagatorField;
41
43
44 private:
45 template <class mobj, class robj> accelerator_inline
46 static void BaryonSite(const mobj &D1,
47 const mobj &D2,
48 const mobj &D3,
49 const Gamma GammaA_left,
50 const Gamma GammaB_left,
51 const Gamma GammaA_right,
52 const Gamma GammaB_right,
53 const int parity,
54 const int wick_contractions,
55 robj &result);
56 template <class mobj, class robj> accelerator_inline
57 static void BaryonSiteMatrix(const mobj &D1,
58 const mobj &D2,
59 const mobj &D3,
60 const Gamma GammaA_left,
61 const Gamma GammaB_left,
62 const Gamma GammaA_right,
63 const Gamma GammaB_right,
64 const int wick_contractions,
65 robj &result);
66 public:
67 static void WickContractions(std::string qi,
68 std::string qf,
69 int &wick_contractions);
70 static void ContractBaryons(const PropagatorField &q1_left,
71 const PropagatorField &q2_left,
72 const PropagatorField &q3_left,
73 const Gamma GammaA_left,
74 const Gamma GammaB_left,
75 const Gamma GammaA_right,
76 const Gamma GammaB_right,
77 const int wick_contractions,
78 const int parity,
79 ComplexField &baryon_corr);
80 static void ContractBaryonsMatrix(const PropagatorField &q1_left,
81 const PropagatorField &q2_left,
82 const PropagatorField &q3_left,
83 const Gamma GammaA_left,
84 const Gamma GammaB_left,
85 const Gamma GammaA_right,
86 const Gamma GammaB_right,
87 const int wick_contractions,
88 SpinMatrixField &baryon_corr);
89 template <class mobj, class robj>
90 static void ContractBaryonsSliced(const mobj &D1,
91 const mobj &D2,
92 const mobj &D3,
93 const Gamma GammaA_left,
94 const Gamma GammaB_left,
95 const Gamma GammaA_right,
96 const Gamma GammaB_right,
97 const int wick_contractions,
98 const int parity,
99 const int nt,
100 robj &result);
101 template <class mobj, class robj>
102 static void ContractBaryonsSlicedMatrix(const mobj &D1,
103 const mobj &D2,
104 const mobj &D3,
105 const Gamma GammaA_left,
106 const Gamma GammaB_left,
107 const Gamma GammaA_right,
108 const Gamma GammaB_right,
109 const int wick_contractions,
110 const int nt,
111 robj &result);
112 private:
113 template <class mobj, class mobj2, class robj> accelerator_inline
114 static void BaryonGamma3ptGroup1Site(
115 const mobj &Dq1_ti,
116 const mobj2 &Dq2_spec,
117 const mobj2 &Dq3_spec,
118 const mobj &Dq4_tf,
119 const Gamma GammaJ,
120 const Gamma GammaBi,
121 const Gamma GammaBf,
122 int wick_contraction,
123 robj &result);
124
125 template <class mobj, class mobj2, class robj> accelerator_inline
126 static void BaryonGamma3ptGroup2Site(
127 const mobj2 &Dq1_spec,
128 const mobj &Dq2_ti,
129 const mobj2 &Dq3_spec,
130 const mobj &Dq4_tf,
131 const Gamma GammaJ,
132 const Gamma GammaBi,
133 const Gamma GammaBf,
134 int wick_contraction,
135 robj &result);
136
137 template <class mobj, class mobj2, class robj> accelerator_inline
138 static void BaryonGamma3ptGroup3Site(
139 const mobj2 &Dq1_spec,
140 const mobj2 &Dq2_spec,
141 const mobj &Dq3_ti,
142 const mobj &Dq4_tf,
143 const Gamma GammaJ,
144 const Gamma GammaBi,
145 const Gamma GammaBf,
146 int wick_contraction,
147 robj &result);
148 public:
149 template <class mobj>
150 static void BaryonGamma3pt(
151 const PropagatorField &q_ti,
152 const mobj &Dq_spec1,
153 const mobj &Dq_spec2,
154 const PropagatorField &q_tf,
155 int group,
156 int wick_contraction,
157 const Gamma GammaJ,
158 const Gamma GammaBi,
159 const Gamma GammaBf,
160 SpinMatrixField &stn_corr);
161 private:
162 template <class mobj, class mobj2, class robj> accelerator_inline
163 static void SigmaToNucleonQ1EyeSite(const mobj &Dq_loop,
164 const mobj2 &Du_spec,
165 const mobj &Dd_tf,
166 const mobj &Ds_ti,
167 const Gamma Gamma_H,
168 const Gamma GammaB_sigma,
169 const Gamma GammaB_nucl,
170 robj &result);
171 template <class mobj, class mobj2, class robj> accelerator_inline
172 static void SigmaToNucleonQ1NonEyeSite(const mobj &Du_ti,
173 const mobj &Du_tf,
174 const mobj2 &Du_spec,
175 const mobj &Dd_tf,
176 const mobj &Ds_ti,
177 const Gamma Gamma_H,
178 const Gamma GammaB_sigma,
179 const Gamma GammaB_nucl,
180 robj &result);
181
182
183 template <class mobj, class mobj2, class robj> accelerator_inline
184 static void SigmaToNucleonQ2EyeSite(const mobj &Dq_loop,
185 const mobj2 &Du_spec,
186 const mobj &Dd_tf,
187 const mobj &Ds_ti,
188 const Gamma Gamma_H,
189 const Gamma GammaB_sigma,
190 const Gamma GammaB_nucl,
191 robj &result);
192 template <class mobj, class mobj2, class robj> accelerator_inline
193 static void SigmaToNucleonQ2NonEyeSite(const mobj &Du_ti,
194 const mobj &Du_tf,
195 const mobj2 &Du_spec,
196 const mobj &Dd_tf,
197 const mobj &Ds_ti,
198 const Gamma Gamma_H,
199 const Gamma GammaB_sigma,
200 const Gamma GammaB_nucl,
201 robj &result);
202 template <class mobj, class mobj2, class robj> accelerator_inline
203 static void XiToSigmaQ1EyeSite(const mobj &Dq_loop,
204 const mobj2 &Dd_spec,
205 const mobj2 &Ds_spec,
206 const mobj &Dd_tf,
207 const mobj &Ds_ti,
208 const Gamma Gamma_H,
209 const Gamma GammaB_sigma,
210 const Gamma GammaB_nucl,
211 robj &result);
212 template <class mobj, class mobj2, class robj> accelerator_inline
213 static void XiToSigmaQ2EyeSite(const mobj &Dq_loop,
214 const mobj2 &Dd_spec,
215 const mobj2 &Ds_spec,
216 const mobj &Dd_tf,
217 const mobj &Ds_ti,
218 const Gamma Gamma_H,
219 const Gamma GammaB_sigma,
220 const Gamma GammaB_nucl,
221 robj &result);
222 public:
223 template <class mobj>
224 static void SigmaToNucleonEye(const PropagatorField &qq_loop,
225 const mobj &Du_spec,
226 const PropagatorField &qd_tf,
227 const PropagatorField &qs_ti,
228 const Gamma Gamma_H,
229 const Gamma GammaB_sigma,
230 const Gamma GammaB_nucl,
231 const std::string op,
232 SpinMatrixField &stn_corr);
233 template <class mobj>
234 static void SigmaToNucleonNonEye(const PropagatorField &qq_ti,
235 const PropagatorField &qq_tf,
236 const mobj &Du_spec,
237 const PropagatorField &qd_tf,
238 const PropagatorField &qs_ti,
239 const Gamma Gamma_H,
240 const Gamma GammaB_sigma,
241 const Gamma GammaB_nucl,
242 const std::string op,
243 SpinMatrixField &stn_corr);
244 template <class mobj>
245 static void XiToSigmaEye(const PropagatorField &qq_loop,
246 const mobj &Dd_spec,
247 const mobj &Ds_spec,
248 const PropagatorField &qd_tf,
249 const PropagatorField &qs_ti,
250 const Gamma Gamma_H,
251 const Gamma GammaB_sigma,
252 const Gamma GammaB_nucl,
253 const std::string op,
254 SpinMatrixField &xts_corr);
255};
256//This computes a baryon contraction on a lattice site, including the spin-trace of the correlation matrix
257template <class FImpl>
258template <class mobj, class robj> accelerator_inline
260 const mobj &D2,
261 const mobj &D3,
262 const Gamma GammaA_i,
263 const Gamma GammaB_i,
264 const Gamma GammaA_f,
265 const Gamma GammaB_f,
266 const int parity,
267 const int wick_contraction,
268 robj &result)
269{
270
271 Gamma g4(Gamma::Algebra::GammaT); //needed for parity P_\pm = 0.5*(1 \pm \gamma_4)
272
273 auto D1_GAi = D1 * GammaA_i;
274 auto D1_GAi_g4 = D1_GAi * g4;
275 auto D1_GAi_P = 0.5*(D1_GAi + (Real)parity * D1_GAi_g4);
276 auto GAf_D1_GAi_P = GammaA_f * D1_GAi_P;
277 auto GBf_D1_GAi_P = GammaB_f * D1_GAi_P;
278
279 auto D2_GBi = D2 * GammaB_i;
280 auto GBf_D2_GBi = GammaB_f * D2_GBi;
281 auto GAf_D2_GBi = GammaA_f * D2_GBi;
282
283 auto GBf_D3 = GammaB_f * D3;
284 auto GAf_D3 = GammaA_f * D3;
285
286 Real ee;
287
288 for (int ie_f=0; ie_f < 6 ; ie_f++){
289 int a_f = (ie_f < 3 ? ie_f : (6-ie_f)%3 ); //epsilon[ie_n][0]; //a
290 int b_f = (ie_f < 3 ? (ie_f+1)%3 : (8-ie_f)%3 ); //epsilon[ie_n][1]; //b
291 int c_f = (ie_f < 3 ? (ie_f+2)%3 : (7-ie_f)%3 ); //epsilon[ie_n][2]; //c
292 int eSgn_f = (ie_f < 3 ? 1 : -1);
293 for (int ie_i=0; ie_i < 6 ; ie_i++){
294 int a_i = (ie_i < 3 ? ie_i : (6-ie_i)%3 ); //epsilon[ie_s][0]; //a'
295 int b_i = (ie_i < 3 ? (ie_i+1)%3 : (8-ie_i)%3 ); //epsilon[ie_s][1]; //b'
296 int c_i = (ie_i < 3 ? (ie_i+2)%3 : (7-ie_i)%3 ); //epsilon[ie_s][2]; //c'
297 int eSgn_i = (ie_i < 3 ? 1 : -1);
298
299 ee = Real(eSgn_f * eSgn_i); //epsilon_sgn[ie_n] * epsilon_sgn[ie_s];
300 //This is the \delta_{456}^{123} part
301 if (wick_contraction & 1){
302 for (int rho=0; rho<Ns; rho++){
303 auto GAf_D1_GAi_P_rr_cc = GAf_D1_GAi_P()(rho,rho)(c_f,c_i);
304 for (int alpha_f=0; alpha_f<Ns; alpha_f++){
305 for (int beta_i=0; beta_i<Ns; beta_i++){
306 result()()() += ee * GAf_D1_GAi_P_rr_cc
307 * D2_GBi ()(alpha_f,beta_i)(a_f,a_i)
308 * GBf_D3 ()(alpha_f,beta_i)(b_f,b_i);
309 }}
310 }
311 }
312 //This is the \delta_{456}^{231} part
313 if (wick_contraction & 2){
314 for (int rho=0; rho<Ns; rho++){
315 for (int alpha_f=0; alpha_f<Ns; alpha_f++){
316 auto D1_GAi_P_ar_ac = D1_GAi_P()(alpha_f,rho)(a_f,c_i);
317 for (int beta_i=0; beta_i<Ns; beta_i++){
318 result()()() += ee * D1_GAi_P_ar_ac
319 * GBf_D2_GBi ()(alpha_f,beta_i)(b_f,a_i)
320 * GAf_D3 ()(rho,beta_i)(c_f,b_i);
321 }
322 }}
323 }
324 //This is the \delta_{456}^{312} part
325 if (wick_contraction & 4){
326 for (int rho=0; rho<Ns; rho++){
327 for (int alpha_f=0; alpha_f<Ns; alpha_f++){
328 auto GBf_D1_GAi_P_ar_bc = GBf_D1_GAi_P()(alpha_f,rho)(b_f,c_i);
329 for (int beta_i=0; beta_i<Ns; beta_i++){
330 result()()() += ee * GBf_D1_GAi_P_ar_bc
331 * GAf_D2_GBi ()(rho,beta_i)(c_f,a_i)
332 * D3 ()(alpha_f,beta_i)(a_f,b_i);
333 }
334 }}
335 }
336 //This is the \delta_{456}^{132} part
337 if (wick_contraction & 8){
338 for (int rho=0; rho<Ns; rho++){
339 auto GAf_D1_GAi_P_rr_cc = GAf_D1_GAi_P()(rho,rho)(c_f,c_i);
340 for (int alpha_f=0; alpha_f<Ns; alpha_f++){
341 for (int beta_i=0; beta_i<Ns; beta_i++){
342 result()()() -= ee * GAf_D1_GAi_P_rr_cc
343 * GBf_D2_GBi ()(alpha_f,beta_i)(b_f,a_i)
344 * D3 ()(alpha_f,beta_i)(a_f,b_i);
345 }}
346 }
347 }
348 //This is the \delta_{456}^{321} part
349 if (wick_contraction & 16){
350 for (int rho=0; rho<Ns; rho++){
351 for (int alpha_f=0; alpha_f<Ns; alpha_f++){
352 auto GBf_D1_GAi_P_ar_bc = GBf_D1_GAi_P()(alpha_f,rho)(b_f,c_i);
353 for (int beta_i=0; beta_i<Ns; beta_i++){
354 result()()() -= ee * GBf_D1_GAi_P_ar_bc
355 * D2_GBi ()(alpha_f,beta_i)(a_f,a_i)
356 * GAf_D3 ()(rho,beta_i)(c_f,b_i);
357 }
358 }}
359 }
360 //This is the \delta_{456}^{213} part
361 if (wick_contraction & 32){
362 for (int rho=0; rho<Ns; rho++){
363 for (int alpha_f=0; alpha_f<Ns; alpha_f++){
364 auto D1_GAi_P_ar_ac = D1_GAi_P()(alpha_f,rho)(a_f,c_i);
365 for (int beta_i=0; beta_i<Ns; beta_i++){
366 result()()() -= ee * D1_GAi_P_ar_ac
367 * GAf_D2_GBi ()(rho,beta_i)(c_f,a_i)
368 * GBf_D3 ()(alpha_f,beta_i)(b_f,b_i);
369 }
370 }}
371 }
372 }
373 }
374}
375
376//New version without parity projection or trace
377template <class FImpl>
378template <class mobj, class robj> accelerator_inline
380 const mobj &D2,
381 const mobj &D3,
382 const Gamma GammaA_i,
383 const Gamma GammaB_i,
384 const Gamma GammaA_f,
385 const Gamma GammaB_f,
386 const int wick_contraction,
387 robj &result)
388{
389
390 auto D1_GAi = D1 * GammaA_i;
391 auto GAf_D1_GAi = GammaA_f * D1_GAi;
392 auto GBf_D1_GAi = GammaB_f * D1_GAi;
393
394 auto D2_GBi = D2 * GammaB_i;
395 auto GBf_D2_GBi = GammaB_f * D2_GBi;
396 auto GAf_D2_GBi = GammaA_f * D2_GBi;
397
398 auto GBf_D3 = GammaB_f * D3;
399 auto GAf_D3 = GammaA_f * D3;
400
401 Real ee;
402
403 for (int ie_f=0; ie_f < 6 ; ie_f++){
404 int a_f = (ie_f < 3 ? ie_f : (6-ie_f)%3 ); //epsilon[ie_n][0]; //a
405 int b_f = (ie_f < 3 ? (ie_f+1)%3 : (8-ie_f)%3 ); //epsilon[ie_n][1]; //b
406 int c_f = (ie_f < 3 ? (ie_f+2)%3 : (7-ie_f)%3 ); //epsilon[ie_n][2]; //c
407 int eSgn_f = (ie_f < 3 ? 1 : -1);
408 for (int ie_i=0; ie_i < 6 ; ie_i++){
409 int a_i = (ie_i < 3 ? ie_i : (6-ie_i)%3 ); //epsilon[ie_s][0]; //a'
410 int b_i = (ie_i < 3 ? (ie_i+1)%3 : (8-ie_i)%3 ); //epsilon[ie_s][1]; //b'
411 int c_i = (ie_i < 3 ? (ie_i+2)%3 : (7-ie_i)%3 ); //epsilon[ie_s][2]; //c'
412 int eSgn_i = (ie_i < 3 ? 1 : -1);
413
414 ee = Real(eSgn_f * eSgn_i); //epsilon_sgn[ie_n] * epsilon_sgn[ie_s];
415 //This is the \delta_{456}^{123} part
416 if (wick_contraction & 1){
417 for (int rho_i=0; rho_i<Ns; rho_i++){
418 for (int rho_f=0; rho_f<Ns; rho_f++){
419 auto GAf_D1_GAi_rr_cc = GAf_D1_GAi()(rho_f,rho_i)(c_f,c_i);
420 for (int alpha_f=0; alpha_f<Ns; alpha_f++){
421 for (int beta_i=0; beta_i<Ns; beta_i++){
422 result()(rho_f,rho_i)() += ee * GAf_D1_GAi_rr_cc
423 * D2_GBi ()(alpha_f,beta_i)(a_f,a_i)
424 * GBf_D3 ()(alpha_f,beta_i)(b_f,b_i);
425 }}
426 }}
427 }
428 //This is the \delta_{456}^{231} part
429 if (wick_contraction & 2){
430 for (int rho_i=0; rho_i<Ns; rho_i++){
431 for (int alpha_f=0; alpha_f<Ns; alpha_f++){
432 auto D1_GAi_ar_ac = D1_GAi()(alpha_f,rho_i)(a_f,c_i);
433 for (int beta_i=0; beta_i<Ns; beta_i++){
434 auto GBf_D2_GBi_ab_ba = GBf_D2_GBi ()(alpha_f,beta_i)(b_f,a_i);
435 for (int rho_f=0; rho_f<Ns; rho_f++){
436 result()(rho_f,rho_i)() += ee * D1_GAi_ar_ac
437 * GBf_D2_GBi_ab_ba
438 * GAf_D3 ()(rho_f,beta_i)(c_f,b_i);
439 }
440 }
441 }}
442 }
443 //This is the \delta_{456}^{312} part
444 if (wick_contraction & 4){
445 for (int rho_i=0; rho_i<Ns; rho_i++){
446 for (int alpha_f=0; alpha_f<Ns; alpha_f++){
447 auto GBf_D1_GAi_ar_bc = GBf_D1_GAi()(alpha_f,rho_i)(b_f,c_i);
448 for (int beta_i=0; beta_i<Ns; beta_i++){
449 auto D3_ab_ab = D3 ()(alpha_f,beta_i)(a_f,b_i);
450 for (int rho_f=0; rho_f<Ns; rho_f++){
451 result()(rho_f,rho_i)() += ee * GBf_D1_GAi_ar_bc
452 * GAf_D2_GBi ()(rho_f,beta_i)(c_f,a_i)
453 * D3_ab_ab;
454 }
455 }
456 }}
457 }
458 //This is the \delta_{456}^{132} part
459 if (wick_contraction & 8){
460 for (int rho_i=0; rho_i<Ns; rho_i++){
461 for (int rho_f=0; rho_f<Ns; rho_f++){
462 auto GAf_D1_GAi_rr_cc = GAf_D1_GAi()(rho_f,rho_i)(c_f,c_i);
463 for (int alpha_f=0; alpha_f<Ns; alpha_f++){
464 for (int beta_i=0; beta_i<Ns; beta_i++){
465 result()(rho_f,rho_i)() -= ee * GAf_D1_GAi_rr_cc
466 * GBf_D2_GBi ()(alpha_f,beta_i)(b_f,a_i)
467 * D3 ()(alpha_f,beta_i)(a_f,b_i);
468 }}
469 }}
470 }
471 //This is the \delta_{456}^{321} part
472 if (wick_contraction & 16){
473 for (int rho_i=0; rho_i<Ns; rho_i++){
474 for (int alpha_f=0; alpha_f<Ns; alpha_f++){
475 auto GBf_D1_GAi_ar_bc = GBf_D1_GAi()(alpha_f,rho_i)(b_f,c_i);
476 for (int beta_i=0; beta_i<Ns; beta_i++){
477 auto D2_GBi_ab_aa = D2_GBi()(alpha_f,beta_i)(a_f,a_i);
478 for (int rho_f=0; rho_f<Ns; rho_f++){
479 result()(rho_f,rho_i)() -= ee * GBf_D1_GAi_ar_bc
480 * D2_GBi_ab_aa
481 * GAf_D3 ()(rho_f,beta_i)(c_f,b_i);
482 }
483 }
484 }}
485 }
486 //This is the \delta_{456}^{213} part
487 if (wick_contraction & 32){
488 for (int rho_i=0; rho_i<Ns; rho_i++){
489 for (int alpha_f=0; alpha_f<Ns; alpha_f++){
490 auto D1_GAi_ar_ac = D1_GAi()(alpha_f,rho_i)(a_f,c_i);
491 for (int beta_i=0; beta_i<Ns; beta_i++){
492 auto GBf_D3_ab_bb = GBf_D3()(alpha_f,beta_i)(b_f,b_i);
493 for (int rho_f=0; rho_f<Ns; rho_f++){
494 result()(rho_f,rho_i)() -= ee * D1_GAi_ar_ac
495 * GAf_D2_GBi ()(rho_f,beta_i)(c_f,a_i)
496 * GBf_D3_ab_bb;
497 }
498 }
499 }}
500 }
501 }
502 }
503}
504
505/* Computes which wick contractions should be performed for a *
506 * baryon 2pt function given the initial and finals state quark *
507 * flavours. *
508 * The array wick_contractions must be of length 6 */
509template<class FImpl>
510void BaryonUtils<FImpl>::WickContractions(std::string qi, std::string qf, int &wick_contractions) {
511 assert(qi.size() == 3 && qf.size() == 3 && "Only sets of 3 quarks accepted.");
512 const int epsilon[6][3] = {{0,1,2},{1,2,0},{2,0,1},{0,2,1},{2,1,0},{1,0,2}};
513 wick_contractions=0;
514 for (int ie=0; ie < 6 ; ie++) {
515 wick_contractions += ( ( qi[0] == qf[epsilon[ie][0]]
516 && qi[1] == qf[epsilon[ie][1]]
517 && qi[2] == qf[epsilon[ie][2]]) ? 1 : 0) << ie;
518 }
519}
520
521/* The array wick_contractions must be of length 6. The order *
522 * corresponds to the to that shown in the Hadrons documentation *
523 * at https://aportelli.github.io/Hadrons-doc/#/mcontraction *
524 * This can be computed from the quark flavours using the *
525 * Wick_Contractions function above */
526template<class FImpl>
528 const PropagatorField &q2_left,
529 const PropagatorField &q3_left,
530 const Gamma GammaA_left,
531 const Gamma GammaB_left,
532 const Gamma GammaA_right,
533 const Gamma GammaB_right,
534 const int wick_contractions,
535 const int parity,
536 ComplexField &baryon_corr)
537{
538
539 assert(Ns==4 && "Baryon code only implemented for N_spin = 4");
540 assert(Nc==3 && "Baryon code only implemented for N_colour = 3");
541
542 assert(parity==1 || parity == -1 && "Parity must be +1 or -1");
543
544 GridBase *grid = q1_left.Grid();
545
546 autoView(vbaryon_corr , baryon_corr , AcceleratorWrite);
547 autoView( v1 , q1_left , AcceleratorRead);
548 autoView( v2 , q2_left , AcceleratorRead);
549 autoView( v3 , q3_left , AcceleratorRead);
550
551 Real bytes =0.;
552 bytes += grid->oSites() * (432.*sizeof(vComplex) + 126.*sizeof(int) + 36.*sizeof(Real));
553 for (int ie=0; ie < 6 ; ie++){
554 if(ie==0 or ie==3){
555 bytes += ( wick_contractions & (1 << ie) ) ? grid->oSites() * (4.*sizeof(int) + 4752.*sizeof(vComplex)) : 0.;
556 } else{
557 bytes += ( wick_contractions & (1 << ie) ) ? grid->oSites() * (64.*sizeof(int) + 5184.*sizeof(vComplex)) : 0.;
558 }
559 }
560 Real t=0.;
561 t =-usecond();
562
563 accelerator_for(ss, grid->oSites(), grid->Nsimd(), {
564 auto D1 = v1(ss);
565 auto D2 = v2(ss);
566 auto D3 = v3(ss);
567 typedef decltype(coalescedRead(vbaryon_corr[0])) cVec;
568 cVec result=Zero();
569 BaryonSite(D1,D2,D3,GammaA_left,GammaB_left,GammaA_right,GammaB_right,parity,wick_contractions,result);
570 coalescedWrite(vbaryon_corr[ss],result);
571 } );//end loop over lattice sites
572
573 t += usecond();
574
575 std::cout << GridLogDebug << std::setw(10) << bytes/t*1.0e6/1024/1024/1024 << " GB/s " << std::endl;
576}
577
578template<class FImpl>
580 const PropagatorField &q2_left,
581 const PropagatorField &q3_left,
582 const Gamma GammaA_left,
583 const Gamma GammaB_left,
584 const Gamma GammaA_right,
585 const Gamma GammaB_right,
586 const int wick_contractions,
587 SpinMatrixField &baryon_corr)
588{
589
590 assert(Ns==4 && "Baryon code only implemented for N_spin = 4");
591 assert(Nc==3 && "Baryon code only implemented for N_colour = 3");
592
593 GridBase *grid = q1_left.Grid();
594
595 autoView(vbaryon_corr , baryon_corr , AcceleratorWrite);
596 autoView( v1 , q1_left , AcceleratorRead);
597 autoView( v2 , q2_left , AcceleratorRead);
598 autoView( v3 , q3_left , AcceleratorRead);
599
600 accelerator_for(ss, grid->oSites(), grid->Nsimd(), {
601 auto D1 = v1(ss);
602 auto D2 = v2(ss);
603 auto D3 = v3(ss);
604 typedef decltype(coalescedRead(vbaryon_corr[0])) spinor;
605 spinor result=Zero();
606 BaryonSiteMatrix(D1,D2,D3,GammaA_left,GammaB_left,GammaA_right,GammaB_right,wick_contractions,result);
607 coalescedWrite(vbaryon_corr[ss],result);
608 } );//end loop over lattice sites
609}
610
611/* The array wick_contractions must be of length 6. The order *
612 * corresponds to the to that shown in the Hadrons documentation *
613 * at https://aportelli.github.io/Hadrons-doc/#/mcontraction *
614 * This can also be computed from the quark flavours using the *
615 * Wick_Contractions function above */
616template <class FImpl>
617template <class mobj, class robj>
619 const mobj &D2,
620 const mobj &D3,
621 const Gamma GammaA_left,
622 const Gamma GammaB_left,
623 const Gamma GammaA_right,
624 const Gamma GammaB_right,
625 const int wick_contractions,
626 const int parity,
627 const int nt,
628 robj &result)
629{
630
631 assert(Ns==4 && "Baryon code only implemented for N_spin = 4");
632 assert(Nc==3 && "Baryon code only implemented for N_colour = 3");
633
634 assert(parity==1 || parity == -1 && "Parity must be +1 or -1");
635
636 for (int t=0; t<nt; t++) {
637 BaryonSite(D1[t],D2[t],D3[t],GammaA_left,GammaB_left,GammaA_right,GammaB_right,parity,wick_contractions,result[t]);
638 }
639}
640
641template <class FImpl>
642template <class mobj, class robj>
644 const mobj &D2,
645 const mobj &D3,
646 const Gamma GammaA_left,
647 const Gamma GammaB_left,
648 const Gamma GammaA_right,
649 const Gamma GammaB_right,
650 const int wick_contractions,
651 const int nt,
652 robj &result)
653{
654
655 assert(Ns==4 && "Baryon code only implemented for N_spin = 4");
656 assert(Nc==3 && "Baryon code only implemented for N_colour = 3");
657
658 for (int t=0; t<nt; t++) {
659 BaryonSiteMatrix(D1[t],D2[t],D3[t],GammaA_left,GammaB_left,GammaA_right,GammaB_right,wick_contractions,result[t]);
660 }
661}
662
663/***********************************************************************
664 * End of Baryon 2pt-function code. *
665 * *
666 * The following code is for baryonGamma3pt function *
667 **********************************************************************/
668
669/* Dq1_ti is a quark line from t_i to t_J
670 * Dq2_spec is a quark line from t_i to t_f
671 * Dq3_spec is a quark line from t_i to t_f
672 * Dq4_tf is a quark line from t_f to t_J */
673template<class FImpl>
674template <class mobj, class mobj2, class robj> accelerator_inline
676 const mobj &Dq1_ti,
677 const mobj2 &Dq2_spec,
678 const mobj2 &Dq3_spec,
679 const mobj &Dq4_tf,
680 const Gamma GammaJ,
681 const Gamma GammaBi,
682 const Gamma GammaBf,
683 int wick_contraction,
684 robj &result)
685{
686 Gamma g5(Gamma::Algebra::Gamma5);
687
688 auto adjD4 = g5 * adj(Dq4_tf) * g5 ;
689 auto adjD4_g_D1 = adjD4 * GammaJ * Dq1_ti;
690 auto Gf_adjD4_g_D1 = GammaBf * adjD4_g_D1;
691 auto D2_Gi = Dq2_spec * GammaBi;
692 auto Gf_D2_Gi = GammaBf * D2_Gi;
693 auto Gf_D3 = GammaBf * Dq3_spec;
694
695 Real ee;
696
697 for (int ie_f=0; ie_f < 6 ; ie_f++){
698 int a_f = (ie_f < 3 ? ie_f : (6-ie_f)%3 ); //epsilon[ie_n][0]; //a
699 int b_f = (ie_f < 3 ? (ie_f+1)%3 : (8-ie_f)%3 ); //epsilon[ie_n][1]; //b
700 int c_f = (ie_f < 3 ? (ie_f+2)%3 : (7-ie_f)%3 ); //epsilon[ie_n][2]; //c
701 int eSgn_f = (ie_f < 3 ? 1 : -1);
702 for (int ie_i=0; ie_i < 6 ; ie_i++){
703 int a_i = (ie_i < 3 ? ie_i : (6-ie_i)%3 ); //epsilon[ie_s][0]; //a'
704 int b_i = (ie_i < 3 ? (ie_i+1)%3 : (8-ie_i)%3 ); //epsilon[ie_s][1]; //b'
705 int c_i = (ie_i < 3 ? (ie_i+2)%3 : (7-ie_i)%3 ); //epsilon[ie_s][2]; //c'
706 int eSgn_i = (ie_i < 3 ? 1 : -1);
707
708 ee = Real(eSgn_f * eSgn_i);
709
710 for (int alpha_f=0; alpha_f<Ns; alpha_f++){
711 for (int beta_i=0; beta_i<Ns; beta_i++){
712 auto D2_Gi_ab_aa = D2_Gi ()(alpha_f,beta_i)(a_f,a_i);
713 auto Gf_D3_ab_bb = Gf_D3 ()(alpha_f,beta_i)(b_f,b_i);
714 auto Gf_D2_Gi_ab_ba = Gf_D2_Gi ()(alpha_f,beta_i)(b_f,a_i);
715 auto Dq3_spec_ab_ab = Dq3_spec ()(alpha_f,beta_i)(a_f,b_i);
716
717 for (int gamma_i=0; gamma_i<Ns; gamma_i++){
718 auto ee_adjD4_g_D1_ag_ac = ee * adjD4_g_D1 ()(alpha_f,gamma_i)(a_f,c_i);
719 auto ee_Gf_adjD4_g_D1_ag_bc = ee * Gf_adjD4_g_D1()(alpha_f,gamma_i)(b_f,c_i);
720 for (int gamma_f=0; gamma_f<Ns; gamma_f++){
721 auto ee_adjD4_g_D1_gg_cc = ee * adjD4_g_D1 ()(gamma_f,gamma_i)(c_f,c_i);
722 auto Dq3_spec_gb_cb = Dq3_spec ()(gamma_f,beta_i)(c_f,b_i);
723 auto D2_Gi_gb_ca = D2_Gi ()(gamma_f,beta_i)(c_f,a_i);
724
725
726 if(wick_contraction == 1) { // Do contraction I1
727 result()(gamma_f,gamma_i)() -= ee_adjD4_g_D1_gg_cc
728 * D2_Gi_ab_aa
729 * Gf_D3_ab_bb;
730 }
731 if(wick_contraction == 2) { // Do contraction I2
732 result()(gamma_f,gamma_i)() -= ee_adjD4_g_D1_ag_ac
733 * Gf_D2_Gi_ab_ba
734 * Dq3_spec_gb_cb;
735 }
736 if(wick_contraction == 3) { // Do contraction I3
737 result()(gamma_f,gamma_i)() -= ee_Gf_adjD4_g_D1_ag_bc
738 * D2_Gi_gb_ca
739 * Dq3_spec_ab_ab;
740 }
741 if(wick_contraction == 4) { // Do contraction I4
742 result()(gamma_f,gamma_i)() += ee_adjD4_g_D1_gg_cc
743 * Gf_D2_Gi_ab_ba
744 * Dq3_spec_ab_ab;
745 }
746 if(wick_contraction == 5) { // Do contraction I5
747 result()(gamma_f,gamma_i)() += ee_Gf_adjD4_g_D1_ag_bc
748 * D2_Gi_ab_aa
749 * Dq3_spec_gb_cb;
750 }
751 if(wick_contraction == 6) { // Do contraction I6
752 result()(gamma_f,gamma_i)() += ee_adjD4_g_D1_ag_ac
753 * D2_Gi_gb_ca
754 * Gf_D3_ab_bb;
755 }
756 }
757 }
758 }}
759 }
760 }
761}
762
763/* Dq1_spec is a quark line from t_i to t_f
764 * Dq2_ti is a quark line from t_i to t_J
765 * Dq3_spec is a quark line from t_i to t_f
766 * Dq4_tf is a quark line from t_f to t_J */
767template<class FImpl>
768template <class mobj, class mobj2, class robj> accelerator_inline
770 const mobj2 &Dq1_spec,
771 const mobj &Dq2_ti,
772 const mobj2 &Dq3_spec,
773 const mobj &Dq4_tf,
774 const Gamma GammaJ,
775 const Gamma GammaBi,
776 const Gamma GammaBf,
777 int wick_contraction,
778 robj &result)
779{
780 Gamma g5(Gamma::Algebra::Gamma5);
781
782 auto adjD4_g_D2_Gi = g5 * adj(Dq4_tf) * g5 * GammaJ * Dq2_ti * GammaBi;
783 auto Gf_adjD4_g_D2_Gi = GammaBf * adjD4_g_D2_Gi;
784 auto Gf_D1 = GammaBf * Dq1_spec;
785 auto Gf_D3 = GammaBf * Dq3_spec;
786
787 Real ee;
788
789 for (int ie_f=0; ie_f < 6 ; ie_f++){
790 int a_f = (ie_f < 3 ? ie_f : (6-ie_f)%3 ); //epsilon[ie_n][0]; //a
791 int b_f = (ie_f < 3 ? (ie_f+1)%3 : (8-ie_f)%3 ); //epsilon[ie_n][1]; //b
792 int c_f = (ie_f < 3 ? (ie_f+2)%3 : (7-ie_f)%3 ); //epsilon[ie_n][2]; //c
793 int eSgn_f = (ie_f < 3 ? 1 : -1);
794 for (int ie_i=0; ie_i < 6 ; ie_i++){
795 int a_i = (ie_i < 3 ? ie_i : (6-ie_i)%3 ); //epsilon[ie_s][0]; //a'
796 int b_i = (ie_i < 3 ? (ie_i+1)%3 : (8-ie_i)%3 ); //epsilon[ie_s][1]; //b'
797 int c_i = (ie_i < 3 ? (ie_i+2)%3 : (7-ie_i)%3 ); //epsilon[ie_s][2]; //c'
798 int eSgn_i = (ie_i < 3 ? 1 : -1);
799
800 ee = Real(eSgn_f * eSgn_i); //epsilon_sgn[ie_n] * epsilon_sgn[ie_s];
801
802 for (int alpha_f=0; alpha_f<Ns; alpha_f++){
803 for (int beta_i=0; beta_i<Ns; beta_i++){
804 auto adjD4_g_D2_Gi_ab_aa = adjD4_g_D2_Gi ()(alpha_f,beta_i)(a_f,a_i);
805 auto Gf_D3_ab_bb = Gf_D3 ()(alpha_f,beta_i)(b_f,b_i);
806 auto Gf_adjD4_g_D2_Gi_ab_ba = Gf_adjD4_g_D2_Gi ()(alpha_f,beta_i)(b_f,a_i);
807 auto Dq3_spec_ab_ab = Dq3_spec ()(alpha_f,beta_i)(a_f,b_i);
808
809 for (int gamma_i=0; gamma_i<Ns; gamma_i++){
810 auto ee_Dq1_spec_ag_ac = ee * Dq1_spec ()(alpha_f,gamma_i)(a_f,c_i);
811 auto ee_Gf_D1_ag_bc = ee * Gf_D1 ()(alpha_f,gamma_i)(b_f,c_i);
812 for (int gamma_f=0; gamma_f<Ns; gamma_f++){
813 auto ee_Dq1_spec_gg_cc = ee * Dq1_spec ()(gamma_f,gamma_i)(c_f,c_i);
814 auto Dq3_spec_gb_cb = Dq3_spec ()(gamma_f,beta_i)(c_f,b_i);
815 auto adjD4_g_D2_Gi_gb_ca = adjD4_g_D2_Gi ()(gamma_f,beta_i)(c_f,a_i);
816
817 if(wick_contraction == 1) { // Do contraction II1
818 result()(gamma_f,gamma_i)() -= ee_Dq1_spec_gg_cc
819 * adjD4_g_D2_Gi_ab_aa
820 * Gf_D3_ab_bb;
821 }
822 if(wick_contraction == 2) { // Do contraction II2
823 result()(gamma_f,gamma_i)() -= ee_Dq1_spec_ag_ac
824 * Gf_adjD4_g_D2_Gi_ab_ba
825 * Dq3_spec_gb_cb;
826 }
827 if(wick_contraction == 3) { // Do contraction II3
828 result()(gamma_f,gamma_i)() -= ee_Gf_D1_ag_bc
829 * adjD4_g_D2_Gi_gb_ca
830 * Dq3_spec_ab_ab;
831 }
832 if(wick_contraction == 4) { // Do contraction II4
833 result()(gamma_f,gamma_i)() += ee_Dq1_spec_gg_cc
834 * Gf_adjD4_g_D2_Gi_ab_ba
835 * Dq3_spec_ab_ab;
836 }
837 if(wick_contraction == 5) { // Do contraction II5
838 result()(gamma_f,gamma_i)() += ee_Gf_D1_ag_bc
839 * adjD4_g_D2_Gi_ab_aa
840 * Dq3_spec_gb_cb;
841 }
842 if(wick_contraction == 6) { // Do contraction II6
843 result()(gamma_f,gamma_i)() += ee_Dq1_spec_ag_ac
844 * adjD4_g_D2_Gi_gb_ca
845 * Gf_D3_ab_bb;
846 }
847 }
848 }
849 }}
850 }
851 }
852}
853
854/* Dq1_spec is a quark line from t_i to t_f
855 * Dq2_spec is a quark line from t_i to t_f
856 * Dq3_ti is a quark line from t_i to t_J
857 * Dq4_tf is a quark line from t_f to t_J */
858template<class FImpl>
859template <class mobj, class mobj2, class robj> accelerator_inline
861 const mobj2 &Dq1_spec,
862 const mobj2 &Dq2_spec,
863 const mobj &Dq3_ti,
864 const mobj &Dq4_tf,
865 const Gamma GammaJ,
866 const Gamma GammaBi,
867 const Gamma GammaBf,
868 int wick_contraction,
869 robj &result)
870{
871 Gamma g5(Gamma::Algebra::Gamma5);
872
873 auto adjD4_g_D3 = g5 * adj(Dq4_tf) * g5 * GammaJ * Dq3_ti;
874 auto Gf_adjD4_g_D3 = GammaBf * adjD4_g_D3;
875 auto Gf_D1 = GammaBf * Dq1_spec;
876 auto D2_Gi = Dq2_spec * GammaBi;
877 auto Gf_D2_Gi = GammaBf * D2_Gi;
878
879 Real ee;
880
881 for (int ie_f=0; ie_f < 6 ; ie_f++){
882 int a_f = (ie_f < 3 ? ie_f : (6-ie_f)%3 ); //epsilon[ie_n][0]; //a
883 int b_f = (ie_f < 3 ? (ie_f+1)%3 : (8-ie_f)%3 ); //epsilon[ie_n][1]; //b
884 int c_f = (ie_f < 3 ? (ie_f+2)%3 : (7-ie_f)%3 ); //epsilon[ie_n][2]; //c
885 int eSgn_f = (ie_f < 3 ? 1 : -1);
886 for (int ie_i=0; ie_i < 6 ; ie_i++){
887 int a_i = (ie_i < 3 ? ie_i : (6-ie_i)%3 ); //epsilon[ie_s][0]; //a'
888 int b_i = (ie_i < 3 ? (ie_i+1)%3 : (8-ie_i)%3 ); //epsilon[ie_s][1]; //b'
889 int c_i = (ie_i < 3 ? (ie_i+2)%3 : (7-ie_i)%3 ); //epsilon[ie_s][2]; //c'
890 int eSgn_i = (ie_i < 3 ? 1 : -1);
891
892 ee = Real(eSgn_f * eSgn_i); //epsilon_sgn[ie_n] * epsilon_sgn[ie_s];
893
894 for (int alpha_f=0; alpha_f<Ns; alpha_f++){
895 for (int beta_i=0; beta_i<Ns; beta_i++){
896 auto D2_Gi_ab_aa = D2_Gi ()(alpha_f,beta_i)(a_f,a_i);
897 auto Gf_adjD4_g_D3_ab_bb = Gf_adjD4_g_D3 ()(alpha_f,beta_i)(b_f,b_i);
898 auto Gf_D2_Gi_ab_ba = Gf_D2_Gi ()(alpha_f,beta_i)(b_f,a_i);
899 auto adjD4_g_D3_ab_ab = adjD4_g_D3 ()(alpha_f,beta_i)(a_f,b_i);
900
901 for (int gamma_i=0; gamma_i<Ns; gamma_i++) {
902 auto ee_Dq1_spec_ag_ac = ee * Dq1_spec ()(alpha_f,gamma_i)(a_f,c_i);
903 auto ee_Gf_D1_ag_bc = ee * Gf_D1 ()(alpha_f,gamma_i)(b_f,c_i);
904 for (int gamma_f=0; gamma_f<Ns; gamma_f++) {
905 auto ee_Dq1_spec_gg_cc = ee * Dq1_spec ()(gamma_f,gamma_i)(c_f,c_i);
906 auto adjD4_g_D3_gb_cb = adjD4_g_D3 ()(gamma_f,beta_i)(c_f,b_i);
907 auto D2_Gi_gb_ca = D2_Gi ()(gamma_f,beta_i)(c_f,a_i);
908
909 if(wick_contraction == 1) { // Do contraction III1
910 result()(gamma_f,gamma_i)() -= ee_Dq1_spec_gg_cc
911 * D2_Gi_ab_aa
912 * Gf_adjD4_g_D3_ab_bb;
913 }
914 if(wick_contraction == 2) { // Do contraction III2
915 result()(gamma_f,gamma_i)() -= ee_Dq1_spec_ag_ac
916 * Gf_D2_Gi_ab_ba
917 * adjD4_g_D3_gb_cb;
918 }
919 if(wick_contraction == 3) { // Do contraction III3
920 result()(gamma_f,gamma_i)() -= ee_Gf_D1_ag_bc
921 * D2_Gi_gb_ca
922 * adjD4_g_D3_ab_ab;
923 }
924 if(wick_contraction == 4) { // Do contraction III4
925 result()(gamma_f,gamma_i)() += ee_Dq1_spec_gg_cc
926 * Gf_D2_Gi_ab_ba
927 * adjD4_g_D3_ab_ab;
928 }
929 if(wick_contraction == 5) { // Do contraction III5
930 result()(gamma_f,gamma_i)() += ee_Gf_D1_ag_bc
931 * D2_Gi_ab_aa
932 * adjD4_g_D3_gb_cb;
933 }
934 if(wick_contraction == 6) { // Do contraction III6
935 result()(gamma_f,gamma_i)() += ee_Dq1_spec_ag_ac
936 * D2_Gi_gb_ca
937 * Gf_adjD4_g_D3_ab_bb;
938 }
939 }
940 }
941 }}
942 }
943 }
944}
945
946/* The group indicates which inital state quarks the current is *
947 * connected to. It must be in the range 1-3. *
948 * The wick_contraction must be in the range 1-6 correspond to *
949 * the contractions given in the Hadrons documentation at *
950 * https://aportelli.github.io/Hadrons-doc/#/mcontraction */
951template<class FImpl>
952template <class mobj>
954 const PropagatorField &q_ti,
955 const mobj &Dq_spec1,
956 const mobj &Dq_spec2,
957 const PropagatorField &q_tf,
958 int group,
959 int wick_contraction,
960 const Gamma GammaJ,
961 const Gamma GammaBi,
962 const Gamma GammaBf,
963 SpinMatrixField &stn_corr)
964{
965 assert(Ns==4 && "Baryon code only implemented for N_spin = 4");
966 assert(Nc==3 && "Baryon code only implemented for N_colour = 3");
967
968 GridBase *grid = q_tf.Grid();
969
970 autoView( vcorr , stn_corr , AcceleratorWrite);
971 autoView( vq_ti , q_ti , AcceleratorRead);
972 autoView( vq_tf , q_tf , AcceleratorRead);
973
974 deviceVector<mobj> my_Dq_spec(2);
975 acceleratorPut(my_Dq_spec[0],Dq_spec1);
976 acceleratorPut(my_Dq_spec[1],Dq_spec2);
977 mobj * Dq_spec_p = &my_Dq_spec[0];
978
979 if (group == 1) {
980 accelerator_for(ss, grid->oSites(), grid->Nsimd(), {
981 auto Dq_ti = vq_ti(ss);
982 auto Dq_tf = vq_tf(ss);
983 typedef decltype(coalescedRead(vcorr[0])) spinor;
984 spinor result=Zero();
985 BaryonGamma3ptGroup1Site(Dq_ti,Dq_spec_p[0],Dq_spec_p[1],Dq_tf,GammaJ,GammaBi,GammaBf,wick_contraction,result);
986 coalescedWrite(vcorr[ss],coalescedRead(vcorr[ss])+result);
987 });//end loop over lattice sites
988 } else if (group == 2) {
989 accelerator_for(ss, grid->oSites(), grid->Nsimd(), {
990 auto Dq_ti = vq_ti(ss);
991 auto Dq_tf = vq_tf(ss);
992 typedef decltype(coalescedRead(vcorr[0])) spinor;
993 spinor result=Zero();
994 BaryonGamma3ptGroup2Site(Dq_spec_p[0],Dq_ti,Dq_spec_p[1],Dq_tf,GammaJ,GammaBi,GammaBf,wick_contraction,result);
995 coalescedWrite(vcorr[ss],coalescedRead(vcorr[ss])+result);
996 });//end loop over lattice sites
997 } else if (group == 3) {
998 accelerator_for(ss, grid->oSites(), grid->Nsimd(), {
999 auto Dq_ti = vq_ti(ss);
1000 auto Dq_tf = vq_tf(ss);
1001 typedef decltype(coalescedRead(vcorr[0])) spinor;
1002 spinor result=Zero();
1003 BaryonGamma3ptGroup3Site(Dq_spec_p[0],Dq_spec_p[1],Dq_ti,Dq_tf,GammaJ,GammaBi,GammaBf,wick_contraction,result);
1004 coalescedWrite(vcorr[ss],coalescedRead(vcorr[ss])+result);
1005 });//end loop over lattice sites
1006 }
1007
1008}
1009
1010
1011/***********************************************************************
1012 * End of BaryonGamma3pt-function code. *
1013 * *
1014 * The following code is for Sigma -> N rare hypeon decays *
1015 **********************************************************************/
1016
1017/* Dq_loop is a quark line from t_H to t_H
1018 * Du_spec is a quark line from t_i to t_f
1019 * Dd_tf is a quark line from t_f to t_H
1020 * Ds_ti is a quark line from t_i to t_H */
1021template <class FImpl>
1022template <class mobj, class mobj2, class robj> accelerator_inline
1024 const mobj2 &Du_spec,
1025 const mobj &Dd_tf,
1026 const mobj &Ds_ti,
1027 const Gamma Gamma_H,
1028 const Gamma GammaB_sigma,
1029 const Gamma GammaB_nucl,
1030 robj &result)
1031{
1032
1033 Gamma g5(Gamma::Algebra::Gamma5);
1034
1035 auto adjDd_GH_Ds = g5 * adj(Dd_tf) * g5 * Gamma_H * Ds_ti;
1036 auto Gn_adjDd_GH_Ds = GammaB_nucl * adjDd_GH_Ds;
1037 auto Du_Gs = Du_spec * GammaB_sigma;
1038 auto Dq_GH = Dq_loop * Gamma_H;
1039 auto Tr_Dq_GH = trace(Dq_GH)()()();
1040
1041 Real ee;
1042
1043 for (int ie_n=0; ie_n < 6 ; ie_n++){
1044 int a_n = (ie_n < 3 ? ie_n : (6-ie_n)%3 ); //epsilon[ie_n][0]; //a
1045 int b_n = (ie_n < 3 ? (ie_n+1)%3 : (8-ie_n)%3 ); //epsilon[ie_n][1]; //b
1046 int c_n = (ie_n < 3 ? (ie_n+2)%3 : (7-ie_n)%3 ); //epsilon[ie_n][2]; //c
1047 int eSgn_n = (ie_n < 3 ? 1 : -1);
1048 for (int ie_s=0; ie_s < 6 ; ie_s++){
1049 int a_s = (ie_s < 3 ? ie_s : (6-ie_s)%3 ); //epsilon[ie_s][0]; //a'
1050 int b_s = (ie_s < 3 ? (ie_s+1)%3 : (8-ie_s)%3 ); //epsilon[ie_s][1]; //b'
1051 int c_s = (ie_s < 3 ? (ie_s+2)%3 : (7-ie_s)%3 ); //epsilon[ie_s][2]; //c'
1052 int eSgn_s = (ie_s < 3 ? 1 : -1);
1053
1054 ee = Real(eSgn_n * eSgn_s);
1055 for (int alpha_n=0; alpha_n<Ns; alpha_n++){
1056 for (int beta_s=0; beta_s<Ns; beta_s++){
1057
1058 auto Gn_adjDd_GH_Ds_ab_bb = Gn_adjDd_GH_Ds ()(alpha_n, beta_s)(b_n,b_s);
1059
1060 for (int gamma_s=0; gamma_s<Ns; gamma_s++){
1061 for (int gamma_n=0; gamma_n<Ns; gamma_n++){
1062 result()(gamma_n,gamma_s)() += ee * Gn_adjDd_GH_Ds_ab_bb
1063 * Du_spec ()(gamma_n,gamma_s)(c_n,c_s)
1064 * Du_Gs ()(alpha_n, beta_s)(a_n,a_s)
1065 * Tr_Dq_GH;
1066
1067 result()(gamma_n,gamma_s)() -= ee * Gn_adjDd_GH_Ds_ab_bb
1068 * Du_spec ()(alpha_n,gamma_s)(a_n,c_s)
1069 * Du_Gs ()(gamma_n, beta_s)(c_n,a_s)
1070 * Tr_Dq_GH;
1071 }}
1072 }}
1073 }
1074 }
1075}
1076
1077/* Du_ti is a quark line from t_i to t_H
1078 * Du_tf is a quark line from t_f to t_H
1079 * Du_spec is a quark line from t_i to t_f
1080 * Dd_tf is a quark line from t_f to t_H
1081 * Ds_ti is a quark line from t_i to t_H */
1082template <class FImpl>
1083template <class mobj, class mobj2, class robj> accelerator_inline
1085 const mobj &Du_tf,
1086 const mobj2 &Du_spec,
1087 const mobj &Dd_tf,
1088 const mobj &Ds_ti,
1089 const Gamma Gamma_H,
1090 const Gamma GammaB_sigma,
1091 const Gamma GammaB_nucl,
1092 robj &result)
1093{
1094
1095 Gamma g5(Gamma::Algebra::Gamma5);
1096
1097 auto Du_Gs = Du_spec * GammaB_sigma;
1098 auto adjDd_GH_Ds = g5 * adj(Dd_tf) * g5 * Gamma_H * Ds_ti;
1099 auto Gn_adjDd_GH_Ds = GammaB_nucl * adjDd_GH_Ds;
1100 auto adjDu_GH_Du = g5 * adj(Du_tf) * g5 * Gamma_H * Du_ti;
1101 auto adjDu_GH_Du_Gs = adjDu_GH_Du * GammaB_sigma;
1102
1103 Real ee;
1104
1105 for (int ie_n=0; ie_n < 6 ; ie_n++){
1106 int a_n = (ie_n < 3 ? ie_n : (6-ie_n)%3 ); //epsilon[ie_n][0]; //a
1107 int b_n = (ie_n < 3 ? (ie_n+1)%3 : (8-ie_n)%3 ); //epsilon[ie_n][1]; //b
1108 int c_n = (ie_n < 3 ? (ie_n+2)%3 : (7-ie_n)%3 ); //epsilon[ie_n][2]; //c
1109 int eSgn_n = (ie_n < 3 ? 1 : -1);
1110 for (int ie_s=0; ie_s < 6 ; ie_s++){
1111 int a_s = (ie_s < 3 ? ie_s : (6-ie_s)%3 ); //epsilon[ie_s][0]; //a'
1112 int b_s = (ie_s < 3 ? (ie_s+1)%3 : (8-ie_s)%3 ); //epsilon[ie_s][1]; //b'
1113 int c_s = (ie_s < 3 ? (ie_s+2)%3 : (7-ie_s)%3 ); //epsilon[ie_s][2]; //c'
1114 int eSgn_s = (ie_s < 3 ? 1 : -1);
1115
1116 ee = Real(eSgn_n * eSgn_s); //epsilon_sgn[ie_n] * epsilon_sgn[ie_s];
1117
1118 for (int alpha_n=0; alpha_n<Ns; alpha_n++){
1119 for (int beta_s=0; beta_s<Ns; beta_s++){
1120
1121 auto Gn_adjDd_GH_Ds_ab_bb = Gn_adjDd_GH_Ds ()(alpha_n, beta_s)(b_n,b_s);
1122
1123 for (int gamma_s=0; gamma_s<Ns; gamma_s++){
1124 for (int gamma_n=0; gamma_n<Ns; gamma_n++){
1125
1126 result()(gamma_n,gamma_s)() += ee * Gn_adjDd_GH_Ds_ab_bb
1127 * adjDu_GH_Du ()(alpha_n,gamma_s)(a_n,c_s)
1128 * Du_Gs ()(gamma_n, beta_s)(c_n,a_s);
1129
1130 result()(gamma_n,gamma_s)() += ee * Gn_adjDd_GH_Ds_ab_bb
1131 * adjDu_GH_Du_Gs ()(gamma_n, beta_s)(c_n,a_s)
1132 * Du_spec ()(alpha_n,gamma_s)(a_n,c_s);
1133
1134 result()(gamma_n,gamma_s)() -= ee * Gn_adjDd_GH_Ds_ab_bb
1135 * adjDu_GH_Du_Gs ()(alpha_n, beta_s)(a_n,a_s)
1136 * Du_spec ()(gamma_n,gamma_s)(c_n,c_s);
1137
1138 result()(gamma_n,gamma_s)() -= ee * Gn_adjDd_GH_Ds_ab_bb
1139 * adjDu_GH_Du ()(gamma_n,gamma_s)(c_n,c_s)
1140 * Du_Gs ()(alpha_n, beta_s)(a_n,a_s);
1141 }}
1142 }}
1143 }
1144 }
1145}
1146
1147//Equivalent to "One-trace"
1148/* Dq_loop is a quark line from t_H to t_H
1149 * Du_spec is a quark line from t_i to t_f
1150 * Dd_tf is a quark line from t_f to t_H
1151 * Ds_ti is a quark line from t_i to t_H */
1152template <class FImpl>
1153template <class mobj, class mobj2, class robj> accelerator_inline
1155 const mobj2 &Du_spec,
1156 const mobj &Dd_tf,
1157 const mobj &Ds_ti,
1158 const Gamma Gamma_H,
1159 const Gamma GammaB_sigma,
1160 const Gamma GammaB_nucl,
1161 robj &result)
1162{
1163
1164 Gamma g5(Gamma::Algebra::Gamma5);
1165
1166 auto adjDd_GH_Duloop_GH_Ds = g5 * adj(Dd_tf) * g5 * Gamma_H * Dq_loop * Gamma_H * Ds_ti;
1167 auto Gn_adjDd_GH_Duloop_GH_Ds = GammaB_nucl * adjDd_GH_Duloop_GH_Ds;
1168 auto Du_Gs = Du_spec * GammaB_sigma;
1169
1170 Real ee;
1171
1172 for (int ie_n=0; ie_n < 6 ; ie_n++){
1173 int a_n = (ie_n < 3 ? ie_n : (6-ie_n)%3 ); //epsilon[ie_n][0]; //a
1174 int b_n = (ie_n < 3 ? (ie_n+1)%3 : (8-ie_n)%3 ); //epsilon[ie_n][1]; //b
1175 int c_n = (ie_n < 3 ? (ie_n+2)%3 : (7-ie_n)%3 ); //epsilon[ie_n][2]; //c
1176 int eSgn_n = (ie_n < 3 ? 1 : -1);
1177 for (int ie_s=0; ie_s < 6 ; ie_s++){
1178 int a_s = (ie_s < 3 ? ie_s : (6-ie_s)%3 ); //epsilon[ie_s][0]; //a'
1179 int b_s = (ie_s < 3 ? (ie_s+1)%3 : (8-ie_s)%3 ); //epsilon[ie_s][1]; //b'
1180 int c_s = (ie_s < 3 ? (ie_s+2)%3 : (7-ie_s)%3 ); //epsilon[ie_s][2]; //c'
1181 int eSgn_s = (ie_s < 3 ? 1 : -1);
1182
1183 ee = Real(eSgn_n * eSgn_s); //epsilon_sgn[ie_n] * epsilon_sgn[ie_s];
1184
1185 for (int alpha_n=0; alpha_n<Ns; alpha_n++){
1186 for (int beta_s=0; beta_s<Ns; beta_s++){
1187
1188 auto Gn_adjDd_GH_Duloop_GH_Ds_ab_bb = Gn_adjDd_GH_Duloop_GH_Ds ()(alpha_n,beta_s)(b_n,b_s);
1189
1190 for (int gamma_s=0; gamma_s<Ns; gamma_s++){
1191 for (int gamma_n=0; gamma_n<Ns; gamma_n++){
1192
1193 result()(gamma_n,gamma_s)() -= ee * Du_spec ()(gamma_n,gamma_s)(c_n,c_s)
1194 * Du_Gs ()(alpha_n,beta_s)(a_n,a_s)
1195 * Gn_adjDd_GH_Duloop_GH_Ds_ab_bb;
1196
1197 result()(gamma_n,gamma_s)() += ee * Du_Gs ()(alpha_n,gamma_s)(a_n,c_s)
1198 * Du_spec ()(gamma_n,beta_s)(c_n,a_s)
1199 * Gn_adjDd_GH_Duloop_GH_Ds_ab_bb;
1200 }}
1201 }}
1202 }
1203 }
1204}
1205
1206/* Du_ti is a quark line from t_i to t_H
1207 * Du_tf is a quark line from t_f to t_H
1208 * Du_spec is a quark line from t_i to t_f
1209 * Dd_tf is a quark line from t_f to t_H
1210 * Ds_ti is a quark line from t_i to t_H */
1211template <class FImpl>
1212template <class mobj, class mobj2, class robj> accelerator_inline
1214 const mobj &Du_tf,
1215 const mobj2 &Du_spec,
1216 const mobj &Dd_tf,
1217 const mobj &Ds_ti,
1218 const Gamma Gamma_H,
1219 const Gamma GammaB_sigma,
1220 const Gamma GammaB_nucl,
1221 robj &result)
1222{
1223
1224 Gamma g5(Gamma::Algebra::Gamma5);
1225
1226 auto Du_Gs = Du_spec * GammaB_sigma;
1227 auto adjDu_GH_Ds = g5 * adj(Du_tf) * g5 * Gamma_H * Ds_ti;
1228 auto adjDd_GH_Du = g5 * adj(Dd_tf) * g5 * Gamma_H * Du_ti;
1229 auto Gn_adjDd_GH_Du = GammaB_nucl * adjDd_GH_Du; // for some reason I needed to split this into two lines to avoid the compilation error 'error: identifier "Grid::Gamma::mul" is undefined in device code'
1230
1231 auto Gn_adjDd_GH_Du_Gs = Gn_adjDd_GH_Du * GammaB_sigma;
1232
1233 Real ee;
1234
1235 for (int ie_n=0; ie_n < 6 ; ie_n++){
1236 int a_n = (ie_n < 3 ? ie_n : (6-ie_n)%3 ); //epsilon[ie_n][0]; //a
1237 int b_n = (ie_n < 3 ? (ie_n+1)%3 : (8-ie_n)%3 ); //epsilon[ie_n][1]; //b
1238 int c_n = (ie_n < 3 ? (ie_n+2)%3 : (7-ie_n)%3 ); //epsilon[ie_n][2]; //c
1239 int eSgn_n = (ie_n < 3 ? 1 : -1);
1240 for (int ie_s=0; ie_s < 6 ; ie_s++){
1241 int a_s = (ie_s < 3 ? ie_s : (6-ie_s)%3 ); //epsilon[ie_s][0]; //a'
1242 int b_s = (ie_s < 3 ? (ie_s+1)%3 : (8-ie_s)%3 ); //epsilon[ie_s][1]; //b'
1243 int c_s = (ie_s < 3 ? (ie_s+2)%3 : (7-ie_s)%3 ); //epsilon[ie_s][2]; //c'
1244 int eSgn_s = (ie_s < 3 ? 1 : -1);
1245
1246 ee = Real(eSgn_n * eSgn_s); //epsilon_sgn[ie_n] * epsilon_sgn[ie_s];
1247
1248 for (int alpha_n=0; alpha_n<Ns; alpha_n++){
1249 for (int beta_s=0; beta_s<Ns; beta_s++){
1250
1251 auto adjDu_GH_Ds_ab_ab = adjDu_GH_Ds()(alpha_n, beta_s)(a_n,b_s);
1252 auto Gn_adjDd_GH_Du_Gs_ab_ba = Gn_adjDd_GH_Du_Gs()(alpha_n, beta_s)(b_n,a_s);
1253
1254 for (int gamma_s=0; gamma_s<Ns; gamma_s++){
1255 auto Gn_adjDd_GH_Du_ag_bc = Gn_adjDd_GH_Du()(alpha_n,gamma_s)(b_n,c_s);
1256 for (int gamma_n=0; gamma_n<Ns; gamma_n++){
1257 auto adjDu_GH_Ds_gb_cb = adjDu_GH_Ds()(gamma_n, beta_s)(c_n,b_s);
1258
1259 result()(gamma_n,gamma_s)() += ee * adjDu_GH_Ds_ab_ab
1260 * Gn_adjDd_GH_Du_Gs_ab_ba
1261 * Du_spec()(gamma_n,gamma_s)(c_n,c_s);
1262
1263 result()(gamma_n,gamma_s)() -= ee * adjDu_GH_Ds_gb_cb
1264 * Gn_adjDd_GH_Du_Gs_ab_ba
1265 * Du_spec()(alpha_n,gamma_s)(a_n,c_s);
1266
1267 result()(gamma_n,gamma_s)() += ee * adjDu_GH_Ds_gb_cb
1268 * Gn_adjDd_GH_Du_ag_bc
1269 * Du_Gs()(alpha_n, beta_s)(a_n,a_s);
1270
1271 result()(gamma_n,gamma_s)() -= ee * adjDu_GH_Ds_ab_ab
1272 * Gn_adjDd_GH_Du_ag_bc
1273 * Du_Gs()(gamma_n, beta_s)(c_n,a_s);
1274 }
1275 }
1276 }}
1277 }
1278 }
1279
1280}
1281
1282template<class FImpl>
1283template <class mobj>
1285 const mobj &Du_spec,
1286 const PropagatorField &qd_tf,
1287 const PropagatorField &qs_ti,
1288 const Gamma Gamma_H,
1289 const Gamma GammaB_sigma,
1290 const Gamma GammaB_nucl,
1291 const std::string op,
1292 SpinMatrixField &stn_corr)
1293{
1294
1295 assert(Ns==4 && "Baryon code only implemented for N_spin = 4");
1296 assert(Nc==3 && "Baryon code only implemented for N_colour = 3");
1297
1298 GridBase *grid = qs_ti.Grid();
1299
1300 autoView( vcorr , stn_corr , AcceleratorWrite);
1301 autoView( vq_loop , qq_loop , AcceleratorRead);
1302 autoView( vd_tf , qd_tf , AcceleratorRead);
1303 autoView( vs_ti , qs_ti , AcceleratorRead);
1304
1305 deviceVector<mobj> my_Dq_spec(1);
1306 acceleratorPut(my_Dq_spec[0],Du_spec);
1307 mobj * Dq_spec_p = &my_Dq_spec[0];
1308
1309 if(op == "Q1"){
1310 accelerator_for(ss, grid->oSites(), grid->Nsimd(), {
1311 auto Dq_loop = vq_loop(ss);
1312 auto Dd_tf = vd_tf(ss);
1313 auto Ds_ti = vs_ti(ss);
1314 typedef decltype(coalescedRead(vcorr[0])) spinor;
1315 spinor result=Zero();
1316 SigmaToNucleonQ1EyeSite(Dq_loop,Dq_spec_p[0],Dd_tf,Ds_ti,Gamma_H,GammaB_sigma,GammaB_nucl,result);
1317 coalescedWrite(vcorr[ss],result);
1318 });//end loop over lattice sites
1319 } else if(op == "Q2"){
1320 accelerator_for(ss, grid->oSites(), grid->Nsimd(), {
1321 auto Dq_loop = vq_loop(ss);
1322 auto Dd_tf = vd_tf(ss);
1323 auto Ds_ti = vs_ti(ss);
1324 typedef decltype(coalescedRead(vcorr[0])) spinor;
1325 spinor result=Zero();
1326 SigmaToNucleonQ2EyeSite(Dq_loop,Dq_spec_p[0],Dd_tf,Ds_ti,Gamma_H,GammaB_sigma,GammaB_nucl,result);
1327 coalescedWrite(vcorr[ss],result);
1328 });//end loop over lattice sites
1329 } else {
1330 assert(0 && "Weak Operator not correctly specified");
1331 }
1332}
1333
1334template<class FImpl>
1335template <class mobj>
1337 const PropagatorField &qq_tf,
1338 const mobj &Du_spec,
1339 const PropagatorField &qd_tf,
1340 const PropagatorField &qs_ti,
1341 const Gamma Gamma_H,
1342 const Gamma GammaB_sigma,
1343 const Gamma GammaB_nucl,
1344 const std::string op,
1345 SpinMatrixField &stn_corr)
1346{
1347
1348 assert(Ns==4 && "Baryon code only implemented for N_spin = 4");
1349 assert(Nc==3 && "Baryon code only implemented for N_colour = 3");
1350
1351 GridBase *grid = qs_ti.Grid();
1352
1353 autoView( vcorr , stn_corr , AcceleratorWrite );
1354 autoView( vq_ti , qq_ti , AcceleratorRead );
1355 autoView( vq_tf , qq_tf , AcceleratorRead );
1356 autoView( vd_tf , qd_tf , AcceleratorRead );
1357 autoView( vs_ti , qs_ti , AcceleratorRead );
1358
1359 deviceVector<mobj> my_Dq_spec(1);
1360 acceleratorPut(my_Dq_spec[0],Du_spec);
1361 mobj * Dq_spec_p = &my_Dq_spec[0];
1362
1363 if(op == "Q1"){
1364 accelerator_for(ss, grid->oSites(), grid->Nsimd(), {
1365 auto Dq_ti = vq_ti(ss);
1366 auto Dq_tf = vq_tf(ss);
1367 auto Dd_tf = vd_tf(ss);
1368 auto Ds_ti = vs_ti(ss);
1369 typedef decltype(coalescedRead(vcorr[0])) spinor;
1370 spinor result=Zero();
1371 SigmaToNucleonQ1NonEyeSite(Dq_ti,Dq_tf,Dq_spec_p[0],Dd_tf,Ds_ti,Gamma_H,GammaB_sigma,GammaB_nucl,result);
1372 coalescedWrite(vcorr[ss],result);
1373 });//end loop over lattice sites
1374 } else if(op == "Q2"){
1375 accelerator_for(ss, grid->oSites(), grid->Nsimd(), {
1376 auto Dq_ti = vq_ti(ss);
1377 auto Dq_tf = vq_tf(ss);
1378 auto Dd_tf = vd_tf(ss);
1379 auto Ds_ti = vs_ti(ss);
1380 typedef decltype(coalescedRead(vcorr[0])) spinor;
1381 spinor result=Zero();
1382 SigmaToNucleonQ2NonEyeSite(Dq_ti,Dq_tf,Dq_spec_p[0],Dd_tf,Ds_ti,Gamma_H,GammaB_sigma,GammaB_nucl,result);
1383 coalescedWrite(vcorr[ss],result);
1384 });//end loop over lattice sites
1385 } else {
1386 assert(0 && "Weak Operator not correctly specified");
1387 }
1388}
1389
1390
1391/***********************************************************************
1392 * The following code is for Xi -> Sigma rare hypeon decays *
1393 **********************************************************************/
1394
1395/* Dq_loop is a quark line from t_H to t_H
1396 * Dd_spec is a quark line from t_i to t_f
1397 * Ds_spec is a quark line from t_i to t_f
1398 * Dd_tf is a quark line from t_f to t_H
1399 * Ds_ti is a quark line from t_i to t_H */
1400template <class FImpl>
1401template <class mobj, class mobj2, class robj> accelerator_inline
1403 const mobj2 &Dd_spec,
1404 const mobj2 &Ds_spec,
1405 const mobj &Dd_tf,
1406 const mobj &Ds_ti,
1407 const Gamma Gamma_H,
1408 const Gamma GammaB_xi,
1409 const Gamma GammaB_sigma,
1410 robj &result)
1411{
1412
1413 Gamma g5(Gamma::Algebra::Gamma5);
1414
1415 auto DdG = Dd_spec * GammaB_sigma;
1416 auto GDs = GammaB_xi * Ds_spec;
1417 // Ds * \gamma_\mu^L * (\gamma_5 * Dd^\dagger * \gamma_5)
1418 auto DsGDd = Ds_ti * Gamma_H * g5 * adj(Dd_tf) * g5;
1419 // DsGDd * GammaB
1420 auto DsGDdG = DsGDd * GammaB_sigma;
1421 // GammaB * DsGDd
1422 auto GDsGDd = GammaB_xi * DsGDd;
1423 // GammaB * DsGDd * GammaB
1424 auto GDsGDdG = GDsGDd * GammaB_sigma;
1425 // \gamma_\mu^L * Dq_loop
1426 auto trGDq = TensorRemove(trace(Gamma_H * Dq_loop));
1427
1428 Real ee;
1429
1430 for (int ie_s=0; ie_s < 6 ; ie_s++){
1431 int a_s = (ie_s < 3 ? ie_s : (6-ie_s)%3 ); //epsilon[ie_s][0]; //a'
1432 int b_s = (ie_s < 3 ? (ie_s+1)%3 : (8-ie_s)%3 ); //epsilon[ie_s][1]; //b'
1433 int c_s = (ie_s < 3 ? (ie_s+2)%3 : (7-ie_s)%3 ); //epsilon[ie_s][2]; //c'
1434 int eSgn_s = (ie_s < 3 ? 1 : -1);
1435 for (int ie_x=0; ie_x < 6 ; ie_x++){
1436 int a_x = (ie_x < 3 ? ie_x : (6-ie_x)%3 ); //epsilon[ie_x][0]; //a'
1437 int b_x = (ie_x < 3 ? (ie_x+1)%3 : (8-ie_x)%3 ); //epsilon[ie_x][1]; //b'
1438 int c_x = (ie_x < 3 ? (ie_x+2)%3 : (7-ie_x)%3 ); //epsilon[ie_x][2]; //c'
1439 int eSgn_x = (ie_x < 3 ? 1 : -1);
1440 ee = Real(eSgn_s * eSgn_x);
1441 auto ee_GD = ee * trGDq;
1442 for (int alpha_x=0; alpha_x<Ns; alpha_x++){
1443 for (int beta_s=0; beta_s<Ns; beta_s++){
1444 auto GDsGDdG_ab_ba = GDsGDd()(alpha_x,beta_s)(b_x,a_s);
1445 auto Ds_ab_ab = Ds_spec()(alpha_x,beta_s)(a_x,b_s);
1446 auto DsGDdG_ab_aa = DsGDd()(alpha_x,beta_s)(a_x,a_s);
1447 auto GDs_ab_bb = GDs()(alpha_x,beta_s)(b_x,b_s);
1448 for (int gamma_x=0; gamma_x<Ns; gamma_x++){
1449 auto DdG_cb_ca = DdG()(gamma_x,beta_s)(c_x,a_s);
1450 for (int gamma_s=0; gamma_s<Ns; gamma_s++){
1451 result()(gamma_x,gamma_s)() -= ee_GD * Dd_spec()(gamma_x,gamma_s)(c_x,c_s) * GDsGDdG_ab_ba * Ds_ab_ab;
1452 result()(gamma_x,gamma_s)() += ee_GD * DdG_cb_ca * GDsGDd()(alpha_x,gamma_s)(b_x,c_s) * Ds_ab_ab;
1453 result()(gamma_x,gamma_s)() += ee_GD * Dd_spec()(gamma_x,gamma_s)(c_x,c_s) * DsGDdG_ab_aa * GDs_ab_bb;
1454 result()(gamma_x,gamma_s)() -= ee_GD * DdG_cb_ca * DsGDd()(alpha_x,gamma_s)(a_x,c_s) * GDs_ab_bb;
1455 }
1456 }
1457 }}
1458 }
1459 }
1460}
1461
1462
1463//Equivalent to "One-trace"
1464/* Dq_loop is a quark line from t_H to t_H
1465 * Dd_spec is a quark line from t_i to t_f
1466 * Ds_spec is a quark line from t_i to t_f
1467 * Dd_tf is a quark line from t_f to t_H
1468 * Ds_ti is a quark line from t_i to t_H */
1469template <class FImpl>
1470template <class mobj, class mobj2, class robj> accelerator_inline
1472 const mobj2 &Dd_spec,
1473 const mobj2 &Ds_spec,
1474 const mobj &Dd_tf,
1475 const mobj &Ds_ti,
1476 const Gamma Gamma_H,
1477 const Gamma GammaB_xi,
1478 const Gamma GammaB_sigma,
1479 robj &result)
1480{
1481
1482 Gamma g5(Gamma::Algebra::Gamma5);
1483
1484 auto DdG = Dd_spec * GammaB_sigma;
1485 auto GDs = GammaB_xi * Ds_spec;
1486 // Ds * \gamma_\mu^L * Dq_loop * \gamma_\mu^L * (\gamma_5 * Dd^\dagger * \gamma_5)
1487 auto DsGDqGDd = Ds_ti * Gamma_H * Dq_loop * Gamma_H * g5 * adj(Dd_tf) * g5;
1488 // DsGDd * GammaB
1489 auto DsGDqGDdG = DsGDqGDd * GammaB_sigma;
1490 // GammaB * DsGDd
1491 auto GDsGDqGDd = GammaB_xi * DsGDqGDd;
1492 // GammaB * DsGDd * GammaB
1493 auto GDsGDqGDdG = GDsGDqGDd * GammaB_sigma;
1494
1495 Real ee;
1496
1497 for (int ie_s=0; ie_s < 6 ; ie_s++){
1498 int a_s = (ie_s < 3 ? ie_s : (6-ie_s)%3 ); //epsilon[ie_s][0]; //a'
1499 int b_s = (ie_s < 3 ? (ie_s+1)%3 : (8-ie_s)%3 ); //epsilon[ie_s][1]; //b'
1500 int c_s = (ie_s < 3 ? (ie_s+2)%3 : (7-ie_s)%3 ); //epsilon[ie_s][2]; //c'
1501 int eSgn_s = (ie_s < 3 ? 1 : -1);
1502 for (int ie_x=0; ie_x < 6 ; ie_x++){
1503 int a_x = (ie_x < 3 ? ie_x : (6-ie_x)%3 ); //epsilon[ie_x][0]; //a'
1504 int b_x = (ie_x < 3 ? (ie_x+1)%3 : (8-ie_x)%3 ); //epsilon[ie_x][1]; //b'
1505 int c_x = (ie_x < 3 ? (ie_x+2)%3 : (7-ie_x)%3 ); //epsilon[ie_x][2]; //c'
1506 int eSgn_x = (ie_x < 3 ? 1 : -1);
1507 ee = Real(eSgn_s * eSgn_x);
1508 for (int alpha_x=0; alpha_x<Ns; alpha_x++){
1509 for (int beta_s=0; beta_s<Ns; beta_s++){
1510 auto GDsGDqGDdG_ab_ba = GDsGDqGDdG()(alpha_x,beta_s)(b_x,a_s);
1511 auto Ds_ab_ab = Ds_spec()(alpha_x,beta_s)(a_x,b_s);
1512 auto DsGDqGDdG_ab_aa = GDsGDqGDdG()(alpha_x,beta_s)(a_x,a_s);
1513 auto GDs_ab_bb = GDs()(alpha_x,beta_s)(b_x,b_s);
1514 for (int gamma_x=0; gamma_x<Ns; gamma_x++){
1515 auto DdG_cb_ca = DdG()(gamma_x, beta_s)(c_x,a_s);
1516 for (int gamma_s=0; gamma_s<Ns; gamma_s++){
1517 result()(gamma_x,gamma_s)() -= ee * Dd_spec()(gamma_x,gamma_s)(c_x,c_s) * GDsGDqGDdG_ab_ba * Ds_ab_ab;
1518 result()(gamma_x,gamma_s)() += ee * DdG_cb_ca * GDsGDqGDd()(alpha_x,gamma_s)(b_x,c_s) * Ds_ab_ab;
1519 result()(gamma_x,gamma_s)() += ee * Dd_spec()(gamma_x,gamma_s)(c_x,c_s) * DsGDqGDdG_ab_aa * GDs_ab_bb;
1520 result()(gamma_x,gamma_s)() -= ee * DdG_cb_ca * DsGDqGDd()(alpha_x,gamma_s)(a_x,c_s) * GDs_ab_bb;
1521 }}
1522 }}
1523 }
1524 }
1525}
1526
1527template<class FImpl>
1528template <class mobj>
1530 const mobj &Dd_spec,
1531 const mobj &Ds_spec,
1532 const PropagatorField &qd_tf,
1533 const PropagatorField &qs_ti,
1534 const Gamma Gamma_H,
1535 const Gamma GammaB_xi,
1536 const Gamma GammaB_sigma,
1537 const std::string op,
1538 SpinMatrixField &xts_corr)
1539{
1540
1541 assert(Ns==4 && "Baryon code only implemented for N_spin = 4");
1542 assert(Nc==3 && "Baryon code only implemented for N_colour = 3");
1543
1544 GridBase *grid = qs_ti.Grid();
1545
1546 autoView( vcorr , xts_corr , AcceleratorWrite);
1547 autoView( vq_loop , qq_loop , AcceleratorRead);
1548 autoView( vd_tf , qd_tf , AcceleratorRead);
1549 autoView( vs_ti , qs_ti , AcceleratorRead);
1550
1551 deviceVector<mobj> my_Dq_spec(2);
1552 acceleratorPut(my_Dq_spec[0],Dd_spec);
1553 acceleratorPut(my_Dq_spec[0],Ds_spec);
1554 mobj * Dq_spec_p = &my_Dq_spec[0];
1555
1556 if(op == "Q1"){
1557 accelerator_for(ss, grid->oSites(), grid->Nsimd(), {
1558 auto Dq_loop = vq_loop(ss);
1559 auto Dd_tf = vd_tf(ss);
1560 auto Ds_ti = vs_ti(ss);
1561 typedef decltype(coalescedRead(vcorr[0])) spinor;
1562 spinor result=Zero();
1563 XiToSigmaQ1EyeSite(Dq_loop,Dq_spec_p[0],Dq_spec_p[1],Dd_tf,Ds_ti,Gamma_H,GammaB_xi,GammaB_sigma,result);
1564 coalescedWrite(vcorr[ss],result);
1565 } );//end loop over lattice sites
1566 } else if(op == "Q2"){
1567 accelerator_for(ss, grid->oSites(), grid->Nsimd(), {
1568 auto Dq_loop = vq_loop(ss);
1569 auto Dd_tf = vd_tf(ss);
1570 auto Ds_ti = vs_ti(ss);
1571 typedef decltype(coalescedRead(vcorr[0])) spinor;
1572 spinor result=Zero();
1573 XiToSigmaQ2EyeSite(Dq_loop,Dq_spec_p[0],Dq_spec_p[1],Dd_tf,Ds_ti,Gamma_H,GammaB_xi,GammaB_sigma,result);
1574 coalescedWrite(vcorr[ss],result);
1575 } );//end loop over lattice sites
1576 } else {
1577 assert(0 && "Weak Operator not correctly specified");
1578 }
1579}
1580
1581
void acceleratorPut(T &dev, const T &host)
#define accelerator_inline
#define accelerator_for(iterator, num, nsimd,...)
std::vector< T, devAllocator< T > > deviceVector
accelerator_inline Grid_simd2< S, V > trace(const Grid_simd2< S, V > &arg)
Lattice< vobj > adj(const Lattice< vobj > &lhs)
#define autoView(l_v, l, mode)
GridLogger GridLogDebug(1, "Debug", GridLogColours, "PURPLE")
@ AcceleratorRead
@ AcceleratorWrite
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
static constexpr int Ns
Definition QCD.h:51
static constexpr int Nc
Definition QCD.h:50
RealF Real
Definition Simd.h:65
vComplexD vComplex
Definition Simd.h:238
accelerator_inline std::enable_if<!isGridTensor< T >::value, T >::type TensorRemove(T arg)
double usecond(void)
Definition Timer.h:50
static accelerator_inline void BaryonSite(const mobj &D1, const mobj &D2, const mobj &D3, const Gamma GammaA_left, const Gamma GammaB_left, const Gamma GammaA_right, const Gamma GammaB_right, const int parity, const int wick_contractions, robj &result)
static void ContractBaryonsMatrix(const PropagatorField &q1_left, const PropagatorField &q2_left, const PropagatorField &q3_left, const Gamma GammaA_left, const Gamma GammaB_left, const Gamma GammaA_right, const Gamma GammaB_right, const int wick_contractions, SpinMatrixField &baryon_corr)
static void SigmaToNucleonEye(const PropagatorField &qq_loop, const mobj &Du_spec, const PropagatorField &qd_tf, const PropagatorField &qs_ti, const Gamma Gamma_H, const Gamma GammaB_sigma, const Gamma GammaB_nucl, const std::string op, SpinMatrixField &stn_corr)
static void BaryonGamma3pt(const PropagatorField &q_ti, const mobj &Dq_spec1, const mobj &Dq_spec2, const PropagatorField &q_tf, int group, int wick_contraction, const Gamma GammaJ, const Gamma GammaBi, const Gamma GammaBf, SpinMatrixField &stn_corr)
static accelerator_inline void SigmaToNucleonQ2EyeSite(const mobj &Dq_loop, const mobj2 &Du_spec, const mobj &Dd_tf, const mobj &Ds_ti, const Gamma Gamma_H, const Gamma GammaB_sigma, const Gamma GammaB_nucl, robj &result)
Lattice< iSpinMatrix< typename FImpl::Simd > > SpinMatrixField
Definition BaryonUtils.h:42
static accelerator_inline void BaryonSiteMatrix(const mobj &D1, const mobj &D2, const mobj &D3, const Gamma GammaA_left, const Gamma GammaB_left, const Gamma GammaA_right, const Gamma GammaB_right, const int wick_contractions, robj &result)
static accelerator_inline void BaryonGamma3ptGroup1Site(const mobj &Dq1_ti, const mobj2 &Dq2_spec, const mobj2 &Dq3_spec, const mobj &Dq4_tf, const Gamma GammaJ, const Gamma GammaBi, const Gamma GammaBf, int wick_contraction, robj &result)
FImpl::PropagatorField PropagatorField
Definition BaryonUtils.h:40
FImpl::ComplexField ComplexField
Definition BaryonUtils.h:38
static void ContractBaryons(const PropagatorField &q1_left, const PropagatorField &q2_left, const PropagatorField &q3_left, const Gamma GammaA_left, const Gamma GammaB_left, const Gamma GammaA_right, const Gamma GammaB_right, const int wick_contractions, const int parity, ComplexField &baryon_corr)
static void SigmaToNucleonNonEye(const PropagatorField &qq_ti, const PropagatorField &qq_tf, const mobj &Du_spec, const PropagatorField &qd_tf, const PropagatorField &qs_ti, const Gamma Gamma_H, const Gamma GammaB_sigma, const Gamma GammaB_nucl, const std::string op, SpinMatrixField &stn_corr)
static accelerator_inline void BaryonGamma3ptGroup2Site(const mobj2 &Dq1_spec, const mobj &Dq2_ti, const mobj2 &Dq3_spec, const mobj &Dq4_tf, const Gamma GammaJ, const Gamma GammaBi, const Gamma GammaBf, int wick_contraction, robj &result)
static void WickContractions(std::string qi, std::string qf, int &wick_contractions)
static accelerator_inline void SigmaToNucleonQ2NonEyeSite(const mobj &Du_ti, const mobj &Du_tf, const mobj2 &Du_spec, const mobj &Dd_tf, const mobj &Ds_ti, const Gamma Gamma_H, const Gamma GammaB_sigma, const Gamma GammaB_nucl, robj &result)
static void ContractBaryonsSlicedMatrix(const mobj &D1, const mobj &D2, const mobj &D3, const Gamma GammaA_left, const Gamma GammaB_left, const Gamma GammaA_right, const Gamma GammaB_right, const int wick_contractions, const int nt, robj &result)
FImpl::FermionField FermionField
Definition BaryonUtils.h:39
static accelerator_inline void XiToSigmaQ1EyeSite(const mobj &Dq_loop, const mobj2 &Dd_spec, const mobj2 &Ds_spec, const mobj &Dd_tf, const mobj &Ds_ti, const Gamma Gamma_H, const Gamma GammaB_sigma, const Gamma GammaB_nucl, robj &result)
static accelerator_inline void XiToSigmaQ2EyeSite(const mobj &Dq_loop, const mobj2 &Dd_spec, const mobj2 &Ds_spec, const mobj &Dd_tf, const mobj &Ds_ti, const Gamma Gamma_H, const Gamma GammaB_sigma, const Gamma GammaB_nucl, robj &result)
static accelerator_inline void BaryonGamma3ptGroup3Site(const mobj2 &Dq1_spec, const mobj2 &Dq2_spec, const mobj &Dq3_ti, const mobj &Dq4_tf, const Gamma GammaJ, const Gamma GammaBi, const Gamma GammaBf, int wick_contraction, robj &result)
static void ContractBaryonsSliced(const mobj &D1, const mobj &D2, const mobj &D3, const Gamma GammaA_left, const Gamma GammaB_left, const Gamma GammaA_right, const Gamma GammaB_right, const int wick_contractions, const int parity, const int nt, robj &result)
static accelerator_inline void SigmaToNucleonQ1EyeSite(const mobj &Dq_loop, const mobj2 &Du_spec, const mobj &Dd_tf, const mobj &Ds_ti, const Gamma Gamma_H, const Gamma GammaB_sigma, const Gamma GammaB_nucl, robj &result)
static accelerator_inline void SigmaToNucleonQ1NonEyeSite(const mobj &Du_ti, const mobj &Du_tf, const mobj2 &Du_spec, const mobj &Dd_tf, const mobj &Ds_ti, const Gamma Gamma_H, const Gamma GammaB_sigma, const Gamma GammaB_nucl, robj &result)
static void XiToSigmaEye(const PropagatorField &qq_loop, const mobj &Dd_spec, const mobj &Ds_spec, const PropagatorField &qd_tf, const PropagatorField &qs_ti, const Gamma Gamma_H, const Gamma GammaB_sigma, const Gamma GammaB_nucl, const std::string op, SpinMatrixField &xts_corr)
Definition Gamma.h:10
int oSites(void) const
int Nsimd(void) const