43 namespace OvlapPartFrac4DFermActEnv
47 multi1d<LatticeColorMatrix>,
58 multi1d<LatticeColorMatrix>,
89 XMLReader
in(xml, path);
93 if(
in.count(
"AuxFermAct") == 1 )
95 XMLReader xml_tmp(
in,
"AuxFermAct");
96 std::ostringstream os;
108 if(
in.count(
"RatPolyDegPrecond") == 1 ) {
115 if(
in.count(
"ApproximationType") == 1 ) {
128 if(
in.count(
"InnerSolve/ReorthFreq") == 1 ) {
136 if(
in.count(
"InnerSolve/SolverType") == 1 ) {
147 QDPIO::cerr <<
"Caught Exception reading Zolo4D Fermact params: " << e << std::endl;
155 push( xml_out, path);
158 xml_out <<
p.AuxFermAct;
159 write(xml_out,
"Mass",
p.Mass);
160 write(xml_out,
"RatPolyDeg",
p.RatPolyDeg);
161 write(xml_out,
"RatPolyDegPrecond",
p.RatPolyDegPrecond);
162 push(xml_out,
"InnerSolve");
163 write(xml_out,
"MaxCG",
p.invParamInner.MaxCG);
164 write(xml_out,
"RsdCG",
p.invParamInner.RsdCG);
165 write(xml_out,
"ReorthFreq",
p.ReorthFreqInner);
166 write(xml_out,
"SolverType",
p.inner_solver_type);
167 write(xml_out,
"ApproximationType",
p.approximation_type);
168 write(xml_out,
"ApproxMin",
p.approxMin);
169 write(xml_out,
"ApproxMax",
p.approxMax);
170 write(xml_out,
"IsChiral",
p.isChiralP);
192 fbc(fbc_),
params(params_)
194 QDPIO::cout <<
"Constructing OvlapPartFrac4D FermAct from params" << std::endl;
196 XMLReader fermacttop(xml_s);
200 if (
fbc.operator->() == 0)
210 struct UnprecCastFailure {
211 UnprecCastFailure(
std::string e) : auxfermact(e) {};
218 read(fermacttop, fermact_path +
"/FermAct", auxfermact);
219 QDPIO::cout <<
"AuxFermAct: " << auxfermact << std::endl;
222 QDPIO::cout <<
"AuxFermAct Mass: " <<
params.
AuxMass << std::endl;
234 if( S_aux == 0 )
throw UnprecCastFailure(auxfermact);
242 catch(
const UnprecCastFailure& e) {
245 QDPIO::cerr <<
"Unable to upcast auxiliary fermion action to "
246 <<
"UnprecWilsonTypeFermAct " << std::endl;
248 <<
"auxiliary FermActs" << std::endl;
249 QDPIO::cerr <<
"You passed : " << std::endl;
250 QDPIO::cerr << e.auxfermact << std::endl;
253 catch (
const std::exception& e) {
255 QDPIO::cerr <<
"Error reading data: " << e.what() << std::endl;
268 multi1d<Real>& rootQ,
270 multi1d<Real>& EigValFunc,
279 zolotarev_data *rdata ;
305 int NEigVal =
state.getNEig();
321 QDPIO::cout <<
"Initing Linop with Zolotarev Coefficients" << std::endl;
324 QDPIO::cout <<
" NEigVal = " << NEigVal << std::endl;
347 QDPIO::cerr <<
"Failed to get Zolo Coeffs" << std::endl;
356 QDPIO::cout <<
"Initing Linop with Higham Rep tanh Coefficients" << std::endl;
359 QDPIO::cout <<
" NEigVal = " << NEigVal << std::endl;
377 scale_fac = Real(1) ;
380 QDPIO::cout <<
"Initing Linop with Unscaled Higham Rep tanh Coefficients" << std::endl;
383 QDPIO::cout <<
" NEigVal = " << NEigVal << std::endl;
408 maxerr = (Real)(rdata -> Delta);
409 QDPIO::cout <<
"Maxerr " << maxerr << std::flush << std::endl;
423 numroot = rdata -> dd;
425 rootQ.resize(numroot);
427 resP.resize(numroot);
431 coeffP = rdata ->
alpha[rdata -> da - 1];
434 for(
int n=0;
n < numroot; ++
n) {
436 rootQ[
n] = rdata -> ap[
n];
437 rootQ[
n] = -rootQ[
n];
451 coeffP = rdata ->
alpha[rdata -> da - 1] * scale_fac;
454 Real
t = Real(1) / (scale_fac * scale_fac);
455 for(
int n=0;
n < numroot; ++
n) {
457 resP[
n] = rdata ->
alpha[
n] / scale_fac;
458 rootQ[
n] = rdata -> ap[
n];
459 rootQ[
n] = -(rootQ[
n] *
t);
472 QDPIO::cout <<
"PartFracApprox 4d n=" <<
params.
RatPolyDeg <<
" scale=" << scale_fac
473 <<
" coeff=" << coeffP <<
" Nwils= " << NEigVal <<
" Mass="
476 QDPIO::cout <<
"Approximation on [-1,-eps] U [eps,1] with eps = " <<
eps <<
478 QDPIO::cout <<
"Maximum error |R(x) - sqn(x)| <= " << maxerr << std::endl;
482 QDPIO::cout <<
"Coefficients from Zolotarev" << std::endl;
485 QDPIO::cout <<
"Approximation type " << type <<
" with R(0) = 0"
489 QDPIO::cout <<
"Approximation type " << type <<
" with R(0) = infinity" << std::endl;
494 QDPIO::cout <<
"Coefficients from Higham Tanh representation" << std::endl;
498 QDPIO::cout <<
"Coefficients from Unscaled Higham Tanh representation" << std::endl;
510 QDPIO::cout <<
"Using Single Pass Inner Solver" << std::endl;
513 QDPIO::cout <<
"Using Neuberger/Chu Double Pass Inner Solver" << std::endl;
516 QDPIO::cerr <<
"Unknown inner solver type " << std::endl;
520 QDPIO::cout <<
"Number of poles= " << numroot << std::endl;
521 QDPIO::cout <<
"Overall Factor= " << coeffP << std::endl;
522 QDPIO::cout <<
"Numerator coefficients:" << std::endl;
523 for(
int n=0;
n < numroot;
n++) {
524 QDPIO::cout <<
" resP[" <<
n <<
"]= " << resP[
n] << std::endl;
526 QDPIO::cout <<
"Denominator roots: " << std::endl;
527 for(
int n=0;
n < numroot;
n++) {
528 QDPIO::cout <<
" rootQ[" <<
n<<
"]= " << rootQ[
n] << std::endl;
535 for(
int i = 0;
i < NEigVal;
i++)
537 if (toBool(
state.getEvalues()[
i] > 0.0))
539 else if (toBool(
state.getEvalues()[
i] < 0.0))
540 EigValFunc[
i] = -1.0;
555 multi1d<Real>& rootQ,
557 multi1d<Real>& EigValFunc,
563 XMLBufferWriter my_writer;
567 zolotarev_data *rdata ;
593 int NEigVal =
state.getNEig();
608 QDPIO::cout <<
"Initing Linop with Zolotarev Coefficients" << std::endl;
612 QDPIO::cout <<
" NEigVal = " << NEigVal << std::endl;
634 maxerr = (Real)(rdata -> Delta);
640 QDPIO::cout <<
"Initing Linop with Higham Rep tanh Coefficients" << std::endl;
644 QDPIO::cout <<
" NEigVal = " << NEigVal << std::endl;
659 maxerr = (Real)(rdata -> Delta);
662 scale_fac = Real(1) ;
665 QDPIO::cout <<
"Initing Preconditioning Linop with Unscaled Higham Rep tanh Coefficients" << std::endl;
668 QDPIO::cout <<
" NEigVal = " << NEigVal << std::endl;
695 numroot = rdata -> dd;
697 rootQ.resize(numroot);
700 resP.resize(numroot);
704 coeffP = rdata ->
alpha[rdata -> da - 1];
707 for(
int n=0;
n < numroot; ++
n) {
709 rootQ[
n] = rdata -> ap[
n];
710 rootQ[
n] = -rootQ[
n];
725 coeffP = rdata ->
alpha[rdata -> da - 1] * scale_fac;
728 Real
t = Real(1) / (scale_fac * scale_fac);
729 for(
int n=0;
n < numroot; ++
n) {
731 resP[
n] = rdata ->
alpha[
n] / scale_fac;
732 rootQ[
n] = rdata -> ap[
n];
733 rootQ[
n] = -(rootQ[
n] *
t);
749 <<
" coeff=" << coeffP <<
" Nwils= " << NEigVal <<
" Mass="
752 QDPIO::cout <<
"Approximation on [-1,-eps] U [eps,1] with eps = " <<
eps <<
754 QDPIO::cout <<
"Maximum error |R(x) - sqn(x)| <= " << maxerr << std::endl;
758 QDPIO::cout <<
"Coefficients from Zolotarev" << std::endl;
761 QDPIO::cout <<
"Approximation type " << type <<
" with R(0) = 0"
765 QDPIO::cout <<
"Approximation type " << type <<
" with R(0) = infinity" << std::endl;
770 QDPIO::cout <<
"Coefficients from Higham Tanh representation" << std::endl;
775 QDPIO::cout <<
"Coefficients from Higham Tanh representation" << std::endl;
782 QDPIO::cout << std::flush;
786 QDPIO::cout <<
"Using Single Pass Inner Solver" << std::endl;
789 QDPIO::cout <<
"Using Neuberger/Chu Double Pass Inner Solver" << std::endl;
792 QDPIO::cerr <<
"Unknown inner solver type " << std::endl;
796 QDPIO::cout <<
"Number of poles= " << numroot << std::endl;
797 QDPIO::cout <<
"Overall Factor= " << coeffP << std::endl;
798 QDPIO::cout <<
"Numerator coefficients:" << std::endl;
799 for(
int n=0;
n < numroot;
n++) {
800 QDPIO::cout <<
" resP[" <<
n <<
"]= " << resP[
n] << std::endl;
802 QDPIO::cout <<
"Denominator roots: " << std::endl;
803 for(
int n=0;
n < numroot;
n++) {
804 QDPIO::cout <<
" rootQ[" <<
n<<
"]= " << rootQ[
n] << std::endl;
812 for(
int i = 0;
i < NEigVal;
i++)
814 if (toBool(
state.getEvalues()[
i] > 0.0))
816 else if (toBool(
state.getEvalues()[
i] < 0.0))
817 EigValFunc[
i] = -1.0;
826 QDPIO::cout <<
"Leaving Init!" << std::endl << std::flush;
838 multi1d<LatticeColorMatrix>,
839 multi1d<LatticeColorMatrix> >*
847 int NEigVal =
state.getNEig();
868 multi1d<Real> EigValFunc(NEigVal);
871 init(numroot, coeffP, resP, rootQ, NEig, EigValFunc,
state);
879 numroot, coeffP, resP, rootQ,
880 NEig, EigValFunc,
state.getEvectors(),
887 numroot, coeffP, resP, rootQ,
888 NEig, EigValFunc,
state.getEvectors(),
899 catch(std::bad_cast) {
900 QDPIO::cerr <<
"OverlapPartFrac4DFermAct::unprecLinOp: "
901 <<
" Failed to downcast ConnectState to OverlapConnectState"
908 QDPIO::cout <<
"DANGER!!! About to return zero! " << std::endl;
925 int NEigVal =
state.getNEig();
946 multi1d<Real> EigValFunc(NEigVal);
949 initPrec(numroot, coeffP, resP, rootQ, NEig, EigValFunc,
state);
957 numroot, coeffP, resP, rootQ,
958 NEig, EigValFunc,
state.getEvectors(),
963 numroot, coeffP, resP, rootQ,
964 NEig, EigValFunc,
state.getEvectors(),
973 catch(std::bad_cast) {
974 QDPIO::cerr <<
"OverlapPartFrac4DFermAct::linOpPrecondition: "
975 <<
" Failed to downcast ConnectState to OverlapConnectState"
999 int NEigVal =
state.getNEig();
1010 multi1d<Real> rootQ;
1020 multi1d<Real> EigValFunc(NEigVal);
1023 init(numroot, coeffP, resP, rootQ, NEig, EigValFunc,
state);
1031 numroot, coeffP, resP, rootQ,
1032 NEig, EigValFunc,
state.getEvectors(),
1037 numroot, coeffP, resP, rootQ,
1038 NEig, EigValFunc,
state.getEvectors(),
1046 catch(std::bad_cast) {
1047 QDPIO::cerr <<
"OverlapPartFrac4DFermAct::lgamma5epsH: "
1048 <<
" Failed to downcast ConnectState to OverlapConnectState"
1071 int NEigVal =
state.getNEig();
1082 multi1d<Real> rootQ;
1092 multi1d<Real> EigValFunc(NEigVal);
1095 initPrec(numroot, coeffP, resP, rootQ, NEig, EigValFunc,
state);
1103 numroot, coeffP, resP, rootQ,
1104 NEig, EigValFunc,
state.getEvectors(),
1109 numroot, coeffP, resP, rootQ,
1110 NEig, EigValFunc,
state.getEvectors(),
1131 multi1d<LatticeColorMatrix>,
1132 multi1d<LatticeColorMatrix> >*
1149 multi1d<LatticeColorMatrix>,
1150 multi1d<LatticeColorMatrix> >*
1161 int NEigVal =
state.getNEig();
1172 multi1d<Real> rootQ;
1182 multi1d<Real> EigValFunc(NEigVal);
1185 init(numroot, coeffP, resP, rootQ, NEig, EigValFunc,
state);
1193 numroot, coeffP, resP, rootQ,
1194 NEig, EigValFunc,
state.getEvectors(),
1199 numroot, coeffP, resP, rootQ,
1200 NEig, EigValFunc,
state.getEvectors(),
1232 int NEigVal =
state.getNEig();
1243 multi1d<Real> rootQ;
1253 multi1d<Real> EigValFunc(NEigVal);
1256 initPrec(numroot, coeffP, resP, rootQ, NEig, EigValFunc,
state);
1264 numroot, coeffP, resP, rootQ,
1265 NEig, EigValFunc,
state.getEvectors(),
1270 numroot, coeffP, resP, rootQ,
1271 NEig, EigValFunc,
state.getEvectors(),
1313 XMLReader& state_info_xml,
1316 XMLFileWriter test(
"./test");
1317 test << state_info_xml;
1322 if( state_info_xml.count(
"/StateInfo/eigen_info_id") == 1 ) {
1324 read(state_info_xml,
"/StateInfo/eigen_info_id", eigen_info_id);
1325 QDPIO::cout <<
"Using eigen_info_id: " << eigen_info_id << std::endl;
1334 for(
int vec = 0; vec < ret_val->
getNEig(); vec++) {
1336 LatticeFermion lambda_e, H_e;
1340 (*Maux)(H_e, ev,
PLUS);
1341 lambda_e = lambda * ev;
1343 LatticeFermion diff = H_e - lambda_e;
1344 Double norm_diff = sqrt(norm2(diff));
1345 Double norm_diff_rel = norm_diff/fabs(lambda);
1347 QDPIO::cout <<
"EV Check["<< vec<<
"]: lambda="<< lambda <<
" resid="<<norm_diff<<
" rel. resid="<< norm_diff_rel << std::endl;
1354 QDPIO::cout <<
"No StateInfo Found: " << std::endl;
Primary include file for CHROMA library code.
Create a simple ferm connection state.
Differentiable Linear Operator.
Differentiable M^dag.M linear operator.
multi1d< Real > & getEvalues()
Return the eigenvalues.
multi1d< LatticeFermion > & getEvectors()
Base class for all fermion action boundary conditions.
Support class for fermion actions and linear operators.
Base class for quadratic matter actions (e.g., fermions)
Class for counted reference semantics.
virtual UnprecLinearOperator< T, P, Q > * linOp(Handle< FermState< T, P, Q > > state) const
Override to produce a DWF-link unprec. linear operator for this action.
4D Zolotarev variant of Overlap-Dirac operator
UnprecLinearOperator< T, P, Q > * unprecLinOp(Handle< FermState< T, P, Q > > state, const Real &m_q) const
Produce a linear operator for this action.
LinearOperator< T > * lgamma5epsHPrecondition(Handle< FermState< T, P, Q > > state) const
Produce a linear operator that gives back gamma_5 eps(H)
LinearOperator< T > * linOpPrecondition(Handle< FermState< T, P, Q > > state) const
Produce a linear operator for this action.
LinearOperator< T > * lMdagMPrecondition(Handle< FermState< T, P, Q > > state) const
Produce a linear operator M^dag.M for this action.
DiffLinearOperator< T, P, Q > * lMdagM(Handle< FermState< T, P, Q > > state) const
Produce a linear operator M^dag.M for this action.
Handle< FermBC< T, P, Q > > fbc
Handle< UnprecWilsonTypeFermAct< T, P, Q > > Mact
OvlapPartFrac4DFermActParams params
LinearOperator< T > * lgamma5epsH(Handle< FermState< T, P, Q > > state) const
Produce a linear operator that gives back gamma_5 eps(H)
OvlapPartFrac4DFermAct()
Partial constructor not allowed.
Handle< CreateFermState< T, P, Q > > cfs
void init(int &numroot, Real &coeffP, multi1d< Real > &resP, multi1d< Real > &rootQ, int &NEig, multi1d< Real > &EigValFunc, const EigenConnectState &state) const
Helper in construction.
void initPrec(int &numroot, Real &coeffP, multi1d< Real > &resP, multi1d< Real > &rootQ, int &NEig, multi1d< Real > &EigValFunc, const EigenConnectState &state) const
Construct stuff but use RatPolyDegPrec in the polynomial.
EigenConnectState * createState(const multi1d< LatticeColorMatrix > &u, XMLReader &state_info_xml, const std::string &state_info_path) const
Create OverlapFermState<T,P,Q> from XML.
Simple version of FermState.
Unpreconditioned linear operator including derivatives.
Unpreconditioned Wilson-like fermion actions with derivatives.
Wilson-like fermion actions.
Internal Overlap-pole operator sign function.
Internal Overlap-pole operator.
Internal Overlap-pole operator.
Internal Overlap-pole operator.
Internal Overlap-pole operator.
Internal Overlap-pole operator.
All ferm create-state method.
Fermion action factories.
Fermionic boundary condition reader.
void read(XMLReader &xml, const std::string &path, AsqtadFermActParams ¶m)
Read parameters.
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams ¶m)
Writer parameters.
Handle< FermBC< LatticeFermion, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > > reader(XMLReader &xml_in, const std::string &path)
Helper function for the FermionAction readers.
@ COEFF_TYPE_TANH_UNSCALED
@ OVERLAP_INNER_CG_DOUBLE_PASS
@ OVERLAP_INNER_CG_SINGLE_PASS
Internal Overlap-pole operator.
Internal pole epsilon operator. Just the unitary part.
Internal Overlap-pole operator.
Internal Overlap-pole operator.
Internal Overlap-pole operator.
Internal Overlap-pole operator.
static bool registered
Local registration flag.
bool registerAll()
Register all the factories.
FermionAction< LatticeFermion, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > * createFermAct(XMLReader &xml_in, const std::string &path)
Callback function.
const std::string name
Name to be used.
WilsonTypeFermAct< LatticeFermion, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > * createFermAct4D(XMLReader &xml_in, const std::string &path)
Callback function.
static const LatticeInteger & alpha(const int dim)
Asqtad Staggered-Dirac operator.
push(xml_out,"Condensates")
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
const WilsonTypeFermAct< multi1d< LatticeFermion > > & S_f
static QDP_ColorVector * in
FloatingPoint< double > Double
4D Zolotarev variant of Overlap-Dirac operator
Simple ferm state and a creator.
Params for overlap ferm acts.
OvlapPartFrac4DFermActParams()
OverlapInnerSolverType inner_solver_type
CoeffType approximation_type
Type of approximation ZOLOTAREV or TANH.
struct Chroma::OvlapPartFrac4DFermActParams::InvParamInner invParamInner
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)