CHROMA
inline_sfpcac_w.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Inline Schroedinger functional measurements
3  */
4 
5 #include "fermact.h"
8 #include "meas/glue/mesplq.h"
9 #include "util/ft/sftmom.h"
10 #include "util/info/proginfo.h"
14 
16 
17 #include "meas/schrfun/sfpcac_w.h"
18 
19 namespace Chroma
20 {
21  //! SFpcac input
22  void read(XMLReader& xml, const std::string& path, InlineSFpcacEnv::Params::NamedObject_t& input)
23  {
24  XMLReader inputtop(xml, path);
25 
26  read(inputtop, "gauge_id", input.gauge_id);
27  }
28 
29  //! SFpcac output
30  void write(XMLWriter& xml, const std::string& path, const InlineSFpcacEnv::Params::NamedObject_t& input)
31  {
32  push(xml, path);
33 
34  write(xml, "gauge_id", input.gauge_id);
35 
36  pop(xml);
37  }
38 
39 
40  //! SFpcac input
41  void read(XMLReader& xml, const std::string& path, InlineSFpcacEnv::Params::SFpcac_t& input)
42  {
43  XMLReader inputtop(xml, path);
44 
45  read(inputtop, "decay_dir", input.decay_dir);
46  read(inputtop, "ZVfactP", input.ZVfactP);
47  read(inputtop, "ZAfactP", input.ZAfactP);
48  read(inputtop, "x0", input.x0);
49  read(inputtop, "y0", input.y0);
50  }
51 
52  //! SFpcac output
53  void write(XMLWriter& xml, const std::string& path, const InlineSFpcacEnv::Params::SFpcac_t& input)
54  {
55  push(xml, path);
56 
57  write(xml, "decay_dir", input.decay_dir);
58  write(xml, "ZVfactP", input.ZVfactP);
59  write(xml, "ZAfactP", input.ZAfactP);
60  write(xml, "x0", input.x0);
61  write(xml, "y0", input.y0);
62 
63  pop(xml);
64  }
65 
66 
67  namespace InlineSFpcacEnv
68  {
69  namespace
70  {
71  AbsInlineMeasurement* createMeasurement(XMLReader& xml_in,
72  const std::string& path)
73  {
74  return new InlineMeas(Params(xml_in, path));
75  }
76 
77  //! Local registration flag
78  bool registered = false;
79  }
80 
81  const std::string name = "SCHROEDINGER_FUNCTIONAL_PCAC";
82 
83  //! Register all the factories
84  bool registerAll()
85  {
86  bool success = true;
87  if (! registered)
88  {
90  success &= TheInlineMeasurementFactory::Instance().registerObject(name, createMeasurement);
91  registered = true;
92  }
93  return success;
94  }
95 
96 
97  // Param stuff
99 
100  Params::Params(XMLReader& xml_in, const std::string& path)
101  {
102  try
103  {
104  XMLReader paramtop(xml_in, path);
105 
106  if (paramtop.count("Frequency") == 1)
107  read(paramtop, "Frequency", frequency);
108  else
109  frequency = 1;
110 
111  // Parameters for propagator solver
112  read(paramtop, "Param", param);
113 
114  // Parameters for Schroedinger functional
115  read(paramtop, "SFpcac", sfpcac);
116 
117  // Read in the output propagator/source configuration info
118  read(paramtop, "NamedObject", named_obj);
119 
120  // Possible alternate XML file pattern
121  if (paramtop.count("xml_file") != 0)
122  {
123  read(paramtop, "xml_file", xml_file);
124  }
125  }
126  catch(const std::string& e)
127  {
128  QDPIO::cerr << __func__ << ": Caught Exception reading XML: " << e << std::endl;
129  QDP_abort(1);
130  }
131  }
132 
133 
134  void
135  Params::writeXML(XMLWriter& xml_out, const std::string& path)
136  {
137  push(xml_out, path);
138 
139  write(xml_out, "Param", param);
140  write(xml_out, "SFpcac", sfpcac);
141  write(xml_out, "NamedObject", named_obj);
142 
143  pop(xml_out);
144  }
145 
146 
147  // Function call
148  void
149  InlineMeas::operator()(unsigned long update_no,
150  XMLWriter& xml_out)
151  {
152  // If xml file not empty, then use alternate
153  if (params.xml_file != "")
154  {
155  std::string xml_file = makeXMLFileName(params.xml_file, update_no);
156 
157  push(xml_out, "SFpcac");
158  write(xml_out, "update_no", update_no);
159  write(xml_out, "xml_file", xml_file);
160  pop(xml_out);
161 
162  XMLFileWriter xml(xml_file);
163  func(update_no, xml);
164  }
165  else
166  {
167  func(update_no, xml_out);
168  }
169  }
170 
171 
172  // Real work done here
173  void
174  InlineMeas::func(unsigned long update_no,
175  XMLWriter& xml_out)
176  {
177  START_CODE();
178 
179  QDPIO::cout << name << ": Schroedinger functional calculation" << std::endl;
180 
181  StopWatch snoop;
182  snoop.reset();
183  snoop.start();
184 
185  // Test and grab a reference to the gauge field
186  multi1d<LatticeColorMatrix> u;
187  XMLBufferWriter gauge_xml;
188  try
189  {
190  u = TheNamedObjMap::Instance().getData< multi1d<LatticeColorMatrix> >(params.named_obj.gauge_id);
191  TheNamedObjMap::Instance().get(params.named_obj.gauge_id).getRecordXML(gauge_xml);
192  }
193  catch( std::bad_cast )
194  {
195  QDPIO::cerr << name << ": caught dynamic cast error"
196  << std::endl;
197  QDP_abort(1);
198  }
199  catch (const std::string& e)
200  {
201  QDPIO::cerr << name << ": std::map call failed: " << e
202  << std::endl;
203  QDP_abort(1);
204  }
205 
206  push(xml_out, "SFpcac");
207  write(xml_out, "update_no", update_no);
208 
209  proginfo(xml_out); // Print out basic program info
210 
211  // Write out the input
212  params.writeXML(xml_out, "Input");
213 
214  // Write out the config header
215  write(xml_out, "Config_info", gauge_xml);
216 
217  push(xml_out, "Output_version");
218  write(xml_out, "out_version", 1);
219  pop(xml_out);
220 
221  // Calculate some gauge invariant observables just for info.
222  MesPlq(xml_out, "Observables", u);
223 
224  //
225  // Initialize fermion action
226  //
227  std::istringstream xml_s(params.param.fermact.xml);
228  XMLReader fermacttop(xml_s);
229  QDPIO::cout << "FermAct = " << params.param.fermact.id << std::endl;
230 
231 
232  // Initialize the slow Fourier transform phases
233  SftMom phases(0, true, params.sfpcac.decay_dir);
234 
235  //
236  // Try the factories
237  //
238  try
239  {
240  StopWatch swatch;
241  swatch.reset();
242  QDPIO::cout << "Try the various factories" << std::endl;
243 
244  // Typedefs to save typing
245  typedef LatticeFermion T;
246  typedef multi1d<LatticeColorMatrix> P;
247  typedef multi1d<LatticeColorMatrix> Q;
248 
249  // Generic Wilson-Type stuff
252  fermacttop,
254 
255 
256  Handle< FermState<T,P,Q> > state(S_f->createState(u));
257 
258  QDPIO::cout << "Suitable factory found: do the measurements" << std::endl;
260 
261  swatch.start();
262 
263  // SF measurements
264  SFpcac(qprop, state, phases,
268  xml_out, std::string("sfpcac"));
269 
270  swatch.stop();
271 QDPIO::cout << "SFpcac computed: time= "
272  << swatch.getTimeInSeconds()
273  << " secs" << std::endl;
274  }
275  catch( std::bad_cast )
276  {
277  QDPIO::cerr << name << ": caught dynamic cast error"
278  << std::endl;
279  QDP_abort(1);
280  }
281  catch (const std::string& e)
282  {
283  QDPIO::cout << name << ": caught exception with fermion action: " << e << std::endl;
284  }
285 
286 
287  pop(xml_out); // sfpcac
288 
289  snoop.stop();
290  QDPIO::cout << name << ": total time = "
291  << snoop.getTimeInSeconds()
292  << " secs" << std::endl;
293 
294  QDPIO::cout << name << ": ran successfully" << std::endl;
295 
296  END_CODE();
297  }
298 
299  } // namespace InlineSFpcacEnv
300 
301 } // namespace Chroma
Inline measurement factory.
Class for counted reference semantics.
Definition: handle.h:33
Inline measurement of Wilson loops.
void func(const unsigned long update_no, XMLWriter &xml_out)
Do the measurement.
void operator()(const unsigned long update_no, XMLWriter &xml_out)
Do the measurement.
Fourier transform phase factor support.
Definition: sftmom.h:35
static T & Instance()
Definition: singleton.h:432
Class structure for fermion actions.
Fermion action factories.
All Wilson-type fermion actions.
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 proginfo(XMLWriter &xml)
Print out basic information about this program.
Definition: proginfo.cc:24
std::string makeXMLFileName(std::string xml_file, unsigned long update_no)
Return a xml file name for inline measurements.
void SFpcac(Handle< SystemSolver< LatticeFermion > > qprop, Handle< FermState< LatticeFermion, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > > state, const SftMom &phases, bool ZVfactP, bool ZAfactP, int x0, int y0, XMLWriter &xml_out, const std::string &xml_group)
Schroedinger functional stuff.
Definition: sfpcac_w.cc:45
Inline Schroedinger functional measurements.
Make xml file writer.
Named object function std::map.
static bool registered
Local registration flag.
multi1d< LatticeColorMatrix > P
bool registerAll()
Register all the factories.
const std::string name
bool registerAll()
Register all the factories.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static multi1d< LatticeColorMatrix > u
LinOpSysSolverMGProtoClover::Q Q
push(xml_out,"Condensates")
LinOpSysSolverMGProtoClover::T T
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
const WilsonTypeFermAct< multi1d< LatticeFermion > > & S_f
Definition: pbg5p_w.cc:27
::std::string string
Definition: gtest.h:1979
Print out basic info about this program.
Schroedinger functional application of PCAC.
Fourier transform phase factor support.
GroupXML_t invParam
Definition: qprop_io.h:84
GroupXML_t fermact
Definition: qprop_io.h:80
struct Chroma::InlineSFpcacEnv::Params::NamedObject_t named_obj
void writeXML(XMLWriter &xml_out, const std::string &path)
struct Chroma::InlineSFpcacEnv::Params::SFpcac_t sfpcac