CHROMA
inline_plaq_density.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Inline plaquette density
3  */
4 
8 
11 
12 namespace Chroma
13 {
14 
15  namespace InlinePlaqDenEnv
16  {
17  namespace
18  {
19  AbsInlineMeasurement* createMeasurement(XMLReader& xml_in,
20  const std::string& path)
21  {
22  Params p(xml_in, path);
23  return new InlineMeas(p);
24  }
25 
26  //! Local registration flag
27  bool registered = false;
28 
29  const std::string name = "PLAQ_DENSITY";
30  }
31 
32  //! Register all the factories
33  bool registerAll()
34  {
35  bool success = true;
36  if (! registered)
37  {
39  success &= TheInlineMeasurementFactory::Instance().registerObject(name, createMeasurement);
40  registered = true;
41  }
42  return success;
43  }
44 
45 
46  namespace
47  {
48  //! Compute the site-level action
49  void siteAction(multi1d<LatticeReal>& site_act, const multi1d<LatticeColorMatrix>& u)
50  {
51  START_CODE();
52 
53  // Initialize
54  site_act.resize(Nd*(Nd-1)/2);
55 
56  Real one = 1.0;
57  Real third = Real(1) / Real(Nc);
58 
59  // Compute the average plaquettes
60  int cnt = 0;
61  for(int mu=1; mu < Nd; ++mu)
62  {
63  for(int nu=0; nu < mu; ++nu)
64  {
65  /* tmp_0 = u(x+mu,nu)*u_dag(x+nu,mu) */
66  /* tmp_1 = tmp_0*u_dag(x,nu)=u(x+mu,nu)*u_dag(x+nu,mu)*u_dag(x,nu) */
67  /* wplaq_tmp = tr(u(x,mu)*tmp_1=u(x,mu)*u(x+mu,nu)*u_dag(x+nu,mu)*u_dag(x,nu)) */
68  site_act[cnt++] = one - third*real(trace(u[mu]*shift(u[nu],FORWARD,mu)*adj(shift(u[mu],FORWARD,nu))*adj(u[nu])));
69  }
70  }
71 
72  END_CODE();
73  }
74 
75  }
76 
77 
78  //! Parameter input
79  void read(XMLReader& xml, const std::string& path, Params::Param_t& param)
80  {
81  XMLReader paramtop(xml, path);
82 
83  int version;
84  read(paramtop, "version", version);
85 
86  switch (version)
87  {
88  case 1:
89  break;
90 
91  default:
92  QDPIO::cerr << "Params::Param_t: " << version
93  << " unsupported." << std::endl;
94  QDP_abort(1);
95  }
96  }
97 
98  //! Parameter output
99  void write(XMLWriter& xml, const std::string& path, const Params::Param_t& param)
100  {
101  push(xml, path);
102 
103  int version = 1;
104  write(xml, "version", version);
105 
106  pop(xml);
107  }
108 
109 
110  //! Parameter input
111  void read(XMLReader& xml, const std::string& path, Params::NamedObject_t& input)
112  {
113  XMLReader inputtop(xml, path);
114 
115  read(inputtop, "gauge_id", input.gauge_id);
116  read(inputtop, "out_file", input.out_file);
117  }
118 
119  //! Parameter output
120  void write(XMLWriter& xml, const std::string& path, const Params::NamedObject_t& input)
121  {
122  push(xml, path);
123 
124  write(xml, "gauge_id", input.gauge_id);
125  write(xml, "out_file", input.out_file);
126 
127  pop(xml);
128  }
129 
130 
131  // Params
133  {
134  frequency = 0;
135  }
136 
137  Params::Params(XMLReader& xml_in, const std::string& path)
138  {
139  try
140  {
141  XMLReader paramtop(xml_in, path);
142 
143  if (paramtop.count("Frequency") == 1)
144  read(paramtop, "Frequency", frequency);
145  else
146  frequency = 1;
147 
148  // Params
149  read(paramtop, "Param", param);
150 
151  // Ids
152  read(paramtop, "NamedObject", named_obj);
153  }
154  catch(const std::string& e)
155  {
156  QDPIO::cerr << "Caught Exception reading XML: " << e << std::endl;
157  QDP_abort(1);
158  }
159  }
160 
161  void
162  InlineMeas::operator()(unsigned long update_no,
163  XMLWriter& xml_out)
164  {
165  START_CODE();
166 
167  // Grab the object
168  const multi1d<LatticeColorMatrix>& u =
169  TheNamedObjMap::Instance().getData< multi1d<LatticeColorMatrix> >(params.named_obj.gauge_id);
170 
171  push(xml_out, "PlaqDen");
172  write(xml_out, "update_no", update_no);
173 
174  multi1d<LatticeReal> plaq_site;
175 
176  siteAction(plaq_site, u);
177 
178  QDPIO::cout << name << ": write plaquette density to xml file = " << params.named_obj.out_file << std::endl;
179  XMLFileWriter txt(params.named_obj.out_file);
180 
181  write(txt, "plaq_site", plaq_site);
182 
183  pop(xml_out);
184 
185  END_CODE();
186  }
187 
188  }
189 
190 }
Inline measurement factory.
void operator()(unsigned long update_no, XMLWriter &xml_out)
Do the measurement.
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.
Inline plaquette density.
Nd
Definition: meslate.cc:74
Named object function std::map.
static bool registered
Local registration flag.
const std::string name
Name to be used.
bool registerAll()
Register all the factories.
void write(XMLWriter &xml, const std::string &path, const Params::Param_t &param)
Parameter output.
void read(XMLReader &xml, const std::string &path, Params::Param_t &param)
Parameter input.
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
push(xml_out,"Condensates")
pop(xml_out)
START_CODE()
::std::string string
Definition: gtest.h:1979
#define FORWARD
Definition: primitives.h:82
struct Chroma::InlinePlaqDenEnv::Params::Param_t param
struct Chroma::InlinePlaqDenEnv::Params::NamedObject_t named_obj