CHROMA
t_propagator_nrqcd.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Main code for NRQCD propagator generation
3  *
4  *
5  *
6  * This is a template program to help the
7  * Glasgow group impliment the
8  * NRQCD action to whatever order they want.
9  *
10  * See Thacker and Lepage , PRD 43, 1991 ,196
11  *
12  *
13  * To start this off I will just add in the
14  * additional code to this file. Eventally (but quickly),
15  * the fermion operator will be put in the
16  * appropriate place (whatever that is),
17  *
18  * The NRQCD evolution equation is not a natural std::map
19  * to the chroma/qdp++ system. Apply the operators to the
20  * full lattice but only look at a specific time slice,
21  * using the set notation.
22  *
23  * For NRQCD code need the field strength (and derivatives#
24  * of.
25  *
26  * This code needs to be converted from SZIN.
27  * ./actions/ferm/fermacts/prec_clover_fermact_w.cc
28  *
29  *
30  * LATTICE_FIELD_STRENGTH(f);
31  * To get at MesField (u, f);
32  *
33  *
34  */
35 
36 #include <iostream>
37 #include <cstdio>
38 
39 #define MAIN
40 
41 // Include everything...
42 #include "chroma.h"
43 
44 
45 using namespace Chroma;
46 
47 
48 // ----- start of prototypes for NRQCD -----
49 void time_evolve(LatticeFermion & Gplus, const LatticeFermion & Gnow, int t ) ;
50 
51 void compute_nrqcd_prop(LatticeFermion & G,
52  const LatticeFermion & Gsource,
53  const multi1d<LatticeColorMatrix>& u,
54  const Real Mass,
55  int n, int nt ) ;
56 
57 // ----- start of prototypes for NRQCD -----
58 
59 
60 // copied from t_ritz.cc
62 
63 
64 /*
65  * Input
66  */
67 
68 
69 // Parameters which must be determined from the XML input
70 // and written to the XML output
71 struct Param_t
72 {
74  Real Mass; // Staggered mass
75  Real u0; // Tadpole Factor
76 
77  GaugeStartType cfg_type; // storage order for stored gauge configuration
78  PropType prop_type; // storage order for stored propagator
79 
80  GroupXML_t invParam;
81 
82  Real GFAccu, OrPara; // Gauge fixing tolerance and over-relaxation param
83  int GFMax; // Maximum gauge fixing iterations
84 
85  multi1d<int> nrow;
86  multi1d<int> boundary;
87  multi1d<int> t_srce;
88 };
89 
90 
91 struct Prop_t
92 {
93  std::string source_file;
94  std::string prop_file;
95 };
96 
97 struct Propagator_input_t
98 {
99  IO_version_t io_version;
100  Param_t param;
101  Cfg_t cfg;
102  Prop_t prop;
103 };
104 
105 
106 //
107 void read(XMLReader& xml, const std::string& path, Prop_t& input)
108 {
109  XMLReader inputtop(xml, path);
110 
111 // read(inputtop, "source_file", input.source_file);
112  read(inputtop, "prop_file", input.prop_file);
113 }
114 
115 
116 
117 // Reader for input parameters
118 void read(XMLReader& xml, const std::string& path, Propagator_input_t& input)
119 {
120  XMLReader inputtop(xml, path);
121 
122 
123  // First, read the input parameter version. Then, if this version
124  // includes 'Nc' and 'Nd', verify they agree with values compiled
125  // into QDP++
126 
127  // Read in the IO_version
128  try
129  {
130  read(inputtop, "IO_version/version", input.io_version.version);
131  }
132  catch (const std::string& e)
133  {
134  QDPIO::cerr << "Error reading data: " << e << std::endl;
135  throw;
136  }
137 
138 
139  // Currently, in the supported IO versions, there is only a small difference
140  // in the inputs. So, to make code simpler, extract the common bits
141 
142  // Read the uncommon bits first
143  try
144  {
145  XMLReader paramtop(inputtop, "param"); // push into 'param' group
146 
147  switch (input.io_version.version)
148  {
149  /**************************************************************************/
150  case 1 :
151  /**************************************************************************/
152  break;
153 
154  default :
155  /**************************************************************************/
156 
157  QDPIO::cerr << "Input parameter version " << input.io_version.version << " unsupported." << std::endl;
158  QDP_abort(1);
159  }
160  }
161  catch (const std::string& e)
162  {
163  QDPIO::cerr << "Error reading data: " << e << std::endl;
164  throw;
165  }
166 
167 
168  // Read the common bits
169  try
170  {
171  XMLReader paramtop(inputtop, "param"); // push into 'param' group
172 
173  {
174  std::string ferm_type_str;
175  read(paramtop, "FermTypeP", ferm_type_str);
176  if (ferm_type_str == "WILSON") {
178  }
179  }
180 
181  // GTF NOTE: I'm going to switch on FermTypeP here because I want
182  // to leave open the option of treating masses differently.
183  switch (input.param.FermTypeP) {
184  case FERM_TYPE_WILSON :
185 
186  QDPIO::cout << " PROPAGATOR: Propagator for NRQCD" << std::endl;
187 
188  read(paramtop, "Mass", input.param.Mass);
189  read(paramtop, "u0" , input.param.u0);
190 
191  break;
192 
193  default :
194  QDP_error_exit("Fermion type not supported\n.");
195  }
196 
197  {
198  std::string cfg_type_str;
199  read(paramtop, "cfg_type", cfg_type_str);
200  if (cfg_type_str == "NERSC") {
202  }
203  else if (cfg_type_str == "HOT") {
204  input.param.cfg_type = HOT_START;
205  } else if (cfg_type_str == "COLD") {
206  input.param.cfg_type = COLD_START;
207  } else {
208  QDP_error_exit("Only know NERSC/HOT/COLD files yet");
209  }
210 
211  }
212 
213  {
214  std::string prop_type_str;
215  read(paramtop, "prop_type", prop_type_str);
216  if (prop_type_str == "SZIN") {
218  } else {
219  QDP_error_exit("Dont know non SZIN files yet");
220  }
221  }
222 
223 // read(paramtop, "invType", input.param.invType);
224  read(paramtop, "RsdCG", input.param.invParam.RsdCG);
225  read(paramtop, "MaxCG", input.param.invParam.MaxCG);
226  // read(paramtop, "GFAccu", input.param.GFAccu);
227  // read(paramtop, "OrPara", input.param.OrPara);
228  // read(paramtop, "GFMax", input.param.GFMax);
229 
230  read(paramtop, "nrow", input.param.nrow);
231  read(paramtop, "boundary", input.param.boundary);
232  read(paramtop, "t_srce", input.param.t_srce);
233  }
234  catch (const std::string& e)
235  {
236  QDPIO::cerr << "Error reading data: " << e << std::endl;
237  throw;
238  }
239 
240 
241  // Read in the gauge configuration file name
242  try
243  {
244  // read(inputtop, "Cfg", input.cfg);
245  read(inputtop, "Prop", input.prop);
246  }
247  catch (const std::string& e)
248  {
249  QDPIO::cerr << "Error reading data: " << e << std::endl;
250  throw;
251  }
252 }
253 
254 //! Propagator generation
255 /*! \defgroup propagator Propagator generation
256  * \ingroup testsmain
257  *
258  * Main program for propagator generation.
259  */
260 
261 int main(int argc, char **argv)
262 {
263  // Put the machine into a known state
264  Chroma::initialize(&argc, &argv);
265 
266  // Input parameter structure
267  Propagator_input_t input;
268 
269  // Instantiate xml reader for DATA
270  // XMLReader xml_in("INPUT_W.xml");
271  XMLFileWriter& xml_out = Chroma::getXMLOutputInstance();
272 
273  // Read data
274  read(xml_in, "/propagator", input);
275 
276  // Specify lattice size, shape, etc.
277  Layout::setLattSize(input.param.nrow);
278  Layout::create();
279 
280  // Read in the configuration along with relevant information.
281  multi1d<LatticeColorMatrix> u(Nd);
282 
283  XMLReader gauge_xml;
284 
285  QDPIO::cout << "Calculation for SU(" << Nc << ")" << std::endl;
286  switch (input.param.cfg_type)
287  {
288  case FILE_START_NERSC :
289  // su3 specific (at the moment)
290  input.cfg.cfg_file = "t_nersc.cfg" ;
291  readArchiv(gauge_xml, u, input.cfg.cfg_file);
292  break;
293  case COLD_START:
294  for(int j = 0; j < Nd; j++) {
295  u(j) = Real(1);
296  }
297  QDPIO::cout << "COLD unit configuration created" << std::endl;
298  break;
299  case HOT_START :
300  // create a hot configuration
301  for(int dir = 0 ; dir < Nd ; ++dir)
302  {
303  gaussian(u[dir]);
304  reunit(u[dir]) ;
305  }
306  QDPIO::cout << "Hot/Random configuration created" << std::endl;
307  break;
308  default :
309  QDP_error_exit("Configuration type is unsupported.");
310  }
311 
312  // Check if the gauge field configuration is unitarized
313  unitarityCheck(u);
314 
315  // Instantiate XML writer for XMLDAT
316  XMLFileWriter& xml_out = Chroma::getXMLOutputInstance();
317  push(xml_out, "propagator");
318 
319  // Write out the input
320  write(xml_out, "Input", xml_in);
321 
322  // Write out the config header
323  write(xml_out, "Config_info", gauge_xml);
324 
325  // Write out the source header
326  // write(xml_out, "Source_info", source_xml);
327 
328  push(xml_out, "Output_version");
329  write(xml_out, "out_version", 1);
330  pop(xml_out);
331 
332  xml_out.flush();
333 
334 
335  // Calculate some gauge invariant observables just for info.
336  MesPlq(xml_out, "Observables", u);
337  xml_out.flush();
338 
339  //
340  // gauge invariance test
341  //
342 
343  // this parameter will be read from the input file
344  bool do_gauge_transform ;
345  do_gauge_transform = false ;
346  // do_gauge_transform = true ;
347 
348 
349  if( do_gauge_transform )
350  {
351  // gauge transform the gauge fields
352  multi1d<LatticeColorMatrix> u_trans(Nd);
353 
354  // create a random gauge transform
355  LatticeColorMatrix v ;
356 
357  gaussian(v);
358  reunit(v) ;
359 
360  for(int dir = 0 ; dir < Nd ; ++dir)
361  {
362  u_trans[dir] = v*u[dir]*adj(shift(v,FORWARD,dir)) ;
363  u[dir] = u_trans[dir] ;
364  }
365 
366  QDPIO::cout << "Random gauge transform done" << std::endl;
367 
368  } // end of gauge transform
369 
370 
371  int j_decay = Nd-1;
372 
373 
374  // set up the calculation of quark propagators
375 
376  // Create a fermion BC. Note, the handle is on an ABSTRACT type.
378 
379  //
380  // Initialize fermion action
381  //
382  UnprecWilsonFermAct S_f(fbc,input.param.Mass);
383 
384  // Set up a state for the current u,
385  Handle<const ConnectState > state(S_f.createState(u));
386 
387 
388  //
389  // Loop over the source color and spin , creating the source
390  // and calling the relevant propagator routines.
391  //
392  //
393  LatticePropagator quark_propagator;
394  XMLBufferWriter xml_buf;
395  int ncg_had = 0;
396  int n_count;
397 
398  LatticeFermion q_source, psi;
399 
400  int t_source = 0;
401 #ifdef BBBBBBBBBBBB
402  QDPIO::cout << "Source time slice = " << t_source << std::endl;
403 
404  for(int color_source = 0; color_source < Nc; ++color_source)
405  for(int spin_source = 0 ; spin_source < Ns ; ++spin_source)
406  {
407  QDPIO::cout << "Inversion for Color = " << color_source << std::endl;
408  QDPIO::cout << "Inversion for Spin = " << spin_source << std::endl;
409 
410 
411  q_source = zero ;
412  multi1d<int> coord(Nd);
413  coord[0]=0; coord[1] = 0; coord[2] = 0; coord[3] = 0;
414  srcfil(q_source, coord, color_source, spin_source);
415 
416  // initial guess is zero
417  psi = zero; // note this is ``zero'' and not 0
418 
419 
420  // Compute the propagator for given source color/spin
421  // int n_count;
422 
423  const int n_nrqcd = 3 ; // read in from xml
424  compute_nrqcd_prop(psi,q_source,u,n_nrqcd ,input.param.Mass,nt);
425 
426 
427  // ncg_had += n_count;
428 
429  /*
430  * Move the solution to the appropriate components
431  * of quark propagator.
432  */
433  FermToProp(psi, quark_propagator, color_source, spin_source);
434  } //spin / color_source
435 
436 #endif
437 
438  // compute the meson spectrum
439 
440  // source timeslice
441  int t0 = 0 ;
442 
443  // create averaged Fourier phases with (mom)^2 <= 10
444  SftMom phases(10, true, j_decay) ;
445 
446  mesons(quark_propagator,quark_propagator,
447  phases, t0, xml_out,
448  "Point_Point_NRQCD_Mesons") ;
449 
450 
451  xml_out.close();
452  xml_in.close();
453 
454  // Time to bolt
456 
457  exit(0);
458 }
459 
460 
461 class TimeSliceFunc : public SetFunc
462 {
463 public:
464  TimeSliceFunc(int dir): dir_decay(dir) {}
465 
466  int operator() (const multi1d<int>& coordinate) const {return coordinate[dir_decay];}
467  int numSubsets() const {return Layout::lattSize()[dir_decay];}
468 
469  int dir_decay;
470 
471 private:
472  TimeSliceFunc() {} // hide default constructor
473 };
474 
475 /*
476 
477  G_[t+1] = U_t\dagger G[t]
478 
479  for time slice t
480 
481 
482 */
483 
484 void time_evolve(LatticeFermion & Gplus,
485  const LatticeFermion & Gnow,
486  const multi1d<LatticeColorMatrix>& u,
487  int t )
488 {
489  const int tdir = 3 ;
490 
491  Set timeslice;
492  timeslice.make(TimeSliceFunc(tdir)) ;
493 
494  Subset this_time = timeslice[t+1] ;
495 
496  LatticeFermion tmp = shift(adj(u[tdir])*Gnow, BACKWARD, tdir);
497  Gplus[this_time] = tmp ;
498  // Gplus = tmp ; // DEBUG doesn't work
499 
500 }
501 
502 
503 /*
504 
505  Apply the lowest order NRQCD Hamiltonian to
506  a LatticeFermion on a specific timeslice.
507 
508 
509  H = -1 \sum_i \Delta_i \Delta_-i
510  2M
511 
512 
513  Gout = H Gin on time slice t
514 */
515 
516 void apply_lowest_ke(LatticeFermion & Gout,
517  const LatticeFermion & Gin,
518  const multi1d<LatticeColorMatrix>& u,
519  const Real Mass,
520  int t )
521 {
522  const int tdir = 3 ;
523 
524  Set timeslice;
525  timeslice.make(TimeSliceFunc(tdir)) ;
526 
527 
528  Subset this_time = timeslice[t] ;
529 
530  LatticeFermion Gout_all ;
531 
532  Gout_all = Gin / Mass ;
533 
534  LatticeFermion tmp ;
535 
536  for(int dir = 0 ; dir < 3 ; ++dir)
537  {
538  // positive direction
539  tmp = Gin ;
540  displacement(u,tmp,1,dir);
541  Gout_all -= tmp/(2.0*Mass) ;
542 
543  // negative direction
544  tmp = Gin ;
545  displacement(u,tmp,-1,dir);
546  Gout_all -= tmp/(2.0*Mass) ;
547 
548 
549  }
550 
551 
552  // restrict to the timeslice
553  Gout[this_time] = Gout_all ;
554 
555 }
556 
557 
558 
559 
560 
561 //
562 // Compute the NRQCD propagator from a
563 // source in Gsource
564 //
565 // Impliment equation 28 in the Thacker/Lepage paper
566 //
567 //
568 //
569 
570 void compute_nrqcd_prop(LatticeFermion & G,
571  const LatticeFermion & Gsource,
572  const multi1d<LatticeColorMatrix>& u,
573  const Real Mass,
574  int n, int nt )
575 {
576 
577  LatticeFermion Gold ;
578  LatticeFermion G_tmp ;
579 
580  Gold = Gsource ;
581 
582  for(int t = 0 ; t < nt ; ++t)
583  {
584 
585  for(int i = 0 ; i < n ; ++i)
586  {
587  // apply ( 1 - H /n )
588  apply_lowest_ke(G_tmp,Gold,u,Mass,t);
589 
590  G = G - G_tmp / n ;
591  Gold = G ;
592  }
593 
594  // evolve forward one time step
595  time_evolve(G, Gold, u,t);
596  Gold = G ;
597 
598  }
599 
600 }
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
Function object used for constructing the time-slice set.
Definition: barQll_w.h:95
int operator()(const multi1d< int > &coordinate) const
Definition: barQll_w.h:99
Unpreconditioned Wilson fermion action.
int numSubsets() const
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 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.
@ FERM_TYPE_WILSON
LatticePropagator displacement(const multi1d< LatticeColorMatrix > &u, const LatticePropagator &chi, int length, int dir)
Apply a displacement operator to a lattice field.
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
unsigned j
Definition: ldumul_w.cc:35
unsigned n
Definition: ldumul_w.cc:36
multi1d< int > coord(Nd)
int j_decay
Definition: meslate.cc:22
int t
Definition: meslate.cc:37
Nd
Definition: meslate.cc:74
multi1d< LatticeColorMatrix > G
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
gaussian(aux)
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
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > const multi1d< Real > & Mass
Definition: pbg5p_w.cc:29
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
push(xml_out,"Condensates")
int i
Definition: pbg5p_w.cc:55
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
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
#define BACKWARD
Definition: primitives.h:83
Gauge configuration structure.
Definition: cfgtype_io.h:16
std::string cfg_file
Definition: cfgtype_io.h:18
Hold group xml and type id.
Parameters for running program.
Definition: qpropadd.cc:17
PropType prop_type
SysSolverCGParams invParam
FermType FermTypeP
multi1d< int > t_srce
multi1d< int > nrow
Definition: qpropadd.cc:18
CfgType cfg_type
multi1d< int > boundary
Propagators.
std::string prop_file
IO_version_t io_version
GaugeStartType
int main(int argc, char **argv)
@ HOT_START
@ COLD_START
@ FILE_START_NERSC
void compute_nrqcd_prop(LatticeFermion &G, const LatticeFermion &Gsource, const multi1d< LatticeColorMatrix > &u, const Real Mass, int n, int nt)
void apply_lowest_ke(LatticeFermion &Gout, const LatticeFermion &Gin, const multi1d< LatticeColorMatrix > &u, const Real Mass, int t)
void time_evolve(LatticeFermion &Gplus, const LatticeFermion &Gnow, int t)