CHROMA
t_mres_4d.cc
Go to the documentation of this file.
1 
2 #include "chroma.h"
3 
4 using namespace Chroma;
5 
6 struct Prop_t
7 {
8  std::string prop_file;
9 };
10 
11 struct AppInput_t
12 {
13  multi1d<int> nrow;
18 };
19 
20 //! To insure linking of code, place the registered code flags here
21 /*! This is the bit of code that dictates what fermacts are in use */
23 {
24  bool foo = true;
25 
26  // All actions
28 
29  return foo;
30 }
31 
32 
33 void read(XMLReader& xml, const std::string& path, Prop_t& input)
34 {
35  XMLReader inputtop(xml, path);
36  read(inputtop, "prop_file", input.prop_file);
37 }
38 
39 
40 void read(XMLReader& xml, const std::string& path, AppInput_t& input)
41 {
42  XMLReader inputtop(xml, path);
43 
44  // Read the input
45  try
46  {
47  // The parameters holds the version number
48  read(inputtop, "nrow", input.nrow);
49 
50  //
51  XMLReader xml_tmp(inputtop, "FermionAction");
52  std::ostringstream os;
53  xml_tmp.print(os);
54  input.fermact = os.str();
55 
56  // Read in the gauge configuration info
57  read(inputtop, "Cfg", input.cfg);
58 
59  // Read any auxiliary state information
60  if( inputtop.count("StateInfo") == 1 ) {
61  XMLReader xml_state_info(inputtop, "StateInfo");
62  std::ostringstream os;
63  xml_state_info.print(os);
64  input.stateInfo = os.str();
65  }
66  else {
67  XMLBufferWriter s_i_xml;
68  push(s_i_xml, "StateInfo");
69  pop(s_i_xml);
70  input.stateInfo = s_i_xml.str();
71  }
72 
73  // Read in the source/propagator info
74  read(inputtop, "Prop", input.prop);
75  }
76  catch (const std::string& e)
77  {
78  QDPIO::cerr << "Error reading data: " << e << std::endl;
79  throw;
80  }
81 }
82 
83 
84 
85 int main(int argc, char **argv)
86 {
87  // Put the machine into a known state
88  Chroma::initialize(&argc, &argv);
89 
90 
91 
92  AppInput_t input;
93  XMLReader xml_in(Chroma::getXMLInputFileName());
94 
95  try {
96  read(xml_in, "/mres4D", input);
97  }
98  catch( const std::string& e) {
99  QDPIO::cerr << "Caught Exception : " << e << std::endl;
100  QDP_abort(1);
101  }
102 
103 
104  // Setup the lattice
105  Layout::setLattSize(input.nrow);
106  Layout::create();
107 
108  multi1d<LatticeColorMatrix> u(Nd);
109  XMLReader gauge_file_xml, gauge_xml;
110  gaugeStartup(gauge_file_xml, gauge_xml, u, input.cfg);
111 
112  XMLFileWriter& xml_out = Chroma::getXMLOutputInstance();
113  push(xml_out,"t_mres4D");
114 
115  proginfo(xml_out);
116  write(xml_out, "Input", xml_in);
117 
118  // Measure the plaquette on the gauge
119  MesPlq(xml_out, "Observables", u);
120  xml_out.flush();
121 
122  // Read the prop
123 
124  LatticePropagator quark_propagator;
126  PropSourceConst_t source_header;
127 
128  {
129  XMLReader prop_file_xml, prop_record_xml;
130  readQprop(prop_file_xml,
131  prop_record_xml,
132  quark_propagator,
133  input.prop.prop_file,
134  QDPIO_SERIAL);
135 
136  // Try to invert this record XML into a ChromaProp struct
137  // Also pull out the id of this source
138  try {
139  read(prop_record_xml, "/Propagator/ForwardProp", prop_header);
140  read(prop_record_xml, "/Propagator/PropSource", source_header);
141  }
142  catch (const std::string& e) {
143  QDPIO::cerr << "Error extracting forward_prop header: " << e << std::endl;
144  throw;
145  }
146  }
147 
148  int j_decay = source_header.j_decay;
149  multi1d<int> t_source = source_header.t_source;
150  // Flags
151  int t0 = t_source[j_decay];
152 
153  // Initialize the slow Fourier transform phases
154  SftMom phases(0, true, j_decay);
155  {
156  multi1d<Double> forward_prop_corr = sumMulti(localNorm2(quark_propagator),
157  phases.getSet());
158 
159  push(xml_out, "Forward_prop_correlator");
160  write(xml_out, "forward_prop_corr", forward_prop_corr);
161  pop(xml_out);
162  }
163 
164 
165  //
166  // Initialize fermion action
167  //
168  std::istringstream xml_s(input.fermact);
169  XMLReader fermacttop(xml_s);
170  const std::string fermact_path = "/FermionAction";
171  std::string fermact;
172 
173  try
174  {
175  read(fermacttop, fermact_path + "/FermAct", fermact);
176  }
177  catch (const std::string& e)
178  {
179  QDPIO::cerr << "Error reading fermact: " << e << std::endl;
180  throw;
181  }
182 
183  QDPIO::cout << "FermAct = " << fermact << std::endl;
184 
185  // Make a reader for the stateInfo
186  std::istringstream state_info_is(input.stateInfo);
187  XMLReader state_info_xml(state_info_is);
188  std::string state_info_path="/StateInfo";
189 
190 
191  //
192  LatticePropagator delta_prop;
193  LatticePropagator deltaSq_prop;
194 
195  try
196  {
197  // Generic Wilson-Type Array stuff
199  TheFermionActionFactory::Instance().createObject(fermact,
200  fermacttop,
201  fermact_path);
202 
203  Handle<const ConnectState> state(S_f->createState(u,
204  state_info_xml,
205  state_info_path));
206 
208 
209  // Possible actions
212 
213  const OverlapFermActBase* S_ov = dynamic_cast<const OverlapFermActBase*>(S_f);
214 
215  if (S_dwf != 0)
216  {
217  DelLs = const_cast<LinearOperator<LatticeFermion>*>(S_dwf->DeltaLs(state,prop_header.invParam));
218  }
219  else if (S_ov != 0)
220  {
221  DelLs = const_cast<LinearOperator<LatticeFermion>*>(S_ov->DeltaLs(state));
222  }
223  else
224  {
225  throw std::string("no suitable cast found");
226  }
227 
228  for(int col = 0; col < Nc; col++)
229  {
230  for(int spin = 0; spin < Ns; spin++)
231  {
232  LatticeFermion tmp1, tmp2;
233 
234  // Move component from prop to ferm
235  PropToFerm(quark_propagator, tmp1, col, spin);
236 
237  // Apply DeltaLs -> tmp2 = Delta_Ls tmp1
238  (*DelLs)(tmp2, tmp1, PLUS);
239 
240  FermToProp(tmp2, delta_prop, col, spin);
241  }
242  }
243 
244  delete DelLs;
245  delete S_f;
246  }
247  catch(const std::string& e) {
248  QDPIO::cout << "Wilson Factory Error: " << e << std::endl;
249  QDP_abort(1);
250  }
251  catch(std::bad_cast) {
252  QDPIO::cout << "Action entered is not suitable to be cast to OverlapFermActBase " << std::endl;
253  }
254 
255 
256 
257  multi1d<Double> pseudo_prop_corr = sumMulti(localNorm2(quark_propagator),
258  phases.getSet());
259 
260  multi1d<DComplex> delta_prop_corr = sumMulti(trace(adj(quark_propagator)*delta_prop),
261  phases.getSet());
262 
263  multi1d<DComplex> deltaSq_prop_corr = sumMulti(trace(adj(delta_prop)*delta_prop),
264  phases.getSet());
265 
266  int length = pseudo_prop_corr.size();
267  multi1d<Real> shifted_pseudo(length);
268  multi1d<Real> shifted_delta(length);
269  multi1d<Real> shifted_deltaSq(length);
270  int t_src = t_source[j_decay];
271 
272  for(int t=0; t<length; t++){
273  int t_eff( (t - t_src + length) % length ) ;
274  shifted_pseudo[t_eff] = real(pseudo_prop_corr[t]);
275  shifted_delta[t_eff] = real(delta_prop_corr[t]);
276  shifted_deltaSq[t_eff]= real(deltaSq_prop_corr[t]);
277  }
278 
279  push(xml_out, "DeltaProp_correlator");
280  write(xml_out, "delta_prop_corr", shifted_delta);
281  pop(xml_out);
282 
283  push(xml_out, "DeltaSqProp_correlator");
284  write(xml_out, "delta_sq_prop_corr", shifted_deltaSq);
285  pop(xml_out);
286 
287  push(xml_out, "PsuedoPseudo_correlator");
288  write(xml_out, "pseudo_prop_corr", shifted_pseudo);
289  pop(xml_out);
290 
291 
292  pop(xml_out);
293  xml_out.close();
294 
296  exit(0);
297 }
Primary include file for CHROMA in application codes.
Base class for quadratic matter actions (e.g., fermions)
Definition: fermact.h:53
Class for counted reference semantics.
Definition: handle.h:33
Base class for unpreconditioned overlap-like fermion actions.
Fourier transform phase factor support.
Definition: sftmom.h:35
const Set & getSet() const
The set to be used in sumMulti.
Definition: sftmom.h:57
static T & Instance()
Definition: singleton.h:432
Wilson-like fermion actions.
Definition: fermact.orig.h:403
virtual LinearOperator< T > * DeltaLs(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const =0
Produce a DeltaLs = 1-epsilon^2(H) operator.
void PropToFerm(const LatticePropagatorF &b, LatticeFermionF &a, int color_index, int spin_index)
Extract a LatticeFermion from a LatticePropagator.
Definition: transf.cc:226
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 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
ForwardProp_t prop_header
int j_decay
Definition: meslate.cc:22
int t
Definition: meslate.cc:37
Nd
Definition: meslate.cc:74
Double tmp2
Definition: mesq.cc:30
bool registerAll()
Register all the factories.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static multi1d< LatticeColorMatrix > u
push(xml_out,"Condensates")
void initialize(int *argc, char ***argv)
Chroma initialisation routine.
Definition: chroma_init.cc:114
@ PLUS
Definition: chromabase.h:45
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
std::string getXMLInputFileName()
Get input file name.
Definition: chroma_init.cc:88
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
::std::string string
Definition: gtest.h:1979
Prop_t prop
Definition: t_mres_4d.cc:17
std::string fermact
Definition: t_mres_4d.cc:14
std::string stateInfo
Definition: t_mres_4d.cc:16
multi1d< int > nrow
Definition: t_mres_4d.cc:13
Cfg_t cfg
Definition: t_mres_4d.cc:15
Gauge configuration structure.
Definition: cfgtype_io.h:16
Propagator parameters.
Definition: qprop_io.h:75
Propagator source construction parameters.
Definition: qprop_io.h:27
Propagators.
std::string prop_file
bool linkage_hack()
To insure linking of code, place the registered code flags here.
Definition: t_mres_4d.cc:22
int main(int argc, char **argv)
Definition: t_mres_4d.cc:85