CHROMA
klein_gordon_linop_s.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Klein-Gordon boson action masquerading action as a staggered action
3  */
4 
5 #include "chromabase.h"
7 
8 namespace Chroma
9 {
10  // Full constructor
12  const Real& Mass_,
13  const AnisoParam_t& aniso)
14  {
15  create(state_, Mass_, aniso);
16  }
17 
18 
19  // Creation routine with anisotropy
21  const Real& Mass_,
22  const AnisoParam_t& aniso_)
23  {
24  START_CODE();
25 
26  // Save a copy of the aniso params original fields and with aniso folded in
27  Mass = Mass_;
28  anisoParam = aniso_;
29 
30  // Save a copy of the fermbc
31  fbc = state->getFermBC();
32 
33  // Sanity check
34  if (fbc.operator->() == 0)
35  {
36  QDPIO::cerr << "KleinGordonLinOp: error - fbc is null" << std::endl;
37  QDP_abort(1);
38  }
39 
40  // Fold in anisotropy
41  u = state->getLinks();
42  Real ff = where(anisoParam.anisoP, anisoParam.nu / anisoParam.xi_0, Real(1));
43  fact = 1 + (Nd-1)*ff + Mass;
44 
45  if (anisoParam.anisoP)
46  {
47  // Rescale the u fields by the anisotropy
48  for(int mu=0; mu < u.size(); ++mu)
49  {
50  if (mu != anisoParam.t_dir)
51  u[mu] *= ff;
52  }
53  }
54 
55  END_CODE();
56  }
57 
58 
59  // Apply unpreconditioned Klein-Gordon operator
60  void KleinGordonLinOp::operator()(LatticeStaggeredFermion& chi,
61  const LatticeStaggeredFermion& psi,
62  enum PlusMinus isign) const
63  {
64  START_CODE();
65 
66  LatticeStaggeredFermion tmp; moveToFastMemoryHint(tmp);
67  tmp = zero;
68 
69  for(int mu = 0; mu < Nd; ++mu )
70  {
71  tmp += u[mu]*shift(psi, FORWARD, mu);
72  tmp += shift(adj(u[mu])*psi, BACKWARD, mu);
73  }
74 
75  Real mhalf = -0.5;
76  chi = fact*psi + mhalf*tmp;
77 
78  getFermBC().modifyF(chi);
79 
80  END_CODE();
81  }
82 
83 
84  // Derivative of unpreconditioned Klein-Gordon operator
85  void
86  KleinGordonLinOp::deriv(multi1d<LatticeColorMatrix>& ds_u,
87  const LatticeStaggeredFermion& chi,
88  const LatticeStaggeredFermion& psi,
89  enum PlusMinus isign) const
90  {
91  START_CODE();
92 
93  ds_u.resize(Nd);
94 
95  multi1d<Real> anisoWeights(Nd);
96  anisoWeights = 1;
97  Real mhalf = -0.5;
98 
99  Real ff = where(anisoParam.anisoP, anisoParam.nu / anisoParam.xi_0, Real(1));
100 
101  if (anisoParam.anisoP)
102  {
103  // Set the weights
104  for(int mu=0; mu < Nd; ++mu)
105  {
106  if (mu != anisoParam.t_dir)
107  anisoWeights[mu] *= ff;
108  }
109  }
110 
111 
112  // The normalizations here are confusing (at least to RGE). See the comments
113  // in lwldslash_base_w.cc
114  switch (isign)
115  {
116  case PLUS:
117  for(int mu = 0; mu < Nd; ++mu)
118  {
119  // Undaggered:
120  ds_u[mu] = mhalf * anisoWeights[mu] * traceSpin(outerProduct(shift(psi, FORWARD, mu),chi));
121  }
122  break;
123 
124  case MINUS:
125  for(int mu = 0; mu < Nd; ++mu)
126  {
127  // Daggered:
128  ds_u[mu] = mhalf * anisoWeights[mu] * traceSpin(outerProduct(shift(psi, FORWARD, mu),chi));
129  }
130  break;
131 
132  default:
133  QDP_error_exit("unknown case");
134  }
135 
136  getFermBC().zero(ds_u);
137 
138  END_CODE();
139  }
140 
141 
142  // Return flops performed by the operator()
143  unsigned long KleinGordonLinOp::nFlops() const
144  {
145  // fact*psi + U*psi = (fact*psi = 6M) + (8 dirs)*(3 rows)*(3 cols)*(2M + 2A)
146  unsigned long site_flops = 294;
147  return site_flops*(Layout::sitesOnNode());
148  }
149 
150 } // End Namespace Chroma
151 
Primary include file for CHROMA library code.
Support class for fermion actions and linear operators.
Definition: state.h:94
Class for counted reference semantics.
Definition: handle.h:33
Handle< FermBC< T, P, Q > > fbc
void operator()(T &chi, const T &psi, enum PlusMinus isign) const
Apply the operator onto a source std::vector.
const FermBC< T, P, Q > & getFermBC() const
Return the fermion BC object for this linear operator.
void deriv(multi1d< LatticeColorMatrix > &ds_u, const T &chi, const T &psi, enum PlusMinus isign) const
Derivative of unpreconditioned operator.
void create(Handle< FermState< T, P, Q > > fs, const Real &Mass_, const AnisoParam_t &aniso)
Creation routine with Anisotropy.
KleinGordonLinOp()
Partial constructor - Must use create later.
unsigned long nFlops() const
Return flops performed by the operator()
multi1d< LatticeColorMatrix > u
int mu
Definition: cool.cc:24
Klein-Gordon operator.
Nd
Definition: meslate.cc:74
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)
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
@ MINUS
Definition: chromabase.h:45
@ PLUS
Definition: chromabase.h:45
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
START_CODE()
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
Definition: pbg5p_w.cc:28
Double zero
Definition: invbicg.cc:106
#define FORWARD
Definition: primitives.h:82
#define BACKWARD
Definition: primitives.h:83
Parameters for anisotropy.
Definition: aniso_io.h:24