1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-04-05 03:35:55 +01:00

tested and working

This commit is contained in:
Felix Erben 2021-01-08 18:04:50 +00:00
parent f36d6f3923
commit e759367d42

View File

@ -40,14 +40,7 @@ public:
typedef typename FImpl::FermionField FermionField;
typedef typename FImpl::PropagatorField PropagatorField;
typedef typename FImpl::SitePropagator pobj;
typedef typename ComplexField::vector_object vobj;
typedef Lattice<iSpinMatrix<typename FImpl::Simd>> SpinMatrixField;
//typedef typename SpinMatrixField::vector_object sobj;
//static const int epsilon[6][3] ;
//static const Real epsilon_sgn[6];
private:
template <class mobj, class robj> accelerator_inline
@ -122,7 +115,7 @@ public:
static void BaryonGamma3ptGroup1Site(
const mobj &Dq1_ti,
const mobj2 &Dq2_spec,
// const mobj2 &Dq3_spec,
const mobj2 &Dq3_spec,
const mobj &Dq4_tf,
const Gamma GammaJ,
const Gamma GammaBi,
@ -134,7 +127,7 @@ public:
static void BaryonGamma3ptGroup2Site(
const mobj2 &Dq1_spec,
const mobj &Dq2_ti,
//const mobj2 &Dq3_spec,
const mobj2 &Dq3_spec,
const mobj &Dq4_tf,
const Gamma GammaJ,
const Gamma GammaBi,
@ -145,7 +138,7 @@ public:
template <class mobj, class mobj2, class robj> accelerator_inline
static void BaryonGamma3ptGroup3Site(
const mobj2 &Dq1_spec,
//const mobj2 &Dq2_spec,
const mobj2 &Dq2_spec,
const mobj &Dq3_ti,
const mobj &Dq4_tf,
const Gamma GammaJ,
@ -230,13 +223,7 @@ public:
const std::string op,
SpinMatrixField &stn_corr);
};
/*
template <class FImpl>
const int BaryonUtils<FImpl>::epsilon[6][3] = {{0,1,2},{1,2,0},{2,0,1},{0,2,1},{2,1,0},{1,0,2}};
template <class FImpl>
const Real BaryonUtils<FImpl>::epsilon_sgn[6] = {1.,1.,1.,-1.,-1.,-1.};
*/
//This is the old version
//This computes a baryon contraction on a lattice site, including the spin-trace of the correlation matrix
template <class FImpl>
template <class mobj, class robj> accelerator_inline
void BaryonUtils<FImpl>::BaryonSite(const mobj &D1,
@ -325,9 +312,9 @@ void BaryonUtils<FImpl>::BaryonSite(const mobj &D1,
result()()() -= ee * GAf_D1_GAi_P_rr_cc
* GBf_D2_GBi ()(alpha_f,beta_i)(b_f,a_i)
* D3 ()(alpha_f,beta_i)(a_f,b_i);
}
}}
}
}
//This is the \delta_{456}^{321} part
if (wick_contraction[4]){
for (int rho=0; rho<Ns; rho++){
@ -352,7 +339,8 @@ void BaryonUtils<FImpl>::BaryonSite(const mobj &D1,
}
}}
}
}}
}
}
}
//New version without parity projection or trace
@ -380,7 +368,6 @@ void BaryonUtils<FImpl>::BaryonSiteMatrix(const mobj &D1,
auto GBf_D3 = GammaB_f * D3;
auto GAf_D3 = GammaA_f * D3;
Real ee;
for (int ie_f=0; ie_f < 6 ; ie_f++){
@ -419,7 +406,8 @@ void BaryonUtils<FImpl>::BaryonSiteMatrix(const mobj &D1,
result()(rho_f,rho_i)() += ee * D1_GAi_ar_ac
* GBf_D2_GBi_ab_ba
* GAf_D3 ()(rho_f,beta_i)(c_f,b_i);
}}
}
}
}}
}
//This is the \delta_{456}^{312} part
@ -433,7 +421,8 @@ void BaryonUtils<FImpl>::BaryonSiteMatrix(const mobj &D1,
result()(rho_f,rho_i)() += ee * GBf_D1_GAi_ar_bc
* GAf_D2_GBi ()(rho_f,beta_i)(c_f,a_i)
* D3_ab_ab;
}}
}
}
}}
}
//This is the \delta_{456}^{132} part
@ -460,7 +449,8 @@ void BaryonUtils<FImpl>::BaryonSiteMatrix(const mobj &D1,
result()(rho_f,rho_i)() -= ee * GBf_D1_GAi_ar_bc
* D2_GBi_ab_aa
* GAf_D3 ()(rho_f,beta_i)(c_f,b_i);
}}
}
}
}}
}
//This is the \delta_{456}^{213} part
@ -474,10 +464,12 @@ void BaryonUtils<FImpl>::BaryonSiteMatrix(const mobj &D1,
result()(rho_f,rho_i)() -= ee * D1_GAi_ar_ac
* GAf_D2_GBi ()(rho_f,beta_i)(c_f,a_i)
* GBf_D3_ab_bb;
}}
}}
}
}
}}
}
}
}
}
/* Computes which wick contractions should be performed for a *
@ -530,8 +522,7 @@ void BaryonUtils<FImpl>::ContractBaryons(const PropagatorField &q1_left,
for (int ie=0; ie < 6 ; ie++){
if(ie==0 or ie==3){
bytes += grid->oSites() * (4.*sizeof(int) + 4752.*sizeof(vComplex)) * wick_contractions[ie];
}
else{
} else{
bytes += grid->oSites() * (64.*sizeof(int) + 5184.*sizeof(vComplex)) * wick_contractions[ie];
}
}
@ -653,7 +644,7 @@ template <class mobj, class mobj2, class robj> accelerator_inline
void BaryonUtils<FImpl>::BaryonGamma3ptGroup1Site(
const mobj &Dq1_ti,
const mobj2 &Dq2_spec,
// const mobj2 &Dq3_spec,
const mobj2 &Dq3_spec,
const mobj &Dq4_tf,
const Gamma GammaJ,
const Gamma GammaBi,
@ -663,16 +654,12 @@ void BaryonUtils<FImpl>::BaryonGamma3ptGroup1Site(
{
Gamma g5(Gamma::Algebra::Gamma5);
// auto adjD4_g_D1 = g5 * adj(Dq4_tf) * g5 * GammaJ * Dq1_ti;
auto adjD4 = g5 * adj(Dq4_tf) * g5 ;
auto adjD4_g_D1 = adjD4 * GammaJ * Dq1_ti;
auto Gf_adjD4_g_D1 = GammaBf * adjD4_g_D1;
auto D2_Gi = Dq2_spec * GammaBi;
auto Gf_D2_Gi = GammaBf * D2_Gi;
// auto Gf_D3 = GammaBf * Dq3_spec; // including a second mobj2 parameter leads to compilation error
auto Gf_D3 = GammaBf * Dq2_spec; //WRONG!!!!!
auto Gf_D3 = GammaBf * Dq3_spec;
Real ee;
@ -687,23 +674,21 @@ void BaryonUtils<FImpl>::BaryonGamma3ptGroup1Site(
int c_i = (ie_i < 3 ? (ie_i+2)%3 : (7-ie_i)%3 ); //epsilon[ie_s][2]; //c'
int eSgn_i = (ie_i < 3 ? 1 : -1);
ee = Real(eSgn_f * eSgn_i); //epsilon_sgn[ie_n] * epsilon_sgn[ie_s];
ee = Real(eSgn_f * eSgn_i);
for (int alpha_f=0; alpha_f<Ns; alpha_f++){
for (int beta_i=0; beta_i<Ns; beta_i++){
auto D2_Gi_ab_aa = D2_Gi ()(alpha_f,beta_i)(a_f,a_i);
auto Gf_D3_ab_bb = Gf_D3 ()(alpha_f,beta_i)(b_f,b_i);
auto Gf_D2_Gi_ab_ba = Gf_D2_Gi ()(alpha_f,beta_i)(b_f,a_i);
//auto Dq3_spec_ab_ab = Dq3_spec ()(alpha_f,beta_i)(a_f,b_i);
auto Dq3_spec_ab_ab = Dq2_spec ()(alpha_f,beta_i)(a_f,b_i); // WRONG!!!!
auto Dq3_spec_ab_ab = Dq3_spec ()(alpha_f,beta_i)(a_f,b_i);
for (int gamma_i=0; gamma_i<Ns; gamma_i++){
auto ee_adjD4_g_D1_ag_ac = ee * adjD4_g_D1 ()(alpha_f,gamma_i)(a_f,c_i);
auto ee_Gf_adjD4_g_D1_ag_bc = ee * Gf_adjD4_g_D1()(alpha_f,gamma_i)(b_f,c_i);
for (int gamma_f=0; gamma_f<Ns; gamma_f++){
auto ee_adjD4_g_D1_gg_cc = ee * adjD4_g_D1 ()(gamma_f,gamma_i)(c_f,c_i);
//auto Dq3_spec_gb_cb = Dq3_spec ()(gamma_f,beta_i)(c_f,b_i);
auto Dq3_spec_gb_cb = Dq2_spec ()(gamma_f,beta_i)(c_f,b_i); //WRONG!!!!
auto Dq3_spec_gb_cb = Dq3_spec ()(gamma_f,beta_i)(c_f,b_i);
auto D2_Gi_gb_ca = D2_Gi ()(gamma_f,beta_i)(c_f,a_i);
@ -737,9 +722,11 @@ void BaryonUtils<FImpl>::BaryonGamma3ptGroup1Site(
* D2_Gi_gb_ca
* Gf_D3_ab_bb;
}
}
}
}}
}}
}}
}
}
}
/* Dq1_spec is a quark line from t_i to t_f
@ -751,7 +738,7 @@ template <class mobj, class mobj2, class robj> accelerator_inline
void BaryonUtils<FImpl>::BaryonGamma3ptGroup2Site(
const mobj2 &Dq1_spec,
const mobj &Dq2_ti,
// const mobj2 &Dq3_spec,
const mobj2 &Dq3_spec,
const mobj &Dq4_tf,
const Gamma GammaJ,
const Gamma GammaBi,
@ -764,9 +751,7 @@ void BaryonUtils<FImpl>::BaryonGamma3ptGroup2Site(
auto adjD4_g_D2_Gi = g5 * adj(Dq4_tf) * g5 * GammaJ * Dq2_ti * GammaBi;
auto Gf_adjD4_g_D2_Gi = GammaBf * adjD4_g_D2_Gi;
auto Gf_D1 = GammaBf * Dq1_spec;
//auto Gf_D3 = GammaBf * Dq3_spec;
auto Gf_D3 = GammaBf * Dq1_spec; // WRONG!!!!!
auto Gf_D3 = GammaBf * Dq3_spec;
Real ee;
@ -788,16 +773,14 @@ void BaryonUtils<FImpl>::BaryonGamma3ptGroup2Site(
auto adjD4_g_D2_Gi_ab_aa = adjD4_g_D2_Gi ()(alpha_f,beta_i)(a_f,a_i);
auto Gf_D3_ab_bb = Gf_D3 ()(alpha_f,beta_i)(b_f,b_i);
auto Gf_adjD4_g_D2_Gi_ab_ba = Gf_adjD4_g_D2_Gi ()(alpha_f,beta_i)(b_f,a_i);
//auto Dq3_spec_ab_ab = Dq3_spec ()(alpha_f,beta_i)(a_f,b_i);
auto Dq3_spec_ab_ab = Dq1_spec ()(alpha_f,beta_i)(a_f,b_i); //WRONG!!!
auto Dq3_spec_ab_ab = Dq3_spec ()(alpha_f,beta_i)(a_f,b_i);
for (int gamma_i=0; gamma_i<Ns; gamma_i++){
auto ee_Dq1_spec_ag_ac = ee * Dq1_spec ()(alpha_f,gamma_i)(a_f,c_i);
auto ee_Gf_D1_ag_bc = ee * Gf_D1 ()(alpha_f,gamma_i)(b_f,c_i);
for (int gamma_f=0; gamma_f<Ns; gamma_f++){
auto ee_Dq1_spec_gg_cc = ee * Dq1_spec ()(gamma_f,gamma_i)(c_f,c_i);
//auto Dq3_spec_gb_cb = Dq3_spec ()(gamma_f,beta_i)(c_f,b_i);
auto Dq3_spec_gb_cb = Dq1_spec ()(gamma_f,beta_i)(c_f,b_i); //WRONG!!!
auto Dq3_spec_gb_cb = Dq3_spec ()(gamma_f,beta_i)(c_f,b_i);
auto adjD4_g_D2_Gi_gb_ca = adjD4_g_D2_Gi ()(gamma_f,beta_i)(c_f,a_i);
if(wick_contraction == 1) { // Do contraction II1
@ -830,9 +813,11 @@ void BaryonUtils<FImpl>::BaryonGamma3ptGroup2Site(
* adjD4_g_D2_Gi_gb_ca
* Gf_D3_ab_bb;
}
}
}
}}
}}
}}
}
}
}
/* Dq1_spec is a quark line from t_i to t_f
@ -843,7 +828,7 @@ template<class FImpl>
template <class mobj, class mobj2, class robj> accelerator_inline
void BaryonUtils<FImpl>::BaryonGamma3ptGroup3Site(
const mobj2 &Dq1_spec,
// const mobj2 &Dq2_spec,
const mobj2 &Dq2_spec,
const mobj &Dq3_ti,
const mobj &Dq4_tf,
const Gamma GammaJ,
@ -857,11 +842,9 @@ void BaryonUtils<FImpl>::BaryonGamma3ptGroup3Site(
auto adjD4_g_D3 = g5 * adj(Dq4_tf) * g5 * GammaJ * Dq3_ti;
auto Gf_adjD4_g_D3 = GammaBf * adjD4_g_D3;
auto Gf_D1 = GammaBf * Dq1_spec;
//auto D2_Gi = Dq2_spec * GammaBi;
auto D2_Gi = Dq1_spec * GammaBi; //WRONG!!!!!!!!!!!!!!!!!
auto D2_Gi = Dq2_spec * GammaBi;
auto Gf_D2_Gi = GammaBf * D2_Gi;
Real ee;
for (int ie_f=0; ie_f < 6 ; ie_f++){
@ -922,9 +905,11 @@ void BaryonUtils<FImpl>::BaryonGamma3ptGroup3Site(
* D2_Gi_gb_ca
* Gf_adjD4_g_D3_ab_bb;
}
}
}
}}
}}
}}
}
}
}
/* The group indicates which inital state quarks the current is *
@ -951,51 +936,20 @@ void BaryonUtils<FImpl>::BaryonGamma3pt(
GridBase *grid = q_tf.Grid();
// autoView( vcorr, stn_corr, CpuWrite);
// autoView( vq_ti , q_ti, CpuRead);
// autoView( vq_tf , q_tf, CpuRead);
// if (group == 1) {
// accelerator_for(ss, grid->oSites(), grid->Nsimd(), {
// auto Dq_ti = vq_ti[ss];
// auto Dq_tf = vq_tf[ss];
// sobj result=Zero();
// BaryonGamma3ptGroup1Site(Dq_ti,Dq_spec1,Dq_spec2,Dq_tf,GammaJ,GammaBi,GammaBf,wick_contraction,result);
// vcorr[ss] += result;
// });//end loop over lattice sites
// } else if (group == 2) {
// accelerator_for(ss, grid->oSites(), grid->Nsimd(), {
// auto Dq_ti = vq_ti[ss];
// auto Dq_tf = vq_tf[ss];
// sobj result=Zero();
// BaryonGamma3ptGroup2Site(Dq_spec1,Dq_ti,Dq_spec2,Dq_tf,GammaJ,GammaBi,GammaBf,wick_contraction,result);
// vcorr[ss] += result;
// });//end loop over lattice sites
// } else if (group == 3) {
// accelerator_for(ss, grid->oSites(), grid->Nsimd(), {
// auto Dq_ti = vq_ti[ss];
// auto Dq_tf = vq_tf[ss];
// sobj result=Zero();
// BaryonGamma3ptGroup3Site(Dq_spec1,Dq_spec2,Dq_ti,Dq_tf,GammaJ,GammaBi,GammaBf,wick_contraction,result);
// vcorr[ss] += result;
// });//end loop over lattice sites
// }
autoView( vcorr , stn_corr , AcceleratorWrite);
autoView( vq_ti , q_ti , AcceleratorRead);
autoView( vq_tf , q_tf , AcceleratorRead);
Vector<mobj> my_Dq_spec{Dq_spec1,Dq_spec2};
mobj * Dq_spec_p = &my_Dq_spec[0];
if (group == 1) {
accelerator_for(ss, grid->oSites(), grid->Nsimd(), {
auto Dq_ti = vq_ti(ss);
auto Dq_tf = vq_tf(ss);
//sobj result=Zero();
typedef decltype(coalescedRead(vcorr[0])) spinor;
spinor result=Zero();
//BaryonGamma3ptGroup1Site(Dq_ti,Dq_spec1,Dq_spec2,Dq_tf,GammaJ,GammaBi,GammaBf,wick_contraction,result);
BaryonGamma3ptGroup1Site(Dq_ti,Dq_spec1,Dq_tf,GammaJ,GammaBi,GammaBf,wick_contraction,result); //WRONG
// vcorr[ss] += result;
BaryonGamma3ptGroup1Site(Dq_ti,Dq_spec_p[0],Dq_spec_p[1],Dq_tf,GammaJ,GammaBi,GammaBf,wick_contraction,result);
coalescedWrite(vcorr[ss],result);
});//end loop over lattice sites
@ -1003,24 +957,18 @@ void BaryonUtils<FImpl>::BaryonGamma3pt(
accelerator_for(ss, grid->oSites(), grid->Nsimd(), {
auto Dq_ti = vq_ti(ss);
auto Dq_tf = vq_tf(ss);
//sobj result=Zero();
typedef decltype(coalescedRead(vcorr[0])) spinor;
spinor result=Zero();
// BaryonGamma3ptGroup2Site(Dq_spec1,Dq_ti,Dq_spec2,Dq_tf,GammaJ,GammaBi,GammaBf,wick_contraction,result);
BaryonGamma3ptGroup2Site(Dq_spec1,Dq_ti,Dq_tf,GammaJ,GammaBi,GammaBf,wick_contraction,result); //WRONG
// vcorr[ss] += result;
BaryonGamma3ptGroup2Site(Dq_spec_p[0],Dq_ti,Dq_spec_p[1],Dq_tf,GammaJ,GammaBi,GammaBf,wick_contraction,result);
coalescedWrite(vcorr[ss],result);
});//end loop over lattice sites
} else if (group == 3) {
accelerator_for(ss, grid->oSites(), grid->Nsimd(), {
auto Dq_ti = vq_ti(ss);
auto Dq_tf = vq_tf(ss);
//sobj result=Zero();
typedef decltype(coalescedRead(vcorr[0])) spinor;
spinor result=Zero();
//BaryonGamma3ptGroup3Site(Dq_spec1,Dq_spec2,Dq_ti,Dq_tf,GammaJ,GammaBi,GammaBf,wick_contraction,result);
BaryonGamma3ptGroup3Site(Dq_spec1,Dq_ti,Dq_tf,GammaJ,GammaBi,GammaBf,wick_contraction,result); //WRONG
// vcorr[ss] += result;
BaryonGamma3ptGroup3Site(Dq_spec_p[0],Dq_spec_p[1],Dq_ti,Dq_tf,GammaJ,GammaBi,GammaBf,wick_contraction,result);
coalescedWrite(vcorr[ss],result);
});//end loop over lattice sites
}
@ -1052,7 +1000,6 @@ void BaryonUtils<FImpl>::SigmaToNucleonQ1EyeSite(const mobj &Dq_loop,
Gamma g5(Gamma::Algebra::Gamma5);
//auto Gn_adjDd_GH_Ds = GammaB_nucl * g5 * adj(Dd_tf) * g5 * Gamma_H * Ds_ti;
auto adjDd_GH_Ds = g5 * adj(Dd_tf) * g5 * Gamma_H * Ds_ti;
auto Gn_adjDd_GH_Ds = GammaB_nucl * adjDd_GH_Ds;
auto Du_Gs = Du_spec * GammaB_sigma;
@ -1072,8 +1019,7 @@ void BaryonUtils<FImpl>::SigmaToNucleonQ1EyeSite(const mobj &Dq_loop,
int c_s = (ie_s < 3 ? (ie_s+2)%3 : (7-ie_s)%3 ); //epsilon[ie_s][2]; //c'
int eSgn_s = (ie_s < 3 ? 1 : -1);
ee = Real(eSgn_n * eSgn_s); //epsilon_sgn[ie_n] * epsilon_sgn[ie_s];
ee = Real(eSgn_n * eSgn_s);
for (int alpha_n=0; alpha_n<Ns; alpha_n++){
for (int beta_s=0; beta_s<Ns; beta_s++){
@ -1092,7 +1038,8 @@ void BaryonUtils<FImpl>::SigmaToNucleonQ1EyeSite(const mobj &Dq_loop,
* Tr_Dq_GH;
}}
}}
}}
}
}
}
/* Du_ti is a quark line from t_i to t_H
@ -1116,7 +1063,6 @@ void BaryonUtils<FImpl>::SigmaToNucleonQ1NonEyeSite(const mobj &Du_ti,
Gamma g5(Gamma::Algebra::Gamma5);
auto Du_Gs = Du_spec * GammaB_sigma;
//auto Gn_adjDd_GH_Ds = GammaB_nucl * g5 * adj(Dd_tf) * g5 * Gamma_H * Ds_ti;
auto adjDd_GH_Ds = g5 * adj(Dd_tf) * g5 * Gamma_H * Ds_ti;
auto Gn_adjDd_GH_Ds = GammaB_nucl * adjDd_GH_Ds;
auto adjDu_GH_Du = g5 * adj(Du_tf) * g5 * Gamma_H * Du_ti;
@ -1162,7 +1108,8 @@ void BaryonUtils<FImpl>::SigmaToNucleonQ1NonEyeSite(const mobj &Du_ti,
* Du_Gs ()(alpha_n, beta_s)(a_n,a_s);
}}
}}
}}
}
}
}
//Equivalent to "One-trace"
@ -1184,7 +1131,6 @@ void BaryonUtils<FImpl>::SigmaToNucleonQ2EyeSite(const mobj &Dq_loop,
Gamma g5(Gamma::Algebra::Gamma5);
//auto Gn_adjDd_GH_Duloop_GH_Ds = GammaB_nucl * g5 * adj(Dd_tf) * g5 * Gamma_H * Dq_loop * Gamma_H * Ds_ti;
auto adjDd_GH_Duloop_GH_Ds = g5 * adj(Dd_tf) * g5 * Gamma_H * Dq_loop * Gamma_H * Ds_ti;
auto Gn_adjDd_GH_Duloop_GH_Ds = GammaB_nucl * adjDd_GH_Duloop_GH_Ds;
auto Du_Gs = Du_spec * GammaB_sigma;
@ -1221,7 +1167,8 @@ void BaryonUtils<FImpl>::SigmaToNucleonQ2EyeSite(const mobj &Dq_loop,
* Gn_adjDd_GH_Duloop_GH_Ds_ab_bb;
}}
}}
}}
}
}
}
/* Du_ti is a quark line from t_i to t_H
@ -1246,7 +1193,6 @@ void BaryonUtils<FImpl>::SigmaToNucleonQ2NonEyeSite(const mobj &Du_ti,
auto Du_Gs = Du_spec * GammaB_sigma;
auto adjDu_GH_Ds = g5 * adj(Du_tf) * g5 * Gamma_H * Ds_ti;
//auto Gn_adjDd_GH_Du = GammaB_nucl * g5 * adj(Dd_tf) * g5 * Gamma_H * Du_ti;
auto adjDd_GH_Du = g5 * adj(Dd_tf) * g5 * Gamma_H * Du_ti;
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'
@ -1293,9 +1239,11 @@ void BaryonUtils<FImpl>::SigmaToNucleonQ2NonEyeSite(const mobj &Du_ti,
result()(gamma_n,gamma_s)() -= ee * adjDu_GH_Ds_ab_ab
* Gn_adjDd_GH_Du_ag_bc
* Du_Gs()(gamma_n, beta_s)(c_n,a_s);
}
}
}}
}}
}}
}
}
}
template<class FImpl>