CHROMA
pg_gaugeact.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Parallelogram gauge action
3  */
4 
5 #include "chromabase.h"
9 
10 namespace Chroma
11 {
12 
13  namespace PgGaugeActEnv
14  {
15  //! Callback
16  GaugeAction< multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> >* createGaugeAct(XMLReader& xml,
17  const std::string& path)
18  {
19  return new PgGaugeAct(CreateGaugeStateEnv::reader(xml, path),
20  PgGaugeActParams(xml, path));
21  }
22 
23  const std::string name = "PG_GAUGEACT";
24 
25  //! Local registration flag
26  static bool registered = false;
27 
28  //! Register all the factories
29  bool registerAll()
30  {
31  bool success = true;
32  if (! registered)
33  {
34  success &= TheGaugeActFactory::Instance().registerObject(name, createGaugeAct);
35  registered = true;
36  }
37  return success;
38  }
39  }
40 
41 
42  // Param constructor/reader
43  PgGaugeActParams::PgGaugeActParams(XMLReader& xml_in, const std::string& path)
44  {
45  XMLReader paramtop(xml_in, path);
46 
47  try {
48  read(paramtop, "./coeff", coeff);
49  }
50  catch( const std::string& e ) {
51  QDPIO::cerr << "Error reading XML: " << e << std::endl;
52  QDP_abort(1);
53  }
54  }
55 
56  // Read params
57  void read(XMLReader& xml, const std::string& path, PgGaugeActParams& p)
58  {
59  PgGaugeActParams tmp(xml, path);
60  p=tmp;
61  }
62 
63 
64  //! Compute staple
65  /*!
66  * \param u_staple result ( Write )
67  * \param state gauge field ( Read )
68  * \param mu direction for staple ( Read )
69  * \param cb subset on which to compute ( Read )
70  */
71  void
72  PgGaugeAct::staple(LatticeColorMatrix& u_staple,
73  const Handle< GaugeState<P,Q> >& state,
74  int mu, int cb) const
75  {
76  QDPIO::cerr << "PgGaugeAct::staple() - not converted from szin" << std::endl;
77  QDP_abort(1);
78  }
79 
80 
81 
82  //! Computes the derivative of the fermionic action respect to the link field
83  /*!
84  * | dS
85  * ds_u -- | ---- ( Write )
86  * | dU
87  *
88  * \param ds_u result ( Write )
89  * \param state gauge field ( Read )
90  */
91  void
92  PgGaugeAct::deriv(multi1d<LatticeColorMatrix>& ds_u,
93  const Handle< GaugeState<P,Q> >& state) const
94  {
95  START_CODE();
96 
97  ds_u.resize(Nd);
98 
99  LatticeColorMatrix tmp_0;
100  LatticeColorMatrix tmp_1;
101  LatticeColorMatrix tmp_2;
102  LatticeColorMatrix tmp_3;
103  LatticeColorMatrix tmp_4;
104  LatticeColorMatrix tmp_5;
105  LatticeColorMatrix tmp_tot;
106  multi1d<int> fdir(Nd);
107 
108  const multi1d<LatticeColorMatrix>& u = state->getLinks();
109 
110  ds_u = zero;
111 
112 
113  // It is 1/(4Nc) to account for normalisation relevant to fermions
114  // in the taproj, which is a factor of 2 different from the
115  // one used here.
116 
117  Real coeff_tmp = Real(-1)*Real(coeff)/(Real(2*Nc));
118 
119  for(int mu = 0; mu < Nd; ++mu)
120  {
121  tmp_tot = zero;
122 
123  /* generalized parallelogram */
124  for(int nu=mu+1; nu < Nd; nu++)
125  {
126  for(int j=0, k=0; k < Nd; k++)
127  if((k!=mu) && (k!=nu))
128  fdir[j++] = k;
129 
130  tmp_3 = zero;
131 
132  for(int cb=0; cb < 2; cb++)
133  {
134  /* |_ part fitting piece is ~| */
135  tmp_0[rb[1-cb]] = shift(u[mu], FORWARD, nu) * shift(adj(u[nu]), FORWARD, mu);
136  tmp_5[rb[1-cb]] = tmp_0 * coeff_tmp;
137 
138  for(int k=0; k < Nd-2; k++)
139  {
140  int eta = fdir[k];
141  tmp_2[rb[cb]] = shift(u[eta], FORWARD, nu) * shift(tmp_5, FORWARD, eta);
142 
143  if(k==0)
144  {
145  tmp_4[rb[cb]] = tmp_2 * shift(adj(u[eta]), FORWARD, mu);
146  }
147  else
148  {
149  tmp_4[rb[cb]] += tmp_2 * shift(adj(u[eta]), FORWARD, mu);
150  }
151  }
152  tmp_3[rb[cb]] += tmp_4 * adj(u[mu]);
153  tmp_tot[rb[cb]] += adj(tmp_4) * adj(u[nu]);
154 
155  /* _| piece */
156  tmp_0[rb[cb]] = u[nu] * shift(u[mu], FORWARD, nu);
157  tmp_5[rb[cb]] = tmp_0 * coeff_tmp;
158  for(int k=0; k < Nd-2; k++)
159  {
160  int eta = fdir[k];
161  tmp_2[rb[1-cb]] = shift(adj(u[eta])*tmp_5, BACKWARD, mu);
162  tmp_1[rb[1-cb]] = shift(u[eta], FORWARD, nu);
163  if(k==0)
164  {
165  tmp_4[rb[cb]] = shift(tmp_2*tmp_1, BACKWARD, eta);
166  }
167  else
168  {
169  tmp_4[rb[cb]] += shift(tmp_2*tmp_1, BACKWARD, eta);
170  }
171  }
172  tmp_3[rb[cb]] += adj(tmp_4) * shift(u[mu], BACKWARD, mu);
173  tmp_tot[rb[1-cb]] += shift(u[nu]*adj(tmp_4), FORWARD, mu);
174 
175  /* ~| part */
176  tmp_0[rb[1-cb]] = adj(u[nu]) * u[mu];
177  tmp_5[rb[cb]] = shift(tmp_0, BACKWARD, nu) * coeff_tmp;
178  for(int k=0; k < Nd-2; k++)
179  {
180  int eta = fdir[k];
181  tmp_2[rb[1-cb]] = u[eta] * shift(tmp_5, FORWARD, eta);
182  if(k==0)
183  {
184  tmp_4[rb[cb]] = shift(tmp_2, BACKWARD, mu) * adj(shift(u[eta], BACKWARD, nu));
185  }
186  else
187  {
188  tmp_4[rb[cb]] += shift(tmp_2, BACKWARD, mu) * adj(shift(u[eta], BACKWARD, nu));
189  }
190  }
191 
192  tmp_1[rb[cb]] = shift(u[nu], BACKWARD, nu);
193  tmp_tot[rb[1-cb]] += shift(adj(tmp_1)*adj(tmp_4), FORWARD, mu);
194  tmp_1[rb[cb]] = shift(u[mu], BACKWARD, mu);
195  tmp_3[rb[1-cb]] += shift(adj(tmp_1)*tmp_4, FORWARD, nu);
196 
197  /* Finally the |~ part */
198  tmp_0[rb[cb]] = u[mu] * shift(u[nu], FORWARD, mu);
199  tmp_5[rb[cb]] = tmp_0 * coeff_tmp;
200  for(int k=0; k < Nd-2; k++)
201  {
202  int eta = fdir[k];
203  tmp_2[rb[1-cb]] = shift(adj(u[eta])*tmp_5, BACKWARD, nu);
204  tmp_1[rb[1-cb]] = shift(u[eta], FORWARD, mu);
205  if(k==0)
206  {
207  tmp_4[rb[cb]] = shift(tmp_2*tmp_1, BACKWARD, eta);
208  }
209  else
210  {
211  tmp_4[rb[cb]] += shift(tmp_2*tmp_1, BACKWARD, eta);
212  }
213  }
214  tmp_tot[rb[cb]] += adj(tmp_4) * shift(u[nu], BACKWARD, nu);
215  tmp_3[rb[1-cb]] += shift(u[mu]*adj(tmp_4), FORWARD, nu);
216 
217  } /* end loop over cb */
218 
219  /* mult tmp_3 by u(x,nu) matrix) */
220  ds_u[nu] += u[nu] * tmp_3;
221  } /* end loop over nu */
222 
223  /* ds_u = u(x,mu) * tmp_tot */
224  ds_u[mu] += u[mu] * tmp_tot;
225  }
226 
227  // Zero the force on any fixed boundaries
228  getGaugeBC().zero(ds_u);
229 
230  END_CODE();
231  }
232 
233 
234 
235  // Get the gauge action
236  //
237  // S = -(coeff/(Nc) Sum Re Tr Pg
238  //
239  Double
241  {
242  START_CODE();
243 
244  const multi1d<LatticeColorMatrix>& u = state->getLinks();
245 
246  LatticeColorMatrix tmp_0;
247  LatticeColorMatrix tmp_1;
248  LatticeColorMatrix tmp_2;
249  LatticeReal lgimp = zero;
250 
251  // Parallelogram term
252  if (Nd != 4)
253  {
254  QDPIO::cerr << "Parallelogram implemented only for Nd==4" << std::endl;
255  QDP_abort(1);
256  }
257 
258  for(int dir = 0; dir < Nd; ++dir) /* orthogonal direction to the 3-cube */
259  {
260  /*+ */
261  /* There are 3 orientations for */
262  /* (mu,nu,rho,-mu,-nu,-rho) */
263  /*- */
264  for(int mu0 = 0; mu0 < 2; ++mu0) /* 3 orientations in a 3-cube */
265  {
266  int mu = mu0;
267  if (mu >= dir)
268  ++mu;
269 
270  for(int nu0 = 0; nu0 <= 2; ++nu0)
271  {
272  if (nu0 == mu0) continue;
273 
274  int nu = nu0;
275  if (nu >= dir)
276  ++nu;
277 
278  for(int rho0 = mu0+1; rho0 <= 2; ++rho0)
279  {
280  if (rho0 == nu0) continue;
281 
282  int rho = rho0;
283  if (rho >= dir)
284  ++rho;
285 
286  for(int cb = 0; cb < 2; ++cb)
287  {
288  /* 6-link parallelogram. */
289 
290  /* tmp_1(x) = u(x+nu,rho) */
291  tmp_1[rb[1-cb]] = shift(u[rho], FORWARD, nu);
292 
293  /* tmp_2 = u(x,nu) * tmp_1 = u(x,nu)*u(x+nu,rho) */
294  tmp_2[rb[1-cb]] = u[nu] * tmp_1;
295 
296  /* tmp_1(x) = tmp_2(x+mu) */
297  tmp_1[rb[cb]] = shift(tmp_2, FORWARD, mu);
298 
299  /* tmp_2 = u(x,mu) * tmp_1 = u(x,mu)*u(x+mu,nu)*u(x+mu+nu,rho) */
300  tmp_2[rb[cb]] = u[mu] * tmp_1;
301 
302  /* tmp_0 = u_dag(x,rho) * tmp_2 */
303  /* = u_dag(x,rho)*u(x,mu)*u(x+mu,nu)*u(x+mu+nu,rho) */
304  tmp_0[rb[cb]] = adj(u[rho]) * tmp_2;
305 
306  /* tmp_1(x) = u(x+nu,mu) */
307  tmp_1[rb[1-cb]] = shift(u[mu], FORWARD, nu);
308 
309  /* tmp_2 = u(x,nu) * tmp_1 = u(x,nu)*u(x+nu,mu) */
310  tmp_2[rb[1-cb]] = u[nu] * tmp_1;
311 
312  /* tmp_1(x) = tmp_2(x+rho) */
313  tmp_1[rb[cb]] = shift(tmp_2, FORWARD, rho);
314 
315  /* lgimp += trace(tmp_1_dag * tmp_0) */
316  /* += trace(u_dag(x+nu+rho,mu)*u_dag(x+rho,nu)*u_dag(x,rho) */
317  /* *u_(x,mu)*u(x+mu,nu)*u(x+mu+nu,rho)) */
318  lgimp[rb[cb]] += real(trace(adj(tmp_1) * tmp_0));
319  }
320  }
321  }
322  }
323 
324  /*+ */
325  /* 4th orientation in a 3-cube */
326  /* An arbitrary orientation is taken for the ordering */
327  /* (mu,-nu,rho,-mu,nu,-rho) */
328  /*- */
329  int mu = 0;
330  int nu = 1;
331  int rho = 2;
332  if (mu >= dir) mu = mu + 1;
333  if (nu >= dir) nu = nu + 1;
334  if (rho >= dir) rho = rho + 1;
335 
336  for(int cb = 0; cb < 2; ++cb)
337  {
338  /* 6-link parallelogram. */
339 
340  /* tmp_1 = u_dag(x,nu) * u(x,rho) */
341  tmp_1[rb[cb]] = adj(u[nu]) * u[rho];
342 
343  /* tmp_2(x) = tmp_1(x-rho) */
344  tmp_2[rb[1-cb]] = shift(tmp_1, BACKWARD, rho);
345 
346  /* tmp_1(x) = tmp_2(x+mu) */
347  tmp_1[rb[cb]] = shift(tmp_2, FORWARD, mu);
348 
349  /* tmp_2 = tmp_1 * u_dag(x,mu) */
350  /* = u_dag(x+mu-rho,nu)*u(x+mu-rho,rho)*u_dag(x,mu) */
351  tmp_2[rb[cb]] = tmp_1 * adj(u[mu]);
352 
353  /* tmp_1 = tmp_2 * u(x,nu) */
354  /* = u_dag(x+mu-rho,nu)*u(x+mu-rho,rho)*u_dag(x,mu)*u(x,nu) */
355  tmp_1[rb[cb]] = tmp_2 * u[nu];
356 
357  /* tmp_2(x) = tmp_1(x-nu) */
358  tmp_2[rb[1-cb]] = shift(tmp_1, BACKWARD, nu);
359 
360  /* tmp_1(x) = tmp_2(x+rho) */
361  tmp_1[rb[cb]] = shift(tmp_2, FORWARD, rho);
362 
363  /* tmp_0 = u(x,mu) * tmp_1 */
364  /* = u(x,mu)*u_dag(x+mu-nu,nu)*u(x+mu-nu,rho) */
365  /* *u_dag(x-nu+rho,mu)*u(x-nu+rho,nu) */
366  tmp_0[rb[cb]] = u[mu] * tmp_1;
367 
368  /* lgimp += trace(tmp_0 * u_dag(x,rho)) */
369  /* += trace(u(x,mu)*u_dag(x+mu-nu,nu)*u(x+mu-nu,rho) */
370  /* *u_dag(x-nu+rho,mu)*u(x-nu+rho,nu)*u_dag(x,rho)) */
371 // lgimp[rb[cb]] += real(trace(tmp_0 * adj(u[rho])));
372  lgimp[rb[cb]] += real(trace(adj(u[rho]) * tmp_0));
373  }
374  }
375 
376  Double S_pg = sum(lgimp);
377  S_pg *= -coeff / Real(Nc); // note sign
378 
379  END_CODE();
380 
381  return S_pg;
382  }
383 
384 }
385 
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
Parallelogram gauge action.
Definition: pg_gaugeact.h:45
void staple(LatticeColorMatrix &result, const Handle< GaugeState< P, Q > > &state, int mu, int cb) const
Compute staple.
Definition: pg_gaugeact.cc:72
Double S(const Handle< GaugeState< P, Q > > &state) const
Compute the actions.
Definition: pg_gaugeact.cc:240
void deriv(multi1d< LatticeColorMatrix > &result, const Handle< GaugeState< P, Q > > &state) const
Compute dS/dU.
Definition: pg_gaugeact.cc:92
static T & Instance()
Definition: singleton.h:432
int mu
Definition: cool.cc:24
LatticeColorMatrix tmp_tot
Definition: cool.cc:18
int nu
Definition: cool.cc:25
All gauge create-state method.
Fermion action factories.
void read(XMLReader &xml, const std::string &path, AsqtadFermActParams &param)
Read parameters.
unsigned j
Definition: ldumul_w.cc:35
LatticeColorMatrix tmp_2
Definition: meslate.cc:51
LatticeColorMatrix tmp_3
Definition: meslate.cc:52
LatticeColorMatrix tmp_1
Definition: meslate.cc:50
Nd
Definition: meslate.cc:74
Handle< CreateGaugeState< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > > reader(XMLReader &xml_in, const std::string &path)
Helper function for the CreateGaugeState readers.
GaugeAction< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > * createGaugeAct(XMLReader &xml, const std::string &path)
Callback.
Definition: pg_gaugeact.cc:16
bool registerAll()
Register all the factories.
Definition: pg_gaugeact.cc:29
const std::string name
Definition: pg_gaugeact.cc:23
static bool registered
Local registration flag.
Definition: pg_gaugeact.cc:26
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static multi1d< LatticeColorMatrix > u
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
LatticeFermion eta
Definition: mespbg5p_w.cc:37
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
int k
Definition: invbicg.cc:119
FloatingPoint< double > Double
Definition: gtest.h:7351
::std::string string
Definition: gtest.h:1979
Parallelgram gauge action.
#define FORWARD
Definition: primitives.h:82
#define BACKWARD
Definition: primitives.h:83
Double sum
Definition: qtopcor.cc:37