CHROMA
qpropgfix.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Applies gauge transformation matrices on a propagator
3  */
4 
5 #include "chroma.h"
6 
7 using namespace Chroma;
8 
9 /*
10  * Input
11  */
12 
13 
14 
15 // Parameters which must be determined from the XML input
16 // and written to the XML output
17 struct Param_t
18 {
19  multi1d<int> nrow; // Lattice dimension
20 };
21 
22 struct Prop_t
23 {
26 
28  QDP_volfmt_t prop_out_volfmt; // volume format (SINGLEFILE or MULTIFILE)
29 };
30 
32 {
36 };
37 
38 
39 
40 //! Propagator parameters
41 void read(XMLReader& xml, const std::string& path, Prop_t& input)
42 {
43  XMLReader inputtop(xml, path);
44 
45  read(inputtop, "prop_in_file", input.prop_in_file);
46  read(inputtop, "gfix_in_file", input.gfix_in_file);
47 
48  read(inputtop, "prop_out_file", input.prop_out_file);
49  read(inputtop, "prop_out_volfmt", input.prop_out_volfmt); // singlefile or multifile
50 }
51 
52 
53 //! Parameters for running code
54 void read(XMLReader& xml, const std::string& path, Param_t& param)
55 {
56  XMLReader paramtop(xml, path);
57 
58  int version;
59  read(paramtop, "version", version);
60 
61  switch (version)
62  {
63  case 1:
64  /**************************************************************************/
65  break;
66 
67  default :
68  /**************************************************************************/
69  QDPIO::cerr << "Input parameter version " << version << " unsupported." << std::endl;
70  QDP_abort(1);
71  }
72 
73 
74  read(paramtop, "nrow", param.nrow);
75 }
76 
77 
78 // Reader for input parameters
79 void read(XMLReader& xml, const std::string& path, QpropGFix_input_t& input)
80 {
81  XMLReader inputtop(xml, path);
82 
83  // Read all the input groups
84  try
85  {
86  // Read program parameters
87  read(inputtop, "Param", input.param);
88 
89  // Read in the gauge configuration info
90  read(inputtop, "Cfg", input.cfg);
91 
92  // Read in the propagator file info
93  read(inputtop, "Prop", input.prop);
94  }
95  catch (const std::string& e)
96  {
97  QDPIO::cerr << "Error reading qproptransf data: " << e << std::endl;
98  throw;
99  }
100 }
101 
102 
103 //! Applies gauge transformation matrices on a propagator
104 /*! \defgroup qpropgfix Gauge fix a propagator
105  * \ingroup main
106  *
107  * Main program for gauge fixing a propagator
108  */
109 
110 int main(int argc, char *argv[])
111 {
112  // Put the machine into a known state
113  Chroma::initialize(&argc, &argv);
114 
115  START_CODE();
116 
117  // Parameter structure for the input
118  QpropGFix_input_t input;
119 
120  // Instantiate xml reader for DATA
121  XMLReader xml_in(Chroma::getXMLInputFileName());
122 
123  // Read data
124  read(xml_in, "/qpropgfix", input);
125 
126  // Setup QDP
127  Layout::setLattSize(input.param.nrow);
128  Layout::create();
129 
130  QDPIO::cout << "QPROPGFIX: propagator gauge fixing utility" << std::endl;
131 
132  XMLFileWriter& xml_out = Chroma::getXMLOutputInstance();
133  push(xml_out, "qpropgfix");
134 
135  proginfo(xml_out); // Print out basic program info
136 
137  write(xml_out, "input", xml_in); // save a copy of the input
138  xml_out.flush();
139 
140  /*
141  * Now read them thangs...
142  */
143  /*
144  * Read in the gauge fixed configuration along with relevant information.
145  */
146  multi1d<LatticeColorMatrix> u(Nd);
147  XMLReader gauge_file_xml, gauge_xml;
148 
149  // Startup gauge
150  gaugeStartup(gauge_file_xml, gauge_xml, u, input.cfg);
151 
152  /*
153  * Read in the gauge transformation matrices
154  */
155  LatticeColorMatrix g;
156  XMLReader transf_file_xml, transf_xml;
157  {
158  QDPFileReader from(transf_xml, input.prop.gfix_in_file, QDPIO_SERIAL);
159 
160  LatticeColorMatrixF g_f;
161  read(from,transf_xml,g_f); // Always save in single precision!
162  g = g_f;
163 
164  close(from);
165  }
166 
167 
168  /*
169  * Read in a Chroma prop
170  */
171  LatticePropagator prop;
172  XMLReader prop_in_xml, prop_in_file_xml;
173 
174  push(xml_out,"SciDAC_propagator");
175  write(xml_out, "prop_in_file", input.prop.prop_in_file);
176 
177  readQprop(prop_in_file_xml, prop_in_xml, prop,
178  input.prop.prop_in_file, QDPIO_SERIAL);
179 
180  write(xml_out, "File_xml", prop_in_file_xml);
181  write(xml_out, "Record_xml", prop_in_xml);
182  pop(xml_out);
183 
184 
185  // Try to invert this record XML into a source struct
186  // Also pull out the id of this source
188  PropSourceConst_t source_header;
189  try
190  {
191  read(prop_in_xml, "/Propagator/ForwardProp", prop_header);
192  read(prop_in_xml, "/Propagator/PropSource", source_header);
193  }
194  catch (const std::string& e)
195  {
196  QDPIO::cerr << "Error extracting forward_prop header: " << e << std::endl;
197  throw;
198  }
199 
200  // Derived from input prop
201  int j_decay = source_header.j_decay;
202  multi1d<int> t_srce = source_header.getTSrce();
203 
204 
205  // Sanity check - write out the propagator (pion) correlator in the j_decay direction
206  {
207  // Initialize the slow Fourier transform phases
208  SftMom phases(0, true, j_decay);
209 
210  multi1d<Double> prop_corr = sumMulti(localNorm2(prop),
211  phases.getSet());
212 
213  push(xml_out, "Prop_correlator");
214  write(xml_out, "prop_corr", prop_corr);
215  pop(xml_out);
216  }
217 
218  xml_out.flush();
219 
220 
221  /*
222  * Gauge transform the beasty
223  */
224  {
225  LatticePropagator tmp = g * prop * adj(peekSite(g,t_srce));
226  prop = tmp;
227  }
228 
229 
230 
231  // Sanity check - write out the propagator (pion) correlator in the j_decay direction
232  {
233  // Initialize the slow Fourier transform phases
234  SftMom phases(0, true, j_decay);
235 
236  multi1d<Double> gfix_prop_corr = sumMulti(localNorm2(prop),
237  phases.getSet());
238 
239  push(xml_out, "GFixProp_correlator");
240  write(xml_out, "gfix_prop_corr", gfix_prop_corr);
241  pop(xml_out);
242  }
243 
244 
245  /*
246  * Now write them thangs...
247  */
248  {
249  XMLBufferWriter prop_out_file_xml;
250  push(prop_out_file_xml, "propagator");
251  int id = 0; // NEED TO FIX THIS - SOMETHING NON-TRIVIAL NEEDED
252  write(prop_out_file_xml, "id", id);
253  pop(prop_out_file_xml);
254 
255  XMLBufferWriter prop_out_record_xml;
256  push(prop_out_record_xml, "Propagator");
257  write(prop_out_record_xml, "ForwardProp", prop_header);
258  write(prop_out_record_xml, "PropSource", source_header);
259  write(prop_out_record_xml, "Config_info", gauge_xml);
260  pop(prop_out_record_xml);
261 
262  // Write the source
263  writeQprop(prop_out_file_xml, prop_out_record_xml, prop,
264  input.prop.prop_out_file, input.prop.prop_out_volfmt,
265  QDPIO_SERIAL);
266  }
267 
268  pop(xml_out); // qpropgfix
269 
270  END_CODE();
271 
272  // Time to bolt
274 
275  exit(0);
276 }
Primary include file for CHROMA in application codes.
Fourier transform phase factor support.
Definition: sftmom.h:35
const Set & getSet() const
The set to be used in sumMulti.
Definition: sftmom.h:57
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 gaugeStartup(XMLReader &gauge_file_xml, XMLReader &gauge_xml, multi1d< LatticeColorMatrix > &u, Cfg_t &cfg)
Initialize the gauge fields.
void proginfo(XMLWriter &xml)
Print out basic information about this program.
Definition: proginfo.cc:24
std::map< std::string, SinkPropContainer_t > prop
multi1d< int > t_srce
ForwardProp_t prop_header
int j_decay
Definition: meslate.cc:22
Nd
Definition: meslate.cc:74
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static multi1d< LatticeColorMatrix > u
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
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 readQprop(XMLReader &file_xml, XMLReader &record_xml, LatticePropagator &quark_prop, const std::string &file, QDP_serialparallel_t serpar)
Read a Chroma propagator.
Definition: qprop_io.cc:1573
void writeQprop(XMLBufferWriter &file_xml, XMLBufferWriter &record_xml, const LatticePropagator &quark_prop, const std::string &file, QDP_volfmt_t volfmt, QDP_serialparallel_t serpar)
Write a Chroma propagator.
Definition: qprop_io.cc:1532
std::string getXMLInputFileName()
Get input file name.
Definition: chroma_init.cc:88
pop(xml_out)
START_CODE()
XMLFileWriter & getXMLOutputInstance()
Get xml output instance.
Definition: chroma_init.cc:359
::std::string string
Definition: gtest.h:1979
int main(int argc, char *argv[])
Definition: qpropgfix.cc:110
Gauge configuration structure.
Definition: cfgtype_io.h:16
Propagator parameters.
Definition: qprop_io.h:75
Propagator source construction parameters.
Definition: qprop_io.h:27
multi1d< int > getTSrce() const
Definition: qprop_io.cc:120
Parameters for running program.
Definition: qpropadd.cc:17
multi1d< int > nrow
Definition: qpropadd.cc:18
Propagators.
std::string prop_out_file
Definition: qpropgfix.cc:27
QDP_volfmt_t prop_out_volfmt
Definition: qpropgfix.cc:28
std::string prop_in_file
Definition: qpropgfix.cc:24
std::string gfix_in_file
Definition: qpropgfix.cc:25