CHROMA
deriv_quark_displacement_s.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Derivative displacements
3  */
4 
5 #include "chromabase.h"
6 
10 
11 namespace Chroma
12 {
13 
14  // Read parameters
15  void read(XMLReader& xml, const std::string& path, StaggeredDerivQuarkDisplacementEnv::Params& param)
16  {
18  param = tmp;
19  }
20 
21  // Writer
22  void write(XMLWriter& xml, const std::string& path, const StaggeredDerivQuarkDisplacementEnv::Params& param)
23  {
24  param.writeXML(xml, path);
25  }
26 
27 
28  // Read parameters
29  void read(XMLReader& xml, const std::string& path, StaggeredDerivQuarkDisplacementEnv::ParamsDir& param)
30  {
32  param = tmp;
33  }
34 
35  // Writer
36  void write(XMLWriter& xml, const std::string& path, const StaggeredDerivQuarkDisplacementEnv::ParamsDir& param)
37  {
38  param.writeXML(xml, path);
39  }
40 
41 
42 
43  //! Meson sources
44  /*! \ingroup sources */
45  namespace StaggeredDerivQuarkDisplacementEnv
46  {
47  //! Anonymous namespace
48  namespace
49  {
50 
51  //! Determine sign of plusminus
52  /*!
53  * \ingroup sources
54  */
55  int plusMinus(enum PlusMinus isign)
56  {
57  int is = 0;
58  switch (isign)
59  {
60  case PLUS:
61  is = +1;
62  break;
63 
64  case MINUS:
65  is = -1;
66  break;
67 
68  default:
69  QDP_error_exit("illegal isign in plusminus");
70  }
71  return is;
72  }
73 
74 
75  //! Private displacement
76  LatticeStaggeredPropagator displacement(const multi1d<LatticeColorMatrix>& u,
77  const LatticeStaggeredPropagator& psi,
78  int length, int dir)
79  {
80  if (dir < 0 || dir >= Nd)
81  {
82  QDPIO::cerr << __func__ << ": invalid direction: dir=" << dir << std::endl;
83  QDP_abort(1);
84  }
85 
86  LatticeStaggeredPropagator chi = psi;
87 
88  if (length > 0)
89  {
90  for(int n = 0; n < length; ++n)
91  {
92  LatticeStaggeredPropagator tmp = shift(chi, FORWARD, dir);
93  chi = u[dir] * tmp;
94  }
95  }
96  else // If length = or < 0. If length == 0, does nothing.
97  {
98  for(int n = 0; n > length; --n)
99  {
100  LatticeStaggeredPropagator tmp = shift(adj(u[dir])*chi, BACKWARD, dir);
101  chi = tmp;
102  }
103  }
104  return chi;
105  }
106 
107 
108  //! Apply first deriv to the right onto source
109  /*!
110  * \ingroup sources
111  *
112  * \f$\nabla_\mu f(x) = U_\mu(x)f(x+\mu) - U_{-\mu}(x)f(x-\mu)\f$
113  *
114  * \return $\f \nabla_\mu F(x)\f$
115  */
116  LatticeStaggeredPropagator rightNabla(const LatticeStaggeredPropagator& F,
117  const multi1d<LatticeColorMatrix>& u,
118  int mu, int length)
119  {
120  return displacement(u, F, length, mu) - displacement(u, F, -length, mu);
121  }
122 
123 
124  //-------------------- callback functions ---------------------------------------
125 
126  //! Construct (right Nabla) source
127  QuarkDisplacement<LatticeStaggeredPropagator>* rightNablaDisplace(XMLReader& xml_in,
128  const std::string& path)
129  {
131  }
132 
133  } // end anonymous namespace
134 
135 
136  //! Initialize
138  {
139  deriv_length = 0;
140  }
141 
142  //! Read parameters
143  Params::Params(XMLReader& xml, const std::string& path)
144  {
145  XMLReader paramtop(xml, path);
146 
147  int version;
148  read(paramtop, "version", version);
149 
150  switch (version)
151  {
152  case 1:
153  break;
154 
155  default:
156  QDPIO::cerr << __func__ << ": parameter version " << version
157  << " unsupported." << std::endl;
158  QDP_abort(1);
159  }
160 
161  read(paramtop, "DisplacementType", displacement_type);
162  read(paramtop, "deriv_length", deriv_length);
163  }
164 
165  // Writer
166  void Params::writeXML(XMLWriter& xml, const std::string& path) const
167  {
168  push(xml, path);
169 
170  int version = 1;
171  QDP::write(xml, "version", version);
172 
173  write(xml, "DisplacementType", displacement_type);
174  write(xml, "deriv_length", deriv_length);
175 
176  pop(xml);
177  }
178 
179 
180  //! Initialize
182  {
183  deriv_dir = -1;
184  deriv_length = 0;
185  }
186 
187 
188  //! Read parameters
189  ParamsDir::ParamsDir(XMLReader& xml, const std::string& path)
190  {
191  XMLReader paramtop(xml, path);
192 
193  int version;
194  read(paramtop, "version", version);
195 
196  switch (version)
197  {
198  case 1:
199  break;
200 
201  default:
202  QDPIO::cerr << __func__ << ": parameter version " << version
203  << " unsupported." << std::endl;
204  QDP_abort(1);
205  }
206 
207  read(paramtop, "DisplacementType", displacement_type);
208 
209  read(paramtop, "deriv_dir", deriv_dir);
210  read(paramtop, "deriv_length", deriv_length);
211  }
212 
213 
214  // Writer
215  void ParamsDir::writeXML(XMLWriter& xml, const std::string& path) const
216  {
217  push(xml, path);
218 
219  int version = 1;
220  QDP::write(xml, "version", version);
221 
222  write(xml, "DisplacementType", displacement_type);
223  write(xml, "deriv_dir", deriv_dir);
224  write(xml, "deriv_length", deriv_length);
225 
226  pop(xml);
227  }
228 
229 
230  // Construct (right Nabla) source
231  // See corresponding .h file for doxygen comments
232  template<>
233  void
235  const multi1d<LatticeColorMatrix>& u,
236  enum PlusMinus isign) const
237  {
238  START_CODE();
239 
240  LatticeStaggeredPropagator fin;
241  int length = plusMinus(isign) * params.deriv_length;
242 
243  // \f$\Gamma_f \equiv \nabla_i\f$
244  fin = rightNabla(tmp,u,params.deriv_dir,length);
245  tmp = fin;
246 
247  END_CODE();
248  }
249 
250 
251  //! Local registration flag
252  static bool registered = false;
253 
254  //! Register all the possible deriv mesons
255  bool registerAll()
256  {
257  bool success = true;
258  if (! registered)
259  {
260  //! Register all the factories
261  success &= Chroma::TheStagPropDisplacementFactory::Instance().registerObject(std::string("NABLA-DERIV"),
262  rightNablaDisplace);
263 
264  registered = true;
265  }
266  return success;
267  }
268  } // end namespace StaggeredDerivQuarkDisplacementEnv
269 
270 } // end namespace Chroma
271 
272 
273 
274 
Primary include file for CHROMA library code.
Base class for quark displacement.
static T & Instance()
Definition: singleton.h:432
void operator()(T &quark, const multi1d< LatticeColorMatrix > &u, enum PlusMinus isign) const
Displace the quark.
int mu
Definition: cool.cc:24
Staggered Derivative displacements.
void read(XMLReader &xml, const std::string &path, AsqtadFermActParams &param)
Read parameters.
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams &param)
Writer parameters.
LatticeColorVector rightNabla(const multi1d< LatticeColorMatrix > &u, const LatticeColorVector &chi, int length, const multi1d< int > &path)
Apply a right nabla path to a lattice field.
LatticePropagator displacement(const multi1d< LatticeColorMatrix > &u, const LatticePropagator &chi, int length, int dir)
Apply a displacement operator to a lattice field.
void write(XMLWriter &xml, const std::string &path, const StaggeredDerivQuarkDisplacementEnv::ParamsDir &param)
Writer.
Params params
unsigned n
Definition: ldumul_w.cc:36
Nd
Definition: meslate.cc:74
Register all the possible deriv mesons bool registerAll()
Local registration static flag bool registered
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)
static multi1d< LatticeColorMatrix > u
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
push(xml_out,"Condensates")
@ MINUS
Definition: chromabase.h:45
@ PLUS
Definition: chromabase.h:45
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
pop(xml_out)
START_CODE()
::std::string string
Definition: gtest.h:1979
#define FORWARD
Definition: primitives.h:82
#define BACKWARD
Definition: primitives.h:83
All quark displacement constructors.
Factory for producing quark displacement objects.
void writeXML(XMLWriter &in, const std::string &path) const
void writeXML(XMLWriter &in, const std::string &path) const
static INTERNAL_PRECISION F