CHROMA
sf_plaq_plus_two_plaq_gaugeact.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Plaquette plus two-plaquette (plaquette squared) gauge action
3  */
4 
5 #include "chromabase.h"
10 #include "io/aniso_io.h"
11 
12 namespace Chroma
13 {
14 
15  namespace SFPlaqPlusTwoPlaqGaugeActEnv
16  {
17  namespace
18  {
20  multi1d<LatticeColorMatrix> >* createGaugeAct(XMLReader& xml,
21  const std::string& path)
22  {
23  return new GaugeAct(CreateGaugeStateEnv::reader(xml, path),
24  Params(xml, path));
25  }
26 
27  const std::string name = "SF_PLAQ_PLUS_TWO_PLAQ_GAUGEACT";
28 
29  //! Local registration flag
30  static bool registered = false;
31  }
32 
33  //! Register all the factories
34  bool registerAll()
35  {
36  bool success = true;
37  if (! registered)
38  {
39  success &= TheGaugeActFactory::Instance().registerObject(name, createGaugeAct);
40  registered = true;
41  }
42  return success;
43  }
44 
45 
46  Params::Params(XMLReader& xml_in, const std::string& path)
47  {
48  XMLReader paramtop(xml_in, path);
49 
50  try
51  {
52  read(paramtop, "beta_F", beta_F);
53  read(paramtop, "beta_A", beta_A);
54  read(paramtop, "decay_dir", decay_dir);
55  }
56  catch( const std::string& e ) {
57  QDPIO::cerr << "Error reading XML: " << e << std::endl;
58  QDP_abort(1);
59  }
60  }
61 
62 
63  //! General CreateGaugeState<P,Q>
64  //! Read coeff from a param struct
66  cgs(cgs_), param(p)
67  {
68  // Buildup weights for the plaquettes. They are 1 everywhere except on the spatial
69  // boundary where they are 1/2
70  plaq_weight.resize(Nd,Nd);
71  plaq_weight = Real(1);
72 
73  LatticeInteger litmp = Layout::latticeCoordinate(param.decay_dir);
74  LatticeBoolean lbtest = false;
75 
76  /* if (coord(j_decay) == 0) then */
77  lbtest |= (litmp == 0);
78  /* endif */
79 
80  /* if (coord(j_decay) == latt_cb_size(j_decay)-1) then */
81  lbtest |= (litmp == (QDP::Layout::lattSize()[param.decay_dir]-1));
82  /* endif */
83 
84  /* if (lbtest) then */
85  LatticeReal weight = where(lbtest, Real(0.5), Real(1));
86  /* endif */
87 
88  for(int mu=1; mu < Nd; ++mu)
89  {
90  for(int nu=0; nu < mu; ++nu)
91  {
92  if (mu == param.decay_dir || nu == param.decay_dir) {continue;}
93 
94  plaq_weight(mu,nu) = weight;
95  plaq_weight(nu,mu) = weight;
96  }
97  }
98  }
99 
100  //! Compute the action
102  {
103  // Action at the site level
104  multi2d<LatticeReal> plaq_site;
105  this->siteAction(plaq_site, state);
106 
107  // Total action
108  // Fundamental part
109  Double act_F = zero;
110 
111  for(int mu=1; mu < Nd; ++mu)
112  {
113  for(int nu=0; nu < mu; ++nu)
114  {
115  // Sum over plaquettes
116  act_F += sum(plaq_weight(mu,nu) * plaq_site[mu][nu]);
117  }
118  }
119 
120  // TwoPlaq part
121  Double act_A = zero;
122 
123  for(int mu=1; mu < Nd; ++mu)
124  {
125  for(int nu=0; nu < mu; ++nu)
126  {
127  // Sum over plaquettes
128  act_A += sum(plaq_weight(mu,nu) * plaq_site[mu][nu] * plaq_site[mu][nu]);
129  }
130  }
131 
132  // Normalize
133  Real act = -param.beta_F * act_F - Real(0.5)*param.beta_A * act_A;
134 
135  return act;
136  }
137 
138 
139  //! Compute the site-level action
140  void GaugeAct::siteAction(multi2d<LatticeReal>& site_act, const Handle< GaugeState<P,Q> >& state) const
141  {
142  START_CODE();
143 
144  // Initialize
145  site_act.resize(Nd,Nd);
146  site_act = zero;
147 
148  // Handle< const GaugeState<P,Q> > u_bc(createState(u));
149  // Apply boundaries
150  const multi1d<LatticeColorMatrix>& u = state->getLinks();
151 
152  // Compute the average plaquettes
153  for(int mu=1; mu < Nd; ++mu)
154  {
155  for(int nu=0; nu < mu; ++nu)
156  {
157  /* tmp_0 = u(x+mu,nu)*u_dag(x+nu,mu) */
158  /* tmp_1 = tmp_0*u_dag(x,nu)=u(x+mu,nu)*u_dag(x+nu,mu)*u_dag(x,nu) */
159  /* wplaq_tmp = tr(u(x,mu)*tmp_1=u(x,mu)*u(x+mu,nu)*u_dag(x+nu,mu)*u_dag(x,nu)) */
160  site_act[mu][nu] += real(trace(u[mu]*shift(u[nu],FORWARD,mu)*adj(shift(u[mu],FORWARD,nu))*adj(u[nu])));
161 
162  // Account for normalization
163  site_act[mu][nu] *= Real(1) / Real(Nc);
164 
165  // Keep a copy
166  site_act[nu][mu] = site_act[mu][nu];
167  }
168  }
169 
170 
171  END_CODE();
172  }
173 
174 
175  //! Compute staple
176  /*! Default version. Derived class should override this if needed. */
177  void GaugeAct::staple(LatticeColorMatrix& result,
178  const Handle< GaugeState<P,Q> >& state,
179  int mu, int cb) const
180  {
181  QDPIO::cerr << __func__ << ": staple not possible\n";
182  QDP_abort(1);
183  }
184 
185 
186  //! Compute dS/dU
187  void GaugeAct::deriv(multi1d<LatticeColorMatrix>& ds_u,
188  const Handle< GaugeState<P,Q> >& state) const
189  {
190  START_CODE();
191 
192  // Derivate at the site level
193  multi1d<LatticeColorMatrix> deriv_fun;
194  this->derivPlaqFun(deriv_fun, state);
195 
196  // Derivate at the site level
197  multi1d<LatticeColorMatrix> deriv_two;
198  this->derivPlaqTwo(deriv_two, state);
199 
200  // Total derivative
201  // Fold in normalization. The (1/2) in the two_plaq is removed in the derivative via the chain rule
202  ds_u.resize(Nd);
203 
204  for(int mu = 0; mu < Nd; mu++)
205  {
206  ds_u[mu] = (-param.beta_F) * deriv_fun[mu];
207  ds_u[mu] += (-param.beta_A) * deriv_two[mu];
208  }
209 
210  END_CODE();
211  }
212 
213 
214  //! Compute dS/dU
215  void GaugeAct::derivPlaqFun(multi1d<LatticeColorMatrix>& ds_u,
216  const Handle< GaugeState<P,Q> >& state) const
217  {
218  START_CODE();
219 
220  LatticeColorMatrix tmp_0;
221  LatticeColorMatrix tmp_1;
222  LatticeColorMatrix tmp_2;
223 
224  const multi1d<LatticeColorMatrix>& u = state->getLinks();
225 
226  ds_u.resize(Nd);
227  ds_u =zero;
228 
229  for(int mu=0; mu < Nd; mu++)
230  {
231  LatticeColorMatrix G;
232  G = zero;
233 
234  for(int nu = 0; nu < Nd; nu++)
235  {
236  if (mu == nu) continue;
237 
238  LatticeColorMatrix tmp_1 = shift(u[nu], FORWARD, mu);
239  LatticeColorMatrix tmp_2 = shift(u[mu], FORWARD, nu);
240 
241  LatticeColorMatrix up_staple = tmp_1*adj(tmp_2)*adj(u[nu]);
242  LatticeColorMatrix down_staple = adj(tmp_1)*adj(u[mu])*u[nu];
243 
244  G += plaq_weight(mu,nu) * up_staple + shift(plaq_weight(mu,nu) * down_staple, BACKWARD, nu);
245  }
246 
247  ds_u[mu] = u[mu]*G;
248  }
249 
250  // It is 1/(4Nc) to account for normalisation relevant to fermions
251  // in the taproj, which is a factor of 2 different from the
252  // one used here.
253  for(int mu=0; mu < Nd; mu++)
254  {
255  ds_u[mu] *= Real(1)/(Real(2*Nc));
256  }
257 
258  // Zero the force on any fixed boundaries
259  getGaugeBC().zero(ds_u);
260 
261  END_CODE();
262  }
263 
264 
265 
266  //! Compute dS/dU
267  void GaugeAct::derivPlaqTwo(multi1d<LatticeColorMatrix>& ds_u,
268  const Handle< GaugeState<P,Q> >& state) const
269  {
270  START_CODE();
271 
272  // Action at the site level
273  multi2d<LatticeReal> plaq_site;
274  this->siteAction(plaq_site, state);
275 
276  // Derivative part
277  LatticeColorMatrix tmp_0;
278  LatticeColorMatrix tmp_1;
279  LatticeColorMatrix tmp_2;
280 
281  const multi1d<LatticeColorMatrix>& u = state->getLinks();
282 
283  ds_u.resize(Nd);
284  ds_u =zero;
285 
286  for(int mu=0; mu < Nd; mu++)
287  {
288  LatticeColorMatrix G;
289  G = zero;
290 
291  for(int nu = 0; nu < Nd; nu++)
292  {
293  if (mu == nu) continue;
294 
295  LatticeColorMatrix tmp_1 = shift(u[nu], FORWARD, mu);
296  LatticeColorMatrix tmp_2 = shift(u[mu], FORWARD, nu);
297 
298  LatticeColorMatrix up_staple = tmp_1*adj(tmp_2)*adj(u[nu]);
299  LatticeColorMatrix down_staple = adj(tmp_1)*adj(u[mu])*u[nu];
300 
301  LatticeReal down_weight = shift(plaq_weight(mu,nu), BACKWARD, nu);
302 
303  G += plaq_weight(mu,nu) * up_staple * plaq_site[mu][nu];
304  G += shift(down_staple * (plaq_weight(mu,nu) * plaq_site[mu][nu]), BACKWARD, nu);
305  }
306 
307  ds_u[mu] = u[mu]*G;
308  }
309 
310  // It is 1/(4Nc) to account for normalisation relevant to fermions
311  // in the taproj, which is a factor of 2 different from the
312  // one used here.
313  for(int mu=0; mu < Nd; mu++)
314  {
315  ds_u[mu] *= Real(1)/(Real(2*Nc));
316  }
317 
318  // Zero the force on any fixed boundaries
319  getGaugeBC().zero(ds_u);
320 
321  END_CODE();
322  }
323 
324  }
325 
326 }
Anisotropy parameters.
Primary include file for CHROMA library code.
Create a gauge connection state.
Definition: create_state.h:47
Abstract base class for gauge actions.
Definition: gaugeact.h:25
virtual const GaugeBC< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > & getGaugeBC() const
Return the gauge BC object for this action.
Definition: gaugeact.h:46
virtual void zero(P &ds_u) const =0
Zero some gauge-like field in place on the masked links.
Support class for fermion actions and linear operators.
Definition: state.h:74
Class for counted reference semantics.
Definition: handle.h:33
void deriv(multi1d< LatticeColorMatrix > &result, const Handle< GaugeState< P, Q > > &state) const
Compute dS/dU.
void derivPlaqTwo(multi1d< LatticeColorMatrix > &ds_u, const Handle< GaugeState< P, Q > > &state) const
Compute dS/dU.
void staple(LatticeColorMatrix &result, const Handle< GaugeState< P, Q > > &state, int mu, int cb) const
Compute staple.
void derivPlaqFun(multi1d< LatticeColorMatrix > &ds_u, const Handle< GaugeState< P, Q > > &state) const
Compute dS/dU.
GaugeAct(Handle< CreateGaugeState< P, Q > > cgs_, const Params &p)
void siteAction(multi2d< LatticeReal > &site_act, const Handle< GaugeState< P, Q > > &state) const
Compute the site-level action.
Double S(const Handle< GaugeState< P, Q > > &state) const
Compute the actions.
static T & Instance()
Definition: singleton.h:432
int GaugeAct
int mu
Definition: cool.cc:24
int nu
Definition: cool.cc:25
All gauge create-state method.
Gauge create state factory.
Fermion action factories.
void read(XMLReader &xml, const std::string &path, AsqtadFermActParams &param)
Read parameters.
LatticeColorMatrix tmp_2
Definition: meslate.cc:51
LatticeColorMatrix tmp_1
Definition: meslate.cc:50
Nd
Definition: meslate.cc:74
GaugeAction< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > * createGaugeAct(XMLReader &xml, const std::string &path)
static bool registered
Local registration flag.
const std::string name
Name to be used.
Handle< CreateGaugeState< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > > reader(XMLReader &xml_in, const std::string &path)
Helper function for the CreateGaugeState readers.
bool registerAll()
Register all the factories.
multi1d< LatticeColorMatrix > G
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static multi1d< LatticeColorMatrix > u
START_CODE()
int cb
Definition: invbicg.cc:120
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
Definition: pbg5p_w.cc:28
Double zero
Definition: invbicg.cc:106
FloatingPoint< double > Double
Definition: gtest.h:7351
::std::string string
Definition: gtest.h:1979
#define FORWARD
Definition: primitives.h:82
#define BACKWARD
Definition: primitives.h:83
Double sum
Definition: qtopcor.cc:37
Plaquette plus two-plaquette (plaquette squared) gauge action.