CHROMA
t_prec_nef.cc
Go to the documentation of this file.
1 
2 #include "chroma.h"
3 
4 using namespace Chroma;
5 
6 struct App_input_t {
7  GroupXML_t invParam; // Inverter parameters
8  Cfg_t cfg;
9  multi1d<int> nrow;
10 };
11 
12 // Reader for input parameters
13 void read(XMLReader& xml, const std::string& path, App_input_t& input)
14 {
15  XMLReader inputtop(xml, path);
16 
17  // Read the input
18  try
19  {
20  // Read in the gauge configuration info
21  read(inputtop, "Cfg", input.cfg);
22  read(inputtop, "nrow", input.nrow);
23  input.invParam = readXMLGroup(paramtop, "InvertParam", "invType");
24  }
25  catch (const std::string& e)
26  {
27  QDPIO::cerr << "Error reading data: " << e << std::endl;
28  throw;
29  }
30 }
31 
32 
33 int main(int argc, char **argv)
34 {
35  // Put the machine into a known state
36  Chroma::initialize(&argc, &argv);
37 
38  App_input_t input;
39  XMLReader xml_in(Chroma::getXMLInputFileName());
40 
41  try {
42  read(xml_in, "/NEFTest", input);
43  }
44  catch( const std::string& e) {
45  QDPIO::cerr << "Caught Exception : " << e << std::endl;
46  QDP_abort(1);
47  }
48 
49 
50  // Setup the lattice
51  Layout::setLattSize(input.nrow);
52  Layout::create();
53 
54  multi1d<LatticeColorMatrix> u(Nd);
55  {
56  XMLReader gauge_file_xml, gauge_xml;
57  gaugeStartup(gauge_file_xml, gauge_xml, u, input.cfg);
58  }
59 
60  XMLFileWriter& xml_out = Chroma::getXMLOutputInstance();
61  push(xml_out,"NEFTest");
62 
63 
64  // Measure the plaquette on the gauge
65  MesPlq(xml_out, "Observables", u);
66  xml_out.flush();
67 
68  // Create actions
69  std::string zpath = "/NEFTest/ZNEF";
72 
73  std::string npath = "/NEFTest/NEF";
75  EvenOddPrecNEFFermActArrayParams(xml_in, npath));
76 
78 
79  int N5 = S_znef.size();
80  QDPIO::cout << "Znef size = " << S_znef.size() << std::endl;
81  QDPIO::cout << "Nef size = " << S_nef.size() << std::endl;
82 
83  {
84  // Make the znef linOp
86 
87  // Make the nef linOp
89 
90  multi1d<LatticeFermion> psi5a(N5);
91  multi1d<LatticeFermion> chi5(N5);
92  multi1d<LatticeFermion> psi5b(N5);
93  multi1d<LatticeFermion> tmp5(N5);
94 
95  for(int n=0; n<N5; n++)
96  {
97  gaussian(psi5a[n]);
98  gaussian(psi5b[n]);
99  gaussian(chi5[n]);
100  }
101 
102  (*M_z)(psi5a, chi5, PLUS);
103  (*M_n)(psi5b, chi5, PLUS);
104  for(int n=0; n < N5; ++n)
105  {
106  tmp5[n][M_z->subset()] = psi5a[n];
107  tmp5[n][M_z->subset()] -= psi5b[n];
108  }
109  QDPIO::cout << "PLUS: norm2(psi5a-psi5b)=" << norm2(tmp5,M_z->subset()) << std::endl;
110 
111  (*M_z)(psi5a, chi5, MINUS);
112  (*M_n)(psi5b, chi5, MINUS);
113  for(int n=0; n < N5; ++n)
114  {
115  tmp5[n][M_z->subset()] = psi5a[n];
116  tmp5[n][M_z->subset()] -= psi5b[n];
117  }
118  QDPIO::cout << "MINUS: norm2(psi5a-psi5b)=" << norm2(tmp5,M_z->subset()) << std::endl;
119 
120 
121  // Make the znef unprec linOp
123  U_z(S_znef.unprecLinOp(S_znef.createState(u),Real(1)));
124 
125  // Make the nef unprec linOp
127  U_n(S_nef.unprecLinOp(S_nef.createState(u),Real(1)));
128 
129  (*U_z)(psi5a, chi5, PLUS);
130  (*U_n)(psi5b, chi5, PLUS);
131  for(int n=0; n < N5; ++n)
132  {
133  tmp5[n][U_z->subset()] = psi5a[n];
134  tmp5[n][U_z->subset()] -= psi5b[n];
135  }
136  QDPIO::cout << "PLUS: norm2(psi5a-psi5b)=" << norm2(tmp5,U_z->subset()) << std::endl;
137 
138  (*U_z)(psi5a, chi5, MINUS);
139  (*U_n)(psi5b, chi5, MINUS);
140  for(int n=0; n < N5; ++n)
141  {
142  tmp5[n][U_z->subset()] = psi5a[n];
143  tmp5[n][U_z->subset()] -= psi5b[n];
144  }
145  QDPIO::cout << "MINUS: norm2(psi5a-psi5b)=" << norm2(tmp5,U_z->subset()) << std::endl;
146  }
147 
148  {
151 
152  multi1d<LatticeFermion> psi5a(N5);
153  multi1d<LatticeFermion> chi5(N5);
154  multi1d<LatticeFermion> psi5b(N5);
155  multi1d<LatticeFermion> tmp5(N5);
156 
157  for(int n=0; n<N5; n++)
158  {
159  gaussian(psi5a[n]);
160  gaussian(psi5b[n]);
161  gaussian(chi5[n]);
162  }
163 
164  int n_counta = (*ZQ)(psi5a, chi5);
165  int n_countb = (*NQ)(psi5b, chi5);
166 
167  for(int n=0; n<N5; n++)
168  tmp5[n] = psi5b[n] - psi5a[n];
169 
170  QDPIO::cout << "norm(qpropT_diff)=" << Real(norm2(tmp5))
171  << " norm2(psi5a)=" << Real(norm2(psi5a))
172  << " norm2(psi5b)=" << Real(norm2(psi5b))
173  << std::endl;
174  for(int n=0; n < N5; ++n)
175  {
176  QDPIO::cout << "QpropT:"
177  << " norm2(tmp5[" << n << "])= " << Real(norm2(tmp5[n]))
178  << " norm2(psi5a[])= " << Real(norm2(psi5a[n]))
179  << " norm2(psi5b[])= " << Real(norm2(psi5b[n]))
180  << std::endl;
181  }
182 
183 #if 1
184  push(xml_out,"QpropT");
185  write(xml_out,"psi5a",psi5a);
186  write(xml_out,"psi5b",psi5b);
187  write(xml_out,"tmp5",tmp5);
188  pop(xml_out);
189 #endif
190  }
191 
192  {
195 
196  LatticeFermion psia, psib, chi;
197  gaussian(chi);
198  gaussian(psia);
199  gaussian(psib);
200 
201  int n_counta = (*ZQ)(psia, chi);
202  int n_countb = (*NQ)(psib, chi);
203 
204  QDPIO::cout << "norm(qprop_diff)=" << Real(norm2(psib - psia))
205  << " norm2(psia)=" << Real(norm2(psia))
206  << " norm2(psib)=" << Real(norm2(psib))
207  << std::endl;
208  }
209 
210  pop(xml_out);
212 
213  exit(0);
214 }
Primary include file for CHROMA in application codes.
virtual EvenOddPrecDWLikeLinOpBaseArray< T, P, Q > * linOp(Handle< FermState< T, P, Q > > state) const
Override to produce a DWF-link even-odd prec. linear operator for this action.
SystemSolver< T > * qprop(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const
Define quark propagator routine for 4D fermions.
4D style even-odd preconditioned domain-wall fermion action
UnprecDWLikeLinOpBaseArray< T, P, Q > * unprecLinOp(Handle< FermState< T, P, Q > > state, const Real &m_q) const
Produce an unpreconditioned linear operator for this action with arbitrary quark mass.
int size() const
Length of DW flavor index/space.
virtual SystemSolverArray< T > * qpropT(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const
Return quark prop solver, solution of unpreconditioned system.
EvenOddPreconditioned NEF fermion action.
UnprecDWLikeLinOpBaseArray< T, P, Q > * unprecLinOp(Handle< FermState< T, P, Q > > state, const Real &m_q) const
Produce an unpreconditioned linear operator for this action with arbitrary quark mass.
int size() const
Length of DW flavor index/space.
virtual FermState< T, P, Q > * createState(const Q &q) const
Given links (coordinates Q) create the state needed for the linear operators.
Definition: fermact.h:59
Class for counted reference semantics.
Definition: handle.h:33
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.
GroupXML_t readXMLGroup(XMLReader &xml_in, const std::string &path, const std::string &type_name)
Read group and return as a std::string.
unsigned n
Definition: ldumul_w.cc:36
Nd
Definition: meslate.cc:74
Handle< FermBC< LatticeStaggeredFermion, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > > reader(XMLReader &xml_in, const std::string &path)
Helper function for the FermionAction readers.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
gaussian(aux)
static multi1d< LatticeColorMatrix > u
push(xml_out,"Condensates")
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
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
::std::string string
Definition: gtest.h:1979
InvertParam_t invParam
Definition: t_invborici.cc:24
multi1d< int > nrow
Definition: t_invborici.cc:22
GroupXML_t invParam
Definition: t_prec_nef.cc:7
Gauge configuration structure.
Definition: cfgtype_io.h:16
Hold group xml and type id.
int main(int argc, char **argv)
Definition: t_prec_nef.cc:33