CHROMA
dwf_quarkprop4_w.cc
Go to the documentation of this file.
1 // $Log: dwf_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/20 20:05:50 edwards
8 // Added norm.
9 //
10 // Revision 3.1 2006/06/11 06:30:32 edwards
11 // Change in interface. The quarkProp routines now all take a "numRetries"
12 // variable for the number of times to call the qprop routine. The propagator
13 // regression tests have all been up to version 10 to read this new variable.
14 // The SystemSolver routines now all return a SystemSolverResults_t struct
15 // instead of an int of "n_count" . A residual of the unpreconditioned
16 // system of equations for the qprop and qpropT is computed.
17 //
18 // Revision 3.0 2006/04/03 04:58:52 edwards
19 // Major overhaul of fermion and gauge action interface. Basically,
20 // all fermacts and gaugeacts now carry out <T,P,Q> template parameters. These are
21 // the fermion type, the "P" - conjugate momenta, and "Q" - generalized coordinates
22 // in the sense of Hamilton's equations. The fermbc's have been rationalized to never
23 // be over multi1d<T>. The "createState" within the FermionAction is now fixed meaning
24 // the "u" fields are now from the coordinate type. There are now "ConnectState" that
25 // derive into FermState<T,P,Q> and GaugeState<P,Q>.
26 //
27 // Revision 2.0 2005/09/25 21:04:30 edwards
28 // Moved to version 2.0
29 //
30 // Revision 1.25 2005/02/21 19:28:59 edwards
31 // Changed initHeader's to be instead the appropriate default constructor
32 // for the ChiralParam, AnisoParam and QQQ structs. Removed all
33 // calls to initHeader. Changed quarkProp routines to instead take
34 // the appropriate SystemSolver instead of fermact. Added AnisoParam
35 // support for DWF and SSE DWF.
36 //
37 // Revision 1.24 2005/01/14 20:13:06 edwards
38 // Removed all using namespace QDP/Chroma from lib files. The library
39 // should now be 100% in the Chroma namespace. All mainprogs need a
40 // using namespace Chroma.
41 //
42 // Revision 1.23 2005/01/07 04:53:53 edwards
43 // Some debugging output added.
44 //
45 // Revision 1.22 2005/01/02 05:21:10 edwards
46 // Rearranged top-level fermion actions and linear operators.
47 // The deriv is pushed up much higher. This has the effect that
48 // now the "P" type (conjugate momentum type) is carried around
49 // in DiffFermAct4D<T,P> and below carry this "P" template param.
50 // All fermacts now have at least default deriv support (possibly
51 // Not Implemented error). Made qprop and qpropT now go through
52 // factory functions.
53 //
54 // Revision 1.21 2004/12/29 22:13:41 edwards
55 // Rearranged the top-level FermionAction structure. Moved up
56 // 5d-style actions to be a FermAct5D and there is a FermAct4D.
57 // Consolidated quarkprop routines and fermact factories.
58 //
59 // Revision 1.20 2004/10/19 03:25:03 edwards
60 // Added SSE even/odd CG inverter hooks for now.
61 //
62 // Revision 1.19 2004/09/08 02:48:26 edwards
63 // Big switch-over of fermact IO. New fermact startup mechanism -
64 // now using Singleton Factory object. Moved quarkprop4 to be
65 // a virtual func with top level FermionAction. Disconnected
66 // zolo4d and 5d fermacts temporarily. Removing usage of old
67 // fermact and subsequently md,gaugeact IO mechanisms.
68 //
69 // Revision 1.18.2.2 2004/09/02 16:00:07 bjoo
70 // Trolled beneath the fermact mountains and changed the invocations
71 // of the inverters to conform to the new inverter interface (invParam -- vs RsdCG, MaxCG and friends) - also in the qprop_files too.
72 //
73 // I HAVE REMOVED ZOLOTAREV4D and ZOLOTAREV5D from the build as these
74 // will need extensive reworking to keep those params inside them
75 // (simply too many). I will get them to conform later. Use the
76 // production branch if you need access to those
77 //
78 // I have added the various LOKI based files (Alexandrescu) to the
79 // Makefile.am so that things install correctly.
80 //
81 // I made the propagator code go through the factory invokation to
82 // do a propagator calculation with prec wilson fermions.
83 //
84 // Interestingly the linkage_hack appeared to be optimised away in its
85 // old form. I turned it into a function that returns the "foo" within,
86 // so it cannot be compiled away. Interestingly, it still doesn't actually
87 // need to be CALLED.
88 //
89 // Main achievements:
90 // Library compiles
91 // Propagator runs with suitable fermacts (I should check DWF etc)
92 //
93 // Revision 1.18.2.1 2004/09/01 15:13:10 edwards
94 // Start of major changes to support std::maps.
95 //
96 // Revision 1.18 2004/07/28 02:38:02 edwards
97 // Changed {START,END}_CODE("foo") to {START,END}_CODE().
98 //
99 // Revision 1.17 2004/02/23 03:05:11 edwards
100 // Pass in j_decay.
101 //
102 // Revision 1.16 2004/02/11 12:51:33 bjoo
103 // Stripped out Read() and Write()
104 //
105 // Revision 1.15 2004/02/10 22:59:46 kostas
106 // fixed a comment
107 //
108 // Revision 1.14 2004/02/06 16:47:41 kostas
109 // Ward identity check works. Fixed the local current sign
110 //
111 // Revision 1.13 2004/02/05 21:15:05 kostas
112 // fixed all bugs. Needs some clean up still
113 //
114 // Revision 1.12 2004/02/05 20:10:38 kostas
115 // Changed remaining getSubset to getSet
116 //
117 // Revision 1.11 2004/02/05 19:19:26 kostas
118 // few bugs fixed
119 //
120 // Revision 1.10 2004/02/03 20:04:53 edwards
121 // Changed phases.getSubset() to phases.getSet(). Removed passing j_decay
122 // into curcor2
123 //
124 // Revision 1.9 2004/01/30 21:35:49 kostas
125 // added uprec_dwf support
126 //
127 // Revision 1.8 2004/01/29 19:48:26 kostas
128 // added the t_src as input parameter
129 //
130 // Revision 1.7 2004/01/29 17:37:33 edwards
131 // Implemented some flop optimizations.
132 //
133 // Revision 1.6 2004/01/29 16:18:52 kostas
134 // Removed the if 1 directive
135 //
136 // Revision 1.5 2004/01/29 16:17:50 kostas
137 // Fixed an ax-ps correlation function bug
138 //
139 // Revision 1.4 2004/01/29 14:59:46 kostas
140 // Fixed the bugs. Code compiles now
141 //
142 /*! \file
143  * \brief Full quark propagator solver for domain wall fermions
144  *
145  * Given a complete propagator as a source, this does all the inversions needed
146  */
147 
148 
149 #include "chromabase.h"
152 #include "util/ferm/transf.h"
153 #include "util/ft/sftmom.h"
154 
155 namespace Chroma
156 {
157 
158  void dwf_conserved_axial_ps_corr(LatticeComplex& corr,
159  const multi1d<LatticeColorMatrix>& u,
160  const multi1d<LatticePropagator>& p5d,
161  const int mu) ;
162 
163  void check_dwf_ward_identity(const multi1d<LatticeColorMatrix>& u,
164  const multi1d<LatticePropagator>& p5d,
165  const LatticePropagator& src,
166  const LatticePropagator& q_q,
167  const LatticePropagator& q_mp_q,
168  const Real& m_q,
169  int j_decay)
170  {
171  QDPIO::cout<<"check_dwf_ward_identity: Checking the chiral Ward Identity...";
172  QDPIO::cout<<std::endl ;
173 
174  LatticeComplex divA = zero;
175  for(int mu(0);mu<Nd;mu++){
176  LatticeComplex tt ;
178  divA += tt - shift(tt,BACKWARD,mu) ;
179  }
180 
181  LatticeComplex mpps_ps = localNorm2(q_mp_q) ;
182  LatticeComplex ps_ps = localNorm2(q_q);
183  LatticeComplex q_bar_q = localInnerProduct(src,q_q);
184  LatticeComplex diff = divA - 2.0 * m_q * ps_ps - 2.0*mpps_ps + 2.0*q_bar_q;
185 
186  SftMom trick(0,false,j_decay) ;
187  multi1d<Double> corr = sumMulti(localNorm2(diff), trick.getSet());
188  QDPIO::cout<<"check_dwf_ward_identity: ";
189  QDPIO::cout<<"Ward Identity violation per timeslice: "<<std::endl;
190  for(int t(0);t<corr.size(); t++){
191  QDPIO::cout<<" "<<t<<" "<< sqrt(corr[t])<<std::endl ;
192  }
193 
194  QDPIO::cout<<"check_dwf_ward_identity: Ward Identity violation: ";
195  QDPIO::cout<<sqrt(norm2(diff))<<std::endl ;
196 
197  QDPIO::cout<<"check_dwf_ward_identity: |divA|^2 : "<<norm2(divA)<<std::endl;
198  QDPIO::cout<<"check_dwf_ward_identity: |ps_ps|^2 : "<<norm2(ps_ps)<<std::endl;
199  QDPIO::cout<<"check_dwf_ward_identity: |mpps_ps|^2 : "<<norm2(mpps_ps)<<std::endl;
200  QDPIO::cout<<"check_dwf_ward_identity: |q_bar_q|^2 : "<<norm2(q_bar_q)<<std::endl;
201  Double gmor( sqrt(norm2(sum(m_q*ps_ps + mpps_ps - q_bar_q))) );
202  QDPIO::cout<<"check_dwf_ward_identity: GMOR : "<<gmor<<std::endl;
203 
204  }
205 
206 
207  //! Given a complete propagator as a source, this does all the inversions needed
208  /*! \ingroup qprop
209  *
210  * This routine is actually generic to Domain Wall fermions (Array) fermions
211  *
212  * \param q_sol quark propagator ( Write )
213  * \param q_src source ( Read )
214  * \param t_src time slice of source ( Read )
215  * \param j_decay direction of decay ( Read )
216  * \param qpropT 5D inverter ( Read )
217  * \param ncg_had number of CG iterations ( Write )
218  */
219  void dwf_quarkProp4(LatticePropagator& q_sol,
220  XMLWriter& xml_out,
221  const LatticePropagator& q_src,
222  int t_src, int j_decay,
224  Handle< FermState<LatticeFermion,
225  multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> > > state,
226  const Real& m_q,
227  int& ncg_had)
228  {
229  START_CODE();
230 
231  QDPIO::cout << "entering DWF_QuarkProp4" << std::endl;
232 
233  push(xml_out, "DWF_QuarkProp4");
234 
235  ncg_had = 0;
236 
237  int N5 = qpropT->size();
238  multi1d<LatticePropagator> prop5d(N5);
239  LatticePropagator q_mp;
240 
241  multi1d<LatticeFermion> psi(N5);
242 
243  // This version loops over all color and spin indices
244  for(int color_source = 0; color_source < Nc; ++color_source)
245  {
246  for(int spin_source = 0; spin_source < Ns; ++spin_source)
247  {
248  QDPIO::cout<<"dwf_quarkProp:: doing color : "<< color_source;
249  QDPIO::cout<<" and spin : "<< spin_source<<std::endl ;
250 
251  psi = zero ; // note this is ``zero'' and not 0
252  LatticeFermion tmp = zero;
253  PropToFerm(q_src, tmp, color_source, spin_source);
254 
255  /*
256  * Normalize the source in case it is really huge or small -
257  * a trick to avoid overflows or underflows
258  */
259 
260  Real fact = 1.0;
261  Real nrm = sqrt(norm2(tmp));
262  if (toFloat(nrm) != 0.0)
263  fact /= nrm;
264 
265  // Rescale
266  tmp *= fact;
267 
268 
269  //QDPIO::cout<<"Normalization Factor: "<< fact<<std::endl ;
270 
271  multi1d<LatticeFermion> chi(N5) ;
272  chi = zero ;
273  // Split the source to oposite walls according to chirality
274  chi[0 ] = chiralProjectPlus(tmp) ;
275  chi[N5-1] = chiralProjectMinus(tmp) ;
276 
277  // now we are ready invert
278  // Compute the propagator for given source color/spin.
279  {
280  SystemSolverResults_t result = (*qpropT)(psi,chi);
281  ncg_had += result.n_count;
282 
283  push(xml_out,"Qprop");
284  write(xml_out, "color_source", color_source);
285  write(xml_out, "spin_source", spin_source);
286  write(xml_out, "n_count", result.n_count);
287  write(xml_out, "resid", result.resid);
288  pop(xml_out);
289  }
290 
291  // Unnormalize the source following the inverse
292  // of the normalization above
293  fact = Real(1) / fact;
294  for(int i = 0; i < N5; ++i)
295  psi[i] *= fact;
296 
297  /*
298  * Move the solution to the appropriate components
299  * of quark propagator.
300  */
301 
302  //First the 5D quark propagator
303  for(int s(0);s<N5;s++)
304  FermToProp(psi[s], prop5d[s], color_source, spin_source);
305  // Now get the 4D propagator too
306 
307  tmp = chiralProjectMinus(psi[0]) + chiralProjectPlus(psi[N5-1]);
308 
309  // move solution to the appropriate components of the 4d
310  // quark propagator
311  FermToProp(tmp, q_sol, color_source, spin_source);
312 
313  // move solution to the appropriate components of the 4d
314  // midpoint quark propagator
315  tmp = chiralProjectPlus(psi[N5/2 - 1]) + chiralProjectMinus(psi[N5/2]) ;
316  FermToProp(tmp, q_mp, color_source, spin_source);
317 
318  } /* end loop over spin_source */
319  } /* end loop over color_source */
320 
321  // Construct the norm of the chiral field throughout the bulk
322  {
323  multi1d<Double> bulk_norm2(N5/2);
324  bulk_norm2 = zero;
325 
326  for(int s=0; s < bulk_norm2.size(); ++s)
327  {
328  bulk_norm2[s] = norm2(chiralProjectMinus(prop5d[s]) + chiralProjectPlus(prop5d[N5-1-s]));
329  }
330 
331  write(xml_out, "bulk_norm2", bulk_norm2);
332  }
333 
334  // constuct the conserved axial current correlator
335  LatticeComplex cfield ;
336  dwf_conserved_axial_ps_corr(cfield,state->getLinks(),prop5d,j_decay);
337 
338 
339  SftMom trick(0,false,j_decay) ;
340  int length = trick.numSubsets(); // Length of lattice in time direction
341 
342  multi1d<Real> mesprop(length);
343  {
344  multi1d<DComplex> corr = sumMulti(cfield, trick.getSet());
345  for(int t(0);t<length; t++){
346  int t_eff( (t - t_src + length) % length ) ;
347  mesprop[t_eff] = real(corr[t]) ;
348  }
349  }
350 
351  push(xml_out, "time_direction");
352  write(xml_out, "t_dir",j_decay);
353  pop(xml_out);
354  push(xml_out, "DWF_ConservedAxial");
355  write(xml_out, "mesprop", mesprop);
356  pop(xml_out);
357 
358  // The local axial corruent pseudoscalar correlator
359  int d(1<<j_decay);
360  cfield = localInnerProduct(q_sol,Gamma(d)*q_sol);
361  {
362  multi1d<DComplex> corr = sumMulti(cfield, trick.getSet()) ;
363  for(int t(0);t<length; t++){
364  int t_eff( (t - t_src + length) % length ) ;
365  mesprop[t_eff] = -real(corr[t]) ; // sign fix
366  }
367  }
368  push(xml_out, "DWF_LocalAxial");
369  write(xml_out, "mesprop", mesprop);
370  pop(xml_out);
371 
372  //Now the midpoint Pseudoscalar correlator
373  multi1d<Double> tmp = sumMulti(localNorm2(q_mp), trick.getSet());
374  for(int t(0);t<length; t++){
375  int t_eff( (t - t_src + length) % length ) ;
376  mesprop[t_eff] = tmp[t] ;
377  }
378 
379  push(xml_out, "DWF_MidPoint_Pseudo");
380  write(xml_out, "mesprop", mesprop);
381  pop(xml_out);
382 
383  tmp = sumMulti(localNorm2(q_sol), trick.getSet());
384  for(int t(0);t<length; t++){
385  int t_eff( (t - t_src + length) % length ) ;
386  mesprop[t_eff] = tmp[t] ; // only need the zero momentum
387  }
388  push(xml_out, "DWF_Psuedo_Pseudo");
389  write(xml_out, "mesprop", mesprop);
390  pop(xml_out);
391 
392  pop(xml_out); // DWF_QuarkProp
393 
394  check_dwf_ward_identity(state->getLinks(),prop5d,q_src,
395  q_sol,q_mp,m_q,
396  j_decay);
397 
398 
399  QDPIO::cout << "exiting DWF_QuarkProp4" << std::endl;
400 
401  END_CODE();
402  }
403 
404 
405  /*!
406  Corelation function:
407  \f[
408  C(t) = \sum_x \sum_s \left[\bar{\Psi}(x+\hat{\mu},t,s) U^{\dagger}_{\mu}(x)
409  \frac{1+\gamma_{\mu}}{2}
410  \Psi (x,t,s) -
411  \bar{\Psi}(x,t,s) U_{\mu}(x)
412  \frac{1-\gamma_{\mu}}{2}
413  \Psi (x+\hat{\mu},t,s)\right]
414  \bar{q}(0,0)\gamma_5 q(0,0) sign(s - \frac{L_s - 1}{2})
415  \f]
416  **/
417  void dwf_conserved_axial_ps_corr(LatticeComplex& corr,
418  const multi1d<LatticeColorMatrix>& u,
419  const multi1d<LatticePropagator>& p5d,
420  const int mu)
421  {
422  // gamma std::mapping G_0 --> Gamma(1)
423  // G_1 --> Gamma(2)
424  // G_2 --> Gamma(4)
425  // G_3 --> Gamma(8)
426  int d(1<<mu);
427  int g5(Ns*Ns - 1) ;
428  int N5(p5d.size());
429 
430  corr = zero;
431 
432  multi1d<LatticePropagator> us_p5d(N5) ;
433  for(int s(0); s<N5;s++)
434  us_p5d[s] = u[mu]*shift(p5d[s],FORWARD,mu) ;
435 
436  for(int s(0); s<N5;s++){
437  // first the 1-gamma_mu term
438  LatticeComplex C;
439  C=0.5*( trace(adj( p5d[N5-1-s])*Gamma(g5)*Gamma(d)*us_p5d[s]) -
440  trace(adj( p5d[N5-1-s])*Gamma(g5) *us_p5d[s]) +
441  //now the 1+gamma_mu term
442  trace(adj(us_p5d[N5-1-s])*Gamma(g5)*Gamma(d)* p5d[s]) +
443  trace(adj(us_p5d[N5-1-s])*Gamma(g5) * p5d[s]) );
444 
445  if(s<N5/2)
446  corr -= C ;
447  else
448  corr += C ;
449  }
450 
451  }
452 
453 }
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
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
int mu
Definition: cool.cc:24
Full quark propagator solver for domain wall fermions.
DWF parity/rotation operator.
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 dwf_quarkProp4(LatticePropagator &q_sol, XMLWriter &xml_out, const LatticePropagator &q_src, int t_src, int j_decay, Handle< SystemSolverArray< LatticeFermion > > qpropT, Handle< FermState< LatticeFermion, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > > state, const Real &m_q, 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
Nd
Definition: meslate.cc:74
SpinMatrix C()
C = Gamma(10)
Definition: barspinmat_w.cc:29
QDPSubTypeTrait< typename BinaryReturn< C1, C2, FnLocalInnerProduct >::Type_t >::Type_t localInnerProduct(const QDPSubType< T1, C1 > &l, const QDPType< T2, C2 > &r)
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
void dwf_conserved_axial_ps_corr(LatticeComplex &corr, const multi1d< LatticeColorMatrix > &u, const multi1d< LatticePropagator > &p5d, const int mu)
static multi1d< LatticeColorMatrix > u
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
push(xml_out,"Condensates")
int i
Definition: pbg5p_w.cc:55
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
pop(xml_out)
DComplex d
Definition: invbicg.cc:99
START_CODE()
void check_dwf_ward_identity(const multi1d< LatticeColorMatrix > &u, const multi1d< LatticePropagator > &p5d, const LatticePropagator &src, const LatticePropagator &q_q, const LatticePropagator &q_mp_q, const Real &m_q, int j_decay)
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
Definition: pbg5p_w.cc:28
Double zero
Definition: invbicg.cc:106
multi1d< LatticeFermion > s(Ncb)
FloatingPoint< double > Double
Definition: gtest.h:7351
#define FORWARD
Definition: primitives.h:82
#define BACKWARD
Definition: primitives.h:83
Double sum
Definition: qtopcor.cc:37
Fourier transform phase factor support.
Holds return info from SystemSolver call.
Definition: syssolver.h:17