CHROMA
quarkprop4_s.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 "chromabase.h"
8 #include "fermact.h"
9 #include "util/ferm/transf.h"
16 
17 
18 namespace Chroma
19 {
20  //! Given a complete propagator as a source, this does all the inversions needed
21  /*! \ingroup qprop
22  *
23  * This routine is actually generic to all Wilson-like fermions
24  *
25  * \param q_sol quark propagator ( Write )
26  * \param q_src source ( Read )
27  * \param invParam inverter parameters ( Read )
28  * \param RsdCG CG (or MR) residual used here ( Read )
29  * \param MaxCG maximum number of CG iterations ( Read )
30  * \param ncg_had number of CG iterations ( Write )
31  */
32 
33  template<typename T, typename P, typename Q>
34  void quarkProp_a(LatticeStaggeredPropagator& q_sol,
35  XMLWriter& xml_out,
36  const LatticeStaggeredPropagator& q_src,
39  const GroupXML_t& invParam,
40  QuarkSpinType quarkSpinType,
41  int& ncg_had)
42  {
43  START_CODE();
44 
45  push(xml_out, "QuarkProp4");
46 
47  ncg_had = 0;
48 
49  Handle<const SystemSolver<T> > qprop(S_f.qprop(state,invParam));
50 
51 // LatticeStaggeredFermion psi = zero; // note this is ``zero'' and not 0
52 
53  // This version loops over all color and spin indices
54  for(int color_source = 0; color_source < Nc; ++color_source)
55  {
56  QDPIO::cout<<"quarkprop_s:: doing color : "<< color_source<<std::endl;
57 
58  LatticeStaggeredFermion psi = zero; // note this is ``zero'' and not 0
59  LatticeStaggeredFermion chi;
60 
61  // Extract a fermion source
62  PropToFerm(q_src, chi, color_source);
63 
64  // Use the last initial guess as the current initial guess
65 
66  /*
67  * Normalize the source in case it is really huge or small -
68  * a trick to avoid overflows or underflows
69  */
70  Real fact = 1.0;
71  Real nrm = sqrt(norm2(chi));
72  if (toFloat(nrm) != 0.0)
73  fact /= nrm;
74 
75  // Rescale
76  chi *= fact;
77 
78  // Compute the propagator for given source color.
79  {
80  SystemSolverResults_t result = (*qprop)(psi,chi);
81  ncg_had += result.n_count;
82 
83  push(xml_out,"Qprop");
84  write(xml_out, "color_source", color_source);
85  write(xml_out, "n_count", result.n_count);
86  write(xml_out, "resid", result.resid);
87  pop(xml_out);
88  }
89 
90  // Unnormalize the source following the inverse of the normalization above
91  fact = Real(1) / fact;
92  psi *= fact;
93 
94  /*
95  * Move the solution to the appropriate components
96  * of quark propagator.
97  */
98  FermToProp(psi, q_sol, color_source);
99  } /* end loop over color_source */
100 
101  pop(xml_out);
102 
103  END_CODE();
104  }
105 
106 
107 
108 
109  typedef LatticeStaggeredFermion LF;
110  typedef multi1d<LatticeColorMatrix> LCM;
111 
112 
113 
114  //! Given a complete propagator as a source, this does all the inversions needed
115  /*! \ingroup qprop
116  *
117  * This routine is actually generic to all Wilson-like fermions
118  *
119  * \param q_sol quark propagator ( Write )
120  * \param q_src source ( Read )
121  * \param invParam inverter parameters ( Read )
122  * \param ncg_had number of CG iterations ( Write )
123  */
124  void quarkProp4(LatticeStaggeredPropagator& q_sol,
125  XMLWriter& xml_out,
126  const LatticeStaggeredPropagator& q_src,
127  const StaggeredTypeFermAct<LatticeStaggeredFermion,
128  multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> >& S_f,
129  Handle< FermState<LatticeStaggeredFermion,
130  multi1d<LatticeColorMatrix>,
131  multi1d<LatticeColorMatrix> > > state,
132  const GroupXML_t& invParam,
133  QuarkSpinType quarkSpinType,
134  int& ncg_had)
135  {
136  quarkProp_a<LatticeStaggeredFermion,
137  multi1d<LatticeColorMatrix>,
138  multi1d<LatticeColorMatrix> >(q_sol, xml_out, q_src, S_f, state, invParam,
139  quarkSpinType, ncg_had);
140  }
141 
142 
143 
144  //! Given a complete propagator as a source, this does all the inversions needed
145  /*! \ingroup qprop
146  *
147  * This routine is actually generic to all Staggered-like fermions
148  *
149  * \param q_sol quark propagator ( Write )
150  * \param q_src source ( Read )
151  * \param invParam inverter parameters ( Read )
152  * \param ncg_had number of CG iterations ( Write )
153  */
154  template<>
155  void
156  StaggeredTypeFermAct<LatticeStaggeredFermion,
157  multi1d<LatticeColorMatrix>,
158  multi1d<LatticeColorMatrix> >::quarkProp(
159  LatticeStaggeredPropagator& q_sol,
160  XMLWriter& xml_out,
161  const LatticeStaggeredPropagator& q_src,
162  Handle< FermState<LatticeStaggeredFermion,
163  multi1d<LatticeColorMatrix>,
164  multi1d<LatticeColorMatrix> > > state,
165  const GroupXML_t& invParam,
166  QuarkSpinType quarkSpinType,
167  int& ncg_had) const
168  {
169  quarkProp4(q_sol, xml_out, q_src, *this, state, invParam, quarkSpinType, ncg_had);
170  }
171 
172 
173 
174 
175 
176  // Return a linear operator solver for this action to solve M*psi=chi
177  /*! \ingroup qprop */
178  template<>
181  const GroupXML_t& invParam) const
182  {
183  std::istringstream xml(invParam.xml);
184  XMLReader paramtop(xml);
185 
186  // THIS NEEDS TO BE FIXED TO USE A PROPER MDAGM
187  return TheLinOpStagFermSystemSolverFactory::Instance().createObject(invParam.id,
188  paramtop,
189  invParam.path,
190  this->linOp(state));
191  }
192 
193 
194  //! Return a linear operator solver for this action to solve MdagM*psi=chi
195  /*! \ingroup qprop */
196  template<>
199  const GroupXML_t& invParam) const
200  {
201  std::istringstream xml(invParam.xml);
202  XMLReader paramtop(xml);
203 
204  // THIS NEEDS TO BE FIXED TO USE A PROPER MDAGM
205  return TheMdagMStagFermSystemSolverFactory::Instance().createObject(invParam.id,
206  paramtop,
207  invParam.path,
208  this->linOp(state));
209  }
210 
211 
212  //! Return a linear operator solver for this action to solve (M+shift_i)*psi_i = chi
213  /*! \ingroup qprop */
214  template<>
217  const GroupXML_t& invParam) const
218  {
219  std::istringstream xml(invParam.xml);
220  XMLReader paramtop(xml);
221 
222  return TheLinOpStagFermMultiSystemSolverFactory::Instance().createObject(invParam.id,
223  paramtop,
224  invParam.path,
225  this->linOp(state));
226  }
227 
228 
229  //! Return a linear operator solver for this action to solve (MdagM+shift_i)*psi_i = chi
230  /*! \ingroup qprop */
231  template<>
234  const GroupXML_t& invParam) const
235  {
236  std::istringstream xml(invParam.xml);
237  XMLReader paramtop(xml);
238 
239  // THIS NEEDS TO BE FIXED TO USE A PROPER MDAGM
240  return TheMdagMStagFermMultiSystemSolverFactory::Instance().createObject(invParam.id,
241  paramtop,
242  invParam.path,
243  this->linOp(state));
244  }
245 
246  //! Return a linear operator solver for this action to solve (MdagM+shift_i)*psi_i = chi
247  /*! \ingroup qprop */
248  template<>
251  const GroupXML_t& invParam) const
252  {
253  std::istringstream xml(invParam.xml);
254  XMLReader paramtop(xml);
255 
256  // THIS NEEDS TO BE FIXED TO USE A PROPER MDAGM
258  paramtop,
259  invParam.path,
260  this->linOp(state));
261  }
262 
263 
264 } // namespace Chroma
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
SystemSolver disambiguator.
SystemSolver disambiguator.
static T & Instance()
Definition: singleton.h:432
Staggered-like fermion actions.
Definition: fermact.orig.h:644
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.
virtual MdagMMultiSystemSolverAccumulate< 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 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 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 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.
Class structure for fermion actions.
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 quarkProp_a(LatticeStaggeredPropagator &q_sol, XMLWriter &xml_out, const LatticeStaggeredPropagator &q_src, const StaggeredTypeFermAct< T, P, Q > &S_f, Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam, QuarkSpinType quarkSpinType, int &ncg_had)
Given a complete propagator as a source, this does all the inversions needed.
Definition: quarkprop4_s.cc:34
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
const WilsonTypeFermAct< multi1d< LatticeFermion > > & S_f
Definition: pbg5p_w.cc:27
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.
Factory for producing system solvers for MdagM*psi = chi.