CHROMA
t_propagator_twisted.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Main code for propagator generation of twisted mass QCD
3  *
4  * This version is for TWISTED Wilson fermions.
5  * This code should work for su3 or su4.
6  *
7  * See hep-lat/0411001 for an introduction to twisted mass
8  * QCD. This code is currently being debugged. When the
9  * code is debugged the input xml file will include
10  * a test case with a mass term in the gamma_5 component.
11  */
12 
13 #include <iostream>
14 #include <cstdio>
15 
16 #define MAIN
17 
18 // Include everything...
19 #include "chroma.h"
20 
21 
22 using namespace Chroma;
23 
24 
25 /*
26  * Input
27  */
28 
29 
30 // Parameters which must be determined from the XML input
31 // and written to the XML output
32 struct Param_t
33 {
35  Real u0; // Tadpole Factor
36 
38 
39  PropType prop_type; // storage order for stored propagator
40 
41  SysSolverCGParams invParam;
42 
43  Real GFAccu, OrPara; // Gauge fixing tolerance and over-relaxation param
44  int GFMax; // Maximum gauge fixing iterations
45 
46  multi1d<int> nrow;
47  multi1d<int> boundary;
48  multi1d<int> t_srce;
49 };
50 
51 
52 struct Prop_t
53 {
54  std::string source_file;
55  std::string prop_file;
56 };
57 
58 struct Propagator_input_t
59 {
60  IO_version_t io_version;
61  Param_t param;
62  Cfg_t cfg;
63  Prop_t prop;
64 };
65 
66 
67 //
68 void read(XMLReader& xml, const std::string& path, Prop_t& input)
69 {
70  XMLReader inputtop(xml, path);
71 
72  read(inputtop, "prop_file", input.prop_file);
73 }
74 
75 
76 
77 // Reader for input parameters
78 // first called
79 //
80 
81 void read(XMLReader& xml, const std::string& path, Propagator_input_t& input)
82 {
83  XMLReader inputtop(xml, path);
84 
85 
86  // First, read the input parameter version. Then, if this version
87  // includes 'Nc' and 'Nd', verify they agree with values compiled
88  // into QDP++
89 
90  // Read in the IO_version
91  try
92  {
93  read(inputtop, "IO_version/version", input.io_version.version);
94  }
95  catch (const std::string& e)
96  {
97  QDPIO::cerr << "Error reading data: " << e << std::endl;
98  throw;
99  }
100 
101 
102  // Currently, in the supported IO versions, there is only a small difference
103  // in the inputs. So, to make code simpler, extract the common bits
104 
105  // Read the uncommon bits first
106  try
107  {
108  XMLReader paramtop(inputtop, "param"); // push into 'param' group
109 
110  switch (input.io_version.version)
111  {
112  /**************************************************************************/
113  case 1 :
114  /**************************************************************************/
115  break;
116 
117  default :
118  /**************************************************************************/
119 
120  QDPIO::cerr << "Input parameter version " << input.io_version.version << " unsupported." << std::endl;
121  QDP_abort(1);
122  }
123  }
124  catch (const std::string& e)
125  {
126  QDPIO::cerr << "Error reading data: " << e << std::endl;
127  throw;
128  }
129 
130 
131  // Read the common bits
132  try
133  {
134  XMLReader paramtop(inputtop, "param"); // push into 'param' group
135 
136  {
137  std::string ferm_type_str;
138  read(paramtop, "FermTypeP", ferm_type_str);
139  if (ferm_type_str == "WILSON") {
141  }
142  }
143 
144  read(paramtop,"Twisted_mass",input.param.mass_param);
145 
146 // read(paramtop, "invType", input.param.invType);
147  read(paramtop, "RsdCG", input.param.invParam.RsdCG);
148  read(paramtop, "MaxCG", input.param.invParam.MaxCG);
149 
150  read(paramtop, "nrow", input.param.nrow);
151  read(paramtop, "boundary", input.param.boundary);
152  read(paramtop, "t_srce", input.param.t_srce);
153 
154  }
155  catch (const std::string& e)
156  {
157  QDPIO::cerr << "Error reading data: " << e << std::endl;
158  throw;
159  }
160 
161  //
162  // outside <param> </param>
163  //
164 
165 
166  // Read in the gauge configuration file name
167  try
168  {
169  read(inputtop, "Cfg", input.cfg);
170  read(inputtop, "Prop", input.prop);
171  }
172  catch (const std::string& e)
173  {
174  QDPIO::cerr << "Error reading data: " << e << std::endl;
175  throw;
176  }
177 }
178 
179 //! Propagator generation
180 /*! \defgroup t_propagator_twisted Propagator generation
181  * \ingroup testsmain
182  *
183  * Main program for propagator generation.
184  */
185 
186 int main(int argc, char **argv)
187 {
188  // Put the machine into a known state
189  Chroma::initialize(&argc, &argv);
190 
191  // Input parameter structure
192  Propagator_input_t input;
193 
194  // Instantiate xml reader for DATA
195  // XMLReader xml_in("INPUT_t_propagator_twisted.xml");
196  XMLReader xml_in(Chroma::getXMLInputFileName());
197 
198  // Read data
199  read(xml_in, "/propagator", input);
200 
201  // Specify lattice size, shape, etc.
202  Layout::setLattSize(input.param.nrow);
203  Layout::create();
204 
205  // Read in the configuration along with relevant information.
206  multi1d<LatticeColorMatrix> u(Nd);
207 
208  QDPIO::cout << "Computation of Meson Correlators for Twisted Mass QCD" << std::endl;
209  QDPIO::cout << "Calculation for SU(" << Nc << ")" << std::endl;
210  XMLReader gauge_file_xml, gauge_xml;
211 
212  // Start up the gauge field
213  gaugeStartup(gauge_file_xml, gauge_xml, u, input.cfg);
214 
215  // Check if the gauge field configuration is unitarized
216  unitarityCheck(u);
217 
218  // Instantiate XML writer for output
219  // XMLFileWriter xml_out("t_propagator_twisted.xml");
220  XMLFileWriter& xml_out = Chroma::getXMLOutputInstance();
221  push(xml_out, "propagator");
222 
223  // Write out the input
224  write(xml_out, "Input", xml_in);
225 
226  // Write out the config header
227  write(xml_out, "Config_info", gauge_xml);
228 
229  push(xml_out, "Output_version");
230  write(xml_out, "out_version", 1);
231  pop(xml_out);
232 
233  xml_out.flush();
234 
235 
236  // Calculate some gauge invariant observables just for info.
237  MesPlq(xml_out, "Observables", u);
238  xml_out.flush();
239 
240 
241  //
242  // gauge invariance test
243  //
244 
245  // this parameter will be read from the input file
246  bool do_gauge_transform = false ;
247  read(xml_in, "/propagator/param/do_gauge_transform",do_gauge_transform );
248 
249  if( do_gauge_transform )
250  {
251  // gauge transform the gauge fields
252  multi1d<LatticeColorMatrix> u_trans(Nd);
253 
254  // create a random gauge transform
255  LatticeColorMatrix v ;
256 
257  gaussian(v);
258  reunit(v) ;
259 
260  for(int dir = 0 ; dir < Nd ; ++dir)
261  {
262  u_trans[dir] = v*u[dir]*adj(shift(v,FORWARD,dir)) ;
263  u[dir] = u_trans[dir] ;
264  }
265 
266  QDPIO::cout << "Random gauge transform done" << std::endl;
267 
268  } // end of gauge transform
269 
270 
271 
272 
273 
274  // -----set up the calculation of quark propagators ---------
275 
276  // Create the fermion boundary conditions.
278 
279  //
280  // Initialize fermion action
281  //
283 
284  GroupXML_t inv_param;
285  {
286  XMLBufferWriter xml_buf;
287  write(xml_buf, "InvertParam", input.param.invParam);
288  XMLReader xml_in(xml_buf);
289  inv_param = readXMLGroup(xml_in, "/InvertParam", "invType");
290  }
291 
292  // Set up a state for the current u,
293  Handle<const ConnectState > state(S_f.createState(u));
294  Handle<const SystemSolver<LatticeFermion> > qprop(S_f.qprop(state,inv_param));
295 
296  LatticePropagator quark_propagator;
297  XMLBufferWriter xml_buf;
298  int ncg_had = 0;
299 
300  LatticeFermion q_source, psi;
301 
302  multi1d<int> coord(Nd);
303  coord = input.param.t_srce ;
304  // coord[0]=0; coord[1] = 0; coord[2] = 0; coord[3] = 0;
305  int t_source = coord[Nd - 1] ;
306  QDPIO::cout << "Source time slice = " << t_source << std::endl;
307 
308  //
309  // Loop over the source color and spin , creating the source
310  // and calling the relevant propagator routines.
311  //
312 
313  for(int color_source = 0; color_source < Nc; ++color_source)
314  for(int spin_source = 0 ; spin_source < Ns ; ++spin_source)
315  {
316  QDPIO::cout << "Inversion for Color = " << color_source ;
317  QDPIO::cout << " Spin = " << spin_source << std::endl;
318 
319  q_source = zero ;
320  srcfil(q_source, coord, color_source, spin_source);
321 
322  // initial guess is zero
323  psi = zero; // note this is ``zero'' and not 0
324 
325 
326  // Compute the propagator for given source color/spin
327  SystemSolverResults_t res = (*qprop)(psi, q_source);
328  ncg_had += res.n_count;
329 
330  push(xml_out,"Qprop");
331  write(xml_out, "Mass" , input.param.mass_param.Mass);
332  write(xml_out, "gamma5_mass" , input.param.mass_param.H);
333  write(xml_out, "RsdCG", input.param.invParam.RsdCG);
334  write(xml_out, "n_count", res.n_count);
335  pop(xml_out);
336 
337  /*
338  * Move the solution to the appropriate components
339  * of quark propagator.
340  */
341  FermToProp(psi, quark_propagator, color_source, spin_source);
342  } //spin / color_source
343 
344 
345  // compute the meson spectrum
346 
347  // create averaged Fourier phases with (mom)^2 <= 10
348  int j_decay = Nd-1;
349  SftMom phases(10, true, j_decay) ;
350 
351  mesons(quark_propagator,quark_propagator,
352  phases, t_source, xml_out,
353  "Point_Point_Twisted_Wilson_Mesons") ;
354 
355  pop(xml_out);
356 
357  xml_out.close();
358  xml_in.close();
359 
360  // Time to bolt
362 
363  exit(0);
364 }
Primary include file for CHROMA in application codes.
Class for counted reference semantics.
Definition: handle.h:33
Fourier transform phase factor support.
Definition: sftmom.h:35
Concrete class for all gauge actions with simple boundary conditions.
Definition: simple_fermbc.h:42
Unpreconditioned Wilson fermion action with parity breaking term.
Real u0
EXTERN int FermTypeP
void FermToProp(const LatticeFermionF &a, LatticePropagatorF &b, int color_index, int spin_index)
Insert a LatticeFermion into a LatticePropagator.
Definition: transf.cc:98
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 mesons(const LatticePropagator &quark_prop_1, const LatticePropagator &quark_prop_2, const SftMom &phases, int t0, XMLWriter &xml, const std::string &xml_group)
Meson 2-pt functions.
Definition: mesons_w.cc:111
FermType
Fermion type.
PropType
Propagator type.
GroupXML_t readXMLGroup(XMLReader &xml_in, const std::string &path, const std::string &type_name)
Read group and return as a std::string.
@ FERM_TYPE_WILSON
void srcfil(LatticeFermion &a, const multi1d< int > &coord, int color_index, int spin_index)
Fill a specific color and spin index with 1.0.
Definition: srcfil.cc:23
std::map< std::string, SinkPropContainer_t > prop
multi1d< int > t_srce
multi1d< int > coord(Nd)
int j_decay
Definition: meslate.cc:22
Nd
Definition: meslate.cc:74
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
void reunit(LatticeColorMatrixF3 &xa)
Definition: reunit.cc:467
std::string getXMLInputFileName()
Get input file name.
Definition: chroma_init.cc:88
LatticeFermion psi
Definition: mespbg5p_w.cc:35
pop(xml_out)
void MesPlq(const multi1d< LatticeColorMatrixF3 > &u, multi2d< Double > &plane_plaq, Double &link)
Definition: mesplq.cc:83
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
Definition: pbg5p_w.cc:28
XMLFileWriter & getXMLOutputInstance()
Get xml output instance.
Definition: chroma_init.cc:359
const WilsonTypeFermAct< multi1d< LatticeFermion > > & S_f
Definition: pbg5p_w.cc:27
Double zero
Definition: invbicg.cc:106
::std::string string
Definition: gtest.h:1979
#define FORWARD
Definition: primitives.h:82
Gauge configuration structure.
Definition: cfgtype_io.h:16
Hold group xml and type id.
Params for CG inverter.
Holds return info from SystemSolver call.
Definition: syssolver.h:17
Parameters for running program.
Definition: qpropadd.cc:17
SysSolverCGParams invParam
FermType FermTypeP
multi1d< int > t_srce
multi1d< int > nrow
Definition: qpropadd.cc:18
UnprecParWilsonFermActParams mass_param
multi1d< int > boundary
Propagators.
std::string prop_file
IO_version_t io_version
int main(int argc, char **argv)