CHROMA
inline_coulgauge.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Inline coulomb (and landau) gauge fixing loops
3  */
4 
7 #include "meas/gfix/coulgauge.h"
8 #include "meas/glue/mesplq.h"
9 #include "util/info/proginfo.h"
10 #include "util/gauge/unit_check.h"
12 
13 namespace Chroma
14 {
15  //! Parameters for running code
16  void read(XMLReader& xml, const std::string& path, InlineCoulGaugeEnv::Params::Param_t& param)
17  {
18  XMLReader paramtop(xml, path);
19 
20  int version;
21  read(paramtop, "version", version);
22 
23  switch (version)
24  {
25  case 1:
26  break;
27 
28  default :
29 
30  QDPIO::cerr << "Input version " << version << " unsupported." << std::endl;
31  QDP_abort(1);
32  }
33 
34  read(paramtop, "j_decay", param.j_decay);
35  read(paramtop, "GFAccu", param.GFAccu);
36  read(paramtop, "GFMax", param.GFMax);
37  read(paramtop, "OrDo", param.OrDo);
38  read(paramtop, "OrPara", param.OrPara);
39  }
40 
41  //! Parameters for running code
42  void write(XMLWriter& xml, const std::string& path, const InlineCoulGaugeEnv::Params::Param_t& param)
43  {
44  push(xml, path);
45 
46  int version = 1;
47  write(xml, "version", version);
48  write(xml, "GFAccu", param.GFAccu);
49  write(xml, "GFMax", param.GFMax);
50  write(xml, "OrDo", param.OrDo);
51  write(xml, "OrPara", param.OrPara);
52  write(xml, "j_decay", param.j_decay);
53 
54  pop(xml);
55  }
56 
57  // Reader for out gauge file
58  void read(XMLReader& xml, const std::string& path, InlineCoulGaugeEnv::Params::NamedObject_t& input)
59  {
60  XMLReader inputtop(xml, path);
61 
62  read(inputtop, "gauge_id", input.gauge_id);
63  read(inputtop, "gfix_id", input.gfix_id);
64  read(inputtop, "gauge_rot_id", input.gauge_rot_id);
65  }
66 
67  // Reader for out gauge file
68  void write(XMLWriter& xml, const std::string& path, const InlineCoulGaugeEnv::Params::NamedObject_t& input)
69  {
70  push(xml, path);
71 
72  write(xml, "gauge_id", input.gauge_id);
73  write(xml, "gfix_id", input.gfix_id);
74  write(xml, "gauge_rot_id", input.gauge_rot_id);
75 
76  pop(xml);
77  }
78 
79 
80 
81  namespace InlineCoulGaugeEnv
82  {
83  //! Anonymous namespace
84  namespace
85  {
86  AbsInlineMeasurement* createMeasurement(XMLReader& xml_in,
87  const std::string& path)
88  {
89  return new InlineMeas(Params(xml_in, path));
90  }
91 
92  //! Local registration flag
93  bool registered = false;
94  }
95 
96  const std::string name = "COULOMB_GAUGEFIX";
97 
98  //! Register all the factories
99  bool registerAll()
100  {
101  bool success = true;
102  if (! registered)
103  {
104  success &= TheInlineMeasurementFactory::Instance().registerObject(name, createMeasurement);
105  registered = true;
106  }
107  return success;
108  }
109 
110 
111  // Param stuff
113  {
114  frequency = 0;
115  }
116 
117  Params::Params(XMLReader& xml_in, const std::string& path)
118  {
119  try
120  {
121  XMLReader paramtop(xml_in, path);
122 
123  if (paramtop.count("Frequency") == 1)
124  read(paramtop, "Frequency", frequency);
125  else
126  frequency = 1;
127 
128  // Read program parameters
129  read(paramtop, "Param", param);
130 
131  // Read in the gfix outfile
132  read(paramtop, "NamedObject", named_obj);
133  }
134  catch(const std::string& e)
135  {
136  QDPIO::cerr << InlineCoulGaugeEnv::name << ": Caught Exception reading XML: " << e << std::endl;
137  QDP_abort(1);
138  }
139  }
140 
141 
142  // Write params
143  void
144  Params::write(XMLWriter& xml, const std::string& path)
145  {
146  push(xml, path);
147 
148  Chroma::write(xml, "Param", param);
149  Chroma::write(xml, "NamedObject", named_obj);
150 
151  pop(xml);
152  }
153 
154 
155  void
156  InlineMeas::operator()(unsigned long update_no,
157  XMLWriter& xml_out)
158  {
159  START_CODE();
160 
161  QDP::StopWatch snoop;
162  snoop.reset();
163  snoop.start();
164 
165  XMLBufferWriter gauge_xml;
166  multi1d<LatticeColorMatrix> u =
167  TheNamedObjMap::Instance().getData< multi1d<LatticeColorMatrix> >(params.named_obj.gauge_id);
168  TheNamedObjMap::Instance().get(params.named_obj.gauge_id).getRecordXML(gauge_xml);
169 
170  push(xml_out, "CoulGauge");
171  write(xml_out, "update_no", update_no);
172 
173  QDPIO::cout << InlineCoulGaugeEnv::name << ": coulomb gauge fix" << std::endl;
174 
175  proginfo(xml_out); // Print out basic program info
176 
177  // Write out the input
178  params.write(xml_out, "Input");
179 
180  // Write out the config header
181  write(xml_out, "Config_info", gauge_xml);
182 
183  push(xml_out, "Output_version");
184  write(xml_out, "out_version", 1);
185  pop(xml_out);
186 
187  // Calculate some gauge invariant observables
188  MesPlq(xml_out, "Observables", u);
189 
190  // Now coulomb (landau) gauge fix
191  multi1d<LatticeColorMatrix> u_gfix(Nd);
192  u_gfix = u;
193 
194  LatticeColorMatrix g; // the gauge rotation fields
195 
196  int n_gf;
198  params.param.OrDo, params.param. OrPara);
199 
200  // Write out what is done
201  push(xml_out,"Gauge_fixing_parameters");
202  write(xml_out, "GFAccu",params.param.GFAccu);
203  write(xml_out, "GFMax",params.param.GFMax);
204  write(xml_out, "iterations",n_gf);
205  pop(xml_out);
206 
207  // Check if the smeared gauge field is unitary
208  unitarityCheck(u_gfix);
209 
210  // Again calculate some gauge invariant observables
211  MesPlq(xml_out, "Gfix_observables", u_gfix);
212 
213  // Now store the configuration to a memory object
214  {
215  XMLBufferWriter file_xml, record_xml;
216  push(file_xml, "gauge");
217  write(file_xml, "id", int(0));
218  pop(file_xml);
219  record_xml << gauge_xml;
220 
221  // Store the gauge field
222  TheNamedObjMap::Instance().create< multi1d<LatticeColorMatrix> >(params.named_obj.gfix_id);
223  TheNamedObjMap::Instance().getData< multi1d<LatticeColorMatrix> >(params.named_obj.gfix_id) = u_gfix;
224  TheNamedObjMap::Instance().get(params.named_obj.gfix_id).setFileXML(file_xml);
225  TheNamedObjMap::Instance().get(params.named_obj.gfix_id).setRecordXML(record_xml);
226 
227  // Store the gauge rotation fields
228  TheNamedObjMap::Instance().create< LatticeColorMatrix >(params.named_obj.gauge_rot_id);
229  TheNamedObjMap::Instance().getData< LatticeColorMatrix >(params.named_obj.gauge_rot_id) = g;
230  TheNamedObjMap::Instance().get(params.named_obj.gauge_rot_id).setFileXML(file_xml);
231  TheNamedObjMap::Instance().get(params.named_obj.gauge_rot_id).setRecordXML(record_xml);
232  }
233 
234  pop(xml_out);
235 
236  snoop.stop();
237  QDPIO::cout << InlineCoulGaugeEnv::name << ": total time = "
238  << snoop.getTimeInSeconds()
239  << " secs" << std::endl;
240 
241  QDPIO::cout << InlineCoulGaugeEnv::name << ": ran successfully" << std::endl;
242 
243  END_CODE();
244  }
245 
246  }
247 
248 }
Inline measurement factory.
Inline measurement of Coulomb gauge fixing.
void operator()(const unsigned long update_no, XMLWriter &xml_out)
Do the measurement.
static T & Instance()
Definition: singleton.h:432
Coulomb (and Landau) gauge fixing.
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 unitarityCheck(const multi1d< LatticeColorMatrixF3 > &u)
Check the unitarity of color matrix in SU(N)
Definition: unit_check.cc:20
void coulGauge(multi1d< LatticeColorMatrix > &u, int &n_gf, int j_decay, const Real &GFAccu, int GFMax, bool OrDo, const Real &OrPara)
Coulomb (and Landau) gauge fixing.
Definition: coulgauge.cc:37
void proginfo(XMLWriter &xml)
Print out basic information about this program.
Definition: proginfo.cc:24
Inline coulomb (and landau) gauge fixing loops.
Nd
Definition: meslate.cc:74
Named object function std::map.
static bool registered
Local registration flag.
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()
::std::string string
Definition: gtest.h:1979
Print out basic info about this program.
struct Chroma::InlineCoulGaugeEnv::Params::NamedObject_t named_obj
struct Chroma::InlineCoulGaugeEnv::Params::Param_t param
void write(XMLWriter &xml_out, const std::string &path)