CHROMA
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 SpatialTwoPlaqGaugeActEnv
17  {
19  multi1d<LatticeColorMatrix> >* createGaugeAct(XMLReader& xml,
20  const std::string& path)
21  {
23  SpatialTwoPlaqGaugeActParams(xml, path));
24  }
25 
26  const std::string name = "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 
44 
46  {
47  XMLReader paramtop(xml_in, path);
48 
49  try {
50  read(paramtop, "./coeff", coeff);
51 
52  // Read optional anisoParam.
53  if (paramtop.count("AnisoParam") != 0)
54  read(paramtop, "AnisoParam", aniso);
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  void read(XMLReader& xml, const std::string& path, SpatialTwoPlaqGaugeActParams& p)
64  {
66  p=tmp;
67  }
68 
69 
70  // Internal initializer
71  void
73  {
74  START_CODE();
75 
76  // THis term is only spatial. Really I just need to divide in the
77  // aniso factors
78  if ( anisoP() ) {
80  }
81  QDPIO::cout << "aniso.t_dir" << param.aniso.t_dir << std::endl;
82 
83  END_CODE();
84  }
85 
86 
87  //! Compute staple
88  /*!
89  * \param u_mu_staple result ( Write )
90  * \param state gauge field ( Read )
91  * \param mu direction for staple ( Read )
92  * \param cb subset on which to compute ( Read )
93  */
94  void
95  SpatialTwoPlaqGaugeAct::staple(LatticeColorMatrix& u_mu_staple,
96  const Handle< GaugeState<P,Q> >& state,
97  int mu, int cb) const
98  {
99  QDPIO::cerr << "Not implemented " << std::endl;
100  }
101 
102 
103 
104  //! Computes the derivative of the fermionic action respect to the link field
105  /*!
106  * | dS
107  * ds_u -- | ---- ( Write )
108  * | dU
109  *
110  *
111  * This is a funny action. It is P(x) P(x+t)
112  * Where P(x) is the real trace of the plaquette
113  *
114  * The chain rule means the derivative is:
115  *
116  * \dot{ P(x) } P(x+t) + P(x) \dot{ P(x + t) }
117  *
118  * I can resum this, in a different way to collect all the terms
119  * on a link U(x). This resumming involves x + t -> x
120  *
121  * so the derivative then becomes
122  *
123  * \dot{ P(x) } P(x+t) + P(x-t) \dot{ P(x) }
124  *
125  * = [ P(x+t) + P(x-t) ] \dot{ P(x) } = P_sum \dot{P(x)}
126  *
127  * Now \dot{P(x)} contains the usual force contribugtions from the plaquette
128  * and P_sum is an array of lattice reals.
129  *
130  * The only remaining complication is that I generate force contributions
131  * in the routine for U_(x,i), U_(x+j,i), U_(x,j) and U_(x+i,j)
132  *
133  * and this is done by shifting staples from x to x+j and x+i
134  *
135  * during this shifting I have also to ensure the same shifting of P_sum
136  *
137  *
138  * \param ds_u result ( Write )
139  * \param state gauge field ( Read )
140  */
141  void
142  SpatialTwoPlaqGaugeAct::deriv(multi1d<LatticeColorMatrix>& ds_u,
143  const Handle< GaugeState<P,Q> >& state) const
144  {
145  START_CODE();
146 
147  ds_u.resize(Nd);
148 
149 
150  const multi1d<LatticeColorMatrix>& u = state->getLinks();
151 
152 
153  multi1d<LatticeColorMatrix> ds_tmp(Nd);
154  LatticeColorMatrix tmp, tmp2;
155 
156  int t_dir = tDir();
157 
158 
159  ds_tmp = zero;
160 
161  for(int mu = 0; mu < Nd; mu++) {
162  if ( mu == t_dir ) continue;
163 
164  for(int nu=mu+1 ; nu < Nd; nu++) {
165  if( nu == t_dir ) continue;
166 
167  // Plaquette Forces ->
168  // For F_i
169  //
170  // U(x,i) term U(x+j,i) term
171  // (1) (2)
172  // < ----- ^ x ^ |
173  // | | | |
174  // | | + | |
175  // x V | <------V
176 
177  // For F_nu
178  //
179  // U(x, j) term U(x+i, j) term
180  // (3) (4)
181  // -------> <------
182  // | + |
183  // | |
184  // x <----- V V----->
185  LatticeColorMatrix u_mu_plus_nu = shift(u[mu],FORWARD, nu);
186  LatticeColorMatrix u_nu_plus_mu = shift(u[nu],FORWARD, mu);
187  // First lets do
188  // <-----
189  // |
190  // | (we'll use this for (1) and (4))
191  // V
192  tmp = adj(u_mu_plus_nu)*adj(u[nu]);
193 
194  // Now we do
195  //
196  // |
197  // | (we'll use this for (2) and (3)
198  // |
199  // <-------v
200  tmp2 = adj(u_nu_plus_mu)*adj(u[mu]);
201 
202 
203  // Make munu plaquette which is just adj(tmp2)*tmp1
204 
205 
206  // Take the real trace
207  LatticeReal P_munu = real(trace(adj(tmp2)*tmp));
208 
209  LatticeReal P_sum = shift(P_munu, FORWARD, t_dir)+
210  shift(P_munu, BACKWARD, t_dir);
211 
212  // It is tmp and tmp2 that will
213  // need to move when I generate the force contrib
214  // for U(x+i,j) and U(x+j,i) (in terms 2 and 4)
215  // It is at these times I also ned to shift the P_sum
216  // in exactly the same way. Terms (1) and (2)
217  // have tmp and tmp2 unshifted and require the local P_sum
218  //
219  // Since the P_sum is made of lattice reals multiplication
220  // is commutative, so it is safe to multiply them into
221  // the tmp and tmp2 right here.
222 
223  tmp *= P_sum;
224  tmp2 *= P_sum;
225 
226  // Now Term (1)
227  ds_tmp[mu] += u_nu_plus_mu*tmp;
228 
229  // Now term (2)
230  ds_tmp[mu] += shift(tmp2*u[nu], BACKWARD, nu);
231 
232  // Now term (3)
233  ds_tmp[nu] += u_mu_plus_nu*tmp2;
234 
235  // Now term (4)
236  ds_tmp[nu] += shift(tmp*u[mu], BACKWARD, mu);
237 
238  }
239  }
240 
241 
242  // Finally multiply by u[mu] in the spatial dirs
243  // and zero out junk in the time dir
244  for(int mu=0; mu < Nd; mu++) {
245  if (mu == t_dir) {
246  ds_u[mu] = zero; // This component is otherwise untouched
247  // So we should zero junk out of it
248  }
249  else {
250  ds_u[mu] = u[mu]*ds_tmp[mu];
251  ds_u[mu] *= Real(-param.coeff)/Real(4*Nc*Nc);
252  }
253  }
254 
255  // Zero the force on any fixed boundaries
256  getGaugeBC().zero(ds_u);
257 
258  END_CODE();
259  }
260 
261  // Get the gauge action
262  //
263  // S = -(coeff/2) Sum P_{ij}(x) P_{ij}(x+t)
264  //
265  // where P_{ij}(x) is the plaquette on lattice point x and i,j are
266  // only spatial directions.
267  //
268  // P has normalisatiom (1/Nc) and so the overall normalisation
269  // for the product is (1/Nc^2). Giving the final multiplier as
270  //
271  // -coeff/(2 Nc^2 )
272  Double
273  SpatialTwoPlaqGaugeAct::S(const Handle< GaugeState<P,Q> >& state) const
274  {
275  START_CODE();
276 
277  Double S_pg = zero;
278 
279  // Handle< const GaugeState<P,Q> > u_bc(createState(u));
280  // Apply boundaries
281  const multi1d<LatticeColorMatrix>& u = state->getLinks();
282  int t_dir = tDir();
283 
284 
285  // Compute the average plaquettes
286  for(int mu=0; mu < Nd; ++mu)
287  {
288  if( mu == t_dir) continue;
289 
290  for(int nu=mu+1; nu < Nd; ++nu)
291  {
292  if( nu == t_dir) continue;
293  /* tmp_0 = u(x+mu,nu)*u_dag(x+nu,mu) */
294  /* tmp_1 = tmp_0*u_dag(x,nu)=u(x+mu,nu)*u_dag(x+nu,mu)*u_dag(x,nu) */
295  /* wplaq_tmp = tr(u(x,mu)*tmp_1=u(x,mu)*u(x+mu,nu)*u_dag(x+nu,mu)*u_dag(x,nu)) */
296 
297  LatticeReal P_munu = real(trace(u[mu]*shift(u[nu],FORWARD,mu)*adj(shift(u[mu],FORWARD,nu))*adj(u[nu])));
298 
299  S_pg += sum(P_munu*shift(P_munu, FORWARD, t_dir));
300 
301  }
302  }
303 
304  // Normalize -> 1 factor of Nc from each P_munu
305  S_pg *= Double(-param.coeff)/Double(2*Nc*Nc);
306 
307  END_CODE();
308 
309  return S_pg;
310  }
311 
312 }
313 
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
static T & Instance()
Definition: singleton.h:432
Double S(const Handle< GaugeState< P, Q > > &state) const
Compute the actions.
int tDir() const
Anisotropic direction.
void staple(LatticeColorMatrix &result, const Handle< GaugeState< P, Q > > &state, int mu, int cb) const
Compute staple.
void deriv(multi1d< LatticeColorMatrix > &result, const Handle< GaugeState< P, Q > > &state) const
Compute dS/dU.
SpatialTwoPlaqGaugeActParams param
bool anisoP() const
Is anisotropy used?
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.
bool registerAll()
Register all the factories.
static bool registered
Local registration flag.
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
Plaquette gauge action.
Take the traceless antihermitian projection of a color matrix.