CHROMA
stagpbp_s.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Calculates noise estimator for the staggered trace
3  */
4 
5 #error "Converted but not tested"
6 
7 #include "chromabase.h"
8 #include "meas/pbp/stagpbp_s.h"
9 
10 namespace Chroma {
11 
12 //! Calculates noise estimator for the staggered trace
13 
14 /*! Calculates noise estimator for the staggered trace used in the
15  * following constructions
16  * <psibar_psi(x)> = Tr D^{-1}
17  * <psibar psi(x) psibar psi(y)> = Tr D^{-2}
18  * <psibar "gamma_5" psi psibar "gamma_5" psi> = Tr (D^dag D)^{-1}
19  * = 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 staggered fermions!
25 
26  * u -- gauge field ( Read )
27  * nhit -- number of Gaussian hits ( Read )
28  * Mass -- array of quark mass values ( Read )
29  * numMass -- number of quark masses ( Read )
30  * RsdCG -- the CG accuracy used for multishift CG ( Read )
31  */
32 
33 void StagPbp(XMLWriter& xml_out,
34  const StaggeredFermActBase& S_f,
36  const multi1d<Real>& Mass,
37  enum InvType invType,
38  const multi1d<Real>& RsdCG,
39  int MaxCG,
40  int nhit)
41 {
42  START_CODE();
43 
44  const int numMass = Mass.size();
45 
46  int n_congrd;
47  int n_congrd_tot;
48  multi1d<Double> TrDinv(numMass);
49  multi1d<Double> TrHinv_sq(numMass);
50  multi1d<Double> TrDinv_sq(numMass);
51  Double TrBdag_B;
52  multi1d<Double> TrBdag_Eta(numMass);
53  multi1d<Double> TrEtadag_Eta(numMass);
54  Double TrBdag_B_avg;
55  multi1d<Double> TrBdag_Eta_avg(numMass);
56  multi1d<Double> TrEtadag_Eta_avg(numMass);
57  multi1d<LatticeStaggeredFermion> eta(numMass);
58  LatticeStaggeredFermion b;
59  LatticeReal lrtrace_aux;
60 
62  Double two;
63  Double mass;
64  int ihit;
65  int i;
66 
67  /* Code is specific to staggered fermions */
68 #if 0
69  if (FermAct != STAGGERED)
70  QDP_error_exit("only support staggered fermions", FermAct);
71 #endif
72 
73 
74  TrBdag_B_avg = 0;
75  TrBdag_Eta_avg = 0;
76  TrEtadag_Eta_avg = 0;
77  n_congrd_tot = 0;
78 
79 
80  for(ihit = 1; ihit <= nhit; ++ihit)
81  {
82  /* Fill with random gaussian noise such that < b_dagger * b > = 1 per d.o.f. */
83  gaussian(b);
84  n_congrd = 0;
85 
86 #if 0
87  /* If using Schroedinger functional, zero out the boundaries */
88  S_f.getFermBC().modifyF(b);
89 #endif
90 
91  /* Keep track of actual norm of noise */
92  TrBdag_B = norm2(b);
93 
94 
95  /* Prop. solution */
96  /* eta = (D*D_dag)^(-1) * b */
97  MStQprop (u, b, Mass, numMass, RsdCG, eta, 4, n_congrd);
98 
99 
100  /* Construct, using that b and eta live only on the even sublattice */
101  /* Tr Bdag_B = < b_dag * b > */
102  /* Tr Bdag_Eta = < b_dag * eta > */
103  /* Tr Etadag_Eta = < eta_dag * eta > */
104  /* Use these to make */
105  /* Tr D^{-1} = m * < b_dag * eta > */
106  /* Tr (D^dag D)^{-1} = Tr H^{-2} = < b_dag * eta > */
107  /* Omega = Tr (D^dag D)^{-1} + Tr D^{-2} */
108  /* = 2 * m^2 * < eta^dag * eta > */
109  /* Tr D^{-2} = Omega - Tr (D^dag D)^{-1} */
110 
111  TrBdag_Eta = 0;
112  TrEtadag_Eta = 0;
113 
114  for(i=0; i < numMass; ++i)
115  {
116  lrtrace_aux = real(trace(adj[b] * eta[i]));
117  TrBdag_Eta[i] += sum(lrtrace_aux);
118 
119  TrEtadag_Eta[i] += norm2(eta[i]);
120  }
121 
122 
123 
124  /* Add on to running average */
125  TrBdag_B_avg += TrBdag_B;
126  TrBdag_Eta_avg += TrBdag_Eta;
127  TrEtadag_Eta_avg += TrEtadag_Eta;
129 
130  /* Normalize and print */
131  ddummy1 = TO_DOUBLE(1) / TO_DOUBLE(vol_cb);
132  TrBdag_B = TrBdag_B * ddummy1;
133  for(i=0; i < numMass; ++i)
134  {
135  TrBdag_Eta[i] = TrBdag_Eta[i] * ddummy1;
136  TrEtadag_Eta[i] = TrEtadag_Eta[i] * ddummy1;
137  }
138 
139  push(xml_out,"Staggered_trace_hit");
140  write(xml_out, "ihit", ihit);
141  write(xml_out, "nhit", nhit);
142  write(xml_out, "TrBdag_B", TrBdag_B);
143  write(xml_out, "TrBdag_Eta", TrBdag_Eta);
144  write(xml_out, "TrEtadag_Eta", TrEtadag_Eta);
145  write(xml_out, "n_congrd", n_congrd);
146  pop(xml_out);
147  }
148 
149 
150  /* Normalize */
151  ddummy1 = TO_DOUBLE(1) / TO_DOUBLE(nhit * vol_cb);
152  TrBdag_B_avg = TrBdag_B_avg * ddummy1;
153  for(i=0; i < numMass; ++i)
154  {
155  TrBdag_Eta_avg[i] = TrBdag_Eta_avg[i] * ddummy1;
156  TrEtadag_Eta_avg[i] = TrEtadag_Eta_avg[i] * ddummy1;
157  }
158 
159  /* For niceties and redundancies, turn into the usual traces */
160  /* The traces are linear combinations of the inner products, so */
161  /* the average goes through */
162  /* Use these to make */
163  /* Tr D^{-1} = m * < b_dag * eta > */
164  /* Tr (D^dag D)^{-1} = Tr H^{-2} = < b_dag * eta > */
165  /* Omega = Tr (D^dag D)^{-1} + Tr D^{-2} */
166  /* = 2 * m^2 * < eta^dag * eta > */
167  /* Tr D^{-2} = Omega - Tr (D^dag D)^{-1} */
168  /* Tr D^{-2} = Omega - Tr H^{-2} */
169 
170  two = 2;
171 
172  for(i=0; i < numMass; ++i)
173  {
174  mass = FLOAT(Mass[i]);
175  ddummy1 = two * mass * mass;
176  TrHinv_sq[i] = TrBdag_Eta_avg[i];
177  TrDinv[i] = TrHinv_sq[i] * mass;
178  TrDinv_sq[i] = -TrHinv_sq[i];
179  TrDinv_sq[i] += TrEtadag_Eta_avg[i] * ddummy1;
180  }
181 
182  push(xml_out,"Staggered_trace_avg");
183  write(xml_out, "nhit", nhit);
184  write(xml_out, "TrBdag_B_avg", TrBdag_B_avg);
185  write(xml_out, "TrBdag_Eta_avg", TrBdag_Eta_avg);
186  write(xml_out, "TrEtadag_Eta_avg", TrEtadag_Eta_avg);
187  write(xml_out, "TrDinv", TrDinv);
188  write(xml_out, "TrHinv_sq", TrHinv_sq);
189  write(xml_out, "TrDinv_sq", TrDinv_sq);
190  write(xml_out, "n_congrd_tot", n_congrd_tot);
191  pop(xml_out);
192 
193 
194 
195  END_CODE();
196 }
197 
198 } // end namespace Chroma
Primary include file for CHROMA library code.
Class for counted reference semantics.
Definition: handle.h:33
int FermAct
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams &param)
Writer parameters.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
gaussian(aux)
Double two
Definition: pbg5p_w.cc:53
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > const multi1d< Real > enum InvType invType const multi1d< Real > & RsdCG
Definition: pbg5p_w.cc:30
QDP_error_exit("too many BiCG iterations", n_count, rsd_sq, cp, c, re_rvr, im_rvr, re_a, im_a, re_b, im_b)
static multi1d< LatticeColorMatrix > u
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > const multi1d< Real > & Mass
Definition: pbg5p_w.cc:29
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 StagPbp(XMLWriter &xml_out, const StaggeredFermActBase &S_f, Handle< const ConnectState > state, const multi1d< Real > &Mass, enum InvType invType, const multi1d< Real > &RsdCG, int MaxCG, int nhit)
Calculates noise estimator for the staggered trace.
Definition: stagpbp_s.cc:33
LatticeReal lrtrace_aux
Definition: mespbg5p_w.cc:40
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
FloatingPoint< double > Double
Definition: gtest.h:7351
#define STAGGERED
Definition: primitives.h:53
Double sum
Definition: qtopcor.cc:37