CHROMA
wupp_smear.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief 3d Laplacian solution on color std::vector
3  */
4 
5 #error "THIS CODE IS NOT YET READY"
6 
7 #include "chromabase.h"
8 #include "meas/smear/wupp_smear.h"
9 #include "util/ft/sftmom.h"
10 
11 namespace Chroma
12 {
13 
14  //! Do a covariant Gaussian smearing of a lattice field
15  /*!
16  * Arguments:
17  *
18  * \param u gauge field ( Read )
19  * \param chi color std::vector field ( Modify )
20  * \param width width of "shell" wave function ( Read )
21  * \param ItrGaus number of iterations to approximate Gaussian ( Read )
22  * \param j_decay direction of decay ( Read )
23  */
24 
25  template<typename T>
26  void gausSmear(const multi1d<LatticeColorMatrix>& u,
27  T& chi,
28  const Real& width, int ItrGaus, int j_decay)
29  {
30  T psi;
31 
32  Real ftmp = - (width*width) / Real(4*ItrGaus);
33  /* The Klein-Gordon operator is (Lapl + mass_sq), where Lapl = -d^2/dx^2.. */
34  /* We want (1 + ftmp * Lapl ) = (Lapl + 1/ftmp)*ftmp */
35  Real ftmpi = Real(1) / ftmp;
36 
37  for(int n = 0; n < ItrGaus; ++n)
38  {
39  psi = chi * ftmp;
40  klein_gord(u, psi, chi, ftmpi, j_decay);
41  }
42  }
43 
44 
45  //! Do a covariant Gaussian smearing of a lattice color std::vector field
46  /*! This is a wrapper over the template definition
47  *
48  * \ingroup smear
49  *
50  * Arguments:
51  *
52  * \param u gauge field ( Read )
53  * \param chi color std::vector field ( Modify )
54  * \param width width of "shell" wave function ( Read )
55  * \param ItrGaus number of iterations to approximate Gaussian ( Read )
56  * \param j_decay direction of decay ( Read )
57  */
58 
59  void gausSmear(const multi1d<LatticeColorMatrix>& u,
60  LatticeColorVector& chi,
61  const Real& width, int ItrGaus, int j_decay)
62  {
63  gausSmear<LatticeColorVector>(u, chi, width, ItrGaus, j_decay);
64  }
65 
66 
67 
68 
69  //! Do a covariant Wuppertal smearing of a color std::vector field
70  /* u -- gauge field ( Read ) */
71  /* chi -- color std::vector field ( Modify ) */
72  /* mass_sq -- mass_sq of Wuppertal "shell" wave function ( Read ) */
73  /* ItrMax -- maximal number of iterations to invert ( Read ) */
74  /* j_decay -- direction of decay ( Read ) */
75  /* RsdCG -- residue for CG inverter ( Read ) */
76 
77  void wuppSmear(const multi1d<LatticeColorMatrix>& u,
78  LatticeColorVector& chi,
79  const Real& mass_sq, int ItrMax, int j_decay, const Real& RsdCG)
80  {
81  LatticeColorVector p;
82  LatticeColorVector r;
83  LatticeColorVector ap;
84  LatticeReal apa;
85  LatticeReal tmp;
86  LatticeInteger t_coord;
87  LatticeBoolean t_mask;
88  Real Rsd;
89  multi1d<Real> zero(length);
90  multi1d<Real> ab(length);
91  multi1d<Double> c(length);
92  multi1d<Double> d(length);
93  multi1d<Double> dd(length);
94  multi1d<Double> chi_norm(length);
95  multi1d<Double> cp(length);
96  int length;
97  int t;
98  int k;
99  int cb;
100  int converged;
101  multi1d<Boolean> is_zero(length);
102  Boolean any_zero;
103 
104  START_CODE();
105 
106  length = nrow[j_decay];
107  Rsd = RsdCG * RsdCG;
108 
109  /* The Klein-Gordon operator is (Lapl + mass_sq), where Lapl = -d^2/dx^2.. */
110  /* Use CG to compute psi = (Lapl + mass_sq)^(-1) chi */
111  /* Note: Lapl is a 3-d laplacian; each time slice is handled independently. */
112 
113 
114  zero = 0;
115 
116  /* chi_norm = |chi[0]|^2 */
117  chi_norm = 0;
118  for(cb = 0; cb < Nsubl; cb++)
119  SLICE_SUMSQ(chi(cb), j_decay, chi_norm, ADD);
120 
121  dd = 0;
122  is_zero = chi_norm == dd;
123  FILL(any_zero,FALSE);
124  for(t = 0; t < length; t++)
125  any_zero = any_zero | is_zero[t];
126 
127  /* p[1] = r[0] = chi */
128  r = chi;
129  p = r;
130 
131  /* Cp = |r[0]|^2 = chi_norm */
132  cp = chi_norm;
133 
134  for(t = 0; t < length; t++)
135  chi_norm[t] *= Rsd;
136 
137  /* We overwrite chi with the solution; initial solution is zero */
138  chi = 0;
139 
140  t_coord = Layout::latticeCoordinate(j_decay);
141 
142  for(k = 1; k <= ItrMax; k++)
143  {
144  /* c = |r[k-1]|^2 */
145  c = cp;
146 
147  /* a[k] = |r[k-1]|^2 / < p[k], Ap[k] > ; */
148  /* First compute ap = Ap[k] */
149  klein_gord (u, p, ap, mass_sq, j_decay);
150 
151  apa = real(trace(adj[p[0]] * ap[0]))
152  tmp = real(trace(adj[p[1]] * ap[1]))
153  apa += tmp;
154 
155  d = sumMulti(apa, timeslice)
156 
157  dd = c / d;
158  ab = FLOAT(dd);
159  if( any_zero )
160  copymask(ab, is_zero, zero, REPLACE);
161 
162  /* Chi[k] += a[k] p[k] */
163  /* SLICE_FILL(apa, ab); */
164  apa = 0;
165  for(t = 0; t < length; t++)
166  if( ! is_zero[t] )
167  {
168  FILL(tmp, ab(t));
169  t_mask = t_coord == t;
170  copymask(apa, t_mask, tmp, REPLACE);
171  }
172  for(cb = 0; cb < Nsubl; cb++)
173  chi[cb] += p[cb] * apa;
174  /* r[k] -= a[k] Ap[k] */
175  for(cb = 0; cb < Nsubl; cb++)
176  r[cb] -= ap[cb] * apa;
177 
178  /* cp = |r[k]|^2 */
179  cp = 0;
180  for(cb = 0; cb < Nsubl; cb++)
181  SLICE_SUMSQ(r(cb), j_decay, cp, ADD);
182 
183  converged = 0;
184  for(t = 0; t < length; t++)
185  if( cp[t] <= chi_norm[t] )
186  converged += 1;
187 
188  /* push(xml_out,"Residues");
189  write(xml_out, "k", k);
190  write(xml_out, "cp", cp);
191  pop(xml_out); */
192 
193  if( converged == length )
194  {
195  push(xml_out,"Wupp_smear_needed");
196  write(xml_out, "k", k);
197  pop(xml_out);
198  return;
199  }
200 
201  /* b[k+1] = |r[k]|^2 / |r[k-1]|^2 */
202  dd = cp / c;
203  ab = FLOAT(dd);
204  if( any_zero )
205  copymask(ab, is_zero, zero, REPLACE);
206 
207  /* p[k+1] = r[k] + b[k+1] p[k] */
208  /* SLICE_FILL(apa, ab); */
209  apa = 0;
210  for(t = 0; t < length; t++)
211  if( ! is_zero[t] )
212  {
213  FILL(tmp, ab(t));
214  t_mask = t_coord == t;
215  copymask(apa, t_mask, tmp, REPLACE);
216  }
217  for(cb = 0; cb < Nsubl; cb++)
218  {
219  p[cb] = p[cb] * apa;
220  p[cb] += r[cb];
221  }
222  }
223 
224  push(xml_out,"Wupp_smear_not_converged");
225  write(xml_out, "k", k);
226  pop(xml_out);
227 
228  END_CODE();
229  }
230 
231 } // namespace Chroma
Primary include file for CHROMA library code.
void klein_gord(const multi1d< LatticeColorMatrix > &u, const T &psi, T &chi, const Real &mass_sq, int j_decay)
Compute the covariant Klein-Gordon operator.
Definition: klein_gord.cc:31
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams &param)
Writer parameters.
void gausSmear(const multi1d< LatticeColorMatrix > &u, T &chi, const Real &width, int ItrGaus, int j_decay)
Do a covariant Gaussian smearing of a lattice field.
Definition: gaus_smear.cc:24
unsigned n
Definition: ldumul_w.cc:36
int j_decay
Definition: meslate.cc:22
int t
Definition: meslate.cc:37
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > const multi1d< Real > enum InvType invType const multi1d< Real > & RsdCG
Definition: pbg5p_w.cc:30
static multi1d< LatticeColorMatrix > u
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
push(xml_out,"Condensates")
Double c
Definition: invbicg.cc:108
Double cp
Definition: invbicg.cc:107
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
pop(xml_out)
void wuppSmear(const multi1d< LatticeColorMatrix > &u, LatticeColorVector &chi, const Real &mass_sq, int ItrMax, int j_decay, const Real &RsdCG)
Do a covariant Wuppertal smearing of a color std::vector field.
Definition: wupp_smear.cc:77
DComplex d
Definition: invbicg.cc:99
START_CODE()
int cb
Definition: invbicg.cc:120
Double chi_norm
Definition: invbicg.cc:79
Double zero
Definition: invbicg.cc:106
int k
Definition: invbicg.cc:119
copymask(lcoord, lbit, ltmp_1, REPLACE)
FILL(ltmp_1, itmp)
Fourier transform phase factor support.
LatticeFermion T
Definition: t_clover.cc:11