CHROMA
sf_plaq_plus_adjoint_gaugeact.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Plaquette plus adjoint (plaquette squared) gauge action
3  */
4 
5 #include "chromabase.h"
10 #include "io/aniso_io.h"
11 
12 namespace Chroma
13 {
14 
15  namespace SFPlaqPlusAdjointGaugeActEnv
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 = "SF_PLAQ_PLUS_ADJOINT_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_F", beta_F);
53  read(paramtop, "beta_A", beta_A);
54  read(paramtop, "decay_dir", decay_dir);
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  //! General CreateGaugeState<P,Q>
64  //! Read coeff from a param struct
66  cgs(cgs_), param(p)
67  {
68  // Buildup weights for the plaquettes. They are 1 everywhere except on the spatial
69  // boundary where they are 1/2
70  plaq_weight.resize(Nd,Nd);
71  plaq_weight = Real(1);
72 
73  LatticeInteger litmp = Layout::latticeCoordinate(param.decay_dir);
74  LatticeBoolean lbtest = false;
75 
76  /* if (coord(j_decay) == 0) then */
77  lbtest |= (litmp == 0);
78  /* endif */
79 
80  /* if (coord(j_decay) == latt_cb_size(j_decay)-1) then */
81  lbtest |= (litmp == (QDP::Layout::lattSize()[param.decay_dir]-1));
82  /* endif */
83 
84  /* if (lbtest) then */
85  LatticeReal weight = where(lbtest, Real(0.5), Real(1));
86  /* endif */
87 
88  for(int mu=1; mu < Nd; ++mu)
89  {
90  for(int nu=0; nu < mu; ++nu)
91  {
92  if (mu == param.decay_dir || nu == param.decay_dir) {continue;}
93 
94  plaq_weight(mu,nu) = weight;
95  plaq_weight(nu,mu) = weight;
96  }
97  }
98  }
99 
100 
101  //! Compute the action
103  {
104  // Action at the site level
105  multi2d<LatticeComplex> plaq_site;
106  this->siteAction(plaq_site, state);
107 
108  // Total action
109  // Fundamental part
110  Double act_F = zero;
111  Double three = Nc;
112  Double nine = Nc*Nc ;
113 
114  for(int mu=1; mu < Nd; ++mu)
115  {
116  for(int nu=0; nu < mu; ++nu)
117  {
118  // Sum over plaquettes
119  act_F += sum(plaq_weight(mu,nu) * (real(plaq_site(mu,nu))-three));
120  }
121  }
122 
123  // Adjoint part
124  Double act_A = zero;
125 
126  for(int mu=1; mu < Nd; ++mu)
127  {
128  for(int nu=0; nu < mu; ++nu)
129  {
130  // Sum over plaquettes
131  // NOTE: do the subtraction per site to mitigate loss of precision in subtracting big numbers
132  act_A += sum(plaq_weight(mu,nu) * (localNorm2(plaq_site(mu,nu)) - nine));
133  }
134  }
135 
136  // Normalize
137  Real act = -(param.beta_F / Real(Nc)) * act_F - (param.beta_A/Real(Nc*Nc)) * act_A;
138 
139  return act;
140  }
141 
142 
143  //! Compute the site-level action
144  void GaugeAct::siteAction(multi2d<LatticeComplex>& site_act, const Handle< GaugeState<P,Q> >& state) const
145  {
146  START_CODE();
147 
148  // Initialize
149  site_act.resize(Nd,Nd);
150  site_act = zero;
151 
152  // Handle< const GaugeState<P,Q> > u_bc(createState(u));
153  // Apply boundaries
154  const multi1d<LatticeColorMatrix>& u = state->getLinks();
155 
156  // Compute the average plaquettes
157  for(int mu=1; mu < Nd; ++mu)
158  {
159  for(int nu=0; nu < mu; ++nu)
160  {
161  /* tmp_0 = u(x+mu,nu)*u_dag(x+nu,mu) */
162  /* tmp_1 = tmp_0*u_dag(x,nu)=u(x+mu,nu)*u_dag(x+nu,mu)*u_dag(x,nu) */
163  /* wplaq_tmp = tr(u(x,mu)*tmp_1=u(x,mu)*u(x+mu,nu)*u_dag(x+nu,mu)*u_dag(x,nu)) */
164  site_act(mu,nu) += trace(u[mu]*shift(u[nu],FORWARD,mu)*adj(shift(u[mu],FORWARD,nu))*adj(u[nu])) ;
165 
166  // Keep a copy
167  site_act(nu,mu) = site_act(mu,nu);
168  }
169  }
170 
171 
172  END_CODE();
173  }
174 
175 
176  //! Compute staple
177  /*! Default version. Derived class should override this if needed. */
178  void GaugeAct::staple(LatticeColorMatrix& result,
179  const Handle< GaugeState<P,Q> >& state,
180  int mu, int cb) const
181  {
182  QDPIO::cerr << __func__ << ": staple not possible\n";
183  QDP_abort(1);
184  }
185 
186 
187  //! Compute dS/dU
188  void GaugeAct::deriv(multi1d<LatticeColorMatrix>& ds_u,
189  const Handle< GaugeState<P,Q> >& state) const
190  {
191  START_CODE();
192 
193  LatticeColorMatrix tmp_1;
194  LatticeColorMatrix tmp_2;
195 
196  const multi1d<LatticeColorMatrix>& u = state->getLinks();
197  multi1d<LatticeColorMatrix> deriv_fun(Nd);
198  multi1d<LatticeColorMatrix> deriv_adj(Nd);
199  ds_u.resize(Nd);
200  for(int mu=0; mu < Nd; mu++)
201  {
202  deriv_fun[mu] = zero ;
203  deriv_adj[mu] = zero ;
204  for(int nu = 0; nu < Nd; nu++)
205  {
206  if (mu == nu) continue;
207 
208  LatticeColorMatrix tmp_1 = shift(u[nu], FORWARD, mu);
209  LatticeColorMatrix tmp_2 = shift(u[mu], FORWARD, nu);
210 
211  LatticeColorMatrix up_plq = u[mu]*tmp_1*adj(tmp_2)*adj(u[nu]);
212  LatticeColorMatrix down_plq = u[mu]*shift(adj(tmp_1)*adj(u[mu])*u[nu],BACKWARD,nu);
213 
214  LatticeReal down_weight = shift(plaq_weight(mu,nu), BACKWARD, nu);
215 
216  deriv_fun[mu] += plaq_weight(mu,nu) * up_plq + down_weight * down_plq;
217 
218  deriv_adj[mu] += plaq_weight(mu,nu) * (up_plq*conj(trace(up_plq))) + down_weight * (down_plq*conj(trace(down_plq)));
219 
220  }// nu
221  // Fold in the normalization from the action
222  ds_u[mu] = (-param.beta_F/Real(2*Nc) ) * deriv_fun[mu];
223  ds_u[mu] += (-param.beta_A/Real(Nc*Nc)) * deriv_adj[mu];
224  }// mu
225 
226  // Zero the force on any fixed boundaries
227  getGaugeBC().zero(ds_u);
228 
229  END_CODE();
230  }
231 
232 
233  }//PlaqPlusAdjointGaugeActEnv
234 
235 } // Chroma
Anisotropy parameters.
Primary include file for CHROMA library code.
Create a gauge connection state.
Definition: create_state.h:47
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 staple(LatticeColorMatrix &result, const Handle< GaugeState< P, Q > > &state, int mu, int cb) const
Compute staple.
Double S(const Handle< GaugeState< P, Q > > &state) const
Compute the actions.
void siteAction(multi2d< LatticeComplex > &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.
GaugeAct(Handle< CreateGaugeState< P, Q > > cgs_, const Params &p)
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.
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.
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.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static multi1d< LatticeColorMatrix > u
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 plus adjoint (plaquette squared) gauge action.