mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-11-04 05:54:32 +00:00 
			
		
		
		
	Added JSON parser (without NextElement)
This commit is contained in:
		@@ -144,7 +144,6 @@ namespace Grid {
 | 
			
		||||
      //
 | 
			
		||||
      //////////////////////////////////////////////////////
 | 
			
		||||
      virtual void deriv(const GaugeField &U,GaugeField & dSdU) {
 | 
			
		||||
      	std::cout << GridLogDebug << "Calling deriv" << std::endl;
 | 
			
		||||
	FermOp.ImportGauge(U);
 | 
			
		||||
 | 
			
		||||
	FermionField X(FermOp.FermionRedBlackGrid());
 | 
			
		||||
@@ -158,16 +157,9 @@ namespace Grid {
 | 
			
		||||
 | 
			
		||||
	X=zero;
 | 
			
		||||
	DerivativeSolver(Mpc,PhiOdd,X);
 | 
			
		||||
        std::cout << GridLogDebug << "Calling deriv 2 " << std::endl;
 | 
			
		||||
	Mpc.Mpc(X,Y);
 | 
			
		||||
                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;
 | 
			
		||||
  	Mpc.MpcDeriv(tmp , Y, X );    dSdU=tmp;
 | 
			
		||||
        Mpc.MpcDagDeriv(tmp , X, Y);  dSdU=dSdU+tmp;
 | 
			
		||||
 | 
			
		||||
	// Treat the EE case. (MdagM)^-1 = Minv Minvdag
 | 
			
		||||
	// Deriv defaults to zero.
 | 
			
		||||
 
 | 
			
		||||
@@ -59,6 +59,12 @@ namespace Grid{
 | 
			
		||||
      
 | 
			
		||||
      virtual std::string action_name(){return "TwoFlavourRatioPseudoFermionAction";}
 | 
			
		||||
 | 
			
		||||
      virtual std::string LogParameters(){
 | 
			
		||||
	std::stringstream sstream;
 | 
			
		||||
	sstream << GridLogMessage << "["<<action_name()<<"] has no parameters" << std::endl;
 | 
			
		||||
	return sstream.str();
 | 
			
		||||
      }  
 | 
			
		||||
      
 | 
			
		||||
      virtual void refresh(const GaugeField &U, GridParallelRNG& pRNG) {
 | 
			
		||||
 | 
			
		||||
	// P(phi) = e^{- phi^dag V (MdagM)^-1 Vdag phi}
 | 
			
		||||
 
 | 
			
		||||
@@ -115,14 +115,18 @@ class HMCResourceManager {
 | 
			
		||||
      ObservablesList.emplace_back(ObsFactory.create(obs_type, Read));
 | 
			
		||||
      ObservablesList[ObservablesList.size() - 1]->print_parameters();
 | 
			
		||||
    } while (Read.nextElement(observable_string));
 | 
			
		||||
    std::cout << "Size of ObservablesList " << ObservablesList.size()
 | 
			
		||||
              << std::endl;
 | 
			
		||||
    Read.pop();
 | 
			
		||||
 | 
			
		||||
    // Loop on levels
 | 
			
		||||
    Read.push("Actions");
 | 
			
		||||
    if(!Read.push("Actions")){
 | 
			
		||||
      std::cout << "Actions not found" << std::endl; 
 | 
			
		||||
      exit(1);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Read.push("Level");// push must check if the node exist
 | 
			
		||||
    if(!Read.push("Level")){// push must check if the node exist
 | 
			
		||||
         std::cout << "Level not found" << std::endl; 
 | 
			
		||||
      exit(1);
 | 
			
		||||
    }
 | 
			
		||||
    do
 | 
			
		||||
    {
 | 
			
		||||
      fill_ActionsLevel(Read); 
 | 
			
		||||
@@ -267,11 +271,12 @@ private:
 | 
			
		||||
      auto &ActionFactory = HMC_LGTActionModuleFactory<gauge_string, ReaderClass>::getInstance(); 
 | 
			
		||||
      std::string action_type;
 | 
			
		||||
      Read.readDefault("name", action_type);
 | 
			
		||||
      std::cout << ActionFactory.getBuilderList() << std::endl;  
 | 
			
		||||
      std::cout << ActionFactory.getBuilderList() << std::endl;  // temporary
 | 
			
		||||
      ActionsList.emplace(m, ActionFactory.create(action_type, Read));
 | 
			
		||||
    } while (Read.nextElement("Action"));
 | 
			
		||||
    ActionsList.find(m)->second->print_parameters();    
 | 
			
		||||
    Read.pop();
 | 
			
		||||
 | 
			
		||||
    ActionsList.find(m)->second->print_parameters();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -242,7 +242,6 @@ class TwoFlavourFModule: public PseudoFermionModuleBase<Impl, TwoFlavourPseudoFe
 | 
			
		||||
   TwoFlavourFModule(Reader<ReaderClass>& R): PseudoFermionModuleBase<Impl, TwoFlavourPseudoFermionAction>(R) {
 | 
			
		||||
    this->getSolverOperator(R, solver_mod, "Solver");
 | 
			
		||||
    this->getFermionOperator(R, fop_mod, "Operator");
 | 
			
		||||
    R.pop();
 | 
			
		||||
   } 
 | 
			
		||||
 | 
			
		||||
  // acquire resource
 | 
			
		||||
@@ -272,7 +271,6 @@ class TwoFlavourEOFModule: public PseudoFermionModuleBase<Impl, TwoFlavourEvenOd
 | 
			
		||||
   TwoFlavourEOFModule(Reader<ReaderClass>& R): PseudoFermionModuleBase<Impl, TwoFlavourEvenOddPseudoFermionAction>(R) {
 | 
			
		||||
    this->getSolverOperator(R, solver_mod, "Solver");
 | 
			
		||||
    this->getFermionOperator(R, fop_mod, "Operator");
 | 
			
		||||
    R.pop();
 | 
			
		||||
   } 
 | 
			
		||||
 | 
			
		||||
  // acquire resource
 | 
			
		||||
@@ -284,6 +282,39 @@ class TwoFlavourEOFModule: public PseudoFermionModuleBase<Impl, TwoFlavourEvenOd
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
template <class Impl >
 | 
			
		||||
class TwoFlavourRatioFModule: public PseudoFermionModuleBase<Impl, TwoFlavourRatioPseudoFermionAction>{
 | 
			
		||||
  typedef PseudoFermionModuleBase<Impl, TwoFlavourRatioPseudoFermionAction> Base;
 | 
			
		||||
  using Base::Base;
 | 
			
		||||
 | 
			
		||||
  typename Base::operator_type fop_numerator_mod;
 | 
			
		||||
  typename Base::operator_type fop_denominator_mod;
 | 
			
		||||
  typename Base::solver_type   solver_mod;
 | 
			
		||||
 | 
			
		||||
 public:
 | 
			
		||||
  virtual void acquireResource(typename Base::Resource& GridMod){
 | 
			
		||||
    fop_numerator_mod->AddGridPair(GridMod);
 | 
			
		||||
    fop_denominator_mod->AddGridPair(GridMod);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
   // constructor
 | 
			
		||||
   template <class ReaderClass>
 | 
			
		||||
   TwoFlavourRatioFModule(Reader<ReaderClass>& R): PseudoFermionModuleBase<Impl, TwoFlavourRatioPseudoFermionAction>(R) {
 | 
			
		||||
    this->getSolverOperator(R, solver_mod, "Solver");
 | 
			
		||||
    this->getFermionOperator(R, fop_numerator_mod, "Numerator");
 | 
			
		||||
    this->getFermionOperator(R, fop_denominator_mod, "Denominator");
 | 
			
		||||
   } 
 | 
			
		||||
 | 
			
		||||
  // acquire resource
 | 
			
		||||
  virtual void initialize() {
 | 
			
		||||
    // here temporarily assuming that the force and action solver are the same
 | 
			
		||||
    this->ActionPtr.reset(new TwoFlavourRatioPseudoFermionAction<Impl>(*(this->fop_numerator_mod->getPtr()), 
 | 
			
		||||
      *(this->fop_denominator_mod->getPtr()), *(this->solver_mod->getPtr()), *(this->solver_mod->getPtr())));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -346,6 +377,7 @@ static Registrar<QCD::PlaqPlusRectangleGMod, HMC_LGTActionModuleFactory<gauge_st
 | 
			
		||||
 | 
			
		||||
// FIXME more general implementation
 | 
			
		||||
static Registrar<QCD::TwoFlavourFModule<QCD::WilsonImplR> , HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __TwoFlavourFmodXMLInit("TwoFlavours"); 
 | 
			
		||||
static Registrar<QCD::TwoFlavourRatioFModule<QCD::WilsonImplR> , HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __TwoFlavourRatioFmodXMLInit("TwoFlavoursRatio"); 
 | 
			
		||||
static Registrar<QCD::TwoFlavourEOFModule<QCD::WilsonImplR> , HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __TwoFlavourEOFmodXMLInit("TwoFlavoursEvenOdd"); 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user