mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-09 21:50:45 +01: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:
parent
f96fac0aee
commit
27dfe816fa
@ -247,8 +247,9 @@ template <class Impl>
|
|||||||
void WilsonFermion<Impl>::DhopDerivOE(GaugeField &mat, const FermionField &U, const FermionField &V, int dag) {
|
void WilsonFermion<Impl>::DhopDerivOE(GaugeField &mat, const FermionField &U, const FermionField &V, int dag) {
|
||||||
conformable(U._grid, _cbgrid);
|
conformable(U._grid, _cbgrid);
|
||||||
conformable(U._grid, V._grid);
|
conformable(U._grid, V._grid);
|
||||||
conformable(U._grid, mat._grid);
|
//conformable(U._grid, mat._grid); not general, leaving as a comment (Guido)
|
||||||
|
// Motivation: look at the SchurDiff operator
|
||||||
|
|
||||||
assert(V.checkerboard == Even);
|
assert(V.checkerboard == Even);
|
||||||
assert(U.checkerboard == Odd);
|
assert(U.checkerboard == Odd);
|
||||||
mat.checkerboard = Odd;
|
mat.checkerboard = Odd;
|
||||||
@ -260,7 +261,7 @@ template <class Impl>
|
|||||||
void WilsonFermion<Impl>::DhopDerivEO(GaugeField &mat, const FermionField &U, const FermionField &V, int dag) {
|
void WilsonFermion<Impl>::DhopDerivEO(GaugeField &mat, const FermionField &U, const FermionField &V, int dag) {
|
||||||
conformable(U._grid, _cbgrid);
|
conformable(U._grid, _cbgrid);
|
||||||
conformable(U._grid, V._grid);
|
conformable(U._grid, V._grid);
|
||||||
conformable(U._grid, mat._grid);
|
//conformable(U._grid, mat._grid);
|
||||||
|
|
||||||
assert(V.checkerboard == Odd);
|
assert(V.checkerboard == Odd);
|
||||||
assert(U.checkerboard == Even);
|
assert(U.checkerboard == Even);
|
||||||
|
@ -67,6 +67,7 @@ namespace Grid{
|
|||||||
|
|
||||||
// NOTE Guido: WE DO NOT WANT TO USE THE ucbgrid GRID FOR THE FORCE
|
// NOTE Guido: WE DO NOT WANT TO USE THE ucbgrid GRID FOR THE FORCE
|
||||||
// it is not conformable with the HMC force field
|
// it is not conformable with the HMC force field
|
||||||
|
// Case: Ls vectorised fields
|
||||||
// INHERIT FROM THE Force field instead
|
// INHERIT FROM THE Force field instead
|
||||||
GridRedBlackCartesian* forcecb = new GridRedBlackCartesian(Force._grid);
|
GridRedBlackCartesian* forcecb = new GridRedBlackCartesian(Force._grid);
|
||||||
GaugeField ForceO(forcecb);
|
GaugeField ForceO(forcecb);
|
||||||
@ -76,9 +77,8 @@ namespace Grid{
|
|||||||
// X^dag Der_oe MeeInv Meo Y
|
// X^dag Der_oe MeeInv Meo Y
|
||||||
// Use Mooee as nontrivial but gauge field indept
|
// Use Mooee as nontrivial but gauge field indept
|
||||||
this->_Mat.Meooe (V,tmp1); // odd->even -- implicit -0.5 factor to be applied
|
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);
|
this->_Mat.MoeDeriv(ForceO,U,tmp2,DaggerNo);
|
||||||
|
|
||||||
// Accumulate X^dag M_oe MeeInv Der_eo Y
|
// 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.MeooeDag (U,tmp1); // even->odd -- implicit -0.5 factor to be applied
|
||||||
this->_Mat.MooeeInvDag(tmp1,tmp2); // even->even
|
this->_Mat.MooeeInvDag(tmp1,tmp2); // even->even
|
||||||
|
@ -31,82 +31,89 @@ directory
|
|||||||
#define QCD_PSEUDOFERMION_TWO_FLAVOUR_EVEN_ODD_H
|
#define QCD_PSEUDOFERMION_TWO_FLAVOUR_EVEN_ODD_H
|
||||||
|
|
||||||
namespace Grid {
|
namespace Grid {
|
||||||
namespace QCD {
|
namespace QCD {
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Two flavour pseudofermion action for any EO prec dop
|
// Two flavour pseudofermion action for any EO prec dop
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
template <class Impl>
|
template <class Impl>
|
||||||
class TwoFlavourEvenOddPseudoFermionAction
|
class TwoFlavourEvenOddPseudoFermionAction
|
||||||
: public Action<typename Impl::GaugeField> {
|
: public Action<typename Impl::GaugeField> {
|
||||||
public:
|
public:
|
||||||
INHERIT_IMPL_TYPES(Impl);
|
INHERIT_IMPL_TYPES(Impl);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FermionOperator<Impl> &FermOp; // the basic operator
|
FermionOperator<Impl> &FermOp; // the basic operator
|
||||||
|
|
||||||
OperatorFunction<FermionField> &DerivativeSolver;
|
OperatorFunction<FermionField> &DerivativeSolver;
|
||||||
OperatorFunction<FermionField> &ActionSolver;
|
OperatorFunction<FermionField> &ActionSolver;
|
||||||
|
|
||||||
FermionField PhiOdd; // 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
|
FermionField PhiEven; // the pseudo fermion field for this trajectory
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/////////////////////////////////////////////////
|
/////////////////////////////////////////////////
|
||||||
// Pass in required objects.
|
// Pass in required objects.
|
||||||
/////////////////////////////////////////////////
|
/////////////////////////////////////////////////
|
||||||
TwoFlavourEvenOddPseudoFermionAction(FermionOperator<Impl> &Op,
|
TwoFlavourEvenOddPseudoFermionAction(FermionOperator<Impl> &Op,
|
||||||
OperatorFunction<FermionField> &DS,
|
OperatorFunction<FermionField> &DS,
|
||||||
OperatorFunction<FermionField> &AS)
|
OperatorFunction<FermionField> &AS)
|
||||||
: FermOp(Op),
|
: FermOp(Op),
|
||||||
DerivativeSolver(DS),
|
DerivativeSolver(DS),
|
||||||
ActionSolver(AS),
|
ActionSolver(AS),
|
||||||
PhiEven(Op.FermionRedBlackGrid()),
|
PhiEven(Op.FermionRedBlackGrid()),
|
||||||
PhiOdd(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
|
// Push the gauge field in to the dops. Assume any BC's and smearing already applied
|
||||||
//////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////
|
||||||
virtual void refresh(const GaugeField &U, GridParallelRNG& pRNG) {
|
virtual void refresh(const GaugeField &U, GridParallelRNG& pRNG) {
|
||||||
|
|
||||||
// P(phi) = e^{- phi^dag (MpcdagMpc)^-1 phi}
|
// P(phi) = e^{- phi^dag (MpcdagMpc)^-1 phi}
|
||||||
// Phi = McpDag eta
|
// Phi = McpDag eta
|
||||||
// P(eta) = e^{- eta^dag eta}
|
// P(eta) = e^{- eta^dag eta}
|
||||||
//
|
//
|
||||||
// e^{x^2/2 sig^2} => sig^2 = 0.5.
|
// e^{x^2/2 sig^2} => sig^2 = 0.5.
|
||||||
|
|
||||||
RealD scale = std::sqrt(0.5);
|
RealD scale = std::sqrt(0.5);
|
||||||
|
|
||||||
FermionField eta (FermOp.FermionGrid());
|
FermionField eta (FermOp.FermionGrid());
|
||||||
FermionField etaOdd (FermOp.FermionRedBlackGrid());
|
FermionField etaOdd (FermOp.FermionRedBlackGrid());
|
||||||
FermionField etaEven(FermOp.FermionRedBlackGrid());
|
FermionField etaEven(FermOp.FermionRedBlackGrid());
|
||||||
|
|
||||||
gaussian(pRNG,eta);
|
gaussian(pRNG,eta);
|
||||||
pickCheckerboard(Even,etaEven,eta);
|
pickCheckerboard(Even,etaEven,eta);
|
||||||
pickCheckerboard(Odd,etaOdd,eta);
|
pickCheckerboard(Odd,etaOdd,eta);
|
||||||
|
|
||||||
FermOp.ImportGauge(U);
|
FermOp.ImportGauge(U);
|
||||||
SchurDifferentiableOperator<Impl> PCop(FermOp);
|
SchurDifferentiableOperator<Impl> PCop(FermOp);
|
||||||
|
|
||||||
|
|
||||||
PCop.MpcDag(etaOdd,PhiOdd);
|
PCop.MpcDag(etaOdd,PhiOdd);
|
||||||
|
|
||||||
FermOp.MooeeDag(etaEven,PhiEven);
|
FermOp.MooeeDag(etaEven,PhiEven);
|
||||||
|
|
||||||
PhiOdd =PhiOdd*scale;
|
PhiOdd =PhiOdd*scale;
|
||||||
PhiEven=PhiEven*scale;
|
PhiEven=PhiEven*scale;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
// S = phi^dag (Mdag M)^-1 phi (odd)
|
// S = phi^dag (Mdag M)^-1 phi (odd)
|
||||||
// + phi^dag (Mdag M)^-1 phi (even)
|
// + phi^dag (Mdag M)^-1 phi (even)
|
||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
virtual RealD S(const GaugeField &U) {
|
virtual RealD S(const GaugeField &U) {
|
||||||
|
|
||||||
FermOp.ImportGauge(U);
|
FermOp.ImportGauge(U);
|
||||||
|
|
||||||
FermionField X(FermOp.FermionRedBlackGrid());
|
FermionField X(FermOp.FermionRedBlackGrid());
|
||||||
@ -137,7 +144,7 @@ class TwoFlavourEvenOddPseudoFermionAction
|
|||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
virtual void deriv(const GaugeField &U,GaugeField & dSdU) {
|
virtual void deriv(const GaugeField &U,GaugeField & dSdU) {
|
||||||
|
std::cout << GridLogDebug << "Calling deriv" << std::endl;
|
||||||
FermOp.ImportGauge(U);
|
FermOp.ImportGauge(U);
|
||||||
|
|
||||||
FermionField X(FermOp.FermionRedBlackGrid());
|
FermionField X(FermOp.FermionRedBlackGrid());
|
||||||
@ -151,10 +158,17 @@ class TwoFlavourEvenOddPseudoFermionAction
|
|||||||
|
|
||||||
X=zero;
|
X=zero;
|
||||||
DerivativeSolver(Mpc,PhiOdd,X);
|
DerivativeSolver(Mpc,PhiOdd,X);
|
||||||
|
std::cout << GridLogDebug << "Calling deriv 2 " << std::endl;
|
||||||
Mpc.Mpc(X,Y);
|
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;
|
Mpc.MpcDagDeriv(tmp , X, Y); dSdU=dSdU+tmp;
|
||||||
|
|
||||||
|
std::cout << GridLogDebug << "Calling deriv 6" << std::endl;
|
||||||
|
|
||||||
// Treat the EE case. (MdagM)^-1 = Minv Minvdag
|
// Treat the EE case. (MdagM)^-1 = Minv Minvdag
|
||||||
// Deriv defaults to zero.
|
// Deriv defaults to zero.
|
||||||
// FermOp.MooeeInvDag(PhiOdd,Y);
|
// FermOp.MooeeInvDag(PhiOdd,Y);
|
||||||
@ -165,10 +179,10 @@ class TwoFlavourEvenOddPseudoFermionAction
|
|||||||
assert(FermOp.ConstEE() == 1);
|
assert(FermOp.ConstEE() == 1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
FermOp.MooeeInvDag(PhiOdd,Y);
|
FermOp.MooeeInvDag(PhiOdd,Y);
|
||||||
FermOp.MooeeInv(Y,X);
|
FermOp.MooeeInv(Y,X);
|
||||||
FermOp.MeeDeriv(tmp , Y, X,DaggerNo ); dSdU=tmp;
|
FermOp.MeeDeriv(tmp , Y, X,DaggerNo ); dSdU=tmp;
|
||||||
FermOp.MeeDeriv(tmp , X, Y,DaggerYes); dSdU=dSdU+tmp;
|
FermOp.MeeDeriv(tmp , X, Y,DaggerYes); dSdU=dSdU+tmp;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//dSdU = Ta(dSdU);
|
//dSdU = Ta(dSdU);
|
||||||
|
@ -72,8 +72,12 @@ public:
|
|||||||
|
|
||||||
class GridModule {
|
class GridModule {
|
||||||
public:
|
public:
|
||||||
GridCartesian* get_full() { return grid_.get(); }
|
GridCartesian* get_full() {
|
||||||
GridRedBlackCartesian* get_rb() { return rbgrid_.get(); }
|
std::cout << GridLogDebug << "Getting cartesian in module"<< std::endl;
|
||||||
|
return grid_.get(); }
|
||||||
|
GridRedBlackCartesian* get_rb() {
|
||||||
|
std::cout << GridLogDebug << "Getting rb-cartesian in module"<< std::endl;
|
||||||
|
return rbgrid_.get(); }
|
||||||
|
|
||||||
void set_full(GridCartesian* grid) { grid_.reset(grid); }
|
void set_full(GridCartesian* grid) { grid_.reset(grid); }
|
||||||
void set_rb(GridRedBlackCartesian* rbgrid) { rbgrid_.reset(rbgrid); }
|
void set_rb(GridRedBlackCartesian* rbgrid) { rbgrid_.reset(rbgrid); }
|
||||||
|
@ -40,11 +40,11 @@ namespace Grid {
|
|||||||
// Actions
|
// Actions
|
||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
template <class Product, class Resource>
|
template <class Product, class R>
|
||||||
class ActionModuleBase: public HMCModuleBase<Product>{
|
class ActionModuleBase: public HMCModuleBase<Product>{
|
||||||
public:
|
public:
|
||||||
typedef Resource Res;
|
typedef R Resource;
|
||||||
virtual void acquireResource(Resource& ){};
|
virtual void acquireResource(R& ){};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -193,57 +193,95 @@ class DBW2GModule: public ActionModule<DBW2GaugeAction<Impl>, BetaGaugeActionPar
|
|||||||
/////////////////////////////////////////
|
/////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
template <class Impl >
|
template <class Impl, template <typename> class FermionA >
|
||||||
class TwoFlavourFModule: public ActionModule<TwoFlavourPseudoFermionAction<Impl>, NoParameters> {
|
class PseudoFermionModuleBase: public ActionModule<FermionA<Impl>, NoParameters> {
|
||||||
typedef ActionModule<TwoFlavourPseudoFermionAction<Impl>, NoParameters> ActionBase;
|
protected:
|
||||||
|
typedef ActionModule<FermionA<Impl>, NoParameters> ActionBase;
|
||||||
using ActionBase::ActionBase; // for constructors
|
using ActionBase::ActionBase; // for constructors
|
||||||
|
|
||||||
std::unique_ptr<HMCModuleBase<OperatorFunction<typename Impl::FermionField> > >solver_mod;
|
typedef std::unique_ptr<FermionOperatorModuleBase<FermionOperator<Impl>> > operator_type;
|
||||||
std::unique_ptr<FermionOperatorModuleBase<FermionOperator<Impl>> > fop_mod;
|
typedef std::unique_ptr<HMCModuleBase<OperatorFunction<typename Impl::FermionField> > > solver_type;
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void acquireResource(typename ActionBase::Res& GridMod){
|
template <class ReaderClass>
|
||||||
fop_mod->AddGridPair(GridMod);
|
void getFermionOperator(Reader<ReaderClass>& Reader, operator_type &fo, std::string section_name){
|
||||||
|
auto &FOFactory = HMC_FermionOperatorModuleFactory<fermionop_string, Impl, ReaderClass>::getInstance();
|
||||||
|
Reader.push(section_name);
|
||||||
|
std::string op_name;
|
||||||
|
read(Reader,"name", op_name);
|
||||||
|
fo = FOFactory.create(op_name, Reader);
|
||||||
|
Reader.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ReaderClass>
|
template <class ReaderClass>
|
||||||
TwoFlavourFModule(Reader<ReaderClass>& Reader) : ActionBase(Reader){
|
void getSolverOperator(Reader<ReaderClass>& Reader, solver_type &so, std::string section_name){
|
||||||
std::cout << "Constructing TwoFlavourFModule" << std::endl;
|
|
||||||
auto& SolverFactory = HMC_SolverModuleFactory<solver_string, typename Impl::FermionField, ReaderClass>::getInstance();
|
auto& SolverFactory = HMC_SolverModuleFactory<solver_string, typename Impl::FermionField, ReaderClass>::getInstance();
|
||||||
Reader.push("Solver");
|
Reader.push(section_name);
|
||||||
std::string solv_name;
|
std::string solv_name;
|
||||||
read(Reader,"name", solv_name);
|
read(Reader,"name", solv_name);
|
||||||
solver_mod = SolverFactory.create(solv_name, Reader);
|
so = SolverFactory.create(solv_name, Reader);
|
||||||
std::cout << "Registered types " << std::endl;
|
Reader.pop();
|
||||||
std::cout << SolverFactory.getBuilderList() << std::endl;
|
}
|
||||||
solver_mod->print_parameters();
|
};
|
||||||
Reader.pop();
|
|
||||||
|
|
||||||
|
|
||||||
|
template <class Impl >
|
||||||
|
class TwoFlavourFModule: public PseudoFermionModuleBase<Impl, TwoFlavourPseudoFermionAction>{
|
||||||
|
typedef PseudoFermionModuleBase<Impl, TwoFlavourPseudoFermionAction> Base;
|
||||||
|
using Base::Base;
|
||||||
|
|
||||||
auto &FOFactory = HMC_FermionOperatorModuleFactory<fermionop_string, Impl, ReaderClass>::getInstance();
|
typename Base::operator_type fop_mod;
|
||||||
Reader.push("Operator");
|
typename Base::solver_type solver_mod;
|
||||||
std::string op_name;
|
|
||||||
read(Reader,"name", op_name);
|
|
||||||
fop_mod = FOFactory.create(op_name, Reader);
|
|
||||||
std::cout << "Registered types " << std::endl;
|
|
||||||
std::cout << FOFactory.getBuilderList() << std::endl;
|
|
||||||
|
|
||||||
fop_mod->print_parameters();
|
public:
|
||||||
Reader.pop();
|
virtual void acquireResource(typename Base::Resource& GridMod){
|
||||||
|
fop_mod->AddGridPair(GridMod);
|
||||||
|
}
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
template <class ReaderClass>
|
||||||
|
TwoFlavourFModule(Reader<ReaderClass>& R): PseudoFermionModuleBase<Impl, TwoFlavourPseudoFermionAction>(R) {
|
||||||
|
this->getSolverOperator(R, solver_mod, "Solver");
|
||||||
|
this->getFermionOperator(R, fop_mod, "Operator");
|
||||||
|
R.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
|
||||||
// acquire resource
|
// acquire resource
|
||||||
virtual void initialize() {
|
virtual void initialize() {
|
||||||
this->ActionPtr.reset(new TwoFlavourPseudoFermionAction<Impl>(*fop_mod->getPtr(), *solver_mod->getPtr(), *solver_mod->getPtr()));
|
// here temporarily assuming that the force and action solver are the same
|
||||||
|
this->ActionPtr.reset(new TwoFlavourPseudoFermionAction<Impl>(*(this->fop_mod->getPtr()), *(this->solver_mod->getPtr()), *(this->solver_mod->getPtr())));
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// very similar, I could have templated this but it is overkilling
|
||||||
|
template <class Impl >
|
||||||
|
class TwoFlavourEOFModule: public PseudoFermionModuleBase<Impl, TwoFlavourEvenOddPseudoFermionAction>{
|
||||||
|
typedef PseudoFermionModuleBase<Impl, TwoFlavourEvenOddPseudoFermionAction> Base;
|
||||||
|
using Base::Base;
|
||||||
|
|
||||||
|
typename Base::operator_type fop_mod;
|
||||||
|
typename Base::solver_type solver_mod;
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual void acquireResource(typename Base::Resource& GridMod){
|
||||||
|
fop_mod->AddGridPair(GridMod);
|
||||||
|
}
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
template <class ReaderClass>
|
||||||
|
TwoFlavourEOFModule(Reader<ReaderClass>& R): PseudoFermionModuleBase<Impl, TwoFlavourEvenOddPseudoFermionAction>(R) {
|
||||||
|
this->getSolverOperator(R, solver_mod, "Solver");
|
||||||
|
this->getFermionOperator(R, fop_mod, "Operator");
|
||||||
|
R.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
// acquire resource
|
||||||
|
virtual void initialize() {
|
||||||
|
// here temporarily assuming that the force and action solver are the same
|
||||||
|
this->ActionPtr.reset(new TwoFlavourEvenOddPseudoFermionAction<Impl>(*(this->fop_mod->getPtr()), *(this->solver_mod->getPtr()), *(this->solver_mod->getPtr())));
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -308,6 +346,9 @@ static Registrar<QCD::PlaqPlusRectangleGMod, HMC_LGTActionModuleFactory<gauge_st
|
|||||||
|
|
||||||
// FIXME more general implementation
|
// FIXME more general implementation
|
||||||
static Registrar<QCD::TwoFlavourFModule<QCD::WilsonImplR> , HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __TwoFlavourFmodXMLInit("TwoFlavours");
|
static Registrar<QCD::TwoFlavourFModule<QCD::WilsonImplR> , HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __TwoFlavourFmodXMLInit("TwoFlavours");
|
||||||
|
static Registrar<QCD::TwoFlavourEOFModule<QCD::WilsonImplR> , HMC_LGTActionModuleFactory<gauge_string, XmlReader> > __TwoFlavourEOFmodXMLInit("TwoFlavoursEvenOdd");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// add here the registration for other implementations and readers
|
// add here the registration for other implementations and readers
|
||||||
|
|
||||||
|
@ -124,8 +124,9 @@ class WilsonFermionModule: public FermionOperatorModule<WilsonFermion, FermionIm
|
|||||||
|
|
||||||
// acquire resource
|
// acquire resource
|
||||||
virtual void initialize(){
|
virtual void initialize(){
|
||||||
typename FermionImpl::GaugeField U(this->GridRefs[0].get().get_full());
|
auto &GridMod = this->GridRefs[0].get();
|
||||||
this->FOPtr.reset(new WilsonFermion<FermionImpl>(U, *(this->GridRefs[0].get().get_full()), *(this->GridRefs[0].get().get_rb()), this->Par_.mass));
|
typename FermionImpl::GaugeField U(GridMod.get_full());
|
||||||
|
this->FOPtr.reset(new WilsonFermion<FermionImpl>(U, *(GridMod.get_full()), *(GridMod.get_rb()), this->Par_.mass));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -43,16 +43,6 @@ class NoParameters{};
|
|||||||
/*
|
/*
|
||||||
Base class for modules with parameters
|
Base class for modules with parameters
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ObjectInfo: Serializable {
|
|
||||||
public:
|
|
||||||
GRID_SERIALIZABLE_CLASS_MEMBERS(ObjectInfo,
|
|
||||||
std::string, name);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
template < class P >
|
template < class P >
|
||||||
class Parametrized{
|
class Parametrized{
|
||||||
public:
|
public:
|
||||||
@ -101,9 +91,6 @@ class Parametrized<NoParameters>{
|
|||||||
/*
|
/*
|
||||||
Lowest level abstract module class
|
Lowest level abstract module class
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <class Prod>
|
template <class Prod>
|
||||||
class HMCModuleBase {
|
class HMCModuleBase {
|
||||||
public:
|
public:
|
||||||
|
@ -1,103 +1,141 @@
|
|||||||
/*************************************************************************************
|
/*************************************************************************************
|
||||||
|
|
||||||
Grid physics library, www.github.com/paboyle/Grid
|
Grid physics library, www.github.com/paboyle/Grid
|
||||||
|
|
||||||
Source file: ./tests/Test_hmc_EOWilsonFermionGauge.cc
|
Source file: ./tests/Test_hmc_WilsonFermionGauge.cc
|
||||||
|
|
||||||
Copyright (C) 2015
|
Copyright (C) 2016
|
||||||
|
|
||||||
Author: Peter Boyle <pabobyle@ph.ed.ac.uk>
|
Author: Guido Cossu <guido.cossu@ed.ac.uk>
|
||||||
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
|
||||||
Author: paboyle <paboyle@ph.ed.ac.uk>
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License along
|
You should have received a copy of the GNU General Public License along
|
||||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
See the full license in the file "LICENSE" in the top level distribution directory
|
See the full license in the file "LICENSE" in the top level distribution
|
||||||
*************************************************************************************/
|
directory
|
||||||
/* END LEGAL */
|
*************************************************************************************/
|
||||||
|
/* END LEGAL */
|
||||||
#include <Grid/Grid.h>
|
#include <Grid/Grid.h>
|
||||||
|
|
||||||
using namespace std;
|
int main(int argc, char **argv) {
|
||||||
using namespace Grid;
|
using namespace Grid;
|
||||||
using namespace Grid::QCD;
|
using namespace Grid::QCD;
|
||||||
|
|
||||||
namespace Grid {
|
|
||||||
namespace QCD {
|
|
||||||
|
|
||||||
|
|
||||||
class HmcRunner : public NerscHmcRunner {
|
|
||||||
public:
|
|
||||||
|
|
||||||
void BuildTheAction (int argc, char **argv)
|
|
||||||
|
|
||||||
{
|
|
||||||
typedef WilsonImplR ImplPolicy;
|
|
||||||
typedef WilsonFermionR FermionAction;
|
|
||||||
typedef typename FermionAction::FermionField FermionField;
|
|
||||||
|
|
||||||
UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
|
|
||||||
UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
|
|
||||||
|
|
||||||
FGrid = UGrid;
|
|
||||||
FrbGrid = UrbGrid;
|
|
||||||
|
|
||||||
// temporarily need a gauge field
|
|
||||||
LatticeGaugeField U(UGrid);
|
|
||||||
|
|
||||||
// Gauge action
|
|
||||||
WilsonGaugeActionR Waction(5.6);
|
|
||||||
|
|
||||||
Real mass=-0.77;
|
|
||||||
FermionAction FermOp(U,*FGrid,*FrbGrid,mass);
|
|
||||||
|
|
||||||
ConjugateGradient<FermionField> CG(1.0e-8,10000);
|
|
||||||
|
|
||||||
TwoFlavourEvenOddPseudoFermionAction<ImplPolicy> Nf2(FermOp,CG,CG);
|
|
||||||
|
|
||||||
//Set smearing (true/false), default: false
|
|
||||||
Nf2.is_smeared=true;
|
|
||||||
|
|
||||||
//Collect actions
|
|
||||||
ActionLevel<LatticeGaugeField> Level1(1);
|
|
||||||
Level1.push_back(&Nf2);
|
|
||||||
|
|
||||||
ActionLevel<LatticeGaugeField> Level2(4);
|
|
||||||
Level2.push_back(&Waction);
|
|
||||||
|
|
||||||
TheAction.push_back(Level1);
|
|
||||||
TheAction.push_back(Level2);
|
|
||||||
|
|
||||||
Run(argc,argv);
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}}
|
|
||||||
|
|
||||||
int main (int argc, char ** argv)
|
|
||||||
{
|
|
||||||
Grid_init(&argc,&argv);
|
|
||||||
|
|
||||||
|
Grid_init(&argc, &argv);
|
||||||
int threads = GridThread::GetThreads();
|
int threads = GridThread::GetThreads();
|
||||||
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl;
|
// here make a routine to print all the relevant information on the run
|
||||||
|
std::cout << GridLogMessage << "Grid is setup to use " << threads << " threads" << std::endl;
|
||||||
|
|
||||||
HmcRunner TheHMC;
|
// Typedefs to simplify notation
|
||||||
|
typedef GenericHMCRunner<MinimumNorm2> HMCWrapper; // Uses the default minimum norm
|
||||||
|
typedef WilsonImplR FermionImplPolicy;
|
||||||
|
typedef WilsonFermionR FermionAction;
|
||||||
|
typedef typename FermionAction::FermionField FermionField;
|
||||||
|
|
||||||
|
|
||||||
|
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
HMCWrapper TheHMC;
|
||||||
|
|
||||||
|
// Grid from the command line
|
||||||
|
TheHMC.Resources.AddFourDimGrid("gauge");
|
||||||
|
// Possibile to create the module by hand
|
||||||
|
// hardcoding parameters or using a Reader
|
||||||
|
|
||||||
|
|
||||||
|
// Checkpointer definition
|
||||||
|
CheckpointerParameters CPparams;
|
||||||
|
CPparams.config_prefix = "ckpoint_lat";
|
||||||
|
CPparams.rng_prefix = "ckpoint_rng";
|
||||||
|
CPparams.saveInterval = 5;
|
||||||
|
CPparams.format = "IEEE64BIG";
|
||||||
|
|
||||||
TheHMC.BuildTheAction(argc,argv);
|
TheHMC.Resources.LoadBinaryCheckpointer(CPparams);
|
||||||
|
|
||||||
|
RNGModuleParameters RNGpar;
|
||||||
|
RNGpar.SerialSeed = {1,2,3,4,5};
|
||||||
|
RNGpar.ParallelSeed = {6,7,8,9,10};
|
||||||
|
TheHMC.Resources.SetRNGSeeds(RNGpar);
|
||||||
|
|
||||||
|
// Construct observables
|
||||||
|
// here there is too much indirection
|
||||||
|
PlaquetteObsParameters PlPar;
|
||||||
|
PlPar.output_prefix = "Plaquette";
|
||||||
|
PlaquetteMod<HMCWrapper::ImplPolicy> PlaqModule(PlPar);
|
||||||
|
TheHMC.Resources.AddObservable(&PlaqModule);
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
// Collect actions, here use more encapsulation
|
||||||
|
// need wrappers of the fermionic classes
|
||||||
|
// that have a complex construction
|
||||||
|
// standard
|
||||||
|
RealD beta = 5.6 ;
|
||||||
|
WilsonGaugeActionR Waction(beta);
|
||||||
|
|
||||||
|
// temporarily need a gauge field
|
||||||
|
auto GridPtr = TheHMC.Resources.GetCartesian();
|
||||||
|
auto GridRBPtr = TheHMC.Resources.GetRBCartesian();
|
||||||
|
|
||||||
|
LatticeGaugeField U(GridPtr);
|
||||||
|
|
||||||
|
Real mass = -0.77;
|
||||||
|
|
||||||
|
// Can we define an overloaded operator that does not need U and initialises
|
||||||
|
// it with zeroes?
|
||||||
|
FermionAction FermOp(U, *GridPtr, *GridRBPtr, mass);
|
||||||
|
|
||||||
|
ConjugateGradient<FermionField> CG(1.0e-8, 2000);
|
||||||
|
|
||||||
|
TwoFlavourEvenOddPseudoFermionAction<FermionImplPolicy> Nf2(FermOp, CG, CG);
|
||||||
|
|
||||||
|
// Set smearing (true/false), default: false
|
||||||
|
Nf2.is_smeared = false;
|
||||||
|
|
||||||
|
|
||||||
|
// Collect actions
|
||||||
|
ActionLevel<HMCWrapper::Field> Level1(1);
|
||||||
|
Level1.push_back(&Nf2);
|
||||||
|
|
||||||
|
ActionLevel<HMCWrapper::Field> Level2(4);
|
||||||
|
Level2.push_back(&Waction);
|
||||||
|
|
||||||
|
TheHMC.TheAction.push_back(Level1);
|
||||||
|
TheHMC.TheAction.push_back(Level2);
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/*
|
||||||
|
double rho = 0.1; // smearing parameter
|
||||||
|
int Nsmear = 2; // number of smearing levels
|
||||||
|
Smear_Stout<HMCWrapper::ImplPolicy> Stout(rho);
|
||||||
|
SmearedConfiguration<HMCWrapper::ImplPolicy> SmearingPolicy(
|
||||||
|
UGrid, Nsmear, Stout);
|
||||||
|
*/
|
||||||
|
|
||||||
|
// HMC parameters are serialisable
|
||||||
|
TheHMC.Parameters.MD.MDsteps = 20;
|
||||||
|
TheHMC.Parameters.MD.trajL = 1.0;
|
||||||
|
|
||||||
|
TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file
|
||||||
|
TheHMC.Run(); // no smearing
|
||||||
|
// TheHMC.Run(SmearingPolicy); // for smearing
|
||||||
|
|
||||||
|
Grid_finalize();
|
||||||
|
|
||||||
|
} // main
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,7 +68,10 @@ int main(int argc, char **argv) {
|
|||||||
// Construct the module
|
// Construct the module
|
||||||
auto myHMCmodule = HMCfactory.create(HMCpar.MD.name, Reader);
|
auto myHMCmodule = HMCfactory.create(HMCpar.MD.name, Reader);
|
||||||
|
|
||||||
|
myHMCmodule->getPtr()->initialize(Reader);
|
||||||
|
myHMCmodule->getPtr()->Run();
|
||||||
|
|
||||||
|
Grid_finalize();
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -100,10 +103,6 @@ int main(int argc, char **argv) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
myHMCmodule->getPtr()->initialize(Reader);
|
|
||||||
myHMCmodule->getPtr()->Run();
|
|
||||||
|
|
||||||
|
|
||||||
Grid_finalize();
|
|
||||||
|
|
||||||
} // main
|
} // main
|
||||||
|
Loading…
x
Reference in New Issue
Block a user