CHROMA
unprec_ovlap_contfrac5d_pv_linop_array_w.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Unpreconditioned Pauli-Villars Continued Fraction 5D
3  */
4 
5 #include "chromabase.h"
6 #include "linearop.h"
7 
9 
10 namespace Chroma
11 {
12  //! Apply the operator onto a source std::vector
13  /*!
14  * The operator acts on the entire lattice
15  *
16  * \param psi Pseudofermion field (Read)
17  * \param isign Flag ( PLUS | MINUS ) (Read)
18  */
19  void
21  const multi1d<LatticeFermion>& psi,
22  enum PlusMinus isign) const
23  {
24  START_CODE();
25 
26  if( chi.size() != N5 ) chi.resize(N5);
27 
28  int G5 = Ns*Ns - 1;
29 
30  // This is the upper limit for the index of the 5th dimension, i.e.
31  // it runs from 0 to TwoN. (altogether TwoN + 1 numbers. This
32  // makes sense since N5 is ALWAYS odd. )
33  int TwoN = N5 - 1;
34 
35  // The sign of the diagonal terms.
36  // We flip Hsign BEFORE using it
37  // This makes the first element always have a PLUS sign
38  int Hsign=-1;
39 
40  // Run through all the pseudofermion fields:
41  // chi(n) = beta(n)*H*psi(0)
42  // chi(TwoN) = beta(TwoN)*H*psi(TwoN)
43 
44  LatticeFermion tmp1, tmp2;
45  Real pmscale;
46 
47  for(int n = 0; n < TwoN; ++n)
48  {
49  (*M)(tmp1, psi[n], PLUS); // tmp1 = M psi[n]
50  tmp2 = Gamma(G5)*tmp1; // tmp2 = gamma_5 M psi
51 
52  // Scale factor and sign for the diagonal term proportional to H
53  // The scale factor should be chosen in the fermact call such that
54  // that scale_fac * gamma5 * M has eigenvalues between -1 and 1
55  Hsign = -Hsign;
56  pmscale = beta[n]*Hsign*scale_fac;
57  chi[n] = pmscale*tmp2;
58 
59  if( n < TwoN-1 ) {
60  chi[n] += alpha[n] * psi[n+1];
61  }
62 
63  if( n > 0 ) {
64  chi[n] += alpha[n-1]*psi[n-1];
65  }
66  }
67 
68  // Last Component
69  // chi[N] = psi[N]
70  chi[TwoN] = psi[TwoN];
71 
72  // Project out eigenvectors from Source if desired
73  if( NEig > 0 )
74  {
75  QDPIO::cerr << "project in contfrac5d PV not supported" << std::endl;
76  QDP_abort(1);
77  }
78 
79  // Complete the last component
80  // chi(N) = chi(N) + beta_{N}*psi_{N}
81  // The contribution beta_{N}*gamma_5*M*psi_{N} is
82  // caluclated only if betaa_{N} != 0 */
83 
84 // if( !isLastZeroP )
85 // {
86 // // This term does not contribute to PV
87 // }
88 
89  getFermBC().modifyF(chi);
90 
91  END_CODE();
92  }
93 
94 
95  //! Derivative
96  void
97  UnprecOvlapContFrac5DPVLinOpArray::deriv(multi1d<LatticeColorMatrix>& ds_u,
98  const multi1d<LatticeFermion>& chi,
99  const multi1d<LatticeFermion>& psi,
100  enum PlusMinus isign) const
101  {
102  START_CODE();
103 
104  ds_u.resize(Nd);
105  ds_u = zero;
106 
107  multi1d<LatticeColorMatrix> ds_tmp(Nd);
108  int G5 = Ns*Ns - 1;
109 
110  // This is the upper limit for the index of the 5th dimension, i.e.
111  // it runs from 0 to TwoN. (altogether TwoN + 1 numbers. This
112  // makes sense since N5 is ALWAYS odd. )
113  int TwoN = N5 - 1;
114 
115  // The sign of the diagonal terms.
116  // We flip Hsign BEFORE using it
117  // This makes the first element always have a PLUS sign
118  int Hsign=-1;
119 
120  // Run through all the pseudofermion fields:
121  // chi(n) = beta(n)*H*psi(0)
122  // chi(TwoN) = beta(TwoN)*H*psi(TwoN)
123 
124  LatticeFermion tmp1, tmp2;
125  Real pmscale;
126 
127  switch (isign)
128  {
129  case PLUS:
130  for(int n = 0; n < TwoN; ++n)
131  {
132  tmp2 = Gamma(G5)*chi[n]; // tmp2 = gamma_5 M chi
133 
134  // Scale factor and sign for the diagonal term proportional to H
135  // The scale factor should be chosen in fermact call such
136  // that scale_fac * gamma5 * M has eigenvalues between -1 and 1
137  Hsign = -Hsign;
138  pmscale = beta[n]*Hsign*scale_fac;
139  tmp1 = pmscale*tmp2;
140 
141  M->deriv(ds_tmp, tmp1, psi[n], PLUS); // tmp1 = M psi[n]
142  ds_u += ds_tmp;
143  }
144  break;
145 
146  case MINUS:
147  for(int n = 0; n < TwoN; ++n)
148  {
149  tmp2 = Gamma(G5)*psi[n]; // tmp2 = M^dag gamma_5 psi
150 
151  // Scale factor and sign for the diagonal term proportional to H
152  // The scale factor should be chosen in fermact call such
153  // that scale_fac * gamma5 * M has eigenvalues between -1 and 1
154  Hsign = -Hsign;
155  pmscale = beta[n]*Hsign*scale_fac;
156  tmp1 = pmscale*tmp2;
157 
158  M->deriv(ds_tmp, chi[n], tmp1, MINUS); // tmp1 = M psi[n]
159  ds_u += ds_tmp;
160  }
161  break;
162 
163  default:
164  QDP_error_exit("unknown case");
165  }
166 
167  // Project out eigenvectors from Source if desired
168  if( NEig > 0 )
169  {
170  QDPIO::cerr << "project in contfrac5d PV not supported" << std::endl;
171  QDP_abort(1);
172  }
173 
174  getFermBC().zero(ds_u);
175 
176  END_CODE();
177  }
178 
179 
180 } // End Namespace Chroma
181 
182 
Primary include file for CHROMA library code.
const FermBC< T, P, Q > & getFermBC() const
Return the fermion BC object for this linear operator.
void deriv(multi1d< LatticeColorMatrix > &ds_u, const multi1d< LatticeFermion > &chi, const multi1d< LatticeFermion > &psi, enum PlusMinus isign) const
Derivative.
void operator()(multi1d< LatticeFermion > &chi, const multi1d< LatticeFermion > &psi, enum PlusMinus isign) const
Apply the operator onto a source std::vector.
unsigned n
Definition: ldumul_w.cc:36
Linear Operators.
Nd
Definition: meslate.cc:74
Double tmp2
Definition: mesq.cc:30
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
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)
int G5
Definition: pbg5p_w.cc:57
@ MINUS
Definition: chromabase.h:45
@ PLUS
Definition: chromabase.h:45
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
START_CODE()
Double zero
Definition: invbicg.cc:106
Unpreconditioned Pauli-Villars Continued Fraction 5D.