mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-11-04 14:04:32 +00:00 
			
		
		
		
	Added TwoFlavorsEO
Had to remove a conformability check in the Derivative of SchurDiff, see the comments in the file
This commit is contained in:
		@@ -67,6 +67,7 @@ namespace Grid{
 | 
			
		||||
 | 
			
		||||
          // NOTE Guido: WE DO NOT WANT TO USE THE ucbgrid GRID FOR THE FORCE
 | 
			
		||||
          // it is not conformable with the HMC force field
 | 
			
		||||
	  // Case: Ls vectorised fields
 | 
			
		||||
          // INHERIT FROM THE Force field instead
 | 
			
		||||
          GridRedBlackCartesian* forcecb = new GridRedBlackCartesian(Force._grid);
 | 
			
		||||
          GaugeField ForceO(forcecb);
 | 
			
		||||
@@ -76,9 +77,8 @@ namespace Grid{
 | 
			
		||||
          //  X^dag Der_oe MeeInv Meo Y
 | 
			
		||||
          // Use Mooee as nontrivial but gauge field indept
 | 
			
		||||
          this->_Mat.Meooe   (V,tmp1);      // odd->even -- implicit -0.5 factor to be applied
 | 
			
		||||
          this->_Mat.MooeeInv(tmp1,tmp2);   // even->even 
 | 
			
		||||
	  this->_Mat.MooeeInv(tmp1,tmp2);   // even->even 
 | 
			
		||||
          this->_Mat.MoeDeriv(ForceO,U,tmp2,DaggerNo);
 | 
			
		||||
          
 | 
			
		||||
          //  Accumulate X^dag M_oe MeeInv Der_eo Y
 | 
			
		||||
          this->_Mat.MeooeDag   (U,tmp1);    // even->odd -- implicit -0.5 factor to be applied
 | 
			
		||||
          this->_Mat.MooeeInvDag(tmp1,tmp2); // even->even 
 | 
			
		||||
 
 | 
			
		||||
@@ -31,82 +31,89 @@ directory
 | 
			
		||||
#define QCD_PSEUDOFERMION_TWO_FLAVOUR_EVEN_ODD_H
 | 
			
		||||
 | 
			
		||||
namespace Grid {
 | 
			
		||||
namespace QCD {
 | 
			
		||||
  namespace QCD {
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// Two flavour pseudofermion action for any EO prec dop
 | 
			
		||||
////////////////////////////////////////////////////////////////////////
 | 
			
		||||
template <class Impl>
 | 
			
		||||
class TwoFlavourEvenOddPseudoFermionAction
 | 
			
		||||
    : public Action<typename Impl::GaugeField> {
 | 
			
		||||
 public:
 | 
			
		||||
  INHERIT_IMPL_TYPES(Impl);
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    // Two flavour pseudofermion action for any EO prec dop
 | 
			
		||||
    ////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    template <class Impl>
 | 
			
		||||
    class TwoFlavourEvenOddPseudoFermionAction
 | 
			
		||||
      : public Action<typename Impl::GaugeField> {
 | 
			
		||||
    public:
 | 
			
		||||
      INHERIT_IMPL_TYPES(Impl);
 | 
			
		||||
 | 
			
		||||
 private:
 | 
			
		||||
  FermionOperator<Impl> &FermOp;  // the basic operator
 | 
			
		||||
    private:
 | 
			
		||||
      FermionOperator<Impl> &FermOp;  // the basic operator
 | 
			
		||||
 | 
			
		||||
  OperatorFunction<FermionField> &DerivativeSolver;
 | 
			
		||||
  OperatorFunction<FermionField> &ActionSolver;
 | 
			
		||||
      OperatorFunction<FermionField> &DerivativeSolver;
 | 
			
		||||
      OperatorFunction<FermionField> &ActionSolver;
 | 
			
		||||
 | 
			
		||||
  FermionField PhiOdd;   // the pseudo fermion field for this trajectory
 | 
			
		||||
  FermionField PhiEven;  // the pseudo fermion field for this trajectory
 | 
			
		||||
      FermionField PhiOdd;   // the pseudo fermion field for this trajectory
 | 
			
		||||
      FermionField PhiEven;  // the pseudo fermion field for this trajectory
 | 
			
		||||
 | 
			
		||||
 public:
 | 
			
		||||
  /////////////////////////////////////////////////
 | 
			
		||||
  // Pass in required objects.
 | 
			
		||||
  /////////////////////////////////////////////////
 | 
			
		||||
  TwoFlavourEvenOddPseudoFermionAction(FermionOperator<Impl> &Op,
 | 
			
		||||
                                       OperatorFunction<FermionField> &DS,
 | 
			
		||||
                                       OperatorFunction<FermionField> &AS)
 | 
			
		||||
      : FermOp(Op),
 | 
			
		||||
        DerivativeSolver(DS),
 | 
			
		||||
        ActionSolver(AS),
 | 
			
		||||
        PhiEven(Op.FermionRedBlackGrid()),
 | 
			
		||||
	PhiOdd(Op.FermionRedBlackGrid())
 | 
			
		||||
		  {};
 | 
			
		||||
    public:
 | 
			
		||||
      /////////////////////////////////////////////////
 | 
			
		||||
      // Pass in required objects.
 | 
			
		||||
      /////////////////////////////////////////////////
 | 
			
		||||
      TwoFlavourEvenOddPseudoFermionAction(FermionOperator<Impl> &Op,
 | 
			
		||||
					   OperatorFunction<FermionField> &DS,
 | 
			
		||||
					   OperatorFunction<FermionField> &AS)
 | 
			
		||||
	: FermOp(Op),
 | 
			
		||||
	  DerivativeSolver(DS),
 | 
			
		||||
	  ActionSolver(AS),
 | 
			
		||||
	  PhiEven(Op.FermionRedBlackGrid()),
 | 
			
		||||
	  PhiOdd(Op.FermionRedBlackGrid())
 | 
			
		||||
      {};
 | 
			
		||||
  
 | 
			
		||||
  virtual std::string action_name(){return "TwoFlavourEvenOddPseudoFermionAction";}
 | 
			
		||||
      virtual std::string action_name(){return "TwoFlavourEvenOddPseudoFermionAction";}
 | 
			
		||||
      
 | 
			
		||||
      virtual std::string LogParameters(){
 | 
			
		||||
	std::stringstream sstream;
 | 
			
		||||
	sstream << GridLogMessage << "["<<action_name()<<"] has no parameters" << std::endl;
 | 
			
		||||
	return sstream.str();
 | 
			
		||||
      }  
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
      //////////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
      // Push the gauge field in to the dops. Assume any BC's and smearing already applied
 | 
			
		||||
      //////////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
      virtual void refresh(const GaugeField &U, GridParallelRNG& pRNG) {
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
	// P(phi) = e^{- phi^dag (MpcdagMpc)^-1 phi}
 | 
			
		||||
	// Phi = McpDag eta 
 | 
			
		||||
	// P(eta) = e^{- eta^dag eta}
 | 
			
		||||
	//
 | 
			
		||||
	// e^{x^2/2 sig^2} => sig^2 = 0.5.
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
	RealD scale = std::sqrt(0.5);
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
	FermionField eta    (FermOp.FermionGrid());
 | 
			
		||||
	FermionField etaOdd (FermOp.FermionRedBlackGrid());
 | 
			
		||||
	FermionField etaEven(FermOp.FermionRedBlackGrid());
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
	gaussian(pRNG,eta);
 | 
			
		||||
	pickCheckerboard(Even,etaEven,eta);
 | 
			
		||||
	pickCheckerboard(Odd,etaOdd,eta);
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
	FermOp.ImportGauge(U);
 | 
			
		||||
	SchurDifferentiableOperator<Impl> PCop(FermOp);
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
	PCop.MpcDag(etaOdd,PhiOdd);
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
	FermOp.MooeeDag(etaEven,PhiEven);
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
	PhiOdd =PhiOdd*scale;
 | 
			
		||||
	PhiEven=PhiEven*scale;
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
      };
 | 
			
		||||
 | 
			
		||||
  
 | 
			
		||||
      //////////////////////////////////////////////////////
 | 
			
		||||
      // S = phi^dag (Mdag M)^-1 phi  (odd)
 | 
			
		||||
      //   + phi^dag (Mdag M)^-1 phi  (even)
 | 
			
		||||
      //////////////////////////////////////////////////////
 | 
			
		||||
      virtual RealD S(const GaugeField &U) {
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	FermOp.ImportGauge(U);
 | 
			
		||||
 | 
			
		||||
	FermionField X(FermOp.FermionRedBlackGrid());
 | 
			
		||||
@@ -137,7 +144,7 @@ class TwoFlavourEvenOddPseudoFermionAction
 | 
			
		||||
      //
 | 
			
		||||
      //////////////////////////////////////////////////////
 | 
			
		||||
      virtual void deriv(const GaugeField &U,GaugeField & dSdU) {
 | 
			
		||||
 | 
			
		||||
      	std::cout << GridLogDebug << "Calling deriv" << std::endl;
 | 
			
		||||
	FermOp.ImportGauge(U);
 | 
			
		||||
 | 
			
		||||
	FermionField X(FermOp.FermionRedBlackGrid());
 | 
			
		||||
@@ -151,10 +158,17 @@ class TwoFlavourEvenOddPseudoFermionAction
 | 
			
		||||
 | 
			
		||||
	X=zero;
 | 
			
		||||
	DerivativeSolver(Mpc,PhiOdd,X);
 | 
			
		||||
        std::cout << GridLogDebug << "Calling deriv 2 " << std::endl;
 | 
			
		||||
	Mpc.Mpc(X,Y);
 | 
			
		||||
  	Mpc.MpcDeriv(tmp , Y, X );    dSdU=tmp;
 | 
			
		||||
                std::cout << GridLogDebug << "Calling deriv 3 " << std::endl;
 | 
			
		||||
  	Mpc.MpcDeriv(tmp , Y, X );  
 | 
			
		||||
                   std::cout << GridLogDebug << "Calling deriv 4 " << std::endl;
 | 
			
		||||
          dSdU=tmp;
 | 
			
		||||
                std::cout << GridLogDebug << "Calling deriv 5 " << std::endl;
 | 
			
		||||
	Mpc.MpcDagDeriv(tmp , X, Y);  dSdU=dSdU+tmp;
 | 
			
		||||
 | 
			
		||||
        std::cout << GridLogDebug << "Calling deriv 6" << std::endl;
 | 
			
		||||
 | 
			
		||||
	// Treat the EE case. (MdagM)^-1 = Minv Minvdag
 | 
			
		||||
	// Deriv defaults to zero.
 | 
			
		||||
	//        FermOp.MooeeInvDag(PhiOdd,Y);
 | 
			
		||||
@@ -165,10 +179,10 @@ class TwoFlavourEvenOddPseudoFermionAction
 | 
			
		||||
	assert(FermOp.ConstEE() == 1);
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
        FermOp.MooeeInvDag(PhiOdd,Y);
 | 
			
		||||
        FermOp.MooeeInv(Y,X);
 | 
			
		||||
  	FermOp.MeeDeriv(tmp , Y, X,DaggerNo );    dSdU=tmp;
 | 
			
		||||
	FermOp.MeeDeriv(tmp , X, Y,DaggerYes);  dSdU=dSdU+tmp;
 | 
			
		||||
	  FermOp.MooeeInvDag(PhiOdd,Y);
 | 
			
		||||
	  FermOp.MooeeInv(Y,X);
 | 
			
		||||
	  FermOp.MeeDeriv(tmp , Y, X,DaggerNo );    dSdU=tmp;
 | 
			
		||||
	  FermOp.MeeDeriv(tmp , X, Y,DaggerYes);  dSdU=dSdU+tmp;
 | 
			
		||||
	*/
 | 
			
		||||
	
 | 
			
		||||
	//dSdU = Ta(dSdU);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user