CHROMA
qproptrev.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Time-reverse 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 {
24  std::string prop_in_file;
25 
26  std::string prop_out_file;
27  QDP_volfmt_t prop_out_volfmt; // volume format (SINGLEFILE or MULTIFILE)
28 };
29 
31 {
34 };
35 
36 
37 
38 //! Propagator parameters
39 void read(XMLReader& xml, const std::string& path, Prop_t& input)
40 {
41  XMLReader inputtop(xml, path);
42 
43  read(inputtop, "prop_in_file", input.prop_in_file);
44 
45  read(inputtop, "prop_out_file", input.prop_out_file);
46  read(inputtop, "prop_out_volfmt", input.prop_out_volfmt); // singlefile or multifile
47 }
48 
49 
50 //! Parameters for running code
51 void read(XMLReader& xml, const std::string& path, Param_t& param)
52 {
53  XMLReader paramtop(xml, path);
54 
55  int version;
56  read(paramtop, "version", version);
57 
58  switch (version)
59  {
60  case 1:
61  /**************************************************************************/
62  break;
63 
64  default :
65  /**************************************************************************/
66  QDPIO::cerr << "Input parameter version " << version << " unsupported." << std::endl;
67  QDP_abort(1);
68  }
69 
70 
71  read(paramtop, "nrow", param.nrow);
72 }
73 
74 
75 // Reader for input parameters
76 void read(XMLReader& xml, const std::string& path, QpropTRev_input_t& input)
77 {
78  XMLReader inputtop(xml, path);
79 
80  // Read all the input groups
81  try
82  {
83  // Read program parameters
84  read(inputtop, "Param", input.param);
85 
86  // Read in the propagator file info
87  read(inputtop, "Prop", input.prop);
88  }
89  catch (const std::string& e)
90  {
91  QDPIO::cerr << "Error reading qproptransf data: " << e << std::endl;
92  throw;
93  }
94 }
95 
96 
97 //! Applies gauge transformation matrices on a propagator
98 /*! \defgroup qproptrev Tranformation routine
99  * \ingroup main
100  *
101  * Main program for gauge fixing a propagator
102  */
103 
104 int main(int argc, char *argv[])
105 {
106  // Put the machine into a known state
107  Chroma::initialize(&argc, &argv);
108 
109  START_CODE();
110 
111  // Parameter structure for the input
112  QpropTRev_input_t input;
113 
114  // Instantiate xml reader for DATA
115  XMLReader xml_in(Chroma::getXMLInputFileName());
116 
117  // Read data
118  read(xml_in, "/qproptrev", input);
119 
120  // Setup QDP
121  Layout::setLattSize(input.param.nrow);
122  Layout::create();
123 
124  QDPIO::cout << "QPROPTREV: propagator gauge fixing utility" << std::endl;
125 
126  XMLFileWriter& xml_out = Chroma::getXMLOutputInstance();
127  push(xml_out, "qproptrev");
128 
129  proginfo(xml_out); // Print out basic program info
130 
131  write(xml_out, "input", xml_in); // save a copy of the input
132  xml_out.flush();
133 
134  /*
135  * Now read them thangs...
136  */
137  /*
138  * Read in a Chroma prop
139  */
140  LatticePropagator prop;
141  XMLReader prop_in_xml, prop_in_file_xml;
142 
143  push(xml_out,"SciDAC_propagator");
144  write(xml_out, "prop_in_file", input.prop.prop_in_file);
145 
146  readQprop(prop_in_file_xml, prop_in_xml, prop,
147  input.prop.prop_in_file, QDPIO_SERIAL);
148 
149  write(xml_out, "File_xml", prop_in_file_xml);
150  write(xml_out, "Record_xml", prop_in_xml);
151  pop(xml_out);
152 
153 
154  // Try to invert this record XML into a source struct
155  // Also pull out the id of this source
157  PropSourceConst_t source_header;
158  try
159  {
160  read(prop_in_xml, "/Propagator/ForwardProp", prop_header);
161  read(prop_in_xml, "/Propagator/PropSource", source_header);
162  }
163  catch (const std::string& e)
164  {
165  QDPIO::cerr << "Error extracting forward_prop header: " << e << std::endl;
166  throw;
167  }
168 
169  // Derived from input prop
170  int j_decay = source_header.j_decay;
171  int t_source = source_header.t_source;
172 
173 
174  // Initialize the slow Fourier transform phases
175  // This is used to get the time-slice subsets in the j_decay dir
176  SftMom phases(0, true, j_decay);
177 
178  // Length of lattice in j_decay direction and 3pt correlations fcns
179  int length = phases.numSubsets();
180 
181  // Sanity check - write out the propagator (pion) correlator in the j_decay direction
182  {
183  multi1d<Double> prop_corr = sumMulti(localNorm2(prop),
184  phases.getSet());
185 
186  push(xml_out, "Prop_correlator");
187  write(xml_out, "prop_corr", prop_corr);
188  pop(xml_out);
189  }
190 
191  xml_out.flush();
192 
193 
194  /*
195  * Charge-conjugation and time-reverse the beasty
196  */
197  {
198  /* Time-charge reverse the quark propagators */
199  /* S_{CT} = gamma_5 gamma_4 = gamma_1 gamma_2 gamma_3 = Gamma(7) */
200  LatticePropagator prop_tmp = - (Gamma(7) * prop * Gamma(7));
201 
202  // This is a really dumb way to implement this. Shift each slice around.
203  // Do nothing on the t=0 slice
204  prop[phases.getSet()[0]] = prop_tmp;
205 
206  LatticePropagator tmp1, tmp2, tmp3;
207 
208  for(int t=1; t < length; ++t)
209  {
210  int tp = (length - t) % length;
211 
212  if (t < tp)
213  {
214  tmp1[phases.getSet()[tp]] = prop_tmp;
215  for(int k=tp-1; k >= t; --k)
216  {
217  tmp2[phases.getSet()[k]] = shift(tmp1, FORWARD, j_decay);
218  tmp1[phases.getSet()[k]] = tmp2;
219  }
220 
221  prop[phases.getSet()[t]] = tmp1;
222  }
223  else if (t == tp)
224  {
225  prop[phases.getSet()[t]] = prop_tmp;
226  }
227  else if (t > tp)
228  {
229  tmp1[phases.getSet()[tp]] = prop_tmp;
230  for(int k=tp+1; k <= t; ++k)
231  {
232  tmp2[phases.getSet()[k]] = shift(tmp1, BACKWARD, j_decay);
233  tmp1[phases.getSet()[k]] = tmp2;
234  }
235 
236  prop[phases.getSet()[t]] = tmp1;
237  }
238  }
239  }
240 
241 
242 
243  // Sanity check - write out the propagator (pion) correlator in the j_decay direction
244  {
245  multi1d<Double> trev_prop_corr = sumMulti(localNorm2(prop),
246  phases.getSet());
247 
248  push(xml_out, "TRevProp_correlator");
249  write(xml_out, "trev_prop_corr", trev_prop_corr);
250  pop(xml_out);
251  }
252 
253 
254  /*
255  * Now write them thangs...
256  */
257  {
258  XMLBufferWriter prop_out_file_xml;
259  push(prop_out_file_xml, "propagator");
260  int id = 0; // NEED TO FIX THIS - SOMETHING NON-TRIVIAL NEEDED
261  write(prop_out_file_xml, "id", id);
262  pop(prop_out_file_xml);
263 
264  source_header.t_source = (length - source_header.t_source) % length;
265 
266  XMLBufferWriter prop_out_record_xml;
267  push(prop_out_record_xml, "Propagator");
268  write(prop_out_record_xml, "ForwardProp", prop_header);
269  write(prop_out_record_xml, "PropSource", source_header);
270  {
271  QDPIO::cout << "Create config info" << std::endl;
272  XMLReader gauge_xml(prop_in_xml, "/Propagator/Config_info");
273  std::ostringstream gauge_str;
274  gauge_xml.print(gauge_str);
275  write(prop_out_record_xml, "Config_info", gauge_str.str());
276  QDPIO::cout << "Done config info" << std::endl;
277  }
278  pop(prop_out_record_xml);
279 
280  // Write the source
281  writeQprop(prop_out_file_xml, prop_out_record_xml, prop,
282  input.prop.prop_out_file, input.prop.prop_out_volfmt,
283  QDPIO_SERIAL);
284  }
285 
286  pop(xml_out); // qproptrev
287 
288  END_CODE();
289 
290  // Time to bolt
292 
293  exit(0);
294 }
Primary include file for CHROMA in application codes.
Fourier transform phase factor support.
Definition: sftmom.h:35
int numSubsets() const
Number of subsets - length in decay direction.
Definition: sftmom.h:63
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 proginfo(XMLWriter &xml)
Print out basic information about this program.
Definition: proginfo.cc:24
std::map< std::string, SinkPropContainer_t > prop
ForwardProp_t prop_header
int j_decay
Definition: meslate.cc:22
int t
Definition: meslate.cc:37
Double tmp2
Definition: mesq.cc:30
Double tmp3
Definition: mesq.cc:31
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
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
int k
Definition: invbicg.cc:119
::std::string string
Definition: gtest.h:1979
#define FORWARD
Definition: primitives.h:82
#define BACKWARD
Definition: primitives.h:83
int main(int argc, char *argv[])
Definition: qproptrev.cc:104
Propagator parameters.
Definition: qprop_io.h:75
Propagator source construction parameters.
Definition: qprop_io.h:27
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