CHROMA
plaq_plus_spatial_two_plaq_gaugeact.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Plaquette gauge action
3  */
4 
5 #include "chromabase.h"
10 #include "meas/glue/mesplq.h"
11 #include "util/gauge/taproj.h"
12 
13 namespace Chroma
14 {
15 
16  namespace PlaqPlusSpatialTwoPlaqGaugeActEnv
17  {
19  multi1d<LatticeColorMatrix> >* createGaugeAct(XMLReader& xml,
20  const std::string& path)
21  {
24  }
25 
26  const std::string name = "PLAQ_PLUS_SPATIAL_TWO_PLAQ_GAUGEACT";
27 
28  //! Local registration flag
29  static bool registered = false;
30 
31  //! Register all the factories
32  bool registerAll()
33  {
34  bool success = true;
35  if (! registered)
36  {
37  success &= TheGaugeActFactory::Instance().registerObject(name, createGaugeAct);
38  registered = true;
39  }
40  return success;
41  }
42 
43  static double time_spent = 0;
44  double getTime() { return time_spent; }
45  }
46 
47 
49  {
50  XMLReader paramtop(xml_in, path);
51 
52  try {
53  // Read optional anisoParam.
54  if (paramtop.count("AnisoParam") != 0)
55  read(paramtop, "AnisoParam", aniso);
56 
57  read(paramtop, "./coeff_plaq_s", coeff_plaq_s);
58  read(paramtop, "./coeff_plaq_t", coeff_plaq_t);
59  read(paramtop, "./coeff_two_plaq", coeff_two_plaq);
60 
61 
62  }
63  catch( const std::string& e ) {
64  QDPIO::cerr << "Error reading XML: " << e << std::endl;
65  QDP_abort(1);
66  }
67  }
68 
69 
70  void read(XMLReader& xml, const std::string& path, PlaqPlusSpatialTwoPlaqGaugeActParams& p)
71  {
73  p=tmp;
74  }
75 
76 
77  // Internal initializer
78  void
80  {
81  START_CODE();
82 
83  if ( anisoP() ) {
84  // SPatial guys divided by xi_0
87 
88  // Temporal guy mutiliplied by xi_0
90 
91  }
92  QDPIO::cout << "aniso.t_dir" << param.aniso.t_dir << std::endl;
93 
94  END_CODE();
95  }
96 
97 
98  //! Compute staple
99  /*!
100  * \param u_mu_staple result ( Write )
101  * \param state gauge field ( Read )
102  * \param mu direction for staple ( Read )
103  * \param cb subset on which to compute ( Read )
104  */
105  void
106  PlaqPlusSpatialTwoPlaqGaugeAct::staple(LatticeColorMatrix& u_mu_staple,
107  const Handle< GaugeState<P,Q> >& state,
108  int mu, int cb) const
109  {
110  QDPIO::cerr << "Not implemented " << std::endl;
111  }
112 
113 
114 
115  //! Computes the derivative of the fermionic action respect to the link field
116  /*!
117  * | dS
118  * ds_u -- | ---- ( Write )
119  * | dU
120  *
121  *
122  * This is a funny action. It is P(x) P(x+t)
123  * Where P(x) is the real trace of the plaquette
124  *
125  * The chain rule means the derivative is:
126  *
127  * \dot{ P(x) } P(x+t) + P(x) \dot{ P(x + t) }
128  *
129  * I can resum this, in a different way to collect all the terms
130  * on a link U(x). This resumming involves x + t -> x
131  *
132  * so the derivative then becomes
133  *
134  * \dot{ P(x) } P(x+t) + P(x-t) \dot{ P(x) }
135  *
136  * = [ P(x+t) + P(x-t) ] \dot{ P(x) } = P_sum \dot{P(x)}
137  *
138  * Now \dot{P(x)} contains the usual force contribugtions from the plaquette
139  * and P_sum is an array of lattice reals.
140  *
141  * The only remaining complication is that I generate force contributions
142  * in the routine for U_(x,i), U_(x+j,i), U_(x,j) and U_(x+i,j)
143  *
144  * and this is done by shifting staples from x to x+j and x+i
145  *
146  * during this shifting I have also to ensure the same shifting of P_sum
147  *
148  *
149  * \param ds_u result ( Write )
150  * \param state gauge field ( Read )
151  */
152  void
153  PlaqPlusSpatialTwoPlaqGaugeAct::deriv(multi1d<LatticeColorMatrix>& ds_u,
154  const Handle< GaugeState<P,Q> >& state) const
155  {
156  START_CODE();
157 
158  QDP::StopWatch swatch;
159  swatch.reset();
160  swatch.start();
161 
162  ds_u.resize(Nd);
163 
164  const multi1d<LatticeColorMatrix>& u = state->getLinks();
165 
166  multi1d<LatticeColorMatrix> ds_tmp(Nd);
167  LatticeColorMatrix tmp, tmp2;
168 
169  int t_dir = tDir();
170 
171 
172  ds_tmp = zero;
173 
174  // Do the spatial plaquettes and 2 plaquettes first
175  {
176  Real factor = param.coeff_two_plaq / Real(2*Nc);
177  LatticeReal l_plaq_coeff_s = Real(param.coeff_plaq_s);
178 
179  for(int mu = 0; mu < Nd; mu++) {
180  if ( mu == t_dir ) continue;
181 
182  for(int nu=mu+1 ; nu < Nd; nu++) {
183  if( nu == t_dir ) continue;
184 
185  // Plaquette Forces ->
186  // For F_i
187  //
188  // U(x,i) term U(x+j,i) term
189  // (1) (2)
190  // < ----- ^ x ^ |
191  // | | | |
192  // | | + | |
193  // x V | <------V
194 
195  // For F_nu
196  //
197  // U(x, j) term U(x+i, j) term
198  // (3) (4)
199  // -------> <------
200  // | + |
201  // | |
202  // x <----- V V----->
203 
204  // First lets do
205  // <-----
206  // |
207  // | (we'll use this for (1) and (4))
208  // V
209  //
210  //
211  LatticeColorMatrix u_mu_plus_nu = shift(u[mu], FORWARD, nu);
212  LatticeColorMatrix u_nu_plus_mu = shift(u[nu], FORWARD, mu);
213 
214  tmp = adj(u_mu_plus_nu)*adj(u[nu]);
215 
216  // Now we do
217  //
218  // |
219  // | (we'll use this for (2) and (3)
220  // |
221  // <-------v
222  tmp2 = adj(u_nu_plus_mu)*adj(u[mu]);
223 
224 
225  // Make munu plaquette which is just adj(tmp2)*tmp1
226 
227 
228  // Take the real trace
229  LatticeReal P_munu = real(trace(adj(tmp2)*tmp));
230 
231  // NOw I have c_plaq_s + (c_plaq_t/2Nc)(P_munu(x-t)+P_munu(x+t));
232 
233  LatticeReal P_sum = l_plaq_coeff_s +
234  factor*(shift(P_munu, FORWARD, t_dir)+
235  shift(P_munu, BACKWARD, t_dir));
236 
237  // It is tmp and tmp2 that will
238  // need to move when I generate the force contrib
239  // for U(x+i,j) and U(x+j,i) (in terms 2 and 4)
240  // It is at these times I also ned to shift the P_sum
241  // in exactly the same way. Terms (1) and (2)
242  // have tmp and tmp2 unshifted and require the local P_sum
243  //
244  // Since the P_sum is made of lattice reals multiplication
245  // is commutative, so it is safe to multiply them into
246  // the tmp and tmp2 right here.
247 
248  tmp *= P_sum;
249  tmp2 *= P_sum;
250 
251  // Now Term (1)
252  ds_tmp[mu] += u_nu_plus_mu*tmp;
253 
254  // Now term (2)
255  ds_tmp[mu] += shift(tmp2*u[nu], BACKWARD, nu);
256 
257  // Now term (3)
258  ds_tmp[nu] += u_mu_plus_nu*tmp2;
259 
260  // Now term (4)
261  ds_tmp[nu] += shift(tmp*u[mu], BACKWARD, mu);
262 
263  }
264  }
265  } // l_plaq_coeff_s goes away here.
266 
267 
268  // Now just do the temporal forces
269  for(int nu=0; nu < Nd; nu++) {
270  if( nu == t_dir ) continue;
271 
272  // Plaquette Forces ->
273  // For F_i
274  //
275  // U(x,i) term U(x+j,i) term
276  // (1) (2)
277  // < ----- ^ x ^ |
278  // | | | |
279  // | | + | |
280  // x V | <------V
281 
282  // For F_nu
283  //
284  // U(x, j) term U(x+i, j) term
285  // (3) (4)
286  // -------> <------
287  // | + |
288  // | |
289  // x <----- V V----->
290  LatticeColorMatrix u_t_plus_nu = shift(u[t_dir], FORWARD, nu);
291  LatticeColorMatrix u_nu_plus_t = shift(u[nu], FORWARD, t_dir);
292 
293  // First lets do
294  // <-----
295  // |
296  // | (we'll use this for (1) and (4))
297  // V
298  tmp = adj(u_t_plus_nu)*adj(u[nu]);
299 
300  // Now we do
301  //
302  // |
303  // | (we'll use this for (2) and (3)
304  // |
305  // <-------v
306 
307  tmp2 = adj(u_nu_plus_t)*adj(u[t_dir]);
308 
309 
310  // Now Term (1)
311  // I can write this directly to ds_tmp[t_dir]
312  // which has not been used before
313  ds_tmp[t_dir] += u_nu_plus_t*tmp;
314 
315  // Now term (2)
316  ds_tmp[t_dir] += shift(tmp2*u[nu], BACKWARD, nu);
317 
318  // Terms 3 and 4: I use ds_u[nu] as a dummy
319  // to collect both terms. Then I multiply with the temporal
320  // coefficient and add to ds_tmp[nu]
321 
322  // Now term (3)
323  ds_u[nu] = u_t_plus_nu*tmp2;
324 
325  // Now term (4)
326  ds_u[nu] += shift(tmp*u[t_dir], BACKWARD, t_dir);
327 
328  // Multiply in the coeff for the nu guys
329  ds_tmp[nu] += param.coeff_plaq_t*ds_u[nu];
330  }
331 
332  // Now multiply in the ds_tmp[t_dir] all at once
333  ds_tmp[t_dir] *= param.coeff_plaq_t;
334 
335  // Finally multiply by u[mu] in the spatial dirs
336  for(int mu=0; mu < Nd; mu++) {
337  ds_u[mu] = u[mu]*ds_tmp[mu];
338  ds_u[mu] *= Real(-1)/Real(2*Nc);
339  }
340 
341 
342  // Zero the force on any fixed boundaries
343  getGaugeBC().zero(ds_u);
344 
345  swatch.stop();
346  PlaqPlusSpatialTwoPlaqGaugeActEnv::time_spent += swatch.getTimeInSeconds();
347 
348  END_CODE();
349  }
350 
351  // Get the gauge action
352  //
353  // S = -coeff_plaq_s Sum P_{ij}-(coeff_two_plaq/2) Sum P_{ij}(x) P_{ij}(x+t)
354  // -coeff_plaq_t Sum P_{t}
355  //
356  // where P_{ij}(x) is the plaquette on lattice point x and i,j are
357  // only spatial directions.
358  //
359  // P has normalisatiom (1/Nc) and so the overall normalisation
360  // for the product is (1/Nc^2). Giving the final multiplier as
361  //
362  // -coeff/(2 Nc^2 )
363  Double
364  PlaqPlusSpatialTwoPlaqGaugeAct::S(const Handle< GaugeState<P,Q> >& state) const
365  {
366  START_CODE();
367 
368  Double S_pg = zero;
369 
370 
371  Real factor = param.coeff_two_plaq /(Real(2)*Real(Nc));
372 
373  // Handle< const GaugeState<P,Q> > u_bc(createState(u));
374  // Apply boundaries
375  const multi1d<LatticeColorMatrix>& u = state->getLinks();
376  int t_dir = tDir();
377 
378 
379  // Compute the spatial terms
380  for(int mu=0; mu < Nd; ++mu)
381  {
382  if( mu == t_dir) continue;
383 
384  for(int nu=mu+1; nu < Nd; ++nu)
385  {
386  if( nu == t_dir) continue;
387  /* tmp_0 = u(x+mu,nu)*u_dag(x+nu,mu) */
388  /* tmp_1 = tmp_0*u_dag(x,nu)=u(x+mu,nu)*u_dag(x+nu,mu)*u_dag(x,nu) */
389  /* wplaq_tmp = tr(u(x,mu)*tmp_1=u(x,mu)*u(x+mu,nu)*u_dag(x+nu,mu)*u_dag(x,nu)) */
390 
391  LatticeReal P_munu = real(trace(u[mu]*shift(u[nu],FORWARD,mu)*adj(shift(u[mu],FORWARD,nu))*adj(u[nu])));
392  LatticeReal other_term=param.coeff_plaq_s+factor*shift(P_munu, FORWARD, t_dir);
393 
394  S_pg += sum( other_term*P_munu );
395 
396  }
397  }
398 
399 
400  Double S_pg_t = zero;
401 
402  for(int nu = 0; nu < Nd; nu++) {
403  if ( nu == t_dir ) continue;
404 
405  S_pg_t += sum ( real(trace(u[t_dir]*shift(u[nu],FORWARD,t_dir)*adj(shift(u[t_dir],FORWARD,nu))*adj(u[nu]))) );
406 
407  }
408 
409  // Normalize -> 1 factor of Nc from each P_munu
410  S_pg *= Double(-1)/Double(Nc);
411  S_pg += Double(-param.coeff_plaq_t)/Double(Nc)*S_pg_t;
412 
413  END_CODE();
414 
415  return S_pg;
416  }
417 
418 }
419 
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
Double S(const Handle< GaugeState< P, Q > > &state) const
Compute the actions.
void deriv(multi1d< LatticeColorMatrix > &result, 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.
static T & Instance()
Definition: singleton.h:432
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.
Nd
Definition: meslate.cc:74
Double tmp2
Definition: mesq.cc:30
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)
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static multi1d< LatticeColorMatrix > u
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
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
Take the traceless antihermitian projection of a color matrix.