CHROMA
quarkprop4_w.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Full quark propagator solver
3  *
4  * Given a complete propagator as a source, this does all the inversions needed
5  */
6 
7 #include "wilstype_fermact_w.h"
8 #include "util/ferm/transf.h"
15 
16 
17 namespace Chroma
18 {
19  //! Given a complete propagator as a source, this does all the inversions needed
20  /*! \ingroup qprop
21  *
22  * This routine is actually generic to all Wilson-like fermions
23  *
24  * \param q_sol quark propagator ( Write )
25  * \param q_src source ( Read )
26  * \param RsdCG CG (or MR) residual used here ( Read )
27  * \param MaxCG maximum number of CG iterations ( Read )
28  * \param ncg_had number of CG iterations ( Write )
29  */
30 
31  template<typename T>
32  void quarkProp4_a(LatticePropagator& q_sol,
33  XMLWriter& xml_out,
34  const LatticePropagator& q_src,
35  Handle< SystemSolver<T> > qprop,
36  QuarkSpinType quarkSpinType,
37  int& ncg_had)
38  {
39  START_CODE();
40 
41  QDPIO::cout << "Entering quarkProp4" << std::endl;
42  push(xml_out, "QuarkProp4");
43 
44  ncg_had = 0;
45 
46  int start_spin;
47  int end_spin;
48 
49  switch (quarkSpinType)
50  {
52  start_spin = 0;
53  end_spin = Ns;
54  break;
55 
57  start_spin = 0;
58  end_spin = Ns/2;
59  break;
60 
62  start_spin = Ns/2;
63  end_spin = Ns;
64  break;
65  }
66 
67 // LatticeFermion psi = zero; // note this is ``zero'' and not 0
68 
69  // This version loops over all color and spin indices
70  for(int color_source = 0; color_source < Nc; ++color_source)
71  {
72  for(int spin_source = start_spin; spin_source < end_spin; ++spin_source)
73  {
74  LatticeFermion psi = zero; // note this is ``zero'' and not 0
75  LatticeFermion chi;
76 
77  // Extract a fermion source
78  PropToFerm(q_src, chi, color_source, spin_source);
79 
80  // Use the last initial guess as the current initial guess
81 
82  /*
83  * Normalize the source in case it is really huge or small -
84  * a trick to avoid overflows or underflows
85  */
86  Real fact = 1.0;
87  Real nrm = sqrt(norm2(chi));
88  if (toFloat(nrm) != 0.0)
89  fact /= nrm;
90 
91  // Rescale
92  chi *= fact;
93 
94  // Compute the propagator for given source color/spin.
95  {
96  SystemSolverResults_t result = (*qprop)(psi,chi);
97  ncg_had += result.n_count;
98 
99  push(xml_out,"Qprop");
100  write(xml_out, "color_source", color_source);
101  write(xml_out, "spin_source", spin_source);
102  write(xml_out, "n_count", result.n_count);
103  write(xml_out, "resid", result.resid);
104  pop(xml_out);
105  }
106 
107  // Unnormalize the source following the inverse of the normalization above
108  fact = Real(1) / fact;
109  psi *= fact;
110 
111  /*
112  * Move the solution to the appropriate components
113  * of quark propagator.
114  */
115  FermToProp(psi, q_sol, color_source, spin_source);
116  } /* end loop over spin_source */
117  } /* end loop over color_source */
118 
119 
120  switch (quarkSpinType)
121  {
123  // Do nothing here
124  break;
125 
127  {
128  /* Since this is a non-relativistic prop
129  * negate the quark props 'lower' components
130  * This is because I should have only done a half inversion
131  * on non relativistic channels, where the last two columns of the
132  * source MUST be the negation of the first two columns.
133  * Hence the last two columns of the solution must also be
134  * negations of the first two columns. The half inversion itself
135  * has not put in the minus sign, it just copied the columns.
136  * The post multiply by Gamma_5 adds in the required - sign
137  * in the last two columns
138  */
139  /* Apply Gamma_5 = Gamma(15) by negating the fermion extracted */
140  for(int color_source = 0; color_source < Nc ; ++color_source)
141  {
142  for(int spin_source = Ns/2; spin_source < Ns; ++spin_source)
143  {
144  int copyfrom = spin_source - Ns/2;
145  LatticeFermion psi;
146 
147  PropToFerm(q_sol, psi, color_source, copyfrom);
148  FermToProp(LatticeFermion(-psi), q_sol, color_source, spin_source);
149  }
150  }
151  }
152  break;
153 
155  {
156  /* Since this is a non-relativistic prop
157  * negate the quark props 'lower' components
158  * This is because I should have only done a half inversion
159  * on non relativistic channels, where the last two columns of the
160  * source MUST be the negation of the first two columns.
161  * Hence the last two columns of the solution must also be
162  * negations of the first two columns. The half inversion itself
163  * has not put in the minus sign, it just copied the columns.
164  * The post multiply by Gamma_5 adds in the required - sign
165  * in the last two columns
166  */
167  /* Apply Gamma_5 = Gamma(15) by negating the fermion extracted */
168  for(int color_source = 0; color_source < Nc ; ++color_source)
169  {
170  for(int spin_source = 0; spin_source < Ns/2; ++spin_source)
171  {
172  int copyfrom = spin_source + Ns/2;
173  LatticeFermion psi;
174 
175  PropToFerm(q_sol, psi, color_source, copyfrom);
176  // There is no need for (-) in the lower component case (KNO)
177  FermToProp(LatticeFermion(psi), q_sol, color_source, spin_source);
178  }
179  }
180  }
181  break;
182  } // end switch(quarkSpinType)
183 
184  pop(xml_out);
185  QDPIO::cout << "Exiting quarkProp4" << std::endl;
186 
187  END_CODE();
188  }
189 
190 
191  typedef LatticeFermion LF;
192  typedef multi1d<LatticeColorMatrix> LCM;
193 
194 
195  //! Given a complete propagator as a source, this does all the inversions needed
196  /*! \ingroup qprop
197  *
198  * This routine is actually generic to all Wilson-like fermions
199  *
200  * \param q_sol quark propagator ( Write )
201  * \param q_src source ( Read )
202  * \param invParam inverter parameters ( Read )
203  * \param ncg_had number of CG iterations ( Write )
204  */
205  void quarkProp4(LatticePropagator& q_sol,
206  XMLWriter& xml_out,
207  const LatticePropagator& q_src,
208  Handle< SystemSolver<LF> > qprop,
209  QuarkSpinType quarkSpinType,
210  int& ncg_had)
211  {
212  quarkProp4_a<LF>(q_sol, xml_out, q_src, qprop, quarkSpinType, ncg_had);
213  }
214 
215 
216  //! Given a complete propagator as a source, this does all the inversions needed
217  /*! \ingroup qprop
218  *
219  * This routine is actually generic to all Wilson-like fermions
220  *
221  * \param q_sol quark propagator ( Write )
222  * \param q_src source ( Read )
223  * \param invParam inverter parameters ( Read )
224  * \param ncg_had number of CG iterations ( Write )
225  */
226  template<>
227  void
229  LatticePropagator& q_sol,
230  XMLWriter& xml_out,
231  const LatticePropagator& q_src,
233  const GroupXML_t& invParam,
234  QuarkSpinType quarkSpinType,
235  int& ncg_had) const
236  {
237  QDPIO::cout << "In quarkProp()" << std::endl;
238  StopWatch swatch;
239  swatch.start();
240  Handle< SystemSolver<LF> > qprop(this->qprop(state,invParam));
241  swatch.stop();
242  QDPIO::cout << "Creating qprop took " << swatch.getTimeInSeconds()
243  << "sec " << std::endl;
244  quarkProp4_a<LF>(q_sol, xml_out, q_src, qprop, quarkSpinType, ncg_had);
245  }
246 
247 
248 
249  //! Given a complete propagator as a source, this does all the inversions needed
250  /*! \ingroup qprop
251  *
252  * This routine is actually generic to all Wilson-like fermions
253  *
254  * \param q_sol quark propagator ( Write )
255  * \param q_src source ( Read )
256  * \param invParam inverter parameters ( Read )
257  * \param ncg_had number of CG iterations ( Write )
258  */
259  template<>
260  void
262  LatticePropagator& q_sol,
263  XMLWriter& xml_out,
264  const LatticePropagator& q_src,
266  const GroupXML_t& invParam,
267  QuarkSpinType quarkSpinType,
268  int& ncg_had) const
269  {
270  Handle< SystemSolver<LF> > qprop(this->qprop(state,invParam));
271  quarkProp4_a<LF>(q_sol, xml_out, q_src, qprop, quarkSpinType, ncg_had);
272  }
273 
274 
275 
276  //------------------------------------------------------------------------------------
277 
278  // Return a linear operator solver for this action to solve M*psi=chi
279  /*! \ingroup qprop */
280  template<>
283  const GroupXML_t& invParam) const
284  {
285  std::istringstream xml(invParam.xml);
286  XMLReader paramtop(xml);
287 
288  return TheLinOpFermSystemSolverFactory::Instance().createObject(invParam.id,
289  paramtop,
290  invParam.path,
291  state,
292  this->linOp(state));
293  }
294 
295 
296  //! Return a linear operator solver for this action to solve MdagM*psi=chi
297  /*! \ingroup qprop */
298  template<>
301  const GroupXML_t& invParam) const
302  {
303  std::istringstream xml(invParam.xml);
304  XMLReader paramtop(xml);
305 
306  return TheMdagMFermSystemSolverFactory::Instance().createObject(invParam.id,
307  paramtop,
308  invParam.path,
309  state,
310  this->linOp(state));
311  }
312 
313 
314  //! Return a linear operator solver for this action to solve (M+shift_i)*psi_i = chi
315  /*! \ingroup qprop */
316  template<>
319  const GroupXML_t& invParam) const
320  {
321  std::istringstream xml(invParam.xml);
322  XMLReader paramtop(xml);
323 
324  return TheLinOpFermMultiSystemSolverFactory::Instance().createObject(invParam.id,
325  paramtop,
326  invParam.path,
327  this->linOp(state));
328  }
329 
330 
331  //! Return a linear operator solver for this action to solve (MdagM+shift_i)*psi_i = chi
332  /*! \ingroup qprop */
333  template<>
336  const GroupXML_t& invParam) const
337  {
338  std::istringstream xml(invParam.xml);
339  XMLReader paramtop(xml);
340 
341  return TheMdagMFermMultiSystemSolverFactory::Instance().createObject(invParam.id,
342  paramtop,
343  invParam.path,
344  state,
345  this->linOp(state));
346  }
347 
348  //! Return a linear operator solver for this action to solve (MdagM+shift_i)*psi_i = chi
349  /*! \ingroup qprop */
350  template<>
353  const GroupXML_t& invParam) const
354  {
355  std::istringstream xml(invParam.xml);
356  XMLReader paramtop(xml);
357 
358  return TheMdagMFermMultiSystemSolverAccumulateFactory::Instance().createObject(invParam.id,
359  paramtop,
360  invParam.path,
361  this->linOp(state));
362  }
363 
364 
365 
366  //------------------------------------------------------------------------------------
367 
368  // Return a linear operator solver for this action to solve M*psi=chi
369  /*! \ingroup qprop */
370  template<>
373  const GroupXML_t& invParam) const
374  {
375  std::istringstream xml(invParam.xml);
376  XMLReader paramtop(xml);
377 
378  return TheLinOpFermSystemSolverArrayFactory::Instance().createObject(invParam.id,
379  paramtop,
380  invParam.path,
381  state,
382  this->linOp(state));
383  }
384 
385 
386  //! Return a linear operator solver for this action to solve MdagM*psi=chi
387  /*! \ingroup qprop */
388  template<>
391  const GroupXML_t& invParam) const
392  {
393  std::istringstream xml(invParam.xml);
394  XMLReader paramtop(xml);
395 
396  return TheMdagMFermSystemSolverArrayFactory::Instance().createObject(invParam.id,
397  paramtop,
398  invParam.path,
399  state,
400  this->linOp(state));
401  }
402 
403 
404 
405  // Return a linear operator solver for this action to solve M*psi=chi
406  /*! \ingroup qprop */
407  template<>
410  const GroupXML_t& invParam) const
411  {
412  std::istringstream xml(invParam.xml);
413  XMLReader paramtop(xml);
414 
415  return TheLinOpFermSystemSolverArrayFactory::Instance().createObject(invParam.id,
416  paramtop,
417  invParam.path,
418  state,
419  this->linOpPV(state));
420  }
421 
422 
423  //! Return a linear operator solver for this action to solve PV^dag*PV*psi=chi
424  /*! \ingroup qprop */
425  template<>
428  const GroupXML_t& invParam) const
429  {
430  std::istringstream xml(invParam.xml);
431  XMLReader paramtop(xml);
432 
433  return TheMdagMFermSystemSolverArrayFactory::Instance().createObject(invParam.id,
434  paramtop,
435  invParam.path,
436  state,
437  this->linOpPV(state));
438  }
439 
440 
441  //! Return a linear operator solver for this action to solve (MdagM+shift_i)*psi_i = chi
442  /*! \ingroup qprop */
443  template<>
446  const GroupXML_t& invParam) const
447  {
448  std::istringstream xml(invParam.xml);
449  XMLReader paramtop(xml);
450 
451  return TheMdagMFermMultiSystemSolverArrayFactory::Instance().createObject(invParam.id,
452  paramtop,
453  invParam.path,
454  state,
455  lMdagM(state));
456  }
457 
458  //! Return a linear operator solver for this action to solve (MdagM+shift_i)*psi_i = chi
459  /*! \ingroup qprop */
460  template<>
463  const GroupXML_t& invParam) const
464  {
465  std::istringstream xml(invParam.xml);
466  XMLReader paramtop(xml);
467 
469  paramtop,
470  invParam.path,
471  lMdagM(state));
472  }
473 
474 
475  //! Return a linear operator solver for this action to solve (MdagM+shift_i)*psi_i = chi
476  /*! \ingroup qprop */
477  template<>
480  const GroupXML_t& invParam) const
481  {
482  std::istringstream xml(invParam.xml);
483  XMLReader paramtop(xml);
484 
485  Handle< LinearOperatorArray<LF> > PV(this->linOpPV(state));
487 
489  invParam.id,
490  paramtop,
491  invParam.path,
492  state,
493  MdagM);
494  }
495 
496  //! Return a linear operator solver for this action to solve (MdagM+shift_i)*psi_i = chi
497  /*! \ingroup qprop */
498  template<>
501  const GroupXML_t& invParam) const
502  {
503  std::istringstream xml(invParam.xml);
504  XMLReader paramtop(xml);
505 
506  Handle< LinearOperatorArray<LF> > PV(this->linOpPV(state));
508 
510  invParam.id,
511  paramtop,
512  invParam.path,
513  MdagM);
514  }
515 
516 
517 } // namespace Chroma
Support class for fermion actions and linear operators.
Definition: state.h:94
Class for counted reference semantics.
Definition: handle.h:33
SystemSolver disambiguator.
SystemSolver disambiguator.
M^dag.M linear operator over arrays.
Definition: lmdagm.h:67
SystemSolver disambiguator.
SystemSolver disambiguator.
static T & Instance()
Definition: singleton.h:432
Linear system solvers.
Definition: syssolver.h:34
virtual MdagMMultiSystemSolverArray< T > * mInvMdagM(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const
Return a multi-shift linear operator solver for this action to solve (MdagM+shift)*psi=chi.
virtual MdagMMultiSystemSolverAccumulateArray< T > * mInvMdagMPVAcc(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const
Return a multi-shift linear operator solver for this action to solve (PV^dag*PV+shift)*psi=chi.
virtual LinOpSystemSolverArray< T > * invLinOpPV(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const
Return a linear operator solver for this action to solve PV*psi=chi.
virtual void quarkProp(typename PropTypeTraits< T >::Type_t &q_sol, XMLWriter &xml_out, const typename PropTypeTraits< T >::Type_t &q_src, Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam, QuarkSpinType quarkSpinType, int &ncg_had) const
Given a complete propagator as a source, this does all the inversions needed.
virtual MdagMMultiSystemSolverAccumulateArray< T > * mInvMdagMAcc(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const
Return a multi-shift linear operator solver for this action to solve (MdagM+shift)*psi=chi.
virtual MdagMSystemSolverArray< T > * invMdagM(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const
Return a linear operator solver for this action to solve MdagM*psi=chi.
virtual MdagMSystemSolverArray< T > * invMdagMPV(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const
Return a linear operator solver for this action to solve PV^dag*PV*psi=chi.
virtual MdagMMultiSystemSolverArray< T > * mInvMdagMPV(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const
Return a multi-shift linear operator solver for this action to solve (PV^dag*PV+shift)*psi=chi.
virtual LinOpSystemSolverArray< T > * invLinOp(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const
Return a linear operator solver for this action to solve M*psi=chi.
virtual LinOpMultiSystemSolver< T > * mInvLinOp(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const
Return a multi-shift linear operator solver for this action to solve (M+shift)*psi=chi.
virtual MdagMMultiSystemSolver< T > * mInvMdagM(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const
Return a multi-shift linear operator solver for this action to solve (MdagM+shift)*psi=chi.
virtual MdagMMultiSystemSolverAccumulate< T > * mInvMdagMAcc(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const
virtual void quarkProp(typename PropTypeTraits< T >::Type_t &q_sol, XMLWriter &xml_out, const typename PropTypeTraits< T >::Type_t &q_src, Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam, QuarkSpinType quarkSpinType, int &ncg_had) const
Given a complete propagator as a source, this does all the inversions needed.
virtual MdagMSystemSolver< T > * invMdagM(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const
Return a linear operator solver for this action to solve MdagM*psi=chi.
virtual LinOpSystemSolver< T > * invLinOp(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const
Return a linear operator solver for this action to solve M*psi=chi.
void PropToFerm(const LatticePropagatorF &b, LatticeFermionF &a, int color_index, int spin_index)
Extract a LatticeFermion from a LatticePropagator.
Definition: transf.cc:226
void FermToProp(const LatticeFermionF &a, LatticePropagatorF &b, int color_index, int spin_index)
Insert a LatticeFermion into a LatticePropagator.
Definition: transf.cc:98
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams &param)
Writer parameters.
QuarkSpinType
Quark spin type.
void quarkProp4_a(LatticePropagator &q_sol, XMLWriter &xml_out, const LatticePropagator &q_src, Handle< SystemSolver< T > > qprop, QuarkSpinType quarkSpinType, int &ncg_had)
Given a complete propagator as a source, this does all the inversions needed.
Definition: quarkprop4_w.cc:32
void quarkProp4(LatticeStaggeredPropagator &q_sol, XMLWriter &xml_out, const LatticeStaggeredPropagator &q_src, const StaggeredTypeFermAct< LatticeStaggeredFermion, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > &S_f, Handle< FermState< LatticeStaggeredFermion, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > > state, const GroupXML_t &invParam, QuarkSpinType quarkSpinType, int &ncg_had)
Given a complete propagator as a source, this does all the inversions needed.
Factory for producing system solvers for M*psi = chi.
Factory for producing system solvers for MdagM*psi = chi.
Factory for producing system solvers for MdagM*psi = chi.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
push(xml_out,"Condensates")
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
pop(xml_out)
LatticeStaggeredFermion LF
Definition: asqtad_qprop.cc:19
multi1d< LatticeColorMatrix > LCM
Definition: asqtad_qprop.cc:20
START_CODE()
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
Definition: pbg5p_w.cc:28
Double zero
Definition: invbicg.cc:106
Full quark propagator solver.
Hold group xml and type id.
SystemSolver disambiguator.
SystemSolver disambiguator.
Holds return info from SystemSolver call.
Definition: syssolver.h:17
Factory for solving M*psi=chi where M is not hermitian or pos. def.
Handle< LinearOperator< T > > MdagM
Factory for producing system solvers for MdagM*psi = chi.
Wilson-like fermion actions.