CHROMA
t_meas_wilson_flow_loop.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Wrapper code to the measure the Wilson flow
3  *
4  *
5  *
6  */
7 
8 #include <iostream>
9 #include <cstdio>
10 
11 #define MAIN
12 
13 // Include everything...
14 #include "chroma.h"
15 
17 
18 using namespace Chroma;
19 
20 
21 
22 
23 /*
24  * Input
25  */
26 
27 
28 // Parameters which must be determined from the XML input
29 // and written to the XML output
30 struct Param_t
31 {
32 
33  Real GFAccu, OrPara; // Gauge fixing tolerance and over-relaxation param
34  int GFMax; // Maximum gauge fixing iterations
35 
36  multi1d<int> nrow;
37  multi1d<int> boundary;
38  int nstep ;
39  bool do_gauge_transform ;
40 
41  Real wflow_eps ;
42 
43 };
44 
45 
46 
47 struct Propagator_input_t
48 {
49  IO_version_t io_version;
50  Param_t param;
51  Cfg_t cfg;
52 };
53 
54 
55 //
56 // Reader for input parameters
57 //
58 
59 void read(XMLReader& xml, const std::string& path, Propagator_input_t& input)
60 {
61  XMLReader inputtop(xml, path);
62 
63 
64  // First, read the input parameter version. Then, if this version
65  // includes 'Nc' and 'Nd', verify they agree with values compiled
66  // into QDP++
67 
68  // Read in the IO_version
69  try
70  {
71  read(inputtop, "IO_version/version", input.io_version.version);
72  }
73  catch (const std::string& e)
74  {
75  QDPIO::cerr << "Error reading IO version: " << e << std::endl;
76  throw;
77  }
78 
79  XMLReader paramtop(inputtop, "param"); // push into 'param' group
80 
81  try
82  {
83 
84  read(paramtop, "nrow", input.param.nrow);
85  read(paramtop, "wflow_eps", input.param.wflow_eps);
86  read(paramtop, "nstep", input.param.nstep);
87  read(paramtop, "gauge_trans", input.param.do_gauge_transform);
88 
89  }
90  catch (const std::string& e)
91  {
92  QDPIO::cerr << "Error parameters: " << e << std::endl;
93  throw;
94  }
95 
96 
97  //
98  // outside <param> </param>
99  //
100 
101 
102  // Read in the gauge configuration file name
103  try
104  {
105  read(inputtop, "Cfg", input.cfg);
106  }
107  catch (const std::string& e)
108  {
109  QDPIO::cerr << "Error gauge name data: " << e << std::endl;
110  throw;
111  }
112 }
113 
114 
115 
116 
117 //! Measure Wilson flow
118 /*! \defgroup calculation of Wilson flow
119  * \ingroup
120  *
121  * Main program for calculation of Wilson flow
122  */
123 
124 int main(int argc, char **argv)
125 {
126  // Put the machine into a known state
127  Chroma::initialize(&argc, &argv);
128 
129  QDPIO::cout << "Measure the Wilson flow " << std::endl;
130  QDPIO::cout << "Calculation for SU(" << Nc << ")" << std::endl;
131 
132  std::string queuefile_name = Chroma::getXMLInputFileName() ;
133  TextFileReader text_in ;
134 
135  try
136  {
137  text_in.open(queuefile_name);
138  }
139  catch (...)
140  {
141  QDPIO::cerr << "Error reading input file " << queuefile_name << std::endl;
142  QDPIO::cerr << "The input file name can be passed via the -i flag " << std::endl;
143  QDPIO::cerr << "The default name is ./DATA" << std::endl;
144  throw;
145  }
146 
147  std::string name1;
148  std::string name2;
149 
150  bool successful_read=true;
151 
152  while(successful_read){
153  text_in.read(name1);
154  text_in.read(name2);
155  text_in.fail( );
156  successful_read=!text_in.fail( );
157  if (successful_read){
158  const std::string in_name(name1);
159  const std::string out_name(name2);
160 
161 
162  QDPIO::cout << "Starting run with in_name:\t"<< in_name << std::endl;
163  QDPIO::cout << "Output name = out_name:\t"<< out_name << std::endl ;
164 
165  // Input parameter structure
166  Propagator_input_t input;
167 
169  // Instantiate xml reader for DATA
170  XMLReader xml_in ;
171  try
172  {
173  xml_in.open(in_name);
174  }
175  catch (...)
176  {
177  QDPIO::cerr << "Error reading input file " << in_name << std::endl;
178  QDPIO::cerr << "The input file name can be passed via the -i flag " << std::endl;
179  throw;
180  }
181 
182 
183  // Read data
184  read(xml_in, "/WilsonFlow", input);
185 
186 
187  // Specify lattice size, shape, etc.
188  Layout::setLattSize(input.param.nrow);
189  Layout::create();
190 
191  // Read in the configuration along with relevant information.
192  multi1d<LatticeColorMatrix> u(Nd);
193 
194  XMLReader gauge_file_xml, gauge_xml;
195  // Start up the gauge field
196  gaugeStartup(gauge_file_xml, gauge_xml, u, input.cfg);
197 
198 
199  // Check if the gauge field configuration is unitarized
200  unitarityCheck(u);
201 
202  // Instantiate XML writer for XMLDAT
203  XMLFileWriter xml_out(out_name);
204  push(xml_out, "wilsonFlow_output");
205 
206  // Write out the input
207  write(xml_out, "Input", xml_in);
208 
209 
210  push(xml_out, "Output_version");
211  write(xml_out, "out_version", 1);
212  pop(xml_out);
213 
214  xml_out.flush();
215 
216 
217  // Calculate some gauge invariant observables just for info.
218  MesPlq(xml_out, "Observables", u);
219  xml_out.flush();
220 
221 
222  int j_decay = Nd-1;
223  int jomit=3 ;
224  QDPIO::cout << "FLOW for " << input.cfg.cfg_file << "\n" ;
225  wilson_flow(xml_out, u, input.param.nstep,input.param.wflow_eps ,jomit) ;
226 
227  pop(xml_out);
228 
229  xml_out.close();
230  xml_in.close();
231 
232  } // succesful read
233 
234  } // read files in input parameter
235 
236 
237  // Time to bolt
238  QDPIO::cout << "End of measurements " << std::endl;
240 
241  exit(0);
242 }
Primary include file for CHROMA in application codes.
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 gaugeStartup(XMLReader &gauge_file_xml, XMLReader &gauge_xml, multi1d< LatticeColorMatrix > &u, Cfg_t &cfg)
Initialize the gauge fields.
void wilson_flow(XMLWriter &xml, multi1d< LatticeColorMatrix > &u, int nstep, Real wflow_eps, int t_dir, const multi1d< bool > &smear_dirs)
Compute the Wilson flow.
int j_decay
Definition: meslate.cc:22
Nd
Definition: meslate.cc:74
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static multi1d< LatticeColorMatrix > u
push(xml_out,"Condensates")
void initialize(int *argc, char ***argv)
Chroma initialisation routine.
Definition: chroma_init.cc:114
void finalize(void)
Chroma finalization routine.
Definition: chroma_init.cc:308
std::string getXMLInputFileName()
Get input file name.
Definition: chroma_init.cc:88
pop(xml_out)
void MesPlq(const multi1d< LatticeColorMatrixF3 > &u, multi2d< Double > &plane_plaq, Double &link)
Definition: mesplq.cc:83
void setXMLInputFileName(const std::string &name)
Set input file name.
Definition: chroma_init.cc:101
::std::string string
Definition: gtest.h:1979
Gauge configuration structure.
Definition: cfgtype_io.h:16
std::string cfg_file
Definition: cfgtype_io.h:18
Parameters for running program.
Definition: qpropadd.cc:17
bool do_gauge_transform
multi1d< int > nrow
Definition: qpropadd.cc:18
IO_version_t io_version
int main(int argc, char **argv)