diff --git a/Grid/qcd/action/ActionParams.h b/Grid/qcd/action/ActionParams.h index 6374256e..12d2b91b 100644 --- a/Grid/qcd/action/ActionParams.h +++ b/Grid/qcd/action/ActionParams.h @@ -97,28 +97,34 @@ struct StaggeredImplParams { struct RationalActionParams : Serializable { GRID_SERIALIZABLE_CLASS_MEMBERS(RationalActionParams, int, inv_pow, - RealD, lo, - RealD, hi, - int, MaxIter, - RealD, tolerance, - int, degree, - int, precision, - int, BoundsCheckFreq); + RealD, lo, //low eigenvalue bound of rational approx + RealD, hi, //high eigenvalue bound of rational approx + int, MaxIter, //maximum iterations in msCG + RealD, action_tolerance, //msCG tolerance in action evaluation + int, action_degree, //rational approx tolerance in action evaluation + RealD, md_tolerance, //msCG tolerance in MD integration + int, md_degree, //rational approx tolerance in MD integration + int, precision, //precision of floating point arithmetic + int, BoundsCheckFreq); //frequency the approximation is tested (with Metropolis degree/tolerance); 0 disables the check // constructor RationalActionParams(int _inv_pow = 2, RealD _lo = 0.0, RealD _hi = 1.0, int _maxit = 1000, - RealD tol = 1.0e-8, - int _degree = 10, + RealD _action_tolerance = 1.0e-8, + int _action_degree = 10, + RealD _md_tolerance = 1.0e-8, + int _md_degree = 10, int _precision = 64, int _BoundsCheckFreq=20) : inv_pow(_inv_pow), lo(_lo), hi(_hi), MaxIter(_maxit), - tolerance(tol), - degree(_degree), + action_tolerance(_action_tolerance), + action_degree(_action_degree), + md_tolerance(_md_tolerance), + md_degree(_md_degree), precision(_precision), BoundsCheckFreq(_BoundsCheckFreq){}; }; diff --git a/Grid/qcd/action/pseudofermion/GeneralEvenOddRationalRatio.h b/Grid/qcd/action/pseudofermion/GeneralEvenOddRationalRatio.h index 8561bd36..af64fba7 100644 --- a/Grid/qcd/action/pseudofermion/GeneralEvenOddRationalRatio.h +++ b/Grid/qcd/action/pseudofermion/GeneralEvenOddRationalRatio.h @@ -60,10 +60,17 @@ NAMESPACE_BEGIN(Grid); typedef RationalActionParams Params; Params param; - MultiShiftFunction ApproxPower ; //rational approx for X^{1/inv_pow} - MultiShiftFunction ApproxNegPower; //rational approx for X^{-1/inv_pow} - MultiShiftFunction ApproxHalfPower; //rational approx for X^{1/(2*inv_pow)} - MultiShiftFunction ApproxNegHalfPower; //rational approx for X^{-1/(2*inv_pow)} + //For action evaluation + MultiShiftFunction ApproxPowerAction ; //rational approx for X^{1/inv_pow} + MultiShiftFunction ApproxNegPowerAction; //rational approx for X^{-1/inv_pow} + MultiShiftFunction ApproxHalfPowerAction; //rational approx for X^{1/(2*inv_pow)} + MultiShiftFunction ApproxNegHalfPowerAction; //rational approx for X^{-1/(2*inv_pow)} + + //For the MD integration + MultiShiftFunction ApproxPowerMD ; //rational approx for X^{1/inv_pow} + MultiShiftFunction ApproxNegPowerMD; //rational approx for X^{-1/inv_pow} + MultiShiftFunction ApproxHalfPowerMD; //rational approx for X^{1/(2*inv_pow)} + MultiShiftFunction ApproxNegHalfPowerMD; //rational approx for X^{-1/(2*inv_pow)} private: @@ -90,17 +97,49 @@ NAMESPACE_BEGIN(Grid); int inv_pow = param.inv_pow; int _2_inv_pow = 2*inv_pow; + //Generate approximations for action eval + // MdagM^(+- 1/inv_pow) - std::cout< MdagM(DenOp); - ConjugateGradientMultiShift msCG_M(param.MaxIter,ApproxHalfPower); + ConjugateGradientMultiShift msCG_M(param.MaxIter,ApproxHalfPowerAction); msCG_M(MdagM,etaOdd,tmp); // VdagV^-1/(2*inv_pow) MdagM^1/(2*inv_pow) eta std::cout< VdagV(NumOp); - ConjugateGradientMultiShift msCG_V(param.MaxIter,ApproxNegHalfPower); + ConjugateGradientMultiShift msCG_V(param.MaxIter,ApproxNegHalfPowerAction); msCG_V(VdagV,tmp,PhiOdd); assert(NumOp.ConstEE() == 1); @@ -183,13 +224,13 @@ NAMESPACE_BEGIN(Grid); // VdagV^1/(2*inv_pow) Phi std::cout< VdagV(NumOp); - ConjugateGradientMultiShift msCG_V(param.MaxIter,ApproxHalfPower); + ConjugateGradientMultiShift msCG_V(param.MaxIter,ApproxHalfPowerAction); msCG_V(VdagV,PhiOdd,X); // MdagM^-1/(2*inv_pow) VdagV^1/(2*inv_pow) Phi std::cout< MdagM(DenOp); - ConjugateGradientMultiShift msCG_M(param.MaxIter,ApproxNegHalfPower); + ConjugateGradientMultiShift msCG_M(param.MaxIter,ApproxNegHalfPowerAction); msCG_M(MdagM,X,Y); // Randomly apply rational bounds checks. @@ -198,7 +239,7 @@ NAMESPACE_BEGIN(Grid); FermionField gauss(NumOp.FermionRedBlackGrid()); gauss = PhiOdd; HighBoundCheck(MdagM,gauss,param.hi); - InversePowerBoundsCheck(param.inv_pow,param.MaxIter,param.tolerance*100,MdagM,gauss,ApproxNegPower); + InversePowerBoundsCheck(param.inv_pow,param.MaxIter,param.action_tolerance*100,MdagM,gauss,ApproxNegPowerAction); } // Phidag VdagV^1/(2*inv_pow) MdagM^-1/(2*inv_pow) MdagM^-1/(2*inv_pow) VdagV^1/(2*inv_pow) Phi @@ -240,8 +281,8 @@ NAMESPACE_BEGIN(Grid); virtual void deriv(const GaugeField &U,GaugeField & dSdU) { std::cout< MpvPhi_k (n_pv,NumOp.FermionRedBlackGrid()); std::vector MpvMfMpvPhi_k(n_pv,NumOp.FermionRedBlackGrid()); @@ -260,8 +301,8 @@ NAMESPACE_BEGIN(Grid); SchurDifferentiableOperator VdagV(NumOp); SchurDifferentiableOperator MdagM(DenOp); - ConjugateGradientMultiShift msCG_V(param.MaxIter,ApproxHalfPower); - ConjugateGradientMultiShift msCG_M(param.MaxIter,ApproxNegPower); + ConjugateGradientMultiShift msCG_V(param.MaxIter,ApproxHalfPowerMD); + ConjugateGradientMultiShift msCG_M(param.MaxIter,ApproxNegPowerMD); std::cout<