CHROMA
t_dwflocality.cc
Go to the documentation of this file.
1 
2 #include <iostream>
3 #include <cstdio>
4 
5 #include <stdlib.h>
6 #include <sys/time.h>
7 
8 #include "chroma.h"
9 
10 
11 using namespace Chroma;
12 
13 int main(int argc, char **argv)
14 {
15  // Put the machine into a known state
16  Chroma::initialize(&argc, &argv);
17 
18  // Setup the layout
19  //const int foo[] = {4,4,4,8};
20  //const int boo[] = {1,1,1,0};
21 
22  XMLReader in(Chroma::getXMLInputFileName());
23 
24  multi1d<int> nrow(Nd);
25  multi1d<int> boundary(Nd);
26  XMLReader xml_in(in,"/t_dwflocality" );
27  read(xml_in, "nrow", nrow);
28  read(xml_in, "boundary", boundary);
29 
30 
31  Layout::setLattSize(nrow);
32  Layout::create();
33 
34  int Nt = nrow[3] ;
35  XMLFileWriter xml("t_dwflocality.xml");
36  push(xml,"DWF_locality");
37  push(xml,"lattice");
38  write(xml,"size",nrow);
39  write(xml,"bc",boundary);
40  pop(xml);
41 
42  SysSolverCGParams invParam;
43  int N5 ;
44  Real WilsonMass ;
45  Real m_q = 1.0;
46  invParam.RsdCG = 1.0e-7 ;
47  invParam.MaxCG = 5000 ;
48 
49  read(xml_in, "Ls", N5);
50 
51  read(xml_in, "M5", WilsonMass);
52 
53  push(xml,"ChiralParam");
54  write(xml,"N5",N5);
55  write(xml,"WilsonMass",WilsonMass);
56  pop(xml);
57 
58  Cfg_t cfg;
59 
60  read(xml_in, "cfg", cfg);
61 
62  push(xml,"Configuration");
63  write(xml, "cfg", cfg);
64  pop(xml);
65  QDPIO::cout << "Read config from " << cfg.cfg_file << std::endl;
66 
67 
68  multi1d<LatticeColorMatrix> u(Nd); // Gauge field
69  XMLReader gauge_file_xml, gauge_xml;
70  gaugeStartup(gauge_file_xml, gauge_xml, u, cfg);
71 
74  QDPIO::cout << " Initial plaqettes and link: " << w_plaq
75  << " " << s_plaq << " " << t_plaq << " " << link << std::endl;
76  push(xml,"gauge_observables");
77  write(xml, "w_plaq", w_plaq);
78  write(xml, "s_plaq", s_plaq);
79  write(xml, "t_plaq", t_plaq);
80  write(xml, "link", link);
81  pop(xml);
82 
83 
84  // Typedefs to save typing
85  typedef LatticeFermion T;
86  typedef multi1d<LatticeFermion> MLF;
87  typedef multi1d<LatticeColorMatrix> P;
88  typedef multi1d<LatticeColorMatrix> Q;
89 
90  MLF psi(N5), chi(N5);
91 
92  // Create a FermBC with only periodic BC. Note the handle is on an abstract type.
94 
95  // DWDslash class can be optimised
96 
97  EvenOddPrecDWFermActArray S_pdwf(cfs, WilsonMass, m_q,N5);
99 
100  LatticeFermion chi4;
101  LatticeFermion res4;
102 
103  //! Create source
104  QDPIO::cout << "Constructing source" << std::endl;
105  multi1d<int> coor(4) ;
106  coor[0]=coor[1]=coor[2]=0 ;
107  coor[3]=Nt/2 ;
108  chi4=zero ;
109  srcfil(chi4, coor, 0,0);
110  QDPIO::cout << "Done" << std::endl;
111 
112  QDPIO::cout << "source norm :" << norm2(chi4)<< std::endl;
113  LatticeReal tt ;
114  tt = localNorm2(chi4) ;
115 
116  chi = zero ;
117  // Split the source to oposite walls according to chirality
118  chi[0 ] = chiralProjectPlus(chi4) ;
119  chi[N5-1] = chiralProjectMinus(chi4) ;
120 
121  QDPIO::cout << "5D source norm :" << norm2(chi)<< std::endl;
122 
123  {
124  XMLBufferWriter xml_buf;
125  write(xml_buf, "InvertParam", invParam);
126  XMLReader xml_inn(xml_buf);
127  GroupXML_t inv_param = readXMLGroup(xml_inn, "/InvertParam", "invType");
128 
129  Handle< SystemSolverArray<LatticeFermion> > PQ(S_pdwf.qpropT(state, inv_param));
130  (*PQ)(psi, chi);
131  }
132 
133  res4 = chiralProjectMinus(psi[0]) + chiralProjectPlus(psi[N5-1]) ;
134 
135  LatticeReal mag ;
136 
137  mag = sqrt(localNorm2(chi4 - res4)) ;
138  //mag = localNorm2(chi4) ;
139  multi1d<int> c(4) ;
140  {
141  multi1d<Real> val(nrow[0]);
142  c = coor ;
143  for (int x(0);x<nrow[0];x++){
144  c[0] = x ;
145  val[x] = peekSite(mag,c) ;
146  }
147  push(xml, "x_axis");
148  write(xml,"val",val);
149  pop(xml);
150  }
151  {
152  multi1d<Real> val(nrow[1]);
153  c = coor ;
154  for (int x(0);x<nrow[1];x++){
155  c[1] = x ;
156  val[x] = peekSite(mag,c) ;
157  //QDPIO::cout << "source norm ("<<x<<"):" << peekSite(tt,c)<< std::endl;
158  }
159  push(xml, "y_axis");
160  write(xml,"val",val);
161  pop(xml);
162  }
163  {
164  multi1d<Real> val(nrow[2]);
165  c = coor ;
166  for (int x(0);x<nrow[2];x++){
167  c[2] = x ;
168  val[x] = peekSite(mag,c) ;
169  }
170  push(xml, "z_axis");
171  write(xml,"val",val);
172  pop(xml);
173  }
174  {
175  multi1d<Real> val(nrow[3]);
176  c = coor ;
177  for (int x(0);x<nrow[3];x++){
178  c[3] = x ;
179  val[x] = peekSite(mag,c) ;
180  }
181  push(xml, "t_axis");
182  write(xml,"val",val);
183  pop(xml);
184  }
185 
186  pop(xml);
187 
188  // Time to bolt
190 
191  exit(0);
192 }
Primary include file for CHROMA in application codes.
Create a simple ferm connection state.
4D style even-odd preconditioned domain-wall fermion action
SystemSolverArray< T > * qpropT(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const
Return possibly optimized quark prop solver, solution of preconditioned system.
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.
void srcfil(LatticeFermion &a, const multi1d< int > &coord, int color_index, int spin_index)
Fill a specific color and spin index with 1.0.
Definition: srcfil.cc:23
int x
Definition: meslate.cc:34
Nd
Definition: meslate.cc:74
multi1d< LatticeColorMatrix > P
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static multi1d< LatticeColorMatrix > u
LinOpSysSolverMGProtoClover::Q Q
push(xml_out,"Condensates")
Double c
Definition: invbicg.cc:108
LinOpSysSolverMGProtoClover::T T
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
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
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
Definition: pbg5p_w.cc:28
Double zero
Definition: invbicg.cc:106
static QDP_ColorVector * in
FloatingPoint< double > Double
Definition: gtest.h:7351
Double link
Definition: pade_trln_w.cc:146
Double t_plaq
Definition: pade_trln_w.cc:145
Double w_plaq
Definition: pade_trln_w.cc:143
Double s_plaq
Definition: pade_trln_w.cc:144
Gauge configuration structure.
Definition: cfgtype_io.h:16
std::string cfg_file
Definition: cfgtype_io.h:18
Hold group xml and type id.
Params for CG inverter.
int main(int argc, char **argv)
multi1d< LatticeFermion > MLF
Definition: t_preccfz.cc:12