CHROMA
ovpbg5p_w.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Calculates noise estimator for the overlap trace
3  */
4 
5 #error "Converted but not tested"
6 
7 #include "chromabase.h"
8 #include "meas/pbp/ovpbg5p_w.h"
9 
10 
11 namespace Chroma {
12 
13 //! OVPBG5P - Calculates noise estimator for the overlap trace
14 /*!
15  * OVPBG5P - Calculates noise estimator for the overlap trace used in the
16  * following constructions
17  * <psibar_psi(x)> = Tr D^{-1}
18  * <psibar psi(x) psibar psi(y)> = Tr D^{-2} - Tr D{-1}
19  * <psibar gamma_5 psi psibar gamma_5 psi> = = Tr H^{-2}
20 
21  * What is computed are the traces so iso(flavor) triplets and singlets can be
22  * reconstructed
23 
24  * This routine is specific to Wilson and really Overlap fermions!
25 
26  * state -- gauge field ( Read )
27  * nhit -- number of Gaussian hits ( Read )
28  * n_zero -- the topology of the field ( Read )
29  * Mass -- array of quark mass values ( Read )
30  * numMass -- number of quark masses ( Read )
31  * RsdCG -- the CG accuracy used for multishift CG ( Read )
32  */
33 
34 
35 void OvPbg5p(XMLWriter& xml_out,
36  const OverlapFermActBase& S_f,
38  const multi1d<Real>& Mass,
39  enum InvType invType,
40  const multi1d<Real>& RsdCG,
41  int MaxCG,
42  int n_zero,
43  int nhit)
44 {
45  START_CODE();
46 
47  const int numMass = Mass.size();
48 
49  multi1d<Double> TrDinv(numMass);
50  multi1d<Double> TrHinv_sq(numMass);
51  multi1d<Double> TrDinv_sq(numMass);
52  multi1d<Double> TrBdag_Eta(numMass);
53  multi1d<Double> TrEtadag_Eta(numMass);
54  multi1d<Double> TrBdag_Eta_avg(numMass);
55  multi1d<Double> TrEtadag_Eta_avg(numMass);
56  multi2d<LatticeFermion> eta(Nsubl, numMass);
57  LatticeFermion b;
58 
61 
62  int G5 = Ns*Ns - 1;
63 
64  Double TrBdag_B;
65  Double TrBdag_B_avg = 0;
66  TrBdag_Eta_avg = 0;
67  TrEtadag_Eta_avg = 0;
68  int n_congrd = 0;
69  int n_congrd_tot = 0;
70 
71 
72  for(int ihit = 1; ihit <= nhit; ++ihit)
73  {
74  /* Fill with random gaussian noise such that < b_dagger * b > = 1 per d.o.f. */
75  gaussian(b);
76 
77 #if 0
78  /* If using Schroedinger functional, zero out the boundaries */
79  S_f.getFermBC().modifyF(b);
80 #endif
81 
82  /* Make the source chiral */
83  if (n_zero > 0)
84  {
85  /* Have pos. chirality zero modes, so use neg. chirality for source */
86  LatticeFermion tmp = chiralProjectMinus(b);
87  b = tmp;
88  }
89  else
90  {
91  /* Have either neg. chirality or no zero modes, so use pos. chirality for source */
92  LatticeFermion tmp = chiralProjectPlus(b);
93  b = tmp;
94  }
95 
96  /* Keep track of actual norm of noise */
97  TrBdag_B = norm2(b);
98 
99 
100  /* Prop. solution */
101  /* eta = (D*D_dag)^(-1) * b */
102  /* The inverse of the un-preconditioned matrix is needed here. This */
103  /* is given by MOvQprop! */
104  n_congrd = 0;
105  S_f.multiQprop(eta, Mass, state, b, invType, RsdCG, 4, MaxCG, n_congrd);
106 
107 
108  /* Construct */
109  /* Tr Bdag_B = < b_dag * eta > */
110  /* Tr Bdag_Eta = < b_dag * eta > */
111  /* Tr Etadag_Eta = < eta_dag * eta > */
112  /* Use these to make */
113  /* Tr D^{-1} = 2 * (mu/(1-mu^2)) * <b_dag * (eta - b)> */
114  /* Tr H^{-2} = 2 * (1/(1-mu^2)) * <b_dag * (eta - b)> */
115  /* Omega = Tr H^{-2} + Tr D^{-2} */
116  /* = 4 * (mu^2/(1-mu^2)^2) * <(eta - b)^dag * (eta - b)> */
117  /* Tr D^{-2} = Omega - Tr H^{-2} */
118 
119  TrBdag_Eta = 0;
120  TrEtadag_Eta = 0;
121 
122  for(int i=0; i < numMass; ++i)
123  {
124  TrBdag_Eta[i] += real(innerProductReal(b,eta[i]));
125  TrEtadag_Eta[i] += norm2(eta[i]);
126  }
127 
128  /* Add on to running average */
129  TrBdag_B_avg += TrBdag_B;
130  TrBdag_Eta_avg += TrBdag_Eta;
131  TrEtadag_Eta_avg += TrEtadag_Eta;
133 
134  /* Normalize and print */
135  ddummy1 = Double(1) / Double(Layout::vol());
136  TrBdag_B *= ddummy1;
137  for(int i=0; i < numMass; ++i)
138  {
139  TrBdag_Eta[i] *= ddummy1;
140  TrEtadag_Eta[i] *= ddummy1;
141  }
142 
143  if (nhit > 1)
144  {
145  push(xml_out,"Overlap_trace_hit");
146  write(xml_out, "ihit", ihit);
147  write(xml_out, "nhit", nhit);
148  write(xml_out, "TrBdag_B", TrBdag_B);
149  write(xml_out, "TrBdag_Eta", TrBdag_Eta);
150  write(xml_out, "TrEtadag_Eta", TrEtadag_Eta);
151  write(xml_out, "n_congrd", n_congrd);
152  pop(xml_out);
153  }
154  }
155 
156 
157  /* Normalize */
158  ddummy1 = Double(1) / Double(nhit * Layout::vol());
159  TrBdag_B_avg *= TrBdag_B_avg;
160  for(int i=0; i < numMass; ++i)
161  {
162  TrBdag_Eta_avg[i] *= ddummy1;
163  TrEtadag_Eta_avg[i] *= ddummy1;
164  }
165 
166  /* For niceties and redundancies, turn into the usual traces */
167  /* The traces are linear combinations of the inner products, so */
168  /* the average goes through */
169  /* Use these to make */
170  /* Tr D^{-1} = 2 * (mu/(1-mu^2)) * <b_dag * (eta - b)> */
171  /* Tr H^{-2} = 2 * (1/(1-mu^2)) * <b_dag * (eta - b)> */
172  /* Omega = Tr H^{-2} + Tr D^{-2} */
173  /* = 4 * (mu^2/(1-mu^2)^2) * <(eta - b)^dag * (eta - b)> */
174  /* = 4 * (mu^2/(1-mu^2)^2) * <b_dag*b - 2*b_dag*eta + eta_dag*eta> */
175  /* Tr D^{-2} = Omega - Tr H^{-2} */
176 
177  for(int i=0; i < numMass; ++i)
178  {
179  Real mass = Mass[i];
180  ddummy1 = 2.0 / Double(1.0 - mass*mass);
181  ddummy2 = TrBdag_Eta_avg[i] - TrBdag_B_avg;
182 
183  TrHinv_sq[i] = ddummy1 * ddummy2;
184  TrDinv[i] = TrHinv_sq[i] * mass;
185 
186  ddummy1 *= mass;
187  ddummy2 = TrEtadag_Eta_avg[i] - 2.0*TrBdag_Eta_avg[i] + TrBdag_B_avg;
189  TrDinv_sq[i] = ddummy2 - TrHinv_sq[i];
190  }
191 
192  push(xml_out,"Overlap_trace_avg");
193  write(xml_out, "nhit", nhit);
194  write(xml_out, "TrBdag_B_avg", TrBdag_B_avg);
195  write(xml_out, "TrBdag_Eta_avg", TrBdag_Eta_avg);
196  write(xml_out, "TrEtadag_Eta_avg", TrEtadag_Eta_avg);
197  write(xml_out, "TrDinv", TrDinv);
198  write(xml_out, "TrHinv_sq", TrHinv_sq);
199  write(xml_out, "TrDinv_sq", TrDinv_sq);
200  write(xml_out, "n_congrd_tot", n_congrd_tot);
201  pop(xml_out);
202 
203  END_CODE();
204 }
205 
206 } // end namespace Chroma
Primary include file for CHROMA library code.
Class for counted reference semantics.
Definition: handle.h:33
Base class for unpreconditioned overlap-like fermion actions.
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams &param)
Writer parameters.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
gaussian(aux)
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > const multi1d< Real > enum InvType invType const multi1d< Real > & RsdCG
Definition: pbg5p_w.cc:30
int G5
Definition: pbg5p_w.cc:57
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > const multi1d< Real > & Mass
Definition: pbg5p_w.cc:29
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
int n_congrd
Definition: mespbg5p_w.cc:24
push(xml_out,"Condensates")
Double ddummy1
Definition: mespbg5p_w.cc:44
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > const multi1d< Real > enum InvType invType const multi1d< Real > int MaxCG
Definition: pbg5p_w.cc:32
int i
Definition: pbg5p_w.cc:55
Double mass
Definition: pbg5p_w.cc:54
int ihit
Definition: mespbg5p_w.cc:46
void OvPbg5p(XMLWriter &xml_out, const OverlapFermActBase &S_f, Handle< const ConnectState > state, const multi1d< Real > &Mass, enum InvType invType, const multi1d< Real > &RsdCG, int MaxCG, int n_zero, int nhit)
OVPBG5P - Calculates noise estimator for the overlap trace.
Definition: ovpbg5p_w.cc:35
pop(xml_out)
LatticeFermion eta
Definition: mespbg5p_w.cc:37
int n_congrd_tot
Definition: pbg5p_w.cc:38
START_CODE()
multi1d< Double > TrHinv_sq(numMass)
Complex b
Definition: invbicg.cc:96
int nhit
Definition: mespbg5p_w.cc:26
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
Definition: pbg5p_w.cc:28
multi1d< Double > TrDinv(numMass)
const WilsonTypeFermAct< multi1d< LatticeFermion > > & S_f
Definition: pbg5p_w.cc:27
Double ddummy2
Definition: mespbg5p_w.cc:45
FloatingPoint< double > Double
Definition: gtest.h:7351