CHROMA
plaq_plus_adjoint_gaugeact.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Plaquette gauge action
3  */
4 
5 #include "chromabase.h"
10 #include "io/aniso_io.h"
11 
12 namespace Chroma
13 {
14 
15  namespace PlaqPlusAdjointGaugeActEnv
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 = "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  }
55  catch( const std::string& e ) {
56  QDPIO::cerr << "Error reading XML: " << e << std::endl;
57  QDP_abort(1);
58  }
59  }
60 
61 
62  //! Compute the action
64  {
65  // Action at the site level
66  multi2d<LatticeComplex> plaq_site;
67  this->siteAction(plaq_site, state);
68 
69  // Total action
70  // Fundamental part
71  Double act_F = zero;
72  Double three = Nc;
73  Double nine = Nc*Nc ;
74 
75  for(int mu=1; mu < Nd; ++mu)
76  {
77  for(int nu=0; nu < mu; ++nu)
78  {
79  // Sum over plaquettes
80  act_F += sum(real(plaq_site[mu][nu])-three);
81  }
82  }
83 
84  // Adjoint part
85  Double act_A = zero;
86 
87  for(int mu=1; mu < Nd; ++mu)
88  {
89  for(int nu=0; nu < mu; ++nu)
90  {
91  // Sum over plaquettes
92  // NOTE: do the subtraction per site to mitigate loss of precision in subtracting big numbers
93  act_A += sum(localNorm2(plaq_site[mu][nu]) - nine);
94  }
95  }
96 
97  // Normalize
98  Real act = -(param.beta_F / Real(Nc)) * act_F - (param.beta_A/Real(Nc*Nc)) * act_A;
99 
100  return act;
101  }
102 
103 
104  //! Compute the site-level action
105  void GaugeAct::siteAction(multi2d<LatticeComplex>& site_act, const Handle< GaugeState<P,Q> >& state) const
106  {
107  START_CODE();
108 
109  // Initialize
110  site_act.resize(Nd,Nd);
111  site_act = zero;
112 
113  // Handle< const GaugeState<P,Q> > u_bc(createState(u));
114  // Apply boundaries
115  const multi1d<LatticeColorMatrix>& u = state->getLinks();
116 
117  // Compute the average plaquettes
118  for(int mu=1; mu < Nd; ++mu)
119  {
120  for(int nu=0; nu < mu; ++nu)
121  {
122  /* tmp_0 = u(x+mu,nu)*u_dag(x+nu,mu) */
123  /* tmp_1 = tmp_0*u_dag(x,nu)=u(x+mu,nu)*u_dag(x+nu,mu)*u_dag(x,nu) */
124  /* wplaq_tmp = tr(u(x,mu)*tmp_1=u(x,mu)*u(x+mu,nu)*u_dag(x+nu,mu)*u_dag(x,nu)) */
125  site_act[mu][nu] += trace(u[mu]*shift(u[nu],FORWARD,mu)*adj(shift(u[mu],FORWARD,nu))*adj(u[nu])) ;
126 
127  // Keep a copy
128  site_act[nu][mu] = site_act[mu][nu];
129  }
130  }
131 
132 
133  END_CODE();
134  }
135 
136 
137  //! Compute staple
138  /*! Default version. Derived class should override this if needed. */
139  void GaugeAct::staple(LatticeColorMatrix& result,
140  const Handle< GaugeState<P,Q> >& state,
141  int mu, int cb) const
142  {
143  QDPIO::cerr << __func__ << ": staple not possible\n";
144  QDP_abort(1);
145  }
146 
147 
148  //! Compute dS/dU
149  void GaugeAct::deriv(multi1d<LatticeColorMatrix>& ds_u,
150  const Handle< GaugeState<P,Q> >& state) const
151  {
152  START_CODE();
153 
154  LatticeColorMatrix tmp_1;
155  LatticeColorMatrix tmp_2;
156 
157  const multi1d<LatticeColorMatrix>& u = state->getLinks();
158  multi1d<LatticeColorMatrix> deriv_fun(Nd);
159  multi1d<LatticeColorMatrix> deriv_adj(Nd);
160  ds_u.resize(Nd);
161  for(int mu=0; mu < Nd; mu++)
162  {
163  deriv_fun[mu] = zero ;
164  deriv_adj[mu] = zero ;
165  for(int nu = 0; nu < Nd; nu++)
166  {
167  if (mu == nu) continue;
168 
169  LatticeColorMatrix tmp_1 = shift(u[nu], FORWARD, mu);
170  LatticeColorMatrix tmp_2 = shift(u[mu], FORWARD, nu);
171 
172  LatticeColorMatrix up_plq = u[mu]*tmp_1*adj(tmp_2)*adj(u[nu]);
173  LatticeColorMatrix down_plq = u[mu]*shift(adj(tmp_1)*adj(u[mu])*u[nu],BACKWARD,nu);
174 
175  deriv_fun[mu] += up_plq + down_plq ;
176 
177  deriv_adj[mu] += up_plq*conj(trace(up_plq)) +
178  down_plq*conj(trace(down_plq)) ;
179 
180  }// nu
181  // Fold in the normalization from the action
182  ds_u[mu] = (-param.beta_F/Real(2*Nc) ) * deriv_fun[mu];
183  ds_u[mu] += (-param.beta_A/Real(Nc*Nc)) * deriv_adj[mu];
184  }// mu
185 
186  // Zero the force on any fixed boundaries
187  getGaugeBC().zero(ds_u);
188 
189  END_CODE();
190  }
191 
192 
193  }//PlaqPlusAdjointGaugeActEnv
194 
195 } // Chroma
Anisotropy parameters.
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
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.
void siteAction(multi2d< LatticeComplex > &site_act, const Handle< GaugeState< P, Q > > &state) const
Compute the site-level action.
Double S(const Handle< GaugeState< P, Q > > &state) const
Compute the actions.
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
Plaquette plus adjoint (plaquette squared) gauge action.
#define FORWARD
Definition: primitives.h:82
#define BACKWARD
Definition: primitives.h:83
Double sum
Definition: qtopcor.cc:37