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