mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-09 21:50:45 +01:00
Hadrons: Fermion actions and gauge fields are modules now
This commit is contained in:
parent
6e83b6a203
commit
02ec23cdad
@ -26,18 +26,16 @@ directory.
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <Hadrons/AWilson.hpp>
|
#include <Hadrons/AWilson.hpp>
|
||||||
#include <Hadrons/Environment.hpp>
|
|
||||||
|
|
||||||
using namespace Grid;
|
using namespace Grid;
|
||||||
using namespace QCD;
|
|
||||||
using namespace Hadrons;
|
using namespace Hadrons;
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* AWilson implementation *
|
* AWilson implementation *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
// constructor /////////////////////////////////////////////////////////////////
|
// constructor /////////////////////////////////////////////////////////////////
|
||||||
AWilson::AWilson(const std::string name)
|
AWilson::AWilson(const std::string name)
|
||||||
: FermionAction(name)
|
: Module(name)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// parse parameters ////////////////////////////////////////////////////////////
|
// parse parameters ////////////////////////////////////////////////////////////
|
||||||
@ -46,12 +44,28 @@ void AWilson::parseParameters(XmlReader &reader, const std::string name)
|
|||||||
read(reader, name, par_);
|
read(reader, name, par_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create operator /////////////////////////////////////////////////////////////
|
// dependencies/products ///////////////////////////////////////////////////////
|
||||||
void AWilson::create(Environment &env)
|
std::vector<std::string> AWilson::getInput(void)
|
||||||
{
|
{
|
||||||
auto &U = *env.getGauge();
|
std::vector<std::string> in = {par_.gauge};
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> AWilson::getOutput(void)
|
||||||
|
{
|
||||||
|
std::vector<std::string> out = {getName()};
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// execution ///////////////////////////////////////////////////////////////////
|
||||||
|
void AWilson::execute(Environment &env)
|
||||||
|
{
|
||||||
|
auto &U = *env.getGauge(par_.gauge);
|
||||||
auto &grid = *env.getGrid();
|
auto &grid = *env.getGrid();
|
||||||
auto &gridRb = *env.getRbGrid();
|
auto &gridRb = *env.getRbGrid();
|
||||||
|
|
||||||
setFMat(new WilsonFermionR(U, grid, gridRb, par_.mass));
|
env.addFermionMatrix(getName(),
|
||||||
|
new WilsonFermionR(U, grid, gridRb, par_.mass));
|
||||||
}
|
}
|
||||||
|
@ -29,21 +29,22 @@ directory.
|
|||||||
#define Hadrons_AWilson_hpp_
|
#define Hadrons_AWilson_hpp_
|
||||||
|
|
||||||
#include <Hadrons/Global.hpp>
|
#include <Hadrons/Global.hpp>
|
||||||
#include <Hadrons/FermionAction.hpp>
|
#include <Hadrons/Module.hpp>
|
||||||
#include <Hadrons/FermionActionFactory.hpp>
|
#include <Hadrons/ModuleFactory.hpp>
|
||||||
|
|
||||||
BEGIN_HADRONS_NAMESPACE
|
BEGIN_HADRONS_NAMESPACE
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Wilson fermions *
|
* Wilson quark action *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
class AWilson: public FermionAction
|
class AWilson: public Module
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
class Par: Serializable
|
class Par: Serializable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GRID_SERIALIZABLE_CLASS_MEMBERS(Par, double, mass);
|
GRID_SERIALIZABLE_CLASS_MEMBERS(Par, std::string, gauge,
|
||||||
|
double , mass);
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
// constructor
|
// constructor
|
||||||
@ -52,13 +53,16 @@ public:
|
|||||||
virtual ~AWilson(void) = default;
|
virtual ~AWilson(void) = default;
|
||||||
// parse parameters
|
// parse parameters
|
||||||
virtual void parseParameters(XmlReader &reader, const std::string name);
|
virtual void parseParameters(XmlReader &reader, const std::string name);
|
||||||
// create operator
|
// dependencies/products
|
||||||
virtual void create(Environment &env);
|
virtual std::vector<std::string> getInput(void);
|
||||||
|
virtual std::vector<std::string> getOutput(void);
|
||||||
|
// execution
|
||||||
|
virtual void execute(Environment &env);
|
||||||
private:
|
private:
|
||||||
Par par_;
|
Par par_;
|
||||||
};
|
};
|
||||||
|
|
||||||
ACTION_REGISTER(AWilson);
|
MODULE_REGISTER(AWilson);
|
||||||
|
|
||||||
END_HADRONS_NAMESPACE
|
END_HADRONS_NAMESPACE
|
||||||
|
|
||||||
|
@ -39,17 +39,10 @@ using namespace Hadrons;
|
|||||||
Application::Application(const std::string parameterFileName)
|
Application::Application(const std::string parameterFileName)
|
||||||
: parameterFileName_(parameterFileName)
|
: parameterFileName_(parameterFileName)
|
||||||
, env_(Environment::getInstance())
|
, env_(Environment::getInstance())
|
||||||
, actionFactory_(FermionActionFactory::getInstance())
|
|
||||||
, modFactory_(ModuleFactory::getInstance())
|
, modFactory_(ModuleFactory::getInstance())
|
||||||
{
|
{
|
||||||
LOG(Message) << "Fermion actions available:" << std::endl;
|
|
||||||
auto list = actionFactory_.getBuilderList();
|
|
||||||
for (auto &m: list)
|
|
||||||
{
|
|
||||||
LOG(Message) << " " << m << std::endl;
|
|
||||||
}
|
|
||||||
LOG(Message) << "Modules available:" << std::endl;
|
LOG(Message) << "Modules available:" << std::endl;
|
||||||
list = modFactory_.getBuilderList();
|
auto list = modFactory_.getBuilderList();
|
||||||
for (auto &m: list)
|
for (auto &m: list)
|
||||||
{
|
{
|
||||||
LOG(Message) << " " << m << std::endl;
|
LOG(Message) << " " << m << std::endl;
|
||||||
@ -84,18 +77,6 @@ void Application::parseParameterFile(void)
|
|||||||
|
|
||||||
LOG(Message) << "Reading '" << parameterFileName_ << "'..." << std::endl;
|
LOG(Message) << "Reading '" << parameterFileName_ << "'..." << std::endl;
|
||||||
read(reader, "parameters", par_);
|
read(reader, "parameters", par_);
|
||||||
push(reader, "actions");
|
|
||||||
push(reader, "action");
|
|
||||||
do
|
|
||||||
{
|
|
||||||
read(reader, "id", id);
|
|
||||||
env_.addFermionAction(actionFactory_.create(id.type, id.name));
|
|
||||||
auto &action = *env_.getFermionAction(id.name);
|
|
||||||
action.parseParameters(reader, "options");
|
|
||||||
action.create(env_);
|
|
||||||
} while (reader.nextElement("action"));
|
|
||||||
pop(reader);
|
|
||||||
pop(reader);
|
|
||||||
push(reader, "modules");
|
push(reader, "modules");
|
||||||
push(reader, "module");
|
push(reader, "module");
|
||||||
do
|
do
|
||||||
@ -190,7 +171,6 @@ void Application::configLoop(void)
|
|||||||
{
|
{
|
||||||
LOG(Message) << "Starting measurement for trajectory " << t
|
LOG(Message) << "Starting measurement for trajectory " << t
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
env_.loadUnitGauge();
|
|
||||||
execute(program_);
|
execute(program_);
|
||||||
env_.freeAll();
|
env_.freeAll();
|
||||||
}
|
}
|
||||||
@ -219,8 +199,8 @@ unsigned int Application::execute(const std::vector<std::string> &program)
|
|||||||
}
|
}
|
||||||
for (unsigned int i = 0; i < program.size(); ++i)
|
for (unsigned int i = 0; i < program.size(); ++i)
|
||||||
{
|
{
|
||||||
LOG(Message) << "Measurement step (" << i+1 << "/" << program.size()
|
LOG(Message) << "Measurement step " << i+1 << "/" << program.size()
|
||||||
<< ")" << std::endl;
|
<< " (module '" << program[i] << "')" << std::endl;
|
||||||
(*module_[program[i]])(env_);
|
(*module_[program[i]])(env_);
|
||||||
LOG(Message) << "allocated propagators: " << env_.nProp() << std::endl;
|
LOG(Message) << "allocated propagators: " << env_.nProp() << std::endl;
|
||||||
if (env_.nProp() > memPeak)
|
if (env_.nProp() > memPeak)
|
||||||
|
@ -29,7 +29,6 @@ directory.
|
|||||||
#define Hadrons_Application_hpp_
|
#define Hadrons_Application_hpp_
|
||||||
|
|
||||||
#include <Hadrons/Global.hpp>
|
#include <Hadrons/Global.hpp>
|
||||||
#include <Hadrons/FermionActionFactory.hpp>
|
|
||||||
#include <Hadrons/Environment.hpp>
|
#include <Hadrons/Environment.hpp>
|
||||||
#include <Hadrons/ModuleFactory.hpp>
|
#include <Hadrons/ModuleFactory.hpp>
|
||||||
|
|
||||||
@ -90,7 +89,6 @@ private:
|
|||||||
std::string parameterFileName_;
|
std::string parameterFileName_;
|
||||||
GlobalPar par_;
|
GlobalPar par_;
|
||||||
Environment &env_;
|
Environment &env_;
|
||||||
FermionActionFactory &actionFactory_;
|
|
||||||
ModuleFactory &modFactory_;
|
ModuleFactory &modFactory_;
|
||||||
std::map<std::string, std::unique_ptr<Module>> module_;
|
std::map<std::string, std::unique_ptr<Module>> module_;
|
||||||
std::map<std::string, std::string> associatedModule_;
|
std::map<std::string, std::string> associatedModule_;
|
||||||
|
@ -45,7 +45,7 @@ void CMeson::parseParameters(XmlReader &reader, const std::string name)
|
|||||||
read(reader, name, par_);
|
read(reader, name, par_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// dependency relation /////////////////////////////////////////////////////////
|
// dependencies/products ///////////////////////////////////////////////////////
|
||||||
std::vector<std::string> CMeson::getInput(void)
|
std::vector<std::string> CMeson::getInput(void)
|
||||||
{
|
{
|
||||||
std::vector<std::string> input = {par_.q1, par_.q2};
|
std::vector<std::string> input = {par_.q1, par_.q2};
|
||||||
|
@ -61,7 +61,7 @@ public:
|
|||||||
virtual ~CMeson(void) = default;
|
virtual ~CMeson(void) = default;
|
||||||
// parse parameters
|
// parse parameters
|
||||||
virtual void parseParameters(XmlReader &reader, const std::string name);
|
virtual void parseParameters(XmlReader &reader, const std::string name);
|
||||||
// dependency relation
|
// dependencies/products
|
||||||
virtual std::vector<std::string> getInput(void);
|
virtual std::vector<std::string> getInput(void);
|
||||||
virtual std::vector<std::string> getOutput(void);
|
virtual std::vector<std::string> getOutput(void);
|
||||||
// execution
|
// execution
|
||||||
|
@ -42,8 +42,6 @@ Environment::Environment(void)
|
|||||||
GridDefaultMpi()));
|
GridDefaultMpi()));
|
||||||
gridRb4d_.reset(SpaceTimeGrid::makeFourDimRedBlackGrid(grid4d_.get()));
|
gridRb4d_.reset(SpaceTimeGrid::makeFourDimRedBlackGrid(grid4d_.get()));
|
||||||
rng4d_.reset(new GridParallelRNG(grid4d_.get()));
|
rng4d_.reset(new GridParallelRNG(grid4d_.get()));
|
||||||
gauge_.reset(new LatticeGaugeField(grid4d_.get()));
|
|
||||||
loadUnitGauge();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// dry run /////////////////////////////////////////////////////////////////////
|
// dry run /////////////////////////////////////////////////////////////////////
|
||||||
@ -97,22 +95,22 @@ GridRedBlackCartesian * Environment::getRbGrid(const unsigned int Ls) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fermion actions /////////////////////////////////////////////////////////////
|
// fermion actions /////////////////////////////////////////////////////////////
|
||||||
void Environment::addFermionAction(FActionPt action)
|
void Environment::addFermionMatrix(const std::string name, FMat *fMat)
|
||||||
{
|
{
|
||||||
fAction_[action->getName()] = std::move(action);
|
fMat_[name].reset(fMat);
|
||||||
}
|
}
|
||||||
|
|
||||||
FermionAction * Environment::getFermionAction(const std::string name) const
|
Environment::FMat * Environment::getFermionMatrix(const std::string name) const
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return fAction_.at(name).get();
|
return fMat_.at(name).get();
|
||||||
}
|
}
|
||||||
catch(std::out_of_range &)
|
catch(std::out_of_range &)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return fAction_.at(solverAction_.at(name)).get();
|
return fMat_.at(solverAction_.at(name)).get();
|
||||||
}
|
}
|
||||||
catch (std::out_of_range &)
|
catch (std::out_of_range &)
|
||||||
{
|
{
|
||||||
@ -143,9 +141,9 @@ void Environment::callSolver(const std::string name, LatticeFermion &sol,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// quark propagators ///////////////////////////////////////////////////////////
|
// quark propagators ///////////////////////////////////////////////////////////
|
||||||
void Environment::addProp(const std::string name, const unsigned int Ls)
|
void Environment::createProp(const std::string name, const unsigned int Ls)
|
||||||
{
|
{
|
||||||
GridCartesian *p4 = grid4d_.get();
|
GridCartesian *g4 = getGrid();
|
||||||
|
|
||||||
if (propExists(name))
|
if (propExists(name))
|
||||||
{
|
{
|
||||||
@ -153,21 +151,21 @@ void Environment::addProp(const std::string name, const unsigned int Ls)
|
|||||||
}
|
}
|
||||||
if (Ls > 1)
|
if (Ls > 1)
|
||||||
{
|
{
|
||||||
GridCartesian *p;
|
GridCartesian *g;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
p = grid5d_.at(Ls).get();
|
g = grid5d_.at(Ls).get();
|
||||||
}
|
}
|
||||||
catch(std::out_of_range &)
|
catch(std::out_of_range &)
|
||||||
{
|
{
|
||||||
grid5d_[Ls].reset(SpaceTimeGrid::makeFiveDimGrid(Ls, p4));
|
grid5d_[Ls].reset(SpaceTimeGrid::makeFiveDimGrid(Ls, g4));
|
||||||
gridRb5d_[Ls].reset(SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls, p4));
|
gridRb5d_[Ls].reset(SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls, g4));
|
||||||
p = grid5d_[Ls].get();
|
g = grid5d_[Ls].get();
|
||||||
}
|
}
|
||||||
if (!isDryRun())
|
if (!isDryRun())
|
||||||
{
|
{
|
||||||
prop_[name].reset(new LatticePropagator(p));
|
prop_[name].reset(new LatticePropagator(g));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -179,7 +177,7 @@ void Environment::addProp(const std::string name, const unsigned int Ls)
|
|||||||
{
|
{
|
||||||
if (!isDryRun())
|
if (!isDryRun())
|
||||||
{
|
{
|
||||||
prop_[name].reset(new LatticePropagator(p4));
|
prop_[name].reset(new LatticePropagator(g4));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -269,19 +267,44 @@ unsigned int Environment::nProp(void) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// gauge configuration /////////////////////////////////////////////////////////
|
// gauge configuration /////////////////////////////////////////////////////////
|
||||||
LatticeGaugeField * Environment::getGauge(void) const
|
void Environment::createGauge(const std::string name)
|
||||||
{
|
{
|
||||||
return gauge_.get();
|
if (gaugeExists(name))
|
||||||
|
{
|
||||||
|
HADRON_ERROR("gauge field '" + name + "' already exists");
|
||||||
|
}
|
||||||
|
gauge_[name].reset(new LatticeGaugeField(getGrid()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Environment::loadUnitGauge(void)
|
void Environment::freeGauge(const std::string name)
|
||||||
{
|
{
|
||||||
SU3::ColdConfiguration(*rng4d_, *gauge_);
|
if (gaugeExists(name))
|
||||||
|
{
|
||||||
|
gauge_.erase(name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HADRON_ERROR("trying to free unknown gauge field '" + name + "'");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Environment::loadRandomGauge(void)
|
LatticeGaugeField * Environment::getGauge(const std::string name) const
|
||||||
{
|
{
|
||||||
SU3::HotConfiguration(*rng4d_, *gauge_);
|
if (gaugeExists(name))
|
||||||
|
{
|
||||||
|
return gauge_.at(name).get();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HADRON_ERROR("gauge field '" + name + "' unknown");
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Environment::gaugeExists(const std::string name) const
|
||||||
|
{
|
||||||
|
return (gauge_.find(name) != gauge_.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
// random number generator /////////////////////////////////////////////////////
|
// random number generator /////////////////////////////////////////////////////
|
||||||
@ -300,13 +323,19 @@ void Environment::free(const std::string name)
|
|||||||
{
|
{
|
||||||
if (propExists(name))
|
if (propExists(name))
|
||||||
{
|
{
|
||||||
LOG(Message) << "freeing '" << name << "'" << std::endl;
|
LOG(Message) << "freeing propagator '" << name << "'" << std::endl;
|
||||||
freeProp(name);
|
freeProp(name);
|
||||||
}
|
}
|
||||||
|
else if (gaugeExists(name))
|
||||||
|
{
|
||||||
|
LOG(Message) << "freeing gauge field '" << name << "'" << std::endl;
|
||||||
|
freeGauge(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Environment::freeAll(void)
|
void Environment::freeAll(void)
|
||||||
{
|
{
|
||||||
prop_.clear();
|
prop_.clear();
|
||||||
propSize_.clear();
|
propSize_.clear();
|
||||||
|
gauge_.clear();
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ directory.
|
|||||||
#define Hadrons_Environment_hpp_
|
#define Hadrons_Environment_hpp_
|
||||||
|
|
||||||
#include <Hadrons/Global.hpp>
|
#include <Hadrons/Global.hpp>
|
||||||
#include <Hadrons/FermionAction.hpp>
|
|
||||||
|
|
||||||
BEGIN_HADRONS_NAMESPACE
|
BEGIN_HADRONS_NAMESPACE
|
||||||
|
|
||||||
@ -40,12 +39,13 @@ class Environment
|
|||||||
{
|
{
|
||||||
SINGLETON(Environment);
|
SINGLETON(Environment);
|
||||||
public:
|
public:
|
||||||
|
typedef FermionOperator<WilsonImplR> FMat;
|
||||||
typedef std::function<void(LatticeFermion &,
|
typedef std::function<void(LatticeFermion &,
|
||||||
const LatticeFermion &)> Solver;
|
const LatticeFermion &)> Solver;
|
||||||
typedef std::unique_ptr<GridCartesian> GridPt;
|
typedef std::unique_ptr<GridCartesian> GridPt;
|
||||||
typedef std::unique_ptr<GridRedBlackCartesian> GridRbPt;
|
typedef std::unique_ptr<GridRedBlackCartesian> GridRbPt;
|
||||||
typedef std::unique_ptr<GridParallelRNG> RngPt;
|
typedef std::unique_ptr<GridParallelRNG> RngPt;
|
||||||
typedef std::unique_ptr<FermionAction> FActionPt;
|
typedef std::unique_ptr<FMat> FMatPt;
|
||||||
typedef std::unique_ptr<LatticePropagator> PropPt;
|
typedef std::unique_ptr<LatticePropagator> PropPt;
|
||||||
typedef std::unique_ptr<LatticeGaugeField> GaugePt;
|
typedef std::unique_ptr<LatticeGaugeField> GaugePt;
|
||||||
public:
|
public:
|
||||||
@ -56,8 +56,8 @@ public:
|
|||||||
GridCartesian * getGrid(const unsigned int Ls = 1) const;
|
GridCartesian * getGrid(const unsigned int Ls = 1) const;
|
||||||
GridRedBlackCartesian * getRbGrid(const unsigned int Ls = 1) const;
|
GridRedBlackCartesian * getRbGrid(const unsigned int Ls = 1) const;
|
||||||
// fermion actions
|
// fermion actions
|
||||||
void addFermionAction(FActionPt action);
|
void addFermionMatrix(const std::string name, FMat *mat);
|
||||||
FermionAction * getFermionAction(const std::string name) const;
|
FMat * getFermionMatrix(const std::string name) const;
|
||||||
// solvers
|
// solvers
|
||||||
void addSolver(const std::string name, Solver s,
|
void addSolver(const std::string name, Solver s,
|
||||||
const std::string actionName);
|
const std::string actionName);
|
||||||
@ -65,18 +65,19 @@ public:
|
|||||||
LatticeFermion &sol,
|
LatticeFermion &sol,
|
||||||
const LatticeFermion &src) const;
|
const LatticeFermion &src) const;
|
||||||
// quark propagators
|
// quark propagators
|
||||||
void addProp(const std::string name,
|
void createProp(const std::string name,
|
||||||
const unsigned int Ls = 1);
|
const unsigned int Ls = 1);
|
||||||
void freeProp(const std::string name);
|
void freeProp(const std::string name);
|
||||||
bool isProp5d(const std::string name) const;
|
bool isProp5d(const std::string name) const;
|
||||||
unsigned int getPropLs(const std::string name) const;
|
unsigned int getPropLs(const std::string name) const;
|
||||||
LatticePropagator * getProp(const std::string name) const;
|
LatticePropagator * getProp(const std::string name) const;
|
||||||
bool propExists(const std::string name) const;
|
bool propExists(const std::string name) const;
|
||||||
unsigned int nProp(void) const;
|
unsigned int nProp(void) const;
|
||||||
// gauge configuration
|
// gauge configurations
|
||||||
LatticeGaugeField * getGauge(void) const;
|
void createGauge(const std::string name);
|
||||||
void loadUnitGauge(void);
|
void freeGauge(const std::string name);
|
||||||
void loadRandomGauge(void);
|
LatticeGaugeField * getGauge(const std::string name) const;
|
||||||
|
bool gaugeExists(const std::string name) const;
|
||||||
// random number generator
|
// random number generator
|
||||||
void setSeed(const std::vector<int> &seed);
|
void setSeed(const std::vector<int> &seed);
|
||||||
GridParallelRNG * get4dRng(void) const;
|
GridParallelRNG * get4dRng(void) const;
|
||||||
@ -90,13 +91,12 @@ private:
|
|||||||
GridRbPt gridRb4d_;
|
GridRbPt gridRb4d_;
|
||||||
std::map<unsigned int, GridRbPt> gridRb5d_;
|
std::map<unsigned int, GridRbPt> gridRb5d_;
|
||||||
RngPt rng4d_;
|
RngPt rng4d_;
|
||||||
std::map<std::string, FActionPt> fAction_;
|
std::map<std::string, FMatPt> fMat_;
|
||||||
std::map<std::string, Solver> solver_;
|
std::map<std::string, Solver> solver_;
|
||||||
std::map<std::string, std::string> solverAction_;
|
std::map<std::string, std::string> solverAction_;
|
||||||
std::map<std::string, PropPt> prop_;
|
std::map<std::string, PropPt> prop_;
|
||||||
std::map<std::string, unsigned int> propSize_;
|
std::map<std::string, unsigned int> propSize_;
|
||||||
GaugePt gauge_;
|
std::map<std::string, GaugePt> gauge_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
END_HADRONS_NAMESPACE
|
END_HADRONS_NAMESPACE
|
||||||
|
@ -1,83 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
Grid physics library, www.github.com/paboyle/Grid
|
|
||||||
|
|
||||||
Source file: programs/Hadrons/FermionAction.hpp
|
|
||||||
|
|
||||||
Copyright (C) 2016
|
|
||||||
|
|
||||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
|
||||||
|
|
||||||
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
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
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.,
|
|
||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
|
|
||||||
See the full license in the file "LICENSE" in the top level distribution
|
|
||||||
directory.
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#ifndef Hadrons_FermionAction_hpp_
|
|
||||||
#define Hadrons_FermionAction_hpp_
|
|
||||||
|
|
||||||
#include <Hadrons/Global.hpp>
|
|
||||||
|
|
||||||
BEGIN_HADRONS_NAMESPACE
|
|
||||||
|
|
||||||
// action registration macro
|
|
||||||
#define ACTION_REGISTER(action)\
|
|
||||||
class action##ActionRegistrar\
|
|
||||||
{\
|
|
||||||
public:\
|
|
||||||
action##ActionRegistrar(void)\
|
|
||||||
{\
|
|
||||||
FermionActionFactory &actionFac = FermionActionFactory::getInstance();\
|
|
||||||
actionFac.registerBuilder(#action, [&](const std::string name)\
|
|
||||||
{\
|
|
||||||
return std::unique_ptr<action>(\
|
|
||||||
new action(name));\
|
|
||||||
});\
|
|
||||||
}\
|
|
||||||
};\
|
|
||||||
static action##ActionRegistrar action##ActionRegistrarInstance;
|
|
||||||
|
|
||||||
/******************************************************************************
|
|
||||||
* FermionAction *
|
|
||||||
******************************************************************************/
|
|
||||||
class Environment;
|
|
||||||
|
|
||||||
class FermionAction
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef FermionOperator<WilsonImplR> FMat;
|
|
||||||
typedef std::unique_ptr<FMat> FMatPt;
|
|
||||||
public:
|
|
||||||
// constructor
|
|
||||||
FermionAction(const std::string name);
|
|
||||||
// destructor
|
|
||||||
virtual ~FermionAction(void) = default;
|
|
||||||
// access
|
|
||||||
std::string getName(void) const;
|
|
||||||
virtual unsigned int getLs(void) const;
|
|
||||||
void setFMat(FMat *fMat);
|
|
||||||
FMat * getFMat(void);
|
|
||||||
// parse parameters
|
|
||||||
virtual void parseParameters(XmlReader &reader, const std::string name) = 0;
|
|
||||||
// create operator
|
|
||||||
virtual void create(Environment &env) = 0;
|
|
||||||
private:
|
|
||||||
std::string name_;
|
|
||||||
FMatPt fMat_;
|
|
||||||
};
|
|
||||||
|
|
||||||
END_HADRONS_NAMESPACE
|
|
||||||
|
|
||||||
#endif // Hadrons_FermionAction_hpp_
|
|
@ -1,7 +1,7 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
Grid physics library, www.github.com/paboyle/Grid
|
Grid physics library, www.github.com/paboyle/Grid
|
||||||
|
|
||||||
Source file: programs/Hadrons/FermionAction.cc
|
Source file: programs/Hadrons/GUnit.cc
|
||||||
|
|
||||||
Copyright (C) 2016
|
Copyright (C) 2016
|
||||||
|
|
||||||
@ -25,37 +25,41 @@ See the full license in the file "LICENSE" in the top level distribution
|
|||||||
directory.
|
directory.
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <Hadrons/FermionAction.hpp>
|
#include <Hadrons/GUnit.hpp>
|
||||||
|
|
||||||
using namespace Grid;
|
using namespace Grid;
|
||||||
using namespace QCD;
|
|
||||||
using namespace Hadrons;
|
using namespace Hadrons;
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* FermionAction implementation *
|
* GUnit implementation *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
// constructor /////////////////////////////////////////////////////////////////
|
// constructor /////////////////////////////////////////////////////////////////
|
||||||
FermionAction::FermionAction(const std::string name)
|
GUnit::GUnit(const std::string name)
|
||||||
: name_(name)
|
: Module(name)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// access //////////////////////////////////////////////////////////////////////
|
// dependencies/products ///////////////////////////////////////////////////////
|
||||||
std::string FermionAction::getName(void) const
|
std::vector<std::string> GUnit::getInput(void)
|
||||||
{
|
{
|
||||||
return name_;
|
return std::vector<std::string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int FermionAction::getLs(void) const
|
std::vector<std::string> GUnit::getOutput(void)
|
||||||
{
|
{
|
||||||
return 1;
|
std::vector<std::string> out = {getName()};
|
||||||
|
|
||||||
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FermionAction::setFMat(FMat *fMat)
|
// allocation //////////////////////////////////////////////////////////////////
|
||||||
|
void GUnit::allocate(Environment &env)
|
||||||
{
|
{
|
||||||
fMat_.reset(fMat);
|
env.createGauge(getName());
|
||||||
|
gauge_ = env.getGauge(getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
FermionAction::FMat * FermionAction::getFMat(void)
|
// execution ///////////////////////////////////////////////////////////////////
|
||||||
|
void GUnit::execute(Environment &env)
|
||||||
{
|
{
|
||||||
return fMat_.get();
|
SU3::ColdConfiguration(*env.get4dRng(), *gauge_);
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
Grid physics library, www.github.com/paboyle/Grid
|
Grid physics library, www.github.com/paboyle/Grid
|
||||||
|
|
||||||
Source file: programs/Hadrons/FermionActionFactory.hpp
|
Source file: programs/Hadrons/GUnit.hpp
|
||||||
|
|
||||||
Copyright (C) 2016
|
Copyright (C) 2016
|
||||||
|
|
||||||
@ -25,23 +25,38 @@ See the full license in the file "LICENSE" in the top level distribution
|
|||||||
directory.
|
directory.
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#ifndef Hadrons_FermionActionFactory_hpp_
|
#ifndef Hadrons_GUnit_hpp_
|
||||||
#define Hadrons_FermionActionFactory_hpp_
|
#define Hadrons_GUnit_hpp_
|
||||||
|
|
||||||
#include <Hadrons/Global.hpp>
|
#include <Hadrons/Global.hpp>
|
||||||
#include <Hadrons/Factory.hpp>
|
#include <Hadrons/Module.hpp>
|
||||||
#include <Hadrons/FermionAction.hpp>
|
#include <Hadrons/ModuleFactory.hpp>
|
||||||
|
|
||||||
BEGIN_HADRONS_NAMESPACE
|
BEGIN_HADRONS_NAMESPACE
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* FermionActionFactory *
|
* Unit gauge *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
class FermionActionFactory: public Factory<FermionAction>
|
class GUnit: public Module
|
||||||
{
|
{
|
||||||
SINGLETON_DEFCTOR(FermionActionFactory)
|
public:
|
||||||
|
// constructor
|
||||||
|
GUnit(const std::string name);
|
||||||
|
// destructor
|
||||||
|
virtual ~GUnit(void) = default;
|
||||||
|
// dependencies/products
|
||||||
|
virtual std::vector<std::string> getInput(void);
|
||||||
|
virtual std::vector<std::string> getOutput(void);
|
||||||
|
// allocation
|
||||||
|
virtual void allocate(Environment &env);
|
||||||
|
// execution
|
||||||
|
virtual void execute(Environment &env);
|
||||||
|
private:
|
||||||
|
LatticeGaugeField *gauge_ = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
MODULE_REGISTER(GUnit);
|
||||||
|
|
||||||
END_HADRONS_NAMESPACE
|
END_HADRONS_NAMESPACE
|
||||||
|
|
||||||
#endif // Hadrons_FermionActionFactory_hpp_
|
#endif // Hadrons_GUnit_hpp_
|
@ -39,13 +39,13 @@ MQuark::MQuark(const std::string name)
|
|||||||
: Module(name)
|
: Module(name)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// parse parameters
|
// parse parameters ////////////////////////////////////////////////////////////
|
||||||
void MQuark::parseParameters(XmlReader &reader, const std::string name)
|
void MQuark::parseParameters(XmlReader &reader, const std::string name)
|
||||||
{
|
{
|
||||||
read(reader, name, par_);
|
read(reader, name, par_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// dependency relation
|
// dependencies/products ///////////////////////////////////////////////////////
|
||||||
std::vector<std::string> MQuark::getInput(void)
|
std::vector<std::string> MQuark::getInput(void)
|
||||||
{
|
{
|
||||||
std::vector<std::string> in = {par_.source, par_.solver};
|
std::vector<std::string> in = {par_.source, par_.solver};
|
||||||
@ -63,22 +63,31 @@ std::vector<std::string> MQuark::getOutput(void)
|
|||||||
// setup ///////////////////////////////////////////////////////////////////////
|
// setup ///////////////////////////////////////////////////////////////////////
|
||||||
void MQuark::setup(Environment &env)
|
void MQuark::setup(Environment &env)
|
||||||
{
|
{
|
||||||
Ls_ = env.getFermionAction(par_.solver)->getLs();
|
auto dim = env.getFermionMatrix(par_.solver)->Grid()->GlobalDimensions();
|
||||||
|
|
||||||
|
if (dim.size() == Nd)
|
||||||
|
{
|
||||||
|
Ls_ = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Ls_ = dim[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// allocation //////////////////////////////////////////////////////////////////
|
// allocation //////////////////////////////////////////////////////////////////
|
||||||
void MQuark::allocate(Environment &env)
|
void MQuark::allocate(Environment &env)
|
||||||
{
|
{
|
||||||
env.addProp(getName());
|
env.createProp(getName());
|
||||||
quark_ = env.getProp(getName());
|
quark_ = env.getProp(getName());
|
||||||
if (Ls_ > 1)
|
if (Ls_ > 1)
|
||||||
{
|
{
|
||||||
env.addProp(getName() + "_5d", Ls_);
|
env.createProp(getName() + "_5d", Ls_);
|
||||||
quark5d_ = env.getProp(getName() + "_5d");
|
quark5d_ = env.getProp(getName() + "_5d");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// execution
|
// execution ///////////////////////////////////////////////////////////////////
|
||||||
void MQuark::execute(Environment &env)
|
void MQuark::execute(Environment &env)
|
||||||
{
|
{
|
||||||
LatticePropagator *fullSource;
|
LatticePropagator *fullSource;
|
||||||
|
@ -53,7 +53,7 @@ public:
|
|||||||
virtual ~MQuark(void) = default;
|
virtual ~MQuark(void) = default;
|
||||||
// parse parameters
|
// parse parameters
|
||||||
virtual void parseParameters(XmlReader &reader, const std::string name);
|
virtual void parseParameters(XmlReader &reader, const std::string name);
|
||||||
// dependency relation
|
// dependencies/products
|
||||||
virtual std::vector<std::string> getInput(void);
|
virtual std::vector<std::string> getInput(void);
|
||||||
virtual std::vector<std::string> getOutput(void);
|
virtual std::vector<std::string> getOutput(void);
|
||||||
// setup
|
// setup
|
||||||
|
@ -41,13 +41,13 @@ MSource::MSource(const std::string name)
|
|||||||
: Module(name)
|
: Module(name)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// parse parameters
|
// parse parameters ////////////////////////////////////////////////////////////
|
||||||
void MSource::parseParameters(XmlReader &reader, const std::string name)
|
void MSource::parseParameters(XmlReader &reader, const std::string name)
|
||||||
{
|
{
|
||||||
read(reader, name, par_);
|
read(reader, name, par_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// dependency relation
|
// dependencies/products ///////////////////////////////////////////////////////
|
||||||
std::vector<std::string> MSource::getInput(void)
|
std::vector<std::string> MSource::getInput(void)
|
||||||
{
|
{
|
||||||
return std::vector<std::string>();
|
return std::vector<std::string>();
|
||||||
@ -68,7 +68,7 @@ void MSource::allocate(Environment &env)
|
|||||||
// 4D sources
|
// 4D sources
|
||||||
case Grid::SourceType::point:
|
case Grid::SourceType::point:
|
||||||
case Grid::SourceType::z2Band:
|
case Grid::SourceType::z2Band:
|
||||||
env.addProp(getName());
|
env.createProp(getName());
|
||||||
src_ = env.getProp(getName());
|
src_ = env.getProp(getName());
|
||||||
break;
|
break;
|
||||||
// error
|
// error
|
||||||
|
@ -84,7 +84,7 @@ public:
|
|||||||
virtual ~MSource(void) = default;
|
virtual ~MSource(void) = default;
|
||||||
// parse parameters
|
// parse parameters
|
||||||
virtual void parseParameters(XmlReader &reader, const std::string name);
|
virtual void parseParameters(XmlReader &reader, const std::string name);
|
||||||
// dependency relation
|
// dependencies/products
|
||||||
virtual std::vector<std::string> getInput(void);
|
virtual std::vector<std::string> getInput(void);
|
||||||
virtual std::vector<std::string> getOutput(void);
|
virtual std::vector<std::string> getOutput(void);
|
||||||
// allocation
|
// allocation
|
||||||
|
@ -3,30 +3,33 @@ AM_LDFLAGS = -L$(top_builddir)/lib
|
|||||||
|
|
||||||
bin_PROGRAMS = Hadrons
|
bin_PROGRAMS = Hadrons
|
||||||
|
|
||||||
## general sources
|
# general sources
|
||||||
Hadrons_SOURCES = \
|
Hadrons_SOURCES = \
|
||||||
Application.cc \
|
Application.cc \
|
||||||
Environment.cc \
|
Environment.cc \
|
||||||
FermionAction.cc\
|
|
||||||
Global.cc \
|
Global.cc \
|
||||||
Hadrons.cc \
|
Hadrons.cc \
|
||||||
Module.cc
|
Module.cc
|
||||||
|
|
||||||
## fermion actions
|
# general modules
|
||||||
Hadrons_SOURCES += \
|
|
||||||
AWilson.cc
|
|
||||||
|
|
||||||
## general modules
|
|
||||||
Hadrons_SOURCES += \
|
Hadrons_SOURCES += \
|
||||||
MQuark.cc \
|
MQuark.cc \
|
||||||
MSource.cc
|
MSource.cc
|
||||||
|
|
||||||
## solver modules
|
# fermion actions
|
||||||
Hadrons_SOURCES += \
|
Hadrons_SOURCES += \
|
||||||
SRBPrecCG.cc
|
AWilson.cc
|
||||||
|
|
||||||
## contraction modules
|
# contraction modules
|
||||||
Hadrons_SOURCES += \
|
Hadrons_SOURCES += \
|
||||||
CMeson.cc
|
CMeson.cc
|
||||||
|
|
||||||
|
# gauge modules
|
||||||
|
Hadrons_SOURCES += \
|
||||||
|
GUnit.cc
|
||||||
|
|
||||||
|
# solver modules
|
||||||
|
Hadrons_SOURCES += \
|
||||||
|
SRBPrecCG.cc
|
||||||
|
|
||||||
Hadrons_LDADD = -lGrid
|
Hadrons_LDADD = -lGrid
|
||||||
|
@ -62,8 +62,8 @@ public:
|
|||||||
// access
|
// access
|
||||||
std::string getName(void) const;
|
std::string getName(void) const;
|
||||||
// parse parameters
|
// parse parameters
|
||||||
virtual void parseParameters(XmlReader &reader, const std::string name) = 0;
|
virtual void parseParameters(XmlReader &reader, const std::string name) {};
|
||||||
// dependency relation
|
// dependencies/products
|
||||||
virtual std::vector<std::string> getInput(void) = 0;
|
virtual std::vector<std::string> getInput(void) = 0;
|
||||||
virtual std::vector<std::string> getOutput(void) = 0;
|
virtual std::vector<std::string> getOutput(void) = 0;
|
||||||
// setup
|
// setup
|
||||||
|
@ -39,16 +39,18 @@ SRBPrecCG::SRBPrecCG(const std::string name)
|
|||||||
: Module(name)
|
: Module(name)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// parse parameters
|
// parse parameters ////////////////////////////////////////////////////////////
|
||||||
void SRBPrecCG::parseParameters(XmlReader &reader, const std::string name)
|
void SRBPrecCG::parseParameters(XmlReader &reader, const std::string name)
|
||||||
{
|
{
|
||||||
read(reader, name, par_);
|
read(reader, name, par_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// dependency relation
|
// dependencies/products ///////////////////////////////////////////////////////
|
||||||
std::vector<std::string> SRBPrecCG::getInput(void)
|
std::vector<std::string> SRBPrecCG::getInput(void)
|
||||||
{
|
{
|
||||||
return std::vector<std::string>();
|
std::vector<std::string> in = {par_.action};
|
||||||
|
|
||||||
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> SRBPrecCG::getOutput(void)
|
std::vector<std::string> SRBPrecCG::getOutput(void)
|
||||||
@ -61,7 +63,7 @@ std::vector<std::string> SRBPrecCG::getOutput(void)
|
|||||||
// execution ///////////////////////////////////////////////////////////////////
|
// execution ///////////////////////////////////////////////////////////////////
|
||||||
void SRBPrecCG::execute(Environment &env)
|
void SRBPrecCG::execute(Environment &env)
|
||||||
{
|
{
|
||||||
auto &mat = *(env.getFermionAction(par_.action)->getFMat());
|
auto &mat = *(env.getFermionMatrix(par_.action));
|
||||||
auto solver = [&mat, this](LatticeFermion &sol,
|
auto solver = [&mat, this](LatticeFermion &sol,
|
||||||
const LatticeFermion &source)
|
const LatticeFermion &source)
|
||||||
{
|
{
|
||||||
|
@ -35,7 +35,7 @@ directory.
|
|||||||
BEGIN_HADRONS_NAMESPACE
|
BEGIN_HADRONS_NAMESPACE
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* SRBPrecCG *
|
* Schur red-black preconditioned CG *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
class SRBPrecCG: public Module
|
class SRBPrecCG: public Module
|
||||||
{
|
{
|
||||||
@ -53,7 +53,7 @@ public:
|
|||||||
virtual ~SRBPrecCG(void) = default;
|
virtual ~SRBPrecCG(void) = default;
|
||||||
// parse parameters
|
// parse parameters
|
||||||
virtual void parseParameters(XmlReader &reader, const std::string name);
|
virtual void parseParameters(XmlReader &reader, const std::string name);
|
||||||
// dependency relation
|
// dependencies/products
|
||||||
virtual std::vector<std::string> getInput(void);
|
virtual std::vector<std::string> getInput(void);
|
||||||
virtual std::vector<std::string> getOutput(void);
|
virtual std::vector<std::string> getOutput(void);
|
||||||
// execution
|
// execution
|
||||||
|
Loading…
x
Reference in New Issue
Block a user