CHROMA
inline_wilslp.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Inline Wilson loops
3  */
4 
7 #include "meas/glue/mesplq.h"
8 #include "meas/glue/wilslp.h"
11 
14 
15 namespace Chroma
16 {
17  namespace InlineWilsonLoopEnv
18  {
19  namespace
20  {
21  AbsInlineMeasurement* createMeasurement(XMLReader& xml_in,
22  const std::string& path)
23  {
24  return new InlineWilsonLoop(InlineWilsonLoopParams(xml_in, path));
25  }
26 
27  //! Local registration flag
28  bool registered = false;
29  }
30 
31  const std::string name = "WILSLP";
32 
33  //! Register all the factories
34  bool registerAll()
35  {
36  bool success = true;
37  if (! registered)
38  {
40  success &= TheInlineMeasurementFactory::Instance().registerObject(name, createMeasurement);
41  registered = true;
42  }
43  return success;
44  }
45  }
46 
47 
48 
49  //! WilsonLoop input
50  void read(XMLReader& xml, const std::string& path, InlineWilsonLoopParams::Param_t& param)
51  {
52  XMLReader paramtop(xml, path);
53 
54  int version;
55  read(paramtop, "version", version);
56 
58 
59  switch (version)
60  {
61  case 3:
62  if (paramtop.count("GaugeState") != 0)
63  param.cgs = readXMLGroup(paramtop, "GaugeState", "Name");
64  break;
65 
66  default:
67  QDPIO::cerr << "InlineWilsonLoopParams::Param_t: " << version
68  << " unsupported." << std::endl;
69  QDP_abort(1);
70  }
71 
72  read(paramtop, "kind", param.kind);
73  read(paramtop, "j_decay", param.j_decay);
74  read(paramtop, "t_dir", param.t_dir);
75  }
76 
77  //! WilsonLoop output
78  void write(XMLWriter& xml, const std::string& path, const InlineWilsonLoopParams::Param_t& param)
79  {
80  push(xml, path);
81 
82  int version = 3;
83  write(xml, "version", version);
84  write(xml, "kind", param.kind);
85  write(xml, "j_decay", param.j_decay);
86  write(xml, "t_dir", param.t_dir);
87  xml << param.cgs.xml;
88 
89  pop(xml);
90  }
91 
92 
93  //! WilsonLoop input
94  void read(XMLReader& xml, const std::string& path, InlineWilsonLoopParams::NamedObject_t& param)
95  {
96  XMLReader paramtop(xml, path);
97 
98  read(paramtop, "gauge_id", param.gauge_id);
99  }
100 
101  //! WilsonLoop output
102  void write(XMLWriter& xml, const std::string& path, const InlineWilsonLoopParams::NamedObject_t& param)
103  {
104  push(xml, path);
105 
106  write(xml, "gauge_id", param.gauge_id);
107 
108  pop(xml);
109  }
110 
111 
112  // Param stuff
114  {
115  frequency = 0;
116  }
117 
119  {
120  try
121  {
122  XMLReader paramtop(xml_in, path);
123 
124  read(paramtop, "Frequency", frequency);
125 
126  // Params
127  read(paramtop, "Param", param);
128 
129  // Ids
130  read(paramtop, "NamedObject", named_obj);
131 
132  // Possible alternate XML file pattern
133  if (paramtop.count("xml_file") != 0)
134  {
135  read(paramtop, "xml_file", xml_file);
136  }
137  }
138  catch(const std::string& e)
139  {
140  QDPIO::cerr << "Caught Exception reading XML: " << e << std::endl;
141  QDP_abort(1);
142  }
143  }
144 
145 
146  // Function call
147  void
148  InlineWilsonLoop::operator()(unsigned long update_no,
149  XMLWriter& xml_out)
150  {
151  // If xml file not empty, then use alternate
152  if (params.xml_file != "")
153  {
154  std::string xml_file = makeXMLFileName(params.xml_file, update_no);
155 
156  push(xml_out, "WilsonLoop");
157  write(xml_out, "update_no", update_no);
158  write(xml_out, "xml_file", xml_file);
159  pop(xml_out);
160 
161  XMLFileWriter xml(xml_file);
162  func(update_no, xml);
163  }
164  else
165  {
166  func(update_no, xml_out);
167  }
168  }
169 
170 
171  // Real work done here
172  void
173  InlineWilsonLoop::func(unsigned long update_no,
174  XMLWriter& xml_out)
175  {
176  START_CODE();
177 
178  QDPIO::cout << InlineWilsonLoopEnv::name << ": Wilson-loop measurements" << std::endl;
179 
180  QDP::StopWatch snoop;
181  snoop.reset();
182  snoop.start();
183 
184  push(xml_out, "WilsonLoop");
185  write(xml_out, "update_no", update_no);
186  write(xml_out, "decay_dir", params.param.j_decay);
187  write(xml_out, "t_dir", params.param.t_dir);
188 
189  try
190  {
191  // Grab the gauge field
192  multi1d<LatticeColorMatrix> u =
193  TheNamedObjMap::Instance().getData< multi1d<LatticeColorMatrix> >(params.named_obj.gauge_id);
194  // Calculate some gauge invariant observables
195  MesPlq(xml_out, "Observables", u);
196 
197  // Set the construct state and modify the fields
198  {
199  std::istringstream xml_s(params.param.cgs.xml);
200  XMLReader gaugetop(xml_s);
201 
202  Handle<CreateGaugeState< multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> > >
204  gaugetop,
205  params.param.cgs.path));
206 
207  Handle<GaugeState< multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> > >
208  state((*cgs)(u));
209 
210  // Pull the u fields back out from the state since they might have been
211  // munged with gaugeBC's
212  u = state->getLinks();
213  }
214 
215  // Again calculate some gauge invariant observables
216  MesPlq(xml_out, "Link_observables", u);
217 
218  // Compute the Wilson loops
221  xml_out, "wilslp");
222 
223  pop(xml_out); // pop("WilsonLoop");
224  }
225  catch (std::bad_cast)
226  {
227  QDPIO::cerr << InlineWilsonLoopEnv::name << ": caught dynamic cast error"
228  << std::endl;
229  QDP_abort(1);
230  }
231  catch (const std::string& e)
232  {
233  QDPIO::cerr << InlineWilsonLoopEnv::name << ": caught error: " << e << std::endl;
234  QDP_abort(1);
235  }
236 
237  snoop.stop();
238  QDPIO::cout << InlineWilsonLoopEnv::name << ": total time = "
239  << snoop.getTimeInSeconds()
240  << " secs" << std::endl;
241 
242  QDPIO::cout << InlineWilsonLoopEnv::name << ": ran successfully" << std::endl;
243 
244  END_CODE();
245  }
246 
247 }
Inline measurement factory.
Class for counted reference semantics.
Definition: handle.h:33
Inline measurement of Wilson loops.
Definition: inline_wilslp.h:54
void operator()(const unsigned long update_no, XMLWriter &xml_out)
Do the measurement.
void func(const unsigned long update_no, XMLWriter &xml_out)
Do the measurement.
InlineWilsonLoopParams params
Definition: inline_wilslp.h:74
static T & Instance()
Definition: singleton.h:432
All gauge create-state method.
Gauge create state factory.
void read(XMLReader &xml, const std::string &path, AsqtadFermActParams &param)
Read parameters.
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams &param)
Writer parameters.
void wilslp(const multi1d< LatticeColorMatrix > &u, int j_decay, int t_dir, int kind, XMLWriter &xml, const std::string &xml_group)
Calculate Wilson loops.
Definition: wilslp.cc:32
std::string makeXMLFileName(std::string xml_file, unsigned long update_no)
Return a xml file name for inline measurements.
GroupXML_t readXMLGroup(XMLReader &xml_in, const std::string &path, const std::string &type_name)
Read group and return as a std::string.
Inline Wilson loops.
Make xml file writer.
Named object function std::map.
static bool registered
Local registration flag.
bool registerAll()
Register all the factories.
GroupXML_t nullXMLGroup()
Returns a simple createstate group.
bool registerAll()
Register all the factories.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static multi1d< LatticeColorMatrix > u
push(xml_out,"Condensates")
pop(xml_out)
void MesPlq(const multi1d< LatticeColorMatrixF3 > &u, multi2d< Double > &plane_plaq, Double &link)
Definition: mesplq.cc:83
START_CODE()
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
Definition: pbg5p_w.cc:28
FloatingPoint< double > Double
Definition: gtest.h:7351
::std::string string
Definition: gtest.h:1979
Double link
Definition: pade_trln_w.cc:146
Double t_plaq
Definition: pade_trln_w.cc:145
Double w_plaq
Definition: pade_trln_w.cc:143
Double s_plaq
Definition: pade_trln_w.cc:144
Parameter structure.
Definition: inline_wilslp.h:28
struct Chroma::InlineWilsonLoopParams::NamedObject_t named_obj
struct Chroma::InlineWilsonLoopParams::Param_t param
Calculate Wilson loops.