CHROMA
t_disc_loop_s.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Main code for propagator generation
3  */
4 
5 #include <iostream>
6 #include <cstdio>
7 
8 #define MAIN
9 
10 // Include everything...
11 #include "chroma.h"
12 
14 
15 /*
16  * Here we have various temporary definitions
17  */
18 
19 
20 using namespace Chroma;
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 {
33  Real Mass; // Staggered mass
34  Real u0; // Tadpole Factor
35 
36 
37  CfgType cfg_type; // storage order for stored gauge configuration
38  PropType prop_type; // storage order for stored propagator
39 
41 
43 
44  int Nsamples; // Number of stochastic sources
45  int CFGNO; // Configuration Number used for seeding rng
46  // This WILL be changed soon
47  Real GFAccu, OrPara; // Gauge fixing tolerance and over-relaxation param
48  int GFMax; // Maximum gauge fixing iterations
49 
50  multi1d<int> nrow;
51  multi1d<int> boundary;
52  multi1d<int> t_srce;
53 
55 
56 };
57 
58 
59 struct Prop_t
60 {
61  std::string source_file;
62  std::string prop_file;
63 };
64 
66 {
70 };
71 
72 
73 //
74 void read(XMLReader& xml, const std::string& path, Prop_t& input)
75 {
76  XMLReader inputtop(xml, path);
77 
78  read(inputtop, "prop_file", input.prop_file);
79 }
80 
81 
82 
83 // Reader for input parameters
84 void read(XMLReader& xml, const std::string& path, Propagator_input_t& input)
85 {
86  XMLReader inputtop(xml, path);
87 
88 
89  // First, read the input parameter version. Then, if this version
90  // includes 'Nc' and 'Nd', verify they agree with values compiled
91  // into QDP++
92 
93  // Read in the IO_version
94  int version;
95  try
96  {
97  read(inputtop, "IO_version/version", version);
98  }
99  catch (const std::string& e)
100  {
101  QDPIO::cerr << "Error reading data: " << e << std::endl;
102  throw;
103  }
104 
105 
106  // Currently, in the supported IO versions, there is only a small difference
107  // in the inputs. So, to make code simpler, extract the common bits
108 
109  // Read the uncommon bits first
110  try
111  {
112  XMLReader paramtop(inputtop, "param"); // push into 'param' group
113 
114  switch (version)
115  {
116  /**************************************************************************/
117  case 2 :
118  /**************************************************************************/
119  break;
120 
121  default :
122  /**************************************************************************/
123 
124  QDPIO::cerr << "Input parameter version " << version << " unsupported." << std::endl;
125  QDP_abort(1);
126  }
127  }
128  catch (const std::string& e)
129  {
130  QDPIO::cerr << "Error reading data: " << e << std::endl;
131  throw;
132  }
133 
134 
135  // Read the common bits
136  try
137  {
138  XMLReader paramtop(inputtop, "param"); // push into 'param' group
139 
140  {
141  std::string ferm_type_str;
142  read(paramtop, "FermTypeP", ferm_type_str);
143  if (ferm_type_str == "STAGGERED") {
145  }
146  }
147 
148  // GTF NOTE: I'm going to switch on FermTypeP here because I want
149  // to leave open the option of treating masses differently.
150  switch (input.param.FermTypeP) {
151  case FERM_TYPE_STAGGERED :
152 
153  QDPIO::cout << " PROPAGATOR: Disconnected loops for Staggered fermions" << std::endl;
154 
155  read(paramtop, "Mass", input.param.Mass);
156  read(paramtop, "u0" , input.param.u0);
157 
158  break;
159 
160  default :
161  QDP_error_exit("Fermion type not supported\n.");
162  }
163 
164  {
165  std::string prop_type_str;
166  read(paramtop, "prop_type", prop_type_str);
167  if (prop_type_str == "SZIN") {
169  } else {
170  QDP_error_exit("Dont know non SZIN files yet");
171  }
172  }
173 
174  {
175  std::string vol_type_str;
176  read(paramtop, "volume_source", vol_type_str);
177  if (vol_type_str == "Z2NOISE")
178  {
179  input.param.volume_source = Z2NOISE ;
180  }
181  else if (vol_type_str == "GAUSSIAN")
182  {
183  input.param.volume_source = GAUSSIAN ;
184  }
185  else
186  {
187  QDP_error_exit("Wrong type of volume source");
188  }
189 
190 
191  }
192 
193 
194 
195 // read(paramtop, "invType", input.param.invType);
196 // input.param.invParam.invType = CG_INVERTER; //need to fix this
197  read(paramtop, "RsdCG", input.param.invParam.RsdCG);
198  read(paramtop, "MaxCG", input.param.invParam.MaxCG);
199  read(paramtop, "Nsamples", input.param.Nsamples);
200  read(paramtop, "CFGNO", input.param.CFGNO);
201  read(paramtop, "GFAccu", input.param.GFAccu);
202  read(paramtop, "OrPara", input.param.OrPara);
203  read(paramtop, "GFMax", input.param.GFMax);
204 
205  read(paramtop, "nrow", input.param.nrow);
206  read(paramtop, "boundary", input.param.boundary);
207  read(paramtop, "t_srce", input.param.t_srce);
208 
209  read(paramtop, "use_gauge_invar_oper", input.param.use_gauge_invar_oper);
210 
211  }
212  catch (const std::string& e)
213  {
214  QDPIO::cerr << "Error reading data: " << e << std::endl;
215  throw;
216  }
217 
218 
219  // Read in the gauge configuration file name
220  try
221  {
222  read(inputtop, "Cfg", input.cfg);
223  read(inputtop, "Prop", input.prop);
224  }
225  catch (const std::string& e)
226  {
227  QDPIO::cerr << "Error reading data: " << e << std::endl;
228  throw;
229  }
230 }
231 
232 
233 //! Disconnected loops
234 /*! \defgroup t_disc_loop_s Compute disconnected loops
235  * \ingroup testsmain
236  *
237  * Test computing disconnected loops
238  */
239 
240 int main(int argc, char **argv)
241 {
242  // Put the machine into a known state
243  Chroma::initialize(&argc, &argv);
244 
245  // Input parameter structure
246  Propagator_input_t input;
247 
248  // Instantiate xml reader for DATA
249  XMLReader xml_in ;
251  try
252  {
253  xml_in.open(in_name);
254  }
255  catch (...)
256  {
257  QDPIO::cerr << "Error reading input file " << in_name << std::endl;
258  throw;
259  }
260 
261 
262 
263  // Read data
264  read(xml_in, "/propagator", input);
265 
266  // Specify lattice size, shape, etc.
267  Layout::setLattSize(input.param.nrow);
268  Layout::create();
269 
270  // Read in the configuration along with relevant information.
271  multi1d<LatticeColorMatrix> u(Nd);
272 
273  XMLReader gauge_file_xml, gauge_xml;
274  gaugeStartup(gauge_file_xml, gauge_xml, u, input.cfg);
275 
276  // Instantiate XML writer for output
277  XMLFileWriter& xml_out = Chroma::getXMLOutputInstance();
278  push(xml_out, "STAGGERED_SPECTOSCOPY");
279 
280  // Write out the input
281  write(xml_out, "Input", xml_in);
282 
283  // Write out the config header
284  write(xml_out, "Config_info", gauge_xml);
285 
286  push(xml_out, "Output_version");
287  write(xml_out, "out_version", 1);
288  pop(xml_out);
289 
290  xml_out.flush();
291 
292  // Check if the gauge field configuration is unitarized
293  unitarityCheck(u);
294 
295  // Calculate some gauge invariant observables just for info.
296  MesPlq(xml_out, "Observables", u);
297  xml_out.flush();
298 
299  // Fix to the coulomb gauge
300  int n_gf;
301  int j_decay = Nd-1;
302 
303  // coulGauge(u, n_gf, j_decay, input.param.GFAccu, input.param.GFMax, true, input.param.OrPara);
304  // QDPIO::cout << "No. of gauge fixing iterations =" << n_gf << std::endl;
305 
306  // Calcluate plaq on the gauge fixed field
307  MesPlq(xml_out, "Is_this_gauge_invariant", u);
308  xml_out.flush();
309 
310  // Typedefs to save typing
311  typedef LatticeStaggeredFermion T;
312  typedef multi1d<LatticeColorMatrix> P;
313  typedef multi1d<LatticeColorMatrix> Q;
314 
315  // Create a fermion state
317 
318  //
319  // Initialize fermion action
320  //
321  AsqtadFermActParams asq_param;
322  asq_param.Mass = input.param.Mass;
323  asq_param.u0 = input.param.u0;
324  AsqtadFermAct S_f(cfs, asq_param);
325  Handle< FermState<T,P,Q> > state(S_f.createState(u));
326 
327  GroupXML_t inv_param;
328  {
329  XMLBufferWriter xml_buf;
330  write(xml_buf, "InvertParam", input.param.invParam);
331  XMLReader xml_in(xml_buf);
332  inv_param = readXMLGroup(xml_in, "/InvertParam", "invType");
333  }
334  Handle< SystemSolver<LatticeStaggeredFermion> > qprop(S_f.qprop(state,inv_param));
335 
336 
337  LatticeStaggeredPropagator quark_propagator;
338  XMLBufferWriter xml_buf;
339  int ncg_had = 0;
340  int n_count;
341 
342  int Nsamp = input.param.Nsamples;
343  int t_length = input.param.nrow[3];
344  bool use_gauge_invar_oper = input.param.use_gauge_invar_oper ;
345 
346  LatticeStaggeredFermion q_source, psi ;
347 
348  // This is inefficient for memory
349  multi1d<LatticeStaggeredPropagator> stag_prop(8);
350  for(int src_ind = 0; src_ind < 8; ++src_ind)
351  stag_prop[src_ind] = zero ;
352 
353 
354  int t_source = input.param.t_srce[Nd-1] ;
355 
356  // Connected Correlator, use a point source
357  psi = zero;
358  for(int color_source = 0; color_source < Nc; ++color_source) {
359  int spin_source = 0;
360  q_source = zero;
361  srcfil(q_source, input.param.t_srce, color_source);
362 
363  // Compute the propagator
364  SystemSolverResults_t res = (*qprop)(psi, q_source);
365  ncg_had += res.n_count;
366 
367  push(xml_out,"Qprop");
368  write(xml_out, "Mass" , input.param.Mass);
369  write(xml_out, "RsdCG", input.param.invParam.RsdCG);
370  write(xml_out, "n_count", res.n_count);
371  pop(xml_out);
372 
373  FermToProp(psi, quark_propagator, color_source);
374  }
375 
376  // compute the connected correlators
377  // should be loaded in
378  Stag_shift_option type_of_shift = NON_GAUGE_INVAR ;
379 
380  if( use_gauge_invar_oper )
381  {
382  type_of_shift = SYM_GAUGE_INVAR ;
383  }
384  else
385  {
386  type_of_shift = NON_GAUGE_INVAR ;
387  }
388 
389 
390  staggered_pions pseudoscalar(t_length,u,type_of_shift) ;
391  staggered_scalars scalar_meson(t_length,u,type_of_shift) ;
392  staggered_pion_singlet pion_singlet(t_length,u,type_of_shift);
393 
394  write(xml_out, "use_gauge_invar_oper", use_gauge_invar_oper);
395  if( use_gauge_invar_oper )
396  {
397  std::cout << "Using gauge invariant operators " << std::endl ;
398  // pseudoscalar.use_gauge_invar() ;
399  // scalar_meson.use_gauge_invar() ;
400  // pion_singlet.use_gauge_invar() ;
401  }
402  else
403  {
404  std::cout << "Using NON-gauge invariant operators " << std::endl ;
405  // pseudoscalar.use_NON_gauge_invar() ;
406  // scalar_meson.use_NON_gauge_invar() ;
407  // pion_singlet.use_NON_gauge_invar() ;
408  }
409 
410 
411  stag_prop[0] = quark_propagator ;
412  pseudoscalar.compute(stag_prop, j_decay);
413  scalar_meson.compute(stag_prop, j_decay);
414 
415 
416 
417  //
418  // Calculate the connected part of the taste singlet pseudoscalar
419  // meson.
420  //
421  // The code should be gauge fixed at this point
422  // or gauge invariant operators should be used.
423  //
424 
425 
426  LatticeStaggeredPropagator quark_propagator_4link ;
427 
428  // Connected Correlator, use a point source at: 1111
429  psi = zero;
430  for(int color_source = 0; color_source < Nc; ++color_source) {
431  int spin_source = 0;
432  q_source = zero;
433  multi1d<int> coord(Nd);
434  coord[0]=1; coord[1] = 1; coord[2] = 1; coord[3] = 1;
435  srcfil(q_source, coord,color_source ) ;
436 
437  SystemSolverResults_t res = (*qprop)(psi, q_source);
438 
439  ncg_had += n_count;
440  push(xml_out,"Qprop");
441  write(xml_out, "Mass" , input.param.Mass);
442  write(xml_out, "RsdCG", input.param.invParam.RsdCG);
443  write(xml_out, "n_count", res.n_count);
444  pop(xml_out);
445 
446  FermToProp(psi, quark_propagator_4link, color_source);
447  }
448 
449 
450  pion_singlet.compute(quark_propagator,quark_propagator_4link,j_decay);
451 
452  //
453  // write the connected correlators to disk
454  //
455 
456 
457  push(xml_out, "CONNECTED");
458  pseudoscalar.dump(t_source,xml_out);
459  scalar_meson.dump(t_source,xml_out);
460  pion_singlet.dump(t_source,xml_out ) ;
461  pop(xml_out);
462 
463 
464  //
465  // ----- compute disconnected diagrams -----
466  //
467 
468  // there are now new arguments to this function
469 #if 0
470  ks_local_loops(qprop,q_source,psi,u,xml_out, xml_in,
471  t_length,input.param.Mass,Nsamp,
472  input.param.invParam.RsdCG,input.param.CFGNO,
473  input.param.volume_source) ;
474 #endif
475 
476  // comple the final tag
477  pop(xml_out);
478 
479  xml_out.close();
480  xml_in.close();
481 
482  // Time to bolt
484 
485  QDPIO::cout << "CHROMA_RUN_COMPLETE " << std::endl;
486  exit(0);
487 }
Primary include file for CHROMA in application codes.
Asqtad staggered fermion action.
Create a simple ferm connection state.
Class for counted reference semantics.
Definition: handle.h:33
void dump(int t_source, XMLWriter &xml_out)
Definition: hadron_corr_s.h:33
void compute(LatticeStaggeredPropagator local_quark_prop, LatticeStaggeredPropagator four_shift_quark_prop, int j_decay)
Definition: pion_sing_s.cc:63
void compute(multi1d< LatticeStaggeredPropagator > &quark_props, int j_decay)
Definition: pions_s.cc:69
void compute(multi1d< LatticeStaggeredPropagator > &quark_props, int j_decay)
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.
FermType
Fermion type.
CfgType
Configuration 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_STAGGERED
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
multi1d< int > coord(Nd)
int j_decay
Definition: meslate.cc:22
Nd
Definition: meslate.cc:74
multi1d< LatticeColorMatrix > P
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
QDP_error_exit("too many BiCG iterations", n_count, rsd_sq, cp, c, re_rvr, im_rvr, re_a, im_a, re_b, im_b)
static multi1d< LatticeColorMatrix > u
int n_count
Definition: invbicg.cc:78
LinOpSysSolverMGProtoClover::Q Q
push(xml_out,"Condensates")
LinOpSysSolverMGProtoClover::T T
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
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
void ks_local_loops(Handle< SystemSolver< LatticeStaggeredFermion > > &qprop, LatticeStaggeredFermion &q_source, LatticeStaggeredFermion &psi, const multi1d< LatticeColorMatrix > &u, XMLWriter &xml_out, bool gauge_shift, bool sym_shift, bool loop_checkpoint, int t_length, Real Mass, int Nsamp, Real RsdCG, int CFGNO, VolSrc_type volume_source, int src_seperation, int j_decay)
@ GAUSSIAN
Definition: enum_loops_s.h:18
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
Params for asqtad ferm acts.
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
PropType prop_type
Real OrPara
SysSolverCGParams invParam
bool use_gauge_invar_oper
int Nsamples
VolSrc_type volume_source
FermType FermTypeP
multi1d< int > t_srce
multi1d< int > nrow
Definition: qpropadd.cc:18
CfgType cfg_type
Real GFAccu
multi1d< int > boundary
Propagators.
std::string prop_file
int main(int argc, char **argv)