CHROMA
plaq_plus_plaq_power_gaugeact.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Plaquette plus power of a plaquette (plaquette power) gauge action
3  */
4 
5 #include "chromabase.h"
10 #include "io/aniso_io.h"
11 
12 namespace Chroma
13 {
14 
15  namespace PlaqPlusPlaqPowerGaugeActEnv
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 = "PLAQ_PLUS_PLAQ_POWER_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", beta);
53  read(paramtop, "gamma", gamma);
54  read(paramtop, "q", q);
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  namespace
64  {
65  // Very inefficient way to raise a complex number to a power
66  /*!< Note: should use binary powering */
67  LatticeComplex cpow(const LatticeComplex& plq, int q)
68  {
69  if (q < 0)
70  {
71  QDPIO::cerr << __func__ << ": something messed up with q= " << q << std::endl;
72  exit(1);
73  }
74 
75  if (q == 0)
76  {
77  return 1.0;
78  }
79 
80  LatticeComplex out = plq;
81 
82  for(int n = 2; n <= q; ++n)
83  out *= plq;
84 
85  return out;
86  }
87 
88  }
89 
90 
91  //! Compute the action
93  {
94  // Action at the site level
95  multi2d<LatticeComplex> plaq_site;
96  this->siteAction(plaq_site, state);
97 
98  // Total action
99  Double act_F = zero; // Fundamental part
100  Double act_A = zero; // PlaqPower part
101 
102  for(int mu=1; mu < Nd; ++mu)
103  {
104  for(int nu=0; nu < mu; ++nu)
105  {
106  // Sum over plaquettes
107  act_F += sum(real(plaq_site[mu][nu]));
108  act_A += sum(real(cpow(plaq_site[mu][nu], param.q)));
109  }
110  }
111 
112  // Normalize
113  Real act = param.beta * act_F + param.gamma * act_A;
114 
115  return act;
116  }
117 
118 
119  //! Compute the site-level action
120  void GaugeAct::siteAction(multi2d<LatticeComplex>& site_act, const Handle< GaugeState<P,Q> >& state) const
121  {
122  START_CODE();
123 
124  // Initialize
125  site_act.resize(Nd,Nd);
126  site_act = zero;
127 
128  // Handle< const GaugeState<P,Q> > u_bc(createState(u));
129  // Apply boundaries
130  const multi1d<LatticeColorMatrix>& u = state->getLinks();
131 
132  // Compute the average plaquettes
133  Real one = 1.0;
134  Real third = Real(1) / Real(Nc);
135 
136  for(int mu=1; mu < Nd; ++mu)
137  {
138  for(int nu=0; nu < mu; ++nu)
139  {
140  /* tmp_0 = u(x+mu,nu)*u_dag(x+nu,mu) */
141  /* tmp_1 = tmp_0*u_dag(x,nu)=u(x+mu,nu)*u_dag(x+nu,mu)*u_dag(x,nu) */
142  /* wplaq_tmp = tr(u(x,mu)*tmp_1=u(x,mu)*u(x+mu,nu)*u_dag(x+nu,mu)*u_dag(x,nu)) */
143  site_act[mu][nu] += one - third*trace(u[mu]*shift(u[nu],FORWARD,mu)*adj(shift(u[mu],FORWARD,nu))*adj(u[nu]));
144 
145  // Keep a copy
146  site_act[nu][mu] = site_act[mu][nu];
147  }
148  }
149 
150 
151  END_CODE();
152  }
153 
154 
155  //! Compute staple
156  /*! Default version. Derived class should override this if needed. */
157  void GaugeAct::staple(LatticeColorMatrix& result,
158  const Handle< GaugeState<P,Q> >& state,
159  int mu, int cb) const
160  {
161  QDPIO::cerr << __func__ << ": staple not possible\n";
162  QDP_abort(1);
163  }
164 
165 
166  //! Compute dS/dU
167  void GaugeAct::deriv(multi1d<LatticeColorMatrix>& ds_u,
168  const Handle< GaugeState<P,Q> >& state) const
169  {
170  START_CODE();
171 
172  // Derivate at the site level
173  multi1d<LatticeColorMatrix> deriv_fun;
174  this->derivPlaqFun(deriv_fun, state);
175 
176  // Derivate at the site level
177  multi1d<LatticeColorMatrix> deriv_two;
178  this->derivPlaqTwo(deriv_two, state);
179 
180  // Total derivative
181  // Fold in normalization. The (1/2) in the two_plaq is removed in the derivative via the chain rule
182  ds_u.resize(Nd);
183 
184  for(int mu = 0; mu < Nd; mu++)
185  {
186  ds_u[mu] = param.beta * deriv_fun[mu];
187  ds_u[mu] += param.gamma * deriv_two[mu];
188  }
189 
190  END_CODE();
191  }
192 
193 
194  //! Compute dS/dU
195  void GaugeAct::derivPlaqFun(multi1d<LatticeColorMatrix>& ds_u,
196  const Handle< GaugeState<P,Q> >& state) const
197  {
198  START_CODE();
199 
200  LatticeColorMatrix tmp_0;
201  LatticeColorMatrix tmp_1;
202  LatticeColorMatrix tmp_2;
203 
204  const multi1d<LatticeColorMatrix>& u = state->getLinks();
205 
206  ds_u.resize(Nd);
207  ds_u =zero;
208 
209  for(int mu=0; mu < Nd; mu++)
210  {
211  LatticeColorMatrix G;
212  G = zero;
213 
214  for(int nu = 0; nu < Nd; nu++)
215  {
216  if (mu == nu) continue;
217 
218  LatticeColorMatrix tmp_1 = shift(u[nu], FORWARD, mu);
219  LatticeColorMatrix tmp_2 = shift(u[mu], FORWARD, nu);
220 
221  LatticeColorMatrix up_staple = tmp_1*adj(tmp_2)*adj(u[nu]);
222  LatticeColorMatrix down_staple = adj(tmp_1)*adj(u[mu])*u[nu];
223 
224  G -= up_staple + shift(down_staple, BACKWARD, nu);
225  }
226 
227  ds_u[mu] = u[mu]*G;
228  }
229 
230  // It is 1/(4Nc) to account for normalisation relevant to fermions
231  // in the taproj, which is a factor of 2 different from the
232  // one used here.
233  for(int mu=0; mu < Nd; mu++)
234  {
235  ds_u[mu] *= Real(1)/(Real(2*Nc));
236  }
237 
238  // Zero the force on any fixed boundaries
239  getGaugeBC().zero(ds_u);
240 
241  END_CODE();
242  }
243 
244 
245 
246  //! Compute dS/dU
247  void GaugeAct::derivPlaqTwo(multi1d<LatticeColorMatrix>& ds_u,
248  const Handle< GaugeState<P,Q> >& state) const
249  {
250  START_CODE();
251 
252  // Action at the site level
253  multi2d<LatticeComplex> plaq_site;
254  this->siteAction(plaq_site, state);
255 
256  // Derivative part
257  LatticeColorMatrix tmp_0;
258  LatticeColorMatrix tmp_1;
259  LatticeColorMatrix tmp_2;
260 
261  const multi1d<LatticeColorMatrix>& u = state->getLinks();
262 
263  ds_u.resize(Nd);
264  ds_u =zero;
265 
266  for(int mu=0; mu < Nd; mu++)
267  {
268  LatticeColorMatrix G;
269  G = zero;
270 
271  for(int nu = 0; nu < Nd; nu++)
272  {
273  if (mu == nu) continue;
274 
275  const LatticeComplex& plq = cpow(plaq_site[mu][nu], param.q-1);
276 
277  LatticeColorMatrix tmp_1 = shift(u[nu], FORWARD, mu);
278  LatticeColorMatrix tmp_2 = shift(u[mu], FORWARD, nu);
279 
280  LatticeColorMatrix up_staple = tmp_1*adj(tmp_2)*adj(u[nu]);
281  LatticeColorMatrix down_staple = adj(tmp_1)*adj(u[mu])*u[nu];
282 
283  G -= up_staple * plq;
284  G -= shift(down_staple * plq, BACKWARD, nu);
285  }
286 
287  ds_u[mu] = u[mu]*G;
288  }
289 
290  // It is 1/(4Nc) to account for normalisation relevant to fermions
291  // in the taproj, which is a factor of 2 different from the
292  // one used here.
293  // The extra "q" factor is the chain-rule - the deriv of d f(x)^q/dx -> q * f(x)^{q-1} * d f(x)/dx
294  for(int mu=0; mu < Nd; mu++)
295  {
296  ds_u[mu] *= Real(param.q) * Real(1)/(Real(2*Nc));
297  }
298 
299  // Zero the force on any fixed boundaries
300  getGaugeBC().zero(ds_u);
301 
302  END_CODE();
303  }
304 
305  }
306 
307 }
Anisotropy parameters.
Primary include file for CHROMA library code.
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 derivPlaqFun(multi1d< LatticeColorMatrix > &ds_u, const Handle< GaugeState< P, Q > > &state) const
Compute dS/dU.
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.
Double S(const Handle< GaugeState< P, Q > > &state) const
Compute the actions.
void staple(LatticeColorMatrix &result, const Handle< GaugeState< P, Q > > &state, int mu, int cb) const
Compute staple.
void siteAction(multi2d< LatticeComplex > &site_act, const Handle< GaugeState< P, Q > > &state) const
Compute the site-level action.
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.
unsigned n
Definition: ldumul_w.cc:36
LatticeColorMatrix tmp_2
Definition: meslate.cc:51
LatticeColorMatrix tmp_1
Definition: meslate.cc:50
Nd
Definition: meslate.cc:74
Double q
Definition: mesq.cc:17
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
Double one
Definition: invbicg.cc:105
static QDP_ColorVector * out
Constructor.
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
Plaquette plus power of a plaquette (plaquette power) gauge action.
#define FORWARD
Definition: primitives.h:82
#define BACKWARD
Definition: primitives.h:83
Double sum
Definition: qtopcor.cc:37