CHROMA
nef_quarkprop4_w.cc
Go to the documentation of this file.
1 // $Log: nef_quarkprop4_w.cc,v $
2 // Revision 3.3 2006-10-11 15:42:26 edwards
3 // Removed use of numRetries !! This was a misguided attempt to get restarts
4 // into the code. Will try another way via the system solvers and the
5 // InvertParam xml group.
6 //
7 // Revision 3.2 2006/07/03 15:26:09 edwards
8 // Changed FermionAction API to produce system solver classes. No longer have
9 // a fixed InvertParam set. Removed old inverter enum and support. Have default
10 // creation for inverters to solve M*psi=chi, MdagM*psi=chi, and multi-shift
11 // support. Some older files still have explicit calls to CG solver.
12 //
13 // Revision 3.1 2006/06/11 06:30:32 edwards
14 // Change in interface. The quarkProp routines now all take a "numRetries"
15 // variable for the number of times to call the qprop routine. The propagator
16 // regression tests have all been up to version 10 to read this new variable.
17 // The SystemSolver routines now all return a SystemSolverResults_t struct
18 // instead of an int of "n_count" . A residual of the unpreconditioned
19 // system of equations for the qprop and qpropT is computed.
20 //
21 // Revision 3.0 2006/04/03 04:58:52 edwards
22 // Major overhaul of fermion and gauge action interface. Basically,
23 // all fermacts and gaugeacts now carry out <T,P,Q> template parameters. These are
24 // the fermion type, the "P" - conjugate momenta, and "Q" - generalized coordinates
25 // in the sense of Hamilton's equations. The fermbc's have been rationalized to never
26 // be over multi1d<T>. The "createState" within the FermionAction is now fixed meaning
27 // the "u" fields are now from the coordinate type. There are now "ConnectState" that
28 // derive into FermState<T,P,Q> and GaugeState<P,Q>.
29 //
30 // Revision 2.0 2005/09/25 21:04:30 edwards
31 // Moved to version 2.0
32 //
33 // Revision 1.14 2005/01/14 20:13:06 edwards
34 // Removed all using namespace QDP/Chroma from lib files. The library
35 // should now be 100% in the Chroma namespace. All mainprogs need a
36 // using namespace Chroma.
37 //
38 // Revision 1.13 2005/01/02 05:21:10 edwards
39 // Rearranged top-level fermion actions and linear operators.
40 // The deriv is pushed up much higher. This has the effect that
41 // now the "P" type (conjugate momentum type) is carried around
42 // in DiffFermAct4D<T,P> and below carry this "P" template param.
43 // All fermacts now have at least default deriv support (possibly
44 // Not Implemented error). Made qprop and qpropT now go through
45 // factory functions.
46 //
47 // Revision 1.12 2004/12/29 22:13:41 edwards
48 // Rearranged the top-level FermionAction structure. Moved up
49 // 5d-style actions to be a FermAct5D and there is a FermAct4D.
50 // Consolidated quarkprop routines and fermact factories.
51 //
52 // Revision 1.11 2004/11/24 04:16:56 kostas
53 // code works now
54 //
55 // Revision 1.10 2004/11/20 22:28:45 edwards
56 // Narrowed include dependencies.
57 //
58 // Revision 1.9 2004/11/20 21:16:41 edwards
59 // Tried to simplify number of include lines.
60 //
61 // Revision 1.8 2004/10/29 13:36:13 bjoo
62 // Added generalised preconditioned nef operator, and a zolotarev facade to it. Can now do Chiu! Which is just as well because I am just about to go down with the flu
63 //
64 // Revision 1.7 2004/10/21 16:43:20 bjoo
65 // UNPRECONDITIONED_ZOLO_NEF
66 //
67 // Revision 1.6 2004/10/03 01:21:19 edwards
68 // Removed Dminus on array. Changed Dminus to also require N5 slice.
69 // Changed NEF linop to require an array of b5/c5. Changed NEF fermact to
70 // possibly except an array or scalar for b5/c5.
71 //
72 // Revision 1.5 2004/09/19 02:41:02 edwards
73 // Only indented. NOTE: this routine could soon (?) be merged
74 // as the general dwf_quarkProp4 routine. Needs, currents, etc.
75 //
76 // Revision 1.4 2004/09/16 16:40:53 kostas
77 // nef_quarkprop4 now compiles
78 //
79 // Revision 1.3 2004/09/16 15:20:55 kostas
80 // fixed up mres for NEF
81 //
82 // Revision 1.2 2004/09/03 14:24:36 kostas
83 // added mres measurement for NEF fermions
84 //
85 /*! \file
86  * \brief Full quark propagator solver for domain wall fermions
87  *
88  * Given a complete propagator as a source, this does all the inversions needed
89  */
90 
91 
92 #include "chromabase.h"
94 #include "util/ferm/transf.h"
95 #include "util/ft/sftmom.h"
96 
97 
98 namespace Chroma
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 Domain Wall fermions (Array) fermions
104  *
105  * \param q_sol quark propagator ( Write )
106  * \param q_src source ( Read )
107  * \param t_src time slice of source ( Read )
108  * \param j_decay direction of decay ( Read )
109  * \param invParam inverter params ( Read )
110  * \param ncg_had number of CG iterations ( Write )
111  */
112  template<typename T, typename P, typename Q, template<class,class,class> class C>
113  void nef_quarkProp_a(LatticePropagator& q_sol,
114  XMLWriter& xml_out,
115  const LatticePropagator& q_src,
116  int t_src, int j_decay,
117  const C<T,P,Q>& S_f,
119  const GroupXML_t& invParam,
120  int& ncg_had)
121  {
122  START_CODE();
123 
124  push(xml_out, "DWF_QuarkProp4");
125 
126  ncg_had = 0;
127 
128  // Setup solver
129  Handle< SystemSolverArray<LatticeFermion> > qpropT(S_f.qpropT(state,invParam));
130 
131  multi1d<LatticePropagator> prop5d(S_f.size()) ;
132  LatticePropagator q_mp ;
133 
134  multi1d<LatticeFermion> psi(S_f.size()) ;
135 
136  // This version loops over all color and spin indices
137  for(int color_source = 0; color_source < Nc; ++color_source)
138  {
139  for(int spin_source = 0; spin_source < Ns; ++spin_source)
140  {
141  QDPIO::cout<<"nef_quarkProp:: doing color : "<< color_source;
142  QDPIO::cout<<" and spin : "<< spin_source<<std::endl ;
143 
144  psi = zero ; // note this is ``zero'' and not 0
145  LatticeFermion tmp,tt ;
146  tmp = zero ;
147  PropToFerm(q_src, tmp, color_source, spin_source);
148 
149  /*
150  * Normalize the source in case it is really huge or small -
151  * a trick to avoid overflows or underflows
152  */
153 
154  Real fact = 1.0;
155  Real nrm = sqrt(norm2(tmp));
156  if (toFloat(nrm) != 0.0)
157  fact /= nrm;
158 
159  // Rescale
160  tmp *= fact;
161 
162  QDPIO::cout<<"Normalization Factor: "<< fact<<std::endl ;
163 
164  int N5(S_f.size());
165  QDPIO::cout << "N5=" << N5 << std::endl;
166 
167  multi1d<LatticeFermion> chi(N5) ;
168  chi = zero ;
169  // Split the source to oposite walls according to chirality
170  // and apply Dminus
171  tt = chiralProjectPlus(tmp) ;
172  S_f.Dminus(chi[0 ],tt,state,PLUS,0);
173  tt = chiralProjectMinus(tmp) ;
174  S_f.Dminus(chi[N5-1],tt,state,PLUS,N5-1);
175 
176 
177 
178  // now we are ready invert
179  // Compute the propagator for given source color/spin.
180  {
181  SystemSolverResults_t result = (*qpropT)(psi,chi);
182  ncg_had += result.n_count;
183 
184  push(xml_out,"Qprop");
185  write(xml_out, "color_source", color_source);
186  write(xml_out, "spin_source", spin_source);
187  write(xml_out, "n_count", result.n_count);
188  write(xml_out, "resid", result.resid);
189  pop(xml_out);
190  }
191 
192  // Unnormalize the source following the inverse
193  // of the normalization above
194  fact = Real(1) / fact;
195  for(int i = 0; i < N5; ++i)
196  psi[i] *= fact;
197 
198  /*
199  * Move the solution to the appropriate components
200  * of quark propagator.
201  */
202 
203  //First the 5D quark propagator
204  for(int s(0);s<S_f.size();s++)
205  FermToProp(psi[s], prop5d[s], color_source, spin_source);
206  // Now get the 4D propagator too
207 
208  tmp = chiralProjectMinus(psi[0]) + chiralProjectPlus(psi[N5-1]) ;
209  // move solution to the appropriate components of the 4d
210  // quark propagator
211  FermToProp(tmp, q_sol, color_source, spin_source);
212 
213  // move solution to the appropriate components of the 4d
214  // midpoint quark propagator
215  tmp = chiralProjectPlus(psi[N5/2 - 1]) + chiralProjectMinus(psi[N5/2]) ;
216  FermToProp(tmp, q_mp, color_source, spin_source);
217 
218 
219  } /* end loop over spin_source */
220  } /* end loop over color_source */
221 
222  LatticeComplex cfield ;
223 
224  /**
225  // constuct the conserved axial current correlator
226  nef_conserved_axial_ps_corr(cfield,state->getLinks(),prop5d,j_decay);
227  **/
228 
229  multi1d<DComplex> corr ;
230 
231  SftMom trick(0,false,j_decay) ;
232 
233  corr = sumMulti(cfield, trick.getSet());
234  // Length of lattice in time direction
235  int length = trick.numSubsets();
236  multi1d<Real> mesprop(length);
237  for(int t(0);t<length; t++){
238  int t_eff( (t - t_src + length) % length ) ;
239  mesprop[t_eff] = real(corr[t]) ;
240  }
241 
242  push(xml_out, "time_direction");
243  write(xml_out, "t_dir",j_decay);
244  pop(xml_out);
245 
246  /**
247  push(xml_out, "DWF_ConservedAxial");
248  write(xml_out, "mesprop", mesprop);
249  pop(xml_out);
250 
251  // The local axial corruent pseudoscalar correlator
252  int d(1<<j_decay);
253  cfield = trace( adj(q_sol)*Gamma(d)*q_sol ) ;
254  corr = sumMulti(cfield, trick.getSet()) ;
255  for(int t(0);t<length; t++){
256  int t_eff( (t - t_src + length) % length ) ;
257  mesprop[t_eff] = -real(corr[t]) ; // sign fix
258  }
259  push(xml_out, "DWF_LocalAxial");
260  write(xml_out, "mesprop", mesprop);
261  pop(xml_out);
262  **/
263 
264  //Now the midpoint Pseudoscalar correlator
265  multi1d<Double> tmp(length);
266  tmp = sumMulti(localNorm2(q_mp), trick.getSet());
267  for(int t(0);t<length; t++){
268  int t_eff( (t - t_src + length) % length ) ;
269  mesprop[t_eff] = tmp[t] ;
270  }
271 
272  push(xml_out, "DWF_MidPoint_Pseudo");
273  write(xml_out, "mesprop", mesprop);
274  pop(xml_out);
275 
276 
277  tmp = sumMulti(localNorm2(q_sol), trick.getSet());
278  for(int t(0);t<length; t++){
279  int t_eff( (t - t_src + length) % length ) ;
280  mesprop[t_eff] = tmp[t] ; // only need the zero momentum
281  }
282  push(xml_out, "DWF_Psuedo_Pseudo");
283  write(xml_out, "mesprop", mesprop);
284  pop(xml_out);
285 
286  pop(xml_out); // DWF_QuarkProp
287 
288  /**
289  check_nef_ward_identity(state->getLinks(),prop5d,q_src,
290  q_sol,q_mp,S_f.quark_mass(),
291  j_decay);
292  **/
293 
294  END_CODE();
295  }
296 
297 
298  //! Given a complete propagator as a source, this does all the inversions needed
299  /*! \ingroup qprop
300  *
301  * This routine is actually generic to Domain Wall fermions (Array) fermions
302  *
303  * \param q_sol quark propagator ( Write )
304  * \param q_src source ( Read )
305  * \param t_src time slice of source ( Read )
306  * \param j_decay direction of decay ( Read )
307  * \param invParam inverter params ( Read )
308  * \param ncg_had number of CG iterations ( Write )
309  */
310 
311  void nef_quarkProp4(LatticePropagator& q_sol,
312  XMLWriter& xml_out,
313  const LatticePropagator& q_src,
314  int t_src, int j_decay,
315  const UnprecDWFermActBaseArray<LatticeFermion,
316  multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> >& S_f,
317  Handle< FermState<LatticeFermion,
318  multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> > > state,
319  const GroupXML_t& invParam,
320  int& ncg_had)
321  {
322  nef_quarkProp_a<LatticeFermion,multi1d<LatticeColorMatrix>,multi1d<LatticeColorMatrix>,
324  q_sol,
325  xml_out,
326  q_src,
327  t_src,
328  j_decay,
329  S_f,
330  state,
331  invParam,
332  ncg_had);
333  }
334 
335  //! Given a complete propagator as a source, this does all the inversions needed
336  /*! \ingroup qprop
337  *
338  * This routine is actually generic to Domain Wall fermions (Array) fermions
339  *
340  * \param q_sol quark propagator ( Write )
341  * \param q_src source ( Read )
342  * \param t_src time slice of source ( Read )
343  * \param j_decay direction of decay ( Read )
344  * \param invParam inverter params ( Read )
345  * \param ncg_had number of CG iterations ( Write )
346  */
347 
348  void nef_quarkProp4(LatticePropagator& q_sol,
349  XMLWriter& xml_out,
350  const LatticePropagator& q_src,
351  int t_src, int j_decay,
352  const EvenOddPrecDWFermActBaseArray<LatticeFermion,
353  multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> >& S_f,
354  Handle< FermState<LatticeFermion,
355  multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> > > state,
356  const GroupXML_t& invParam,
357  int& ncg_had)
358  {
359  nef_quarkProp_a<LatticeFermion,multi1d<LatticeColorMatrix>,multi1d<LatticeColorMatrix>,
361  q_sol,
362  xml_out,
363  q_src,
364  t_src,
365  j_decay,
366  S_f,
367  state,
368  invParam,
369  ncg_had);
370  }
371 
372 }
Primary include file for CHROMA library code.
Base class for unpreconditioned domain-wall-like fermion actions.
Support class for fermion actions and linear operators.
Definition: state.h:94
Class for counted reference semantics.
Definition: handle.h:33
Fourier transform phase factor support.
Definition: sftmom.h:35
int numSubsets() const
Number of subsets - length in decay direction.
Definition: sftmom.h:63
const Set & getSet() const
The set to be used in sumMulti.
Definition: sftmom.h:57
Base class for unpreconditioned domain-wall-like 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 nef_quarkProp4(LatticePropagator &q_sol, XMLWriter &xml_out, const LatticePropagator &q_src, int t_src, int j_decay, const UnprecDWFermActBaseArray< LatticeFermion, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > &S_f, Handle< FermState< LatticeFermion, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > > state, const GroupXML_t &invParam, int &ncg_had)
Given a complete propagator as a source, this does all the inversions needed.
void nef_quarkProp_a(LatticePropagator &q_sol, XMLWriter &xml_out, const LatticePropagator &q_src, int t_src, int j_decay, const C< T, P, Q > &S_f, Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam, int &ncg_had)
Given a complete propagator as a source, this does all the inversions needed.
int j_decay
Definition: meslate.cc:22
int t
Definition: meslate.cc:37
SpinMatrix C()
C = Gamma(10)
Definition: barspinmat_w.cc:29
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
push(xml_out,"Condensates")
int i
Definition: pbg5p_w.cc:55
@ PLUS
Definition: chromabase.h:45
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
Double zero
Definition: invbicg.cc:106
multi1d< LatticeFermion > s(Ncb)
Full quark propagator solver for domain wall fermions.
Fourier transform phase factor support.
Hold group xml and type id.
Holds return info from SystemSolver call.
Definition: syssolver.h:17