CHROMA
eoprec_zolo_nef_fermact_array_w.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Unpreconditioned NEF fermion action
3  */
4 
5 #include "chromabase.h"
10 
12 
15 
18 
19 namespace Chroma
20 {
21  //! Hooks to register the class with the fermact factory
22  namespace EvenOddPrecZoloNEFFermActArrayEnv
23  {
24  //! Callback function
25  WilsonTypeFermAct5D<LatticeFermion,
26  multi1d<LatticeColorMatrix>,
27  multi1d<LatticeColorMatrix> >* createFermAct5D(XMLReader& xml_in,
28  const std::string& path)
29  {
32  }
33 
34  //! Callback function
35  /*! Differs in return type */
36  FermionAction<LatticeFermion,
37  multi1d<LatticeColorMatrix>,
38  multi1d<LatticeColorMatrix> >* createFermAct(XMLReader& xml_in,
39  const std::string& path)
40  {
41  return createFermAct5D(xml_in, path);
42  }
43 
44  //! Name to be used
45  const std::string name = "ZOLO_NEF";
46 
47  //! Local registration flag
48  static bool registered = false;
49 
50  //! Register all the factories
51  bool registerAll()
52  {
53  bool success = true;
54  if (! registered)
55  {
56  success &= Chroma::TheFermionActionFactory::Instance().registerObject(name, createFermAct);
58  registered = true;
59  }
60  return success;
61  }
62  }
63 
64 
65  //! Read parameters
67  const std::string& path)
68  {
69  XMLReader paramtop(xml, path);
70  try {
71  // Read the stuff for the action
72  read(paramtop, "OverMass", OverMass);
73  read(paramtop, "Mass", Mass);
74  read(paramtop, "b5", b5);
75  read(paramtop, "c5", c5);
76  read(paramtop, "N5", N5);
77 
78  if( paramtop.count("ApproximationType") == 1 )
79  {
80  read(paramtop, "ApproximationType", approximation_type);
81  }
82  else
83  {
84  // Default coeffs are unscaled tanh
86  }
87 
89  {
90  read(paramtop, "ApproxMin", ApproxMin);
91  read(paramtop, "ApproxMax", ApproxMax);
92  }
93  else
94  {
95  ApproxMin = ApproxMax = 0.0;
96  }
97  }
98  catch(const std::string& e) {
99  QDPIO::cerr << "Caught Exception : " << e << std::endl;
100  }
101  }
102 
103 
104  //! Read parameters
105  void read(XMLReader& xml, const std::string& path, EvenOddPrecZoloNEFFermActArrayParams& param)
106  {
108  param = tmp;
109  }
110 
111 
112 
113  void EvenOddPrecZoloNEFFermActArray::initCoeffs(multi1d<Real>& b5_arr,
114  multi1d<Real>& c5_arr) const
115  {
116  b5_arr.resize(params.N5);
117  c5_arr.resize(params.N5);
118 
119  Real approxMin = params.ApproxMin;
120  Real approxMax = params.ApproxMax;
121 
122  Real epsilon;
123  Real scale_fac;
124  zolotarev_data *rdata;
125 
126  switch(params.approximation_type)
127  {
129  epsilon = approxMin / approxMax;
130  QDPIO::cout << "Initing Linop with Zolotarev Coefficients: epsilon = " << epsilon << std::endl;
131  rdata = zolotarev(toFloat(epsilon), params.N5, 0);
132  scale_fac = approxMax;
133  break;
134 
136  epsilon = approxMin;
137  QDPIO::cout << "Initing Linop with Higham Rep tanh Coefficients" << std::endl;
138  rdata = higham(toFloat(epsilon), params.N5);
139  scale_fac = Real(1);
140  break;
141 
142  default:
143  // The std::map system should ensure that we never get here but
144  // just for style
145  QDPIO::cerr << "Unknown coefficient type: " << params.approximation_type
146  << std::endl;
147  QDP_abort(1);
148  }
149 
150  if( rdata->n != params.N5 ) {
151  QDPIO::cerr << "Error:rdata->n != N5" << std::endl;
152  QDP_abort(1);
153  }
154 
155  multi1d<Real> gamma(params.N5);
156  for(int i=0; i < params.N5; i++) {
157  gamma[i] = Real(rdata->gamma[i])*scale_fac;
158  }
159 
160  Real maxerr=rdata->Delta;
161  zolotarev_free(rdata);
162 
163  QDPIO::cout << "Initing Zolo NEF Linop: N5=" << params.N5
164  << " b5+c5=" << params.b5+params.c5
165  << " b5-c5=" << params.b5-params.c5
166  << " epsilon=" << epsilon
167  << " scale=" << approxMax
168  << " maxerr=" << maxerr << std::endl;
169 
170 
171  for(int i = 0; i < params.N5; i++) {
172  Real omega = Real(1)/gamma[i];
173 
174  b5_arr[i] = Real(0.5)*( (omega + Real(1))*params.b5 + (omega - Real(1))*params.c5 );
175  c5_arr[i] = Real(0.5)*( (omega - Real(1))*params.b5 + (omega + Real(1))*params.c5 );
176 
177  QDPIO::cout << "i=" << i << " omega["<<i<<"]=" << omega
178  << " b5["<< i << "] ="<< b5_arr[i]
179  << " c5["<< i << "] ="<< c5_arr[i] << std::endl;
180  QDPIO::cout << "i=" << i
181  << " b5["<<i<<"]+c5["<<i<<"]/omega["<<i<<"] ="
182  << (b5_arr[i]+c5_arr[i])/omega
183  << " b5["<<i<<"]-c5["<<i<<"]=" << b5_arr[i]-c5_arr[i] << std::endl;
184  }
185 
186  }
187 
188 
189  //! Produce an even-odd preconditioned linear operator for this action with arbitrary quark mass
190  EvenOddPrecDWLikeLinOpBaseArray<LatticeFermion,
191  multi1d<LatticeColorMatrix>,
192  multi1d<LatticeColorMatrix> >*
194  const Real& m_q) const
195  {
196  multi1d<Real> b5_arr;
197  multi1d<Real> c5_arr;
198 
199  initCoeffs(b5_arr,c5_arr);
200 
201  return new EvenOddPrecGenNEFDWLinOpArray(state,params.OverMass,b5_arr,c5_arr,m_q,params.N5);
202  }
203 
204 
205  //! Produce an unpreconditioned linear operator for this action with arbitrary quark mass
206  UnprecDWLikeLinOpBaseArray<LatticeFermion,
207  multi1d<LatticeColorMatrix>,
208  multi1d<LatticeColorMatrix> >*
210  const Real& m_q) const
211  {
212  multi1d<Real> b5_arr;
213  multi1d<Real> c5_arr;
214 
215  initCoeffs(b5_arr,c5_arr);
216 
217  return new UnprecNEFDWLinOpArray(state,params.OverMass,b5_arr,c5_arr,m_q,params.N5);
218  }
219 
220 
221  // Given a complete propagator as a source, this does all the inversions needed
222  void
223  EvenOddPrecZoloNEFFermActArray::quarkProp(LatticePropagator& q_sol,
224  XMLWriter& xml_out,
225  const LatticePropagator& q_src,
226  int t_src, int j_decay,
228  const GroupXML_t& invParam,
229  QuarkSpinType quarkSpinType,
230  bool obsvP,
231  int& ncg_had) const
232  {
233  if (obsvP && (quarkSpinType == QUARK_SPIN_TYPE_FULL))
234  nef_quarkProp4(q_sol, xml_out, q_src, t_src, j_decay, *this, state, invParam, ncg_had);
235  else
236  {
238  quarkProp4(q_sol, xml_out, q_src, qprop, quarkSpinType, ncg_had);
239  }
240  }
241 
242 }
Primary include file for CHROMA library code.
SystemSolver< LatticeFermion > * qprop(Handle< FermState< LatticeFermion, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > > state, const GroupXML_t &invParam) const
Define quark propagator routine for 4D fermions.
4D Even Odd preconditioned domain-wall Dirac operator
4D Even Odd preconditioned NEF domain-wall Dirac operator
EvenOddPreconditioned NEF fermion action.
EvenOddPrecDWLikeLinOpBaseArray< T, P, Q > * precLinOp(Handle< FermState< T, P, Q > > state, const Real &m_q) const
Produce an even-odd preconditioned linear operator for this action with arbitrary quark mass.
void quarkProp(LatticePropagator &q_sol, XMLWriter &xml_out, const LatticePropagator &q_src, int t_src, int j_decay, Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam, QuarkSpinType quarkSpinType, bool obsvP, int &ncg_had) const
Given a complete propagator as a source, this does all the inversions needed.
void initCoeffs(multi1d< Real > &b5_arr, multi1d< Real > &c5_arr) const
UnprecDWLikeLinOpBaseArray< T, P, Q > * unprecLinOp(Handle< FermState< T, P, Q > > state, const Real &m_q) const
Produce an unpreconditioned linear operator for this action with arbitrary quark mass.
Support class for fermion actions and linear operators.
Definition: state.h:94
Base class for quadratic matter actions (e.g., fermions)
Definition: fermact.h:53
Class for counted reference semantics.
Definition: handle.h:33
static T & Instance()
Definition: singleton.h:432
Unpreconditioned domain-wall Dirac operator.
Unpreconditioned domain-wall Dirac operator.
Wilson-like fermion actions.
Definition: fermact.orig.h:403
4D Even Odd preconditioned NEF domain-wall fermion linear operator generalised to take array of b_5 a...
Unpreconditioned NEF domain-wall fermion action.
All ferm create-state method.
Fermion action factories.
void read(XMLReader &xml, const std::string &path, AsqtadFermActParams &param)
Read parameters.
QuarkSpinType
Quark spin type.
@ COEFF_TYPE_ZOLOTAREV
@ COEFF_TYPE_TANH_UNSCALED
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 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.
int j_decay
Definition: meslate.cc:22
Handle< CreateFermState< LatticeFermion, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > > reader(XMLReader &xml_in, const std::string &path)
Helper function for the CreateFermState readers.
WilsonTypeFermAct5D< LatticeFermion, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > * createFermAct5D(XMLReader &xml_in, const std::string &path)
Callback function.
FermionAction< LatticeFermion, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > * createFermAct(XMLReader &xml_in, const std::string &path)
Callback function.
int epsilon(int i, int j, int k)
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
int i
Definition: pbg5p_w.cc:55
Complex omega
Definition: invbicg.cc:97
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
Definition: pbg5p_w.cc:28
::std::string string
Definition: gtest.h:1979
Full quark propagator solver for domain wall fermions.
Full quark propagator solver.
CoeffType approximation_type
ZOLOTAREV | TANH | Other approximation coeffs.
Hold group xml and type id.
Unpreconditioned NEF domain-wall fermion linear operator.
Unpreconditioned Wilson fermion action.
void zolotarev_free(ZOLOTAREV_DATA *f)
ZOLOTAREV_DATA * higham(PRECISION epsilon, int n)
ZOLOTAREV_DATA * zolotarev(PRECISION epsilon, int n, int type)