CHROMA
plaq_plus_adj_power_gaugeact.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Plaquette plus a power of a adjoint gauge action
3  */
4 
5 #include "chromabase.h"
10 #include "io/aniso_io.h"
11 
12 namespace Chroma
13 {
14 
15  namespace PlaqPlusAdjPowerGaugeActEnv
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_ADJ_POWER_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", beta);
53  read(paramtop, "gamma", gamma);
54  read(paramtop, "q", q);
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  //! Compute the action
65  {
66  // Action at the site level
67  multi2d<LatticeComplex> plq;
68  this->siteAction(plq, state);
69 
70  // Total action
71  Double act_F = zero;
72  Double act_A = zero;
73  Real one = Real(1);
74  int q2 = param.q >> 1;
75 
76  for(int mu=1; mu < Nd; ++mu)
77  {
78  for(int nu=0; nu < mu; ++nu)
79  {
80  // Sum over plaquettes
81  act_F += sum(one - real(plq[mu][nu]));
82  act_A += sum(pow(one - localNorm2(plq[mu][nu]), q2));
83  }
84  }
85 
86  // Normalize
87  Double act = param.beta*act_F + param.gamma*act_A;
88 
89  return act;
90  }
91 
92 
93  //! Compute the plaquette
94  void GaugeAct::siteAction(multi2d<LatticeComplex>& plq, const Handle< GaugeState<P,Q> >& state) const
95  {
96  START_CODE();
97 
98  // Initialize
99  plq.resize(Nd,Nd);
100  plq = zero;
101 
102  // Handle< const GaugeState<P,Q> > u_bc(createState(u));
103  // Apply boundaries
104  const multi1d<LatticeColorMatrix>& u = state->getLinks();
105  Real third = Real(1) / Real(Nc);
106 
107  // Compute the average plaquettes
108  for(int mu=1; mu < Nd; ++mu)
109  {
110  for(int nu=0; nu < mu; ++nu)
111  {
112  /* tmp_0 = u(x+mu,nu)*u_dag(x+nu,mu) */
113  /* tmp_1 = tmp_0*u_dag(x,nu)=u(x+mu,nu)*u_dag(x+nu,mu)*u_dag(x,nu) */
114  /* wplaq_tmp = tr(u(x,mu)*tmp_1=u(x,mu)*u(x+mu,nu)*u_dag(x+nu,mu)*u_dag(x,nu)) */
115  plq[mu][nu] += third*trace(u[mu]*shift(u[nu],FORWARD,mu)*adj(shift(u[mu],FORWARD,nu))*adj(u[nu]));
116 
117  // Keep a copy
118  plq[nu][mu] = plq[mu][nu];
119  }
120  }
121 
122 
123  END_CODE();
124  }
125 
126 
127  //! Compute staple
128  /*! Default version. Derived class should override this if needed. */
129  void GaugeAct::staple(LatticeColorMatrix& result,
130  const Handle< GaugeState<P,Q> >& state,
131  int mu, int cb) const
132  {
133  QDPIO::cerr << __func__ << ": staple not possible\n";
134  QDP_abort(1);
135  }
136 
137 
138  //! Compute dS/dU
139  void GaugeAct::deriv(multi1d<LatticeColorMatrix>& ds_u,
140  const Handle< GaugeState<P,Q> >& state) const
141  {
142  START_CODE();
143 
144  // Action at the site level
145  multi2d<LatticeComplex> plq;
146  this->siteAction(plq, state);
147 
148  const multi1d<LatticeColorMatrix>& u = state->getLinks();
149  multi1d<LatticeColorMatrix> deriv_fun(Nd);
150  multi1d<LatticeColorMatrix> deriv_adj(Nd);
151  ds_u.resize(Nd);
152 
153  Real one = Real(1);
154  int q2 = param.q >> 1;
155 
156  for(int mu=0; mu < Nd; mu++)
157  {
158  deriv_fun[mu] = zero;
159  deriv_adj[mu] = zero;
160 
161  for(int nu = 0; nu < Nd; nu++)
162  {
163  if (mu == nu) continue;
164 
165  const LatticeReal& plaq = pow(one - localNorm2(plq[mu][nu]), q2-1);
166 
167  LatticeColorMatrix tmp_1 = shift(u[nu], FORWARD, mu);
168  LatticeColorMatrix tmp_2 = shift(u[mu], FORWARD, nu);
169  LatticeComplex downp = shift(plaq, BACKWARD,nu);
170 
171  LatticeColorMatrix up_plq = u[mu]*tmp_1*adj(tmp_2)*adj(u[nu]);
172  LatticeColorMatrix down_plq = u[mu]*shift(adj(tmp_1)*adj(u[mu])*u[nu],BACKWARD,nu);
173 
174  deriv_fun[mu] += up_plq + down_plq;
175 
176  deriv_adj[mu] += plaq * up_plq*conj(trace(up_plq));
177  deriv_adj[mu] += downp * down_plq*conj(trace(down_plq));
178 
179  }// nu
180 
181  // Fold in the normalization from the action
182  ds_u[mu] = (-param.beta/Real(2*Nc) ) * deriv_fun[mu];
183  ds_u[mu] += (-Real(q2) * param.gamma/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  }//PlaqPlusAdjPowerGaugeActEnv
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 siteAction(multi2d< LatticeComplex > &site_act, const Handle< GaugeState< P, Q > > &state) const
Compute the site-level action.
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.
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
Double plaq
Definition: meslate.cc:58
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
Double one
Definition: invbicg.cc:105
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 a power of an adjoint gauge action.
#define FORWARD
Definition: primitives.h:82
#define BACKWARD
Definition: primitives.h:83
Double sum
Definition: qtopcor.cc:37