Grid 0.7.0
APEsmearing.h
Go to the documentation of this file.
1/*************************************************************************************
2
3Grid physics library, www.github.com/paboyle/Grid
4
5Source file: ./lib/qcd/modules/plaquette.h
6
7Copyright (C) 2017
8
9Author: Guido Cossu <guido.cossu@ed.ac.uk>
10
11This program is free software; you can redistribute it and/or modify
12it under the terms of the GNU General Public License as published by
13the Free Software Foundation; either version 2 of the License, or
14(at your option) any later version.
15
16This program is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19GNU General Public License for more details.
20
21You should have received a copy of the GNU General Public License along
22with this program; if not, write to the Free Software Foundation, Inc.,
2351 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24
25See the full license in the file "LICENSE" in the top level distribution
26directory
27*************************************************************************************/
28 /* END LEGAL */
32
33#pragma once
34
36
38template <class Gimpl>
39class Smear_APE: public Smear<Gimpl>{
40private:
41 const std::vector<double> rho;
42
43 //This member must be private - we do not want to control from outside
44 std::vector<double> set_rho(const double common_rho) const {
45 std::vector<double> res;
46
47 for(int mn=0; mn<Nd*Nd; ++mn) res.push_back(common_rho);
48 for(int mu=0; mu<Nd; ++mu) res[mu + mu*Nd] = 0.0;
49 return res;
50 }
51
52public:
53 // Defines the gauge field types
55
56
57 // Constructors and destructors
58 Smear_APE(const std::vector<double>& rho_):rho(rho_){} // check vector size
59 Smear_APE(double rho_val):rho(set_rho(rho_val)){}
62
64 void smear(GaugeField& u_smr, const GaugeField& U)const{
65 GridBase *grid = U.Grid();
66 GaugeLinkField Cup(grid), tmp_stpl(grid);
68 u_smr = Zero();
69
70 for(int mu=0; mu<Nd; ++mu){
71 Cup = Zero();
72 for(int nu=0; nu<Nd; ++nu){
73 if (nu != mu) {
74 // get the staple in direction mu, nu
75 WL.Staple(tmp_stpl, U, mu, nu); //nb staple conventions of IroIro and Grid differ by a dagger
76 Cup += tmp_stpl*rho[mu + Nd * nu];
77 }
78 }
79 // save the Cup link-field on the u_smr gauge-field
80 pokeLorentz(u_smr, adj(Cup), mu); // u_smr[mu] = Cup^dag see conventions for Staple
81 }
82 }
83
85 void derivative(GaugeField& SigmaTerm,
86 const GaugeField& iLambda,
87 const GaugeField& U)const{
88
89 // Reference
90 // Morningstar, Peardon, Phys.Rev.D69,054501(2004)
91 // Equation 75
92 // Computing Sigma_mu, derivative of S[fat links] with respect to the thin links
93 // Output SigmaTerm
94
95 GridBase *grid = U.Grid();
96
98 GaugeLinkField staple(grid), u_tmp(grid);
99 GaugeLinkField iLambda_mu(grid), iLambda_nu(grid);
100 GaugeLinkField U_mu(grid), U_nu(grid);
101 GaugeLinkField sh_field(grid), temp_Sigma(grid);
102 Real rho_munu, rho_numu;
103
104 for(int mu = 0; mu < Nd; ++mu){
105 U_mu = peekLorentz( U, mu);
106 iLambda_mu = peekLorentz(iLambda, mu);
107
108 for(int nu = 0; nu < Nd; ++nu){
109 if(nu==mu) continue;
110 U_nu = peekLorentz( U, nu);
111 iLambda_nu = peekLorentz(iLambda, nu);
112
113 rho_munu = rho[mu + Nd * nu];
114 rho_numu = rho[nu + Nd * mu];
115
116 WL.StapleUpper(staple, U, mu, nu);
117
118 temp_Sigma = -rho_numu*staple*iLambda_nu; //ok
119 //-r_numu*U_nu(x+mu)*Udag_mu(x+nu)*Udag_nu(x)*Lambda_nu(x)
120 Gimpl::AddLink(SigmaTerm, temp_Sigma, mu);
121
122 sh_field = Cshift(iLambda_nu, mu, 1);// general also for Gparity?
123
124 temp_Sigma = rho_numu*sh_field*staple; //ok
125 //r_numu*Lambda_nu(mu)*U_nu(x+mu)*Udag_mu(x+nu)*Udag_nu(x)
126 Gimpl::AddLink(SigmaTerm, temp_Sigma, mu);
127
128 sh_field = Cshift(iLambda_mu, nu, 1);
129
130 temp_Sigma = -rho_munu*staple*U_nu*sh_field*adj(U_nu); //ok
131 //-r_munu*U_nu(x+mu)*Udag_mu(x+nu)*Lambda_mu(x+nu)*Udag_nu(x)
132 Gimpl::AddLink(SigmaTerm, temp_Sigma, mu);
133
134 staple = Zero();
135 sh_field = Cshift(U_nu, mu, 1);
136
137 temp_Sigma = -rho_munu*adj(sh_field)*adj(U_mu)*iLambda_mu*U_nu;
138 temp_Sigma += rho_numu*adj(sh_field)*adj(U_mu)*iLambda_nu*U_nu;
139
140 u_tmp = adj(U_nu)*iLambda_nu;
141 sh_field = Cshift(u_tmp, mu, 1);
142 temp_Sigma += -rho_numu*sh_field*adj(U_mu)*U_nu;
143 sh_field = Cshift(temp_Sigma, nu, -1);
144 Gimpl::AddLink(SigmaTerm, sh_field, mu);
145
146 }
147 }
148 }
149};
150
152
auto Cshift(const Expression &expr, int dim, int shift) -> decltype(closure(expr))
Definition Cshift.h:55
#define INHERIT_GIMPL_TYPES(GImpl)
Lattice< vobj > adj(const Lattice< vobj > &lhs)
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
void pokeLorentz(Lattice< vobj > &lhs, const Lattice< decltype(peekIndex< LorentzIndex >(vobj(), 0))> &rhs, int i)
Definition QCD.h:487
static constexpr int Nd
Definition QCD.h:52
auto peekLorentz(const vobj &rhs, int i) -> decltype(PeekIndex< LorentzIndex >(rhs, 0))
Definition QCD.h:446
RealF Real
Definition Simd.h:65
static INTERNAL_PRECISION U
Definition Zolotarev.cc:230
void derivative(GaugeField &SigmaTerm, const GaugeField &iLambda, const GaugeField &U) const
Definition APEsmearing.h:85
const std::vector< double > rho
Definition APEsmearing.h:41
Smear_APE(const std::vector< double > &rho_)
Definition APEsmearing.h:58
Smear_APE(double rho_val)
Definition APEsmearing.h:59
std::vector< double > set_rho(const double common_rho) const
Definition APEsmearing.h:44
void smear(GaugeField &u_smr, const GaugeField &U) const
Definition APEsmearing.h:64
static void StapleUpper(GaugeMat &staple, const GaugeLorentz &Umu, int mu, int nu)
static void Staple(GaugeMat &staple, const GaugeLorentz &Umu, int mu, int nu)
Definition Simd.h:194