CHROMA
spectrum_s.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Main code for spectrum measurements
3  */
4 
5 #include "chroma.h"
6 #include "meas/gfix/coulgauge.h"
7 
8 using namespace Chroma;
9 
10 void setup_levelthree(QDP::multi1d<int> nrow, int *argc, char ***argv ) ;
11 
12 
13 
14  bool linkageHack(void)
15 {
16  bool foo = true;
17 
18  // Inline Measurements
22 
23  return foo;
24 }
25 
26 
27 //! Spectrum measurements
28 /*! \defgroup spectrumain Spectrum measurements
29  * \ingroup main
30  *
31  * Main program for spectrum measurements
32  */
33 
34 int main(int argc, char **argv)
35 {
36  // Put the machine into a known state
37  Chroma::initialize(&argc, &argv);
38 
39  START_CODE();
40 
41  linkageHack();
42  QDPIO::cerr << "Staggered measurement code." << std::endl;
43 
44  XMLReader xml_in ;
46  try
47  {
48  xml_in.open(in_name);
49  }
50  catch (...)
51  {
52  QDPIO::cerr << "Error reading input file " << in_name << std::endl;
53  QDPIO::cerr << "The input file name can be passed via the -i flag " << std::endl;
54  QDPIO::cerr << "The default name is ./DATA" << std::endl;
55  throw;
56  }
57 
58  // Read data
59  InlineStaggeredSpectrumParams input(xml_in, "/spectrum_s");
60  InlineStaggeredSpectrum meas(input);
61 
62  // Specify lattice size, shape, etc.
63  Layout::setLattSize(input.param.nrow);
64  Layout::create();
65 
66 #if defined(BUILD_CPS_ASQTAD_INVERTER)
67  setup_levelthree(input.param.nrow, &argc, &argv ) ;
68 #endif
69 
70 
71  // Read gauge field info
72  Cfg_t cfg;
73  try
74  {
75  read(xml_in, "/spectrum_s/Cfg", cfg);
76  }
77  catch(const std::string& e)
78  {
79  QDP_error_exit("Error reading in spectrum_s: %s", e.c_str());
80  }
81 
82  // Start up the gauge field
83  multi1d<LatticeColorMatrix> u(Nd);
84  XMLBufferWriter config_xml;
85  {
86  XMLReader gauge_file_xml, gauge_xml;
87 
88  QDPIO::cout << "Initialize Gauge field" << std::endl;
89  gaugeStartup(gauge_file_xml, gauge_xml, u, cfg);
90  QDPIO::cout << "Gauge field initialized!" << std::endl;
91 
92  config_xml << gauge_xml;
93  }
94 
95  // Check if the gauge field configuration is unitarized
97 
98  bool do_gauge_transform = false;
99  read(xml_in, "/spectrum_s/Param/do_gauge_transform",do_gauge_transform );
100  if( do_gauge_transform )
101  {
102  rgauge(u);
103  QDPIO::cout << "Random gauge transform on gauge fields done." << std::endl;
104  }
105 
106 
107  // Output
108  XMLFileWriter& xml_out = Chroma::getXMLOutputInstance();
109 
110 
111  bool gauge_invar_oper = false;
112  read(xml_in, "/spectrum_s/Param/gauge_invar_oper",gauge_invar_oper );
113 
114  // GAUGE FIX
115  if( !gauge_invar_oper){
116  //not using covariant shifts, should gauge-fix
117 
118  //read some input the sloppy way
119  Real GFAccu; // Gauge fixing tolerance
120  Real OrPara; // Gauge fixing over-relaxation param
121  int GFMax; // Maximum gauge fixing iterations
122  int j_decay; // the t-direction
123 
124  read(xml_in, "/spectrum_s/Param/GFAccu", GFAccu );
125  read(xml_in, "/spectrum_s/Param/OrPara", OrPara );
126  read(xml_in, "/spectrum_s/Param/GFMax", GFMax );
127  read(xml_in, "/spectrum_s/Param/j_decay",j_decay );
128  int n_gf;
129 
130 
131  QDPIO::cout << "Not using covariant shift operators.";
132  QDPIO::cout << "Must gauge-fix" << std::endl;
133 
134  QDPIO::cout << "Starting to fix to Coulomb gauge" << std::endl;
135  coulGauge(u, n_gf, j_decay, GFAccu, GFMax, true, OrPara);
136  QDPIO::cout << "No. of gauge fixing iterations =" << n_gf << std::endl;
137  }
138 
139 
140  // Reset and set the default gauge field
142  InlineDefaultGaugeField::set(u, config_xml);
143 
144  // Do the measurement
145  try
146  {
147  unsigned long cur_update = 0;
148  meas(cur_update, xml_out);
149  }
150  catch(std::bad_cast)
151  {
152  QDPIO::cerr << "SPECTRUM_S: caught cast error" << std::endl;
153  QDP_abort(1);
154  }
155  catch(const std::string& e)
156  {
157  QDPIO::cerr << "SPECTRUM_S: Caught Exception: " << e << std::endl;
158  QDP_abort(1);
159  }
160  catch(std::exception& e)
161  {
162  QDPIO::cerr << "SPECTRUM_S: Caught standard library exception: " << e.what() << std::endl;
163  QDP_abort(1);
164  }
165  catch(...)
166  {
167  QDPIO::cerr << "SPECTRUM_S: caught generic exception during measurement" << std::endl;
168  QDP_abort(1);
169  }
170 
171  // Reset the default gauge field
173 
174  xml_out.flush();
175  xml_out.close();
176 
177  END_CODE();
178 
179  // Time to bolt
181 
182  exit(0);
183 }
Primary include file for CHROMA in application codes.
Inline measurement of Wilson loops.
Coulomb (and Landau) gauge fixing.
void read(XMLReader &xml, const std::string &path, AsqtadFermActParams &param)
Read parameters.
void unitarityCheck(const multi1d< LatticeColorMatrixF3 > &u)
Check the unitarity of color matrix in SU(N)
Definition: unit_check.cc:20
void rgauge(multi1d< LatticeColorMatrix > &u, LatticeColorMatrix &g)
Do a random gauge transformation on the u fields.
Definition: rgauge.cc:24
void gaugeStartup(XMLReader &gauge_file_xml, XMLReader &gauge_xml, multi1d< LatticeColorMatrix > &u, Cfg_t &cfg)
Initialize the gauge fields.
void coulGauge(multi1d< LatticeColorMatrix > &u, int &n_gf, int j_decay, const Real &GFAccu, int GFMax, bool OrDo, const Real &OrPara)
Coulomb (and Landau) gauge fixing.
Definition: coulgauge.cc:37
void reset()
Reset the default gauge field state.
void set(const multi1d< LatticeColorMatrix > &u, XMLBufferWriter &record_xml)
Set the default gauge field.
int j_decay
Definition: meslate.cc:22
Nd
Definition: meslate.cc:74
bool registerAll()
Register all the factories.
bool registerAll()
Register all the factories.
bool registerAll()
Register all the factories.
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
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
std::string getXMLInputFileName()
Get input file name.
Definition: chroma_init.cc:88
START_CODE()
XMLFileWriter & getXMLOutputInstance()
Get xml output instance.
Definition: chroma_init.cc:359
::std::string string
Definition: gtest.h:1979
void setup_levelthree(QDP::multi1d< int > nrow, int *argc, char ***argv)
int main(int argc, char **argv)
Definition: spectrum_s.cc:34
Gauge configuration structure.
Definition: cfgtype_io.h:16
struct Chroma::InlineStaggeredSpectrumParams::Param_t param