CHROMA
t_meas_wilson_flow.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 
9 #define MAIN
10 
11 // Include everything...
12 #include "chroma.h"
13 #include <iostream>
14 #include <cstdio>
15 
17 
18 using namespace Chroma;
19 
20 
21  bool linkageHack(void)
22 {
23  bool foo = true;
24 
25  // Inline Measurements
28 
29  return foo;
30 }
31 
32 
33 
34 
35 
36 /*
37  * Input
38  */
39 
40 
41 // Parameters which must be determined from the XML input
42 // and written to the XML output
43 struct Param_t
44 {
45 
46  Real GFAccu, OrPara; // Gauge fixing tolerance and over-relaxation param
47  int GFMax; // Maximum gauge fixing iterations
48 
49  multi1d<int> nrow;
50  multi1d<int> boundary;
51  int nstep ;
53 
54  Real wflow_eps ;
55 
56 };
57 
58 
59 
60 struct Propagator_input_t
61 {
62  IO_version_t io_version;
63  Param_t param;
64  Cfg_t cfg;
65 };
66 
67 
68 //
69 // Reader for input parameters
70 //
71 
72 void read(XMLReader& xml, const std::string& path, Propagator_input_t& input)
73 {
74  XMLReader inputtop(xml, path);
75 
76 
77  // First, read the input parameter version. Then, if this version
78  // includes 'Nc' and 'Nd', verify they agree with values compiled
79  // into QDP++
80 
81  // Read in the IO_version
82  try
83  {
84  read(inputtop, "IO_version/version", input.io_version.version);
85  }
86  catch (const std::string& e)
87  {
88  QDPIO::cerr << "Error reading IO version: " << e << std::endl;
89  throw;
90  }
91 
92  XMLReader paramtop(inputtop, "param"); // push into 'param' group
93 
94  try
95  {
96 
97  read(paramtop, "nrow", input.param.nrow);
98  read(paramtop, "wflow_eps", input.param.wflow_eps);
99  read(paramtop, "nstep", input.param.nstep);
100  read(paramtop, "gauge_trans", input.param.do_gauge_transform);
101 
102  }
103  catch (const std::string& e)
104  {
105  QDPIO::cerr << "Error parameters: " << e << std::endl;
106  throw;
107  }
108 
109 
110  //
111  // outside <param> </param>
112  //
113 
114 
115  // Read in the gauge configuration file name
116  try
117  {
118  read(inputtop, "Cfg", input.cfg);
119  }
120  catch (const std::string& e)
121  {
122  QDPIO::cerr << "Error gauge name data: " << e << std::endl;
123  throw;
124  }
125 }
126 
127 
128 
129 
130 //! Measure Wilson flow
131 /*! \defgroup calculation of Wilson flow
132  * \ingroup
133  *
134  * Main program for calculation of Wilson flow
135  */
136 
137 int main(int argc, char **argv)
138 {
139  // Put the machine into a known state
140  Chroma::initialize(&argc, &argv);
141 
142  QDPIO::cout << "Measure the Wilson flow " << std::endl;
143  QDPIO::cout << "Calculation for SU(" << Nc << ")" << std::endl;
144  linkageHack();
145 
146  // Input parameter structure
147  Propagator_input_t input;
148 
149  // Instantiate xml reader for DATA
150  XMLReader xml_in ;
152  try
153  {
154  xml_in.open(in_name);
155  }
156  catch (...)
157  {
158  QDPIO::cerr << "Error reading input file " << in_name << std::endl;
159  QDPIO::cerr << "The input file name can be passed via the -i flag " << std::endl;
160  QDPIO::cerr << "The default name is ./DATA" << std::endl;
161  throw;
162  }
163 
164 
165  // Read data
166  read(xml_in, "/WilsonFlow", input);
167 
168 
169  // Specify lattice size, shape, etc.
170  Layout::setLattSize(input.param.nrow);
171  Layout::create();
172 
173  // Read in the configuration along with relevant information.
174  multi1d<LatticeColorMatrix> u(Nd);
175 
176 
177 
178  XMLReader gauge_file_xml, gauge_xml;
179  // Start up the gauge field
180  gaugeStartup(gauge_file_xml, gauge_xml, u, input.cfg);
181 
182 
183  // Check if the gauge field configuration is unitarized
184  unitarityCheck(u);
185 
186  // Instantiate XML writer for XMLDAT
187  XMLFileWriter& xml_out = Chroma::getXMLOutputInstance();
188  push(xml_out, "wilsonFlow");
189 
190  // Write out the input
191  write(xml_out, "Input", xml_in);
192 
193 
194  push(xml_out, "Output_version");
195  write(xml_out, "out_version", 1);
196  pop(xml_out);
197 
198  xml_out.flush();
199 
200 
201  // Calculate some gauge invariant observables just for info.
202  MesPlq(xml_out, "Observables", u);
203  xml_out.flush();
204 
205  //
206  // gauge invariance test
207  //
208 
209  if( input.param.do_gauge_transform )
210  {
211  // gauge transform the gauge fields
212  multi1d<LatticeColorMatrix> u_trans(Nd);
213 
214  // create a random gauge transform
215  LatticeColorMatrix v ;
216 
217  gaussian(v);
218  reunit(v) ;
219 
220  for(int dir = 0 ; dir < Nd ; ++dir)
221  {
222  u_trans[dir] = v*u[dir]*adj(shift(v,FORWARD,dir)) ;
223  u[dir] = u_trans[dir] ;
224  }
225 
226  QDPIO::cout << "Random gauge transform done" << std::endl;
227 
228  } // end of gauge transform
229  else
230  {
231  QDPIO::cout << "NO RANDOM GAUGE TRANSFORM" << std::endl;
232  }
233 
234 
235 
236  int j_decay = Nd-1;
237  int jomit=3 ;
238  multi1d<bool> smear_in_this_dirP(Nd);
239 
240  smear_in_this_dirP[0] = true;
241  smear_in_this_dirP[1] = true;
242  smear_in_this_dirP[2] = true;
243  smear_in_this_dirP[3] = false; // this is smear_in_this_dirP[jomit]
244  wilson_flow(xml_out, u, input.param.nstep,input.param.wflow_eps, j_decay, smear_in_this_dirP) ;
245 
246 
247  pop(xml_out);
248 
249  xml_out.close();
250  xml_in.close();
251 
252 
253  // Time to bolt
254  QDPIO::cout << "End of measurements " << std::endl;
256 
257  exit(0);
258 }
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
bool registerAll()
Register all the factories.
bool registerAll()
Register all the factories.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
gaussian(aux)
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
bool linkageHack(void)
Definition: const_hmc.cc:660
void reunit(LatticeColorMatrixF3 &xa)
Definition: reunit.cc:467
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
XMLFileWriter & getXMLOutputInstance()
Get xml output instance.
Definition: chroma_init.cc:359
::std::string string
Definition: gtest.h:1979
#define FORWARD
Definition: primitives.h:82
Gauge configuration structure.
Definition: cfgtype_io.h:16
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)