CHROMA
t_ovlap5d_bj.cc
Go to the documentation of this file.
1 
2 #include <iostream>
3 #include <sstream>
4 #include <iomanip>
5 #include <string>
6 
7 #include <cstdio>
8 
9 #include <stdlib.h>
10 #include <sys/time.h>
11 #include <math.h>
12 
13 #include "chroma.h"
14 
17 using namespace Chroma;
18 
19 struct App_input_t {
20  ChromaProp_t param;
21  Cfg_t cfg;
22 };
23 
24 void read(XMLReader& xml, const std::string& path, App_input_t& input)
25 {
26  XMLReader inputtop(xml, path);
27 
28  // Read the input
29  try
30  {
31  // The parameters holds the version number
32  read(inputtop, "Param", input.param);
33 
34  // Read in the gauge configuration info
35  read(inputtop, "Cfg", input.cfg);
36  }
37  catch (const std::string& e)
38  {
39  QDPIO::cerr << "Error reading data: " << e << std::endl;
40  throw;
41  }
42 }
43 
44 
45 int main(int argc, char **argv)
46 {
47  // Put the machine into a known state
48  Chroma::initialize(&argc, &argv);
49 
50  App_input_t input;
51  XMLReader xml_in(Chroma::getXMLInputFileName());
52 
53  try {
54  read(xml_in, "/ovlapTest", input);
55  }
56  catch( const std::string& e) {
57  QDPIO::cerr << "Caught Exception : " << e << std::endl;
58  QDP_abort(1);
59  }
60 
61 
62 
63  // Setup the lattice
64  Layout::setLattSize(input.param.nrow);
65  Layout::create();
66 
67  multi1d<LatticeColorMatrix> u(Nd);
68  XMLReader gauge_file_xml, gauge_xml;
69  gaugeStartup(gauge_file_xml, gauge_xml, u, input.cfg);
70 
71  XMLFileWriter& xml_out = Chroma::getXMLOutputInstance();
72  push(xml_out,"t_ovlap5d_bj");
73 
74 
75  // Measure the plaquette on the gauge
76  MesPlq(xml_out, "Observables", u);
77  xml_out.flush();
78 
79  //! Wilsoniums;
80  // Put this puppy into a handle to allow Zolo to copy it around as a **BASE** class
81  // WARNING: the handle now owns the data. The use of a bare S_w below is legal,
82  // but just don't delete it.
83 
84  // Create a FermBC
86 
87  Handle< FermBC< multi1d<LatticeFermion> > > fbc5(new SimpleFermBC<multi1d<LatticeFermion> >(input.param.boundary));
88 
89  QDPIO::cout << "FERM_ACT_ZOLOTAREV_5D" << std::endl;
90  const Zolotarev5DFermActParams& zolo5d = dynamic_cast<const Zolotarev5DFermActParams& > (*(input.param.FermActHandle));
91 
92  //! N order Zolo approx, with wilson action.
93  Zolotarev5DFermActArray S(fbc5, fbc, zolo5d, xml_out);
94 
95  Handle<const ConnectState> connect_state(S.createState(u, zolo5d.StateInfo, xml_out,zolo5d.AuxFermActHandle->getMass()));
96 
97  // Make me a linop (this callls the initialise function)
98  Handle<const LinearOperator< multi1d< LatticeFermion > > > D_op(S.linOp(connect_state));
99 
100  Handle<const LinearOperator< multi1d< LatticeFermion > > > DD_op(S.lMdagM(connect_state));
101 
102  int N5 = S.size();
103  int G5 = Ns*Ns-1;
104 
105  LatticeFermion chi4;
106  LatticeFermion psi4;
107  LatticeFermion tmp;
108  int n_count;
109 
110 
111  gaussian(chi4);
112  chi4 /= sqrt(norm2(chi4));
113 
114 
115  // We solve M_5d psi = gamma_5 chi
116  multi1d<LatticeFermion> psi( N5 );
117  multi1d<LatticeFermion> chi( N5 );
118 
119 
120  QDP::StopWatch swatch;
121  double t;
122 
123 
124  for(int i = 0; i < N5; i++) {
125  psi[i] = zero;
126  chi[i] = zero;
127  }
128 
129  chi[N5-1] = Gamma(G5)*chi4; // 4D source in last component
130  // is gamma5 chi
131 
132 
133  swatch.reset();
134  swatch.start();
135  //InvGMRESR_CG(*DD_op, *D_op, *D_op, chi, psi,
136  // input.param.invParam.RsdCG,
137  // input.param.invParam.RsdCGPrec,
138  // input.param.invParam.MaxCG,
139  // input.param.invParam.MaxCGPrec,
140  // n_count);
141 
142  InvMINRES(*D_op, chi, psi, input.param.invParam.RsdCG,
143  input.param.invParam.MaxCG, n_count);
144 
145  swatch.stop();
146  t = swatch.getTimeInSeconds();
147 
148  multi1d<LatticeFermion> tmp5_1(N5);
149  // Multiply back to check inverse
150  (*D_op)(tmp5_1, psi, PLUS);
151 
152 
153  multi1d<LatticeFermion> tmp5_2( N5 );
154  Double dnorm = Double(0);
155  Double g5chi_norm = Double(0);
156  for(int i = 0; i < N5; i++) {
157  tmp5_2[i] = chi[i] - tmp5_1[i];
158  dnorm += norm2(tmp5_2[i]);
159  g5chi_norm += norm2(chi[i]);
160  }
161 
162 
163  Double r_norm5 = sqrt(dnorm/g5chi_norm);
164  QDPIO::cout << "|| chi - D psi ||/ || chi || = " << r_norm5 << std::endl;
165  QDPIO::cout << "time = " << t << " seconds " << std::endl;
166  push(xml_out, "Inv5DCheck");
167  write(xml_out, "r_norm", r_norm5);
168  pop(xml_out);
169 
170 
171 
172  for(int i = 0; i < N5; i++) {
173  psi[i] = zero;
174  chi[i] = zero;
175  tmp5_1[i] = zero;
176  }
177 
178  chi[N5-1] = Gamma(G5)*chi4; // 4D source in last component
179  // is gamma5 chi
180 
181 
182  swatch.reset();
183  swatch.start();
184 
185  // Part of solution process
186  (*D_op)(tmp5_1, chi, MINUS);
187 
188  InvCG1(*DD_op, tmp5_1, psi,
189  input.param.invParam.RsdCG,
190  input.param.invParam.MaxCG,
191  n_count);
192 
193 
194  swatch.stop();
195  t = swatch.getTimeInSeconds();
196 
197  // Multiply back to check inverse
198  (*D_op)(tmp5_1, psi, PLUS);
199 
200 
201  dnorm = Double(0);
202  g5chi_norm = Double(0);
203  for(int i = 0; i < N5; i++) {
204  tmp5_2[i] = chi[i] - tmp5_1[i];
205  dnorm += norm2(tmp5_2[i]);
206  g5chi_norm += norm2(chi[i]);
207  }
208 
209 
210  r_norm5 = sqrt(dnorm/g5chi_norm);
211  QDPIO::cout << "|| chi - D psi ||/ || chi || = " << r_norm5 << std::endl;
212  QDPIO::cout << "time = " << t << " seconds " << std::endl;
213  push(xml_out, "Inv5DCheck");
214  write(xml_out, "r_norm", r_norm5);
215  pop(xml_out);
216 
217 
218  pop(xml_out);
220 
221  exit(0);
222 }
223 
Primary include file for CHROMA in application codes.
Class for counted reference semantics.
Definition: handle.h:33
Concrete class for all gauge actions with simple boundary conditions.
Definition: simple_fermbc.h:42
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.
SystemSolverResults_t InvCG1(const LinearOperator< LatticeFermion > &A, const LatticeFermion &chi, LatticeFermion &psi, const Real &RsdCG, int MaxCG, int MinCG)
Conjugate-Gradient (CGNE) algorithm for a generic Linear Operator.
Definition: invcg1.cc:215
Relaxed GMRESR algorithm of the Wuppertal Group.
int t
Definition: meslate.cc:37
Nd
Definition: meslate.cc:74
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
gaussian(aux)
int G5
Definition: pbg5p_w.cc:57
static multi1d< LatticeColorMatrix > u
void InvMINRES(const LinearOperatorArray< LatticeFermion > &A, const multi1d< LatticeFermion > &chi, multi1d< LatticeFermion > &psi, const Real &RsdCG, int MaxCG, int &n_count)
int n_count
Definition: invbicg.cc:78
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
@ MINUS
Definition: chromabase.h:45
@ PLUS
Definition: chromabase.h:45
void finalize(void)
Chroma finalization routine.
Definition: chroma_init.cc:308
multi1d< LatticeFermion > chi(Ncb)
std::string getXMLInputFileName()
Get input file name.
Definition: chroma_init.cc:88
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
XMLFileWriter & getXMLOutputInstance()
Get xml output instance.
Definition: chroma_init.cc:359
Double zero
Definition: invbicg.cc:106
FloatingPoint< double > Double
Definition: gtest.h:7351
::std::string string
Definition: gtest.h:1979
ChromaProp_t param
Definition: t_bicgstab.cc:19
Gauge configuration structure.
Definition: cfgtype_io.h:16
Propagator parameters.
Definition: qprop_io.h:75
GroupXML_t invParam
Definition: qprop_io.h:84
int main(int argc, char **argv)
Definition: t_ovlap5d_bj.cc:45