CHROMA
simple_baryon_operator_w.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Construct simple baryon operators
3  */
4 
5 #include "qdp_config.h"
6 
7 
11 
14 
17 
18 namespace Chroma
19 {
20 
21  // Read parameters
22  void read(XMLReader& xml, const std::string& path, SimpleBaryonOperatorEnv::Params& param)
23  {
25  param = tmp;
26  }
27 
28  // Writer
29  void write(XMLWriter& xml, const std::string& path, const SimpleBaryonOperatorEnv::Params& param)
30  {
31  param.writeXML(xml, path);
32  }
33 
34 
35  //! Baryon sequential sources
36  /*! \ingroup hadron */
37  namespace SimpleBaryonOperatorEnv
38  {
39 
40  //! Initialize
42  {
43  }
44 
45 
46  //! Read parameters
47  Params::Params(XMLReader& xml, const std::string& path)
48  {
49  try
50  {
51  XMLReader paramtop(xml, path);
52 
53  int version;
54  read(paramtop, "version", version);
55 
56  switch (version)
57  {
58  case 2:
59  break;
60 
61  default:
62  QDPIO::cerr << name << ": parameter version " << version
63  << " unsupported." << std::endl;
64  QDP_abort(1);
65  }
66 
67  source_quark_smearing = readXMLGroup(paramtop, "SourceQuarkSmearing", "wvf_kind");
68  sink_quark_smearing = readXMLGroup(paramtop, "SinkQuarkSmearing", "wvf_kind");
69  link_smearing = readXMLGroup(paramtop, "LinkSmearing", "LinkSmearingType");
70  }
71  catch(const std::string& e)
72  {
73  QDPIO::cerr << name << ": Caught Exception in params: " << e << std::endl;
74  QDP_abort(1);
75  }
76  }
77 
78 
79  // Writer
80  void Params::writeXML(XMLWriter& xml, const std::string& path) const
81  {
82  push(xml, path);
83 
84  int version = 1;
85  write(xml, "version", version);
86  write(xml, "BaryonOperatorType", SimpleBaryonOperatorEnv::name);
88  xml << sink_quark_smearing.xml;
89  xml << link_smearing.xml;
90 
91  pop(xml);
92  }
93 
94 
95 
96  //! Full constructor
97  BarNuclCg5::BarNuclCg5(const Params& p, const multi1d<LatticeColorMatrix>& u_) :
98  params(p), u_smr(u_)
99  {
100  // Factory constructions
101  try
102  {
103  // Smear the gauge field if needed
104  {
105  std::istringstream xml_l(params.link_smearing.xml);
106  XMLReader linktop(xml_l);
107  const std::string link_path = "/LinkSmearing";
108  QDPIO::cout << "Link smearing type = " << params.link_smearing.id << std::endl;
109 
111  linkSmearing(TheLinkSmearingFactory::Instance().createObject(params.link_smearing.id,
112  linktop,
113  link_path));
114  (*linkSmearing)(u_smr);
115  }
116 
117  // Create the source quark smearing object
118  {
119  std::istringstream xml_s(params.source_quark_smearing.xml);
120  XMLReader smeartop(xml_s);
121  const std::string smear_path = "/SourceQuarkSmearing";
122 
125  smeartop,
126  smear_path);
127  }
128 
129  // Create the sink quark smearing object
130  {
131  std::istringstream xml_s(params.sink_quark_smearing.xml);
132  XMLReader smeartop(xml_s);
133  const std::string smear_path = "/SinkQuarkSmearing";
134 
137  smeartop,
138  smear_path);
139  }
140  }
141  catch(const std::string& e)
142  {
143  QDPIO::cerr << name << ": Caught Exception smearing: " << e << std::endl;
144  QDP_abort(1);
145  }
146  }
147 
148 
149  //! Manipulate the quark fields
150  void
151  BarNuclCg5::quarkManip(multi1d<LatticeFermion>& q,
152  const LatticeFermion& q1,
153  const LatticeFermion& q2,
154  const LatticeFermion& q3,
155  enum PlusMinus isign) const
156  {
157  START_CODE();
158 
159  q.resize(3);
160  q[0] = q1;
161  q[1] = q2;
162  q[2] = q3;
163 
164  // Depending on whether this is the sink or source, do the appropriate
165  // combination of smearing and displacing
166  switch (isign)
167  {
168  case PLUS:
169  // Sink smear the quarks
170  for(int i=0; i < q.size(); ++i)
171  (*sinkQuarkSmearing)(q[i], u_smr);
172  break;
173 
174  case MINUS:
175  // Source smear the quarks
176  for(int i=0; i < q.size(); ++i)
178  break;
179 
180  default:
181  QDPIO::cerr << name << ": illegal isign" << std::endl;
182  QDP_abort(1);
183  }
184 
185  END_CODE();
186  }
187 
188 
189  //! Compute the operator
190  multi1d<LatticeComplex>
191  BarNuclCg5::operator()(const LatticeFermion& q1,
192  const LatticeFermion& q2,
193  const LatticeFermion& q3,
194  enum PlusMinus isign) const
195  {
196  START_CODE();
197 
198 
199  // Depending on whether this is the sink or source, do the appropriate
200  // combination of smearing and displacing
201  multi1d<LatticeFermion> q;
202  quarkManip(q, q1, q2, q3, isign);
203 
204  // The return
205  multi1d<LatticeComplex> d(Ns);
206  d = zero;
207 
208  if ( Nc != 3 ){ /* Code is specific to Ns=4 and Nc=3. */
209  QDPIO::cerr<<"BarNuclCg5 code only works for Nc=3 and Ns=4\n";
210  QDP_abort(111) ;
211  }
212 #if QDP_NC == 3
213 
214  // C gamma_5 = Gamma(5)
215  SpinMatrix Cg5 = BaryonSpinMats::Cg5();
216 
217  for(int k=0; k < Ns; ++k)
218  {
219  LatticeSpinMatrix di_quark = zero;
220 
221  for(int j=0; j < Ns; ++j)
222  {
223  for(int i=0; i < Ns; ++i)
224  {
225  // Contract over color indices with antisym tensors
226  LatticeComplex b_oper = colorContract(peekSpin(q[0], i),
227  peekSpin(q[1], j),
228  peekSpin(q[2], k));
229 
230  pokeSpin(di_quark, b_oper, j, i);
231  }
232  }
233 
234  d[k] += traceSpin(Cg5 * di_quark);
235  }
236 
237 #endif
238  END_CODE();
239 
240  return d;
241  }
242 
243 
244  //! Anonymous namespace
245  namespace
246  {
247 
248  //-------------------- callback functions ---------------------------------------
249 
250  //! Nucleon = (u C gamma_5 d) u
251  /*!
252  * \ingroup hadron
253  *
254  * C gamma_5 = Gamma(5) = - (C gamma_5)^T
255  */
256  BaryonOperator<LatticeFermion>* barNuclCg5(XMLReader& xml_in,
257  const std::string& path,
258  const multi1d<LatticeColorMatrix>& u)
259  {
260  return new BarNuclCg5(Params(xml_in, path), u);
261  }
262 
263 
264  //! Local registration flag
265  bool registered = false;
266 
267  } // end anonymous namespace
268 
269 
270  //! Name
271  const std::string name = "NUCLEON";
272 
273  //! Register all the factories
274  bool registerAll()
275  {
276  bool success = true;
277  if (! registered)
278  {
279  success &= Chroma::TheWilsonBaryonOperatorFactory::Instance().registerObject(name, barNuclCg5);
280  registered = true;
281  }
282  return success;
283  }
284 
285  } // namespace BaryonOperatorCallMapEnv
286 
287 
288 } // end namespace Chroma
289 
290 
291 
Baryon spin and projector matrices.
Factory for producing baryon operators.
Class for counted reference semantics.
Definition: handle.h:33
Handle< QuarkSmearing< LatticeFermion > > sinkQuarkSmearing
multi1d< LatticeComplex > operator()(const LatticeFermion &quark1, const LatticeFermion &quark2, const LatticeFermion &quark3, enum PlusMinus isign) const
Compute the operator.
void quarkManip(multi1d< LatticeFermion > &q, const LatticeFermion &q1, const LatticeFermion &q2, const LatticeFermion &q3, enum PlusMinus isign) const
Manipulate the quark fields.
Handle< QuarkSmearing< LatticeFermion > > sourceQuarkSmearing
static T & Instance()
Definition: singleton.h:432
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.
GroupXML_t readXMLGroup(XMLReader &xml_in, const std::string &path, const std::string &type_name)
Read group and return as a std::string.
Params params
unsigned j
Definition: ldumul_w.cc:35
Double q
Definition: mesq.cc:17
static bool registered
Local registration flag.
SpinMatrix Cg5()
C g_5 = C gamma_5 = Gamma(5)
bool registerAll()
Register all the factories.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static multi1d< LatticeColorMatrix > u
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
push(xml_out,"Condensates")
int i
Definition: pbg5p_w.cc:55
@ MINUS
Definition: chromabase.h:45
@ PLUS
Definition: chromabase.h:45
pop(xml_out)
DComplex d
Definition: invbicg.cc:99
START_CODE()
Double zero
Definition: invbicg.cc:106
int k
Definition: invbicg.cc:119
::std::string string
Definition: gtest.h:1979
All quark smearing constructors.
Factory for producing quark smearing objects.
Construct simple baryon operators.
void writeXML(XMLWriter &in, const std::string &path) const