CHROMA
quarkprop4_multi_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 "chromabase.h"
8 #include "fermact.h"
9 #include "util/ferm/transf.h"
11 #include "io/io.h"
12 
13 namespace Chroma {
14  template<class T, class C>
15  static
16  void multiQuarkProp4_m(multi1d<LatticePropagator>& q_sol,
17  XMLWriter& xml_out,
18  const LatticePropagator& q_src,
19  const C& S_f,
20  Handle< FermState<LatticeFermion,
21  multi1d<LatticeColorMatrix>,
22  multi1d<LatticeColorMatrix> > > state,
23  const multi1d<Real>& masses,
24  const GroupXML_t& invParam,
25  int n_soln,
26  int& ncg_had)
27  {
28  START_CODE();
29 
30  push(xml_out, "multiQuarkProp4");
31 
32  // Ensure that q_sol is adequate
33  if ( q_sol.size() != masses.size() ) {
34  q_sol.resize(masses.size());
35  }
36 
37  // Grab a RsdCG like array to pass down.
38  // Set all elements to RsdCG
39  ncg_had = 0;
40 
41  multi1d<T> psi(masses.size());
42 
43  // This version loops over all color and spin indices
44  for(int color_source = 0; color_source < Nc; ++color_source)
45  {
46  for(int spin_source = 0; spin_source < Ns; ++spin_source)
47  {
48  T chi;
49 
50  // Extract a fermion source
51  PropToFerm(q_src, chi, color_source, spin_source);
52 
53  // Use the last initial guess as the current initial guess
54 
55  /*
56  * Normalize the source in case it is really huge or small -
57  * a trick to avoid overflows or underflows
58  */
59  Real fact = 1.0;
60  Real nrm = sqrt(norm2(chi));
61  if (toFloat(nrm) != 0.0)
62  fact /= nrm;
63 
64  // Rescale
65  chi *= fact;
66 
67  // Compute the propagator for given source color/spin.
68  int n_count;
69 
70  // The psi-s are zeroed in multiQprop
71  S_f.multiQprop(psi, masses, state, chi, invParam, n_soln, n_count);
72 
73  ncg_had += n_count;
74 
75  push(xml_out,"Qprop");
76 // write(xml_out, "RsdCG", invParam.RsdCG);
77  write(xml_out, "n_count", n_count);
78  pop(xml_out);
79 
80  // Unnormalize the source following the inverse of the normalization above
81  fact = Real(1) / fact;
82 
83  for(int i=0; i < masses.size(); i++) {
84  psi[i] *= fact;
85  /*
86  * Move the solution to the appropriate components
87  * of quark propagator.
88  */
89  FermToProp(psi[i], q_sol[i], color_source, spin_source);
90  }
91 
92  } /* end loop over spin_source */
93  } /* end loop over color_source */
94 
95  pop(xml_out);
96 
97  END_CODE();
98  }
99 
100 //! Given a complete propagator as a source, this does all the inversions needed
101 /*! \ingroup qprop
102  *
103  * This routine is actually generic to all Wilson-like fermions
104  *
105  * \param q_sol quark propagator ( Write )
106  * \param q_src source ( Read )
107  * \param invType inverter type ( Read (
108  * \param RsdCG CG (or MR) residual used here ( Read )
109  * \param MaxCG maximum number of CG iterations ( Read )
110  * \param ncg_had number of CG iterations ( Write )
111  */
112 
113  void OverlapFermActBase::multiQuarkProp(multi1d<LatticePropagator>& q_sol,
114  XMLWriter& xml_out,
115  const LatticePropagator& q_src,
116  Handle< FermState<LatticeFermion,
117  multi1d<LatticeColorMatrix>,
118  multi1d<LatticeColorMatrix> > > state,
119  const multi1d<Real>& masses,
120  const GroupXML_t& invParam,
121  const int n_soln,
122  int& ncg_had)
123  {
124  multiQuarkProp4_m<LatticeFermion, OverlapFermActBase>(q_sol,
125  xml_out,
126  q_src,
127  *this,
128  state,
129  masses,
130  invParam,
131  n_soln,
132  ncg_had);
133  }
134 
135 }
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
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.
void multiQuarkProp(multi1d< LatticePropagator > &q_sol, XMLWriter &xml_out, const LatticePropagator &q_src, Handle< FermState< T, P, Q > > state, const multi1d< Real > &masses, const GroupXML_t &invParam, const int n_soln, int &ncg_had)
Define a multi mass qprop.
SpinMatrix C()
C = Gamma(10)
Definition: barspinmat_w.cc:29
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
int n_count
Definition: invbicg.cc:78
push(xml_out,"Condensates")
LinOpSysSolverMGProtoClover::T T
int i
Definition: pbg5p_w.cc:55
static void multiQuarkProp4_m(multi1d< LatticePropagator > &q_sol, XMLWriter &xml_out, const LatticePropagator &q_src, const C &S_f, Handle< FermState< LatticeFermion, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > > state, const multi1d< Real > &masses, const GroupXML_t &invParam, int n_soln, int &ncg_had)
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
pop(xml_out)
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
Base class for unpreconditioned overlap-like fermion actions.
Hold group xml and type id.