1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-10 07:55:35 +00:00

Removed A2A contraction module and replaced it with the beginnings of a meson field module

This commit is contained in:
fionnoh 2018-06-28 16:17:26 +01:00
parent 7fe3974c0a
commit a2929f4384
3 changed files with 77 additions and 54 deletions

View File

@ -0,0 +1,7 @@
#include <Grid/Hadrons/Modules/MContraction/MesonFieldGamma.hpp>
using namespace Grid;
using namespace Hadrons;
using namespace MContraction;
template class Grid::Hadrons::MContraction::TMesonFieldGamma<FIMPL>;

View File

@ -1,5 +1,5 @@
#ifndef Hadrons_MContraction_A2AMeson_hpp_ #ifndef Hadrons_MContraction_MesonFieldGamma_hpp_
#define Hadrons_MContraction_A2AMeson_hpp_ #define Hadrons_MContraction_MesonFieldGamma_hpp_
#include <Grid/Hadrons/Global.hpp> #include <Grid/Hadrons/Global.hpp>
#include <Grid/Hadrons/Module.hpp> #include <Grid/Hadrons/Module.hpp>
@ -9,7 +9,7 @@
BEGIN_HADRONS_NAMESPACE BEGIN_HADRONS_NAMESPACE
/****************************************************************************** /******************************************************************************
* A2AMeson * * MesonFieldGamma *
******************************************************************************/ ******************************************************************************/
BEGIN_MODULE_NAMESPACE(MContraction) BEGIN_MODULE_NAMESPACE(MContraction)
@ -21,88 +21,98 @@ class MesonFieldPar : Serializable
int, N, int, N,
std::string, A2A1, std::string, A2A1,
std::string, A2A2, std::string, A2A2,
std::string, action, std::string, gammas,
std::string, epack1,
std::string, epack2,
std::string, gamma,
std::string, output); std::string, output);
}; };
template <typename FImpl> template <typename FImpl>
class TMesonFieldGmu : public Module<MesonFieldPar> class TMesonFieldGamma : public Module<MesonFieldPar>
{ {
public: public:
FERM_TYPE_ALIASES(FImpl, ); FERM_TYPE_ALIASES(FImpl, );
SOLVER_TYPE_ALIASES(FImpl, );
typedef A2AModesSchurDiagTwo<typename FImpl::FermionField, FMat> A2ABase; typedef A2AModesSchurDiagTwo<typename FImpl::FermionField, FMat, Solver> A2ABase;
class Result : Serializable class Result : Serializable
{ {
public: public:
GRID_SERIALIZABLE_CLASS_MEMBERS(Result, GRID_SERIALIZABLE_CLASS_MEMBERS(Result,
Gamma::Algebra, gamma_mu, Gamma::Algebra, gamma,
std::vector<std::vector<std::vector<ComplexD>>>, MesonField); std::vector<std::vector<std::vector<ComplexD>>>, MesonField);
}; };
public: public:
// constructor // constructor
TMesonFieldGmu(const std::string name); TMesonFieldGamma(const std::string name);
// destructor // destructor
virtual ~TMesonFieldGmu(void){}; virtual ~TMesonFieldGamma(void){};
// dependency relation // dependency relation
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);
virtual void parseGammaString(std::vector<Gamma::Algebra> &gammaList);
// setup // setup
virtual void setup(void); virtual void setup(void);
// execution // execution
virtual void execute(void); virtual void execute(void);
}; };
MODULE_REGISTER(A2AMeson, ARG(TMesonFieldGmu<FIMPL>), MContraction); MODULE_REGISTER(MesonFieldGamma, ARG(TMesonFieldGamma<FIMPL>), MContraction);
/****************************************************************************** /******************************************************************************
* TMesonFieldGmu implementation * * TMesonFieldGamma implementation *
******************************************************************************/ ******************************************************************************/
// constructor ///////////////////////////////////////////////////////////////// // constructor /////////////////////////////////////////////////////////////////
template <typename FImpl> template <typename FImpl>
TMesonFieldGmu<FImpl>::TMesonFieldGmu(const std::string name) TMesonFieldGamma<FImpl>::TMesonFieldGamma(const std::string name)
: Module<MesonFieldPar>(name) : Module<MesonFieldPar>(name)
{ {
} }
// dependencies/products /////////////////////////////////////////////////////// // dependencies/products ///////////////////////////////////////////////////////
template <typename FImpl> template <typename FImpl>
std::vector<std::string> TMesonFieldGmu<FImpl>::getInput(void) std::vector<std::string> TMesonFieldGamma<FImpl>::getInput(void)
{ {
std::vector<std::string> in = {par().A2A1, par().A2A2, par().action}; std::vector<std::string> in = {par().A2A1 + "_class", par().A2A2 + "_class"};
in.push_back(par().A2A1 + "_ret");
in.push_back(par().A2A2 + "_ret");
int Nl = par().Nl;
if (Nl > 0)
{
in.push_back(par().epack1);
in.push_back(par().epack2);
}
return in; return in;
} }
template <typename FImpl> template <typename FImpl>
std::vector<std::string> TMesonFieldGmu<FImpl>::getOutput(void) std::vector<std::string> TMesonFieldGamma<FImpl>::getOutput(void)
{ {
std::vector<std::string> out = {}; std::vector<std::string> out = {};
return out; return out;
} }
template <typename FImpl>
void TMesonFieldGamma<FImpl>::parseGammaString(std::vector<Gamma::Algebra> &gammaList)
{
gammaList.clear();
// Determine gamma matrices to insert at source/sink.
if (par().gammas.compare("all") == 0)
{
// Do all contractions.
for (unsigned int i = 1; i < Gamma::nGamma; i += 2)
{
gammaList.push_back(((Gamma::Algebra)i));
}
}
else
{
// Parse individual contractions from input string.
gammaList = strToVec<Gamma::Algebra>(par().gammas);
}
}
// setup /////////////////////////////////////////////////////////////////////// // setup ///////////////////////////////////////////////////////////////////////
template <typename FImpl> template <typename FImpl>
void TMesonFieldGmu<FImpl>::setup(void) void TMesonFieldGamma<FImpl>::setup(void)
{ {
int nt = env().getDim(Tp); int nt = env().getDim(Tp);
int N = par().N; int N = par().N;
int Ls_ = env().getObjectLs(par().A2A1 + "_ret"); int Ls_ = env().getObjectLs(par().A2A1 + "_class");
envTmpLat(FermionField, "w", Ls_); envTmpLat(FermionField, "w", Ls_);
envTmpLat(FermionField, "v", Ls_); envTmpLat(FermionField, "v", Ls_);
@ -112,27 +122,37 @@ void TMesonFieldGmu<FImpl>::setup(void)
// execution /////////////////////////////////////////////////////////////////// // execution ///////////////////////////////////////////////////////////////////
template <typename FImpl> template <typename FImpl>
void TMesonFieldGmu<FImpl>::execute(void) void TMesonFieldGamma<FImpl>::execute(void)
{ {
LOG(Message) << "Computing A2A meson field for gamma_mu = " << par().gamma << ", taking w from " << par().A2A1 << " and v from " << par().A2A2 << std::endl; LOG(Message) << "Computing A2A meson field for gamma = " << par().gammas << ", taking w from " << par().A2A1 << " and v from " << par().A2A2 << std::endl;
Result result;
std::istringstream sstr(par().gamma);
Gamma::Algebra g_mu;
sstr >> g_mu;
Gamma gamma_mu(g_mu);
int N = par().N; int N = par().N;
LOG(Message) << "N for A2A cont: " << N << std::endl;
result.gamma_mu = g_mu;
result.MesonField.resize(N);
int nt = env().getDim(Tp); int nt = env().getDim(Tp);
std::vector<Result> result;
std::vector<Gamma::Algebra> gammaResultList;
std::vector<Gamma> gammaList;
parseGammaString(gammaResultList);
result.resize(gammaResultList.size());
Gamma g5(Gamma::Algebra::Gamma5);
gammaList.resize(gammaResultList.size(), g5);
for (unsigned int i = 0; i < result.size(); ++i)
{
result[i].gamma = gammaResultList[i];
result[i].MesonField.resize(N, std::vector<std::vector<ComplexD>>(N, std::vector<ComplexD>(nt)));
Gamma gamma(gammaResultList[i]);
gammaList[i] = gamma;
}
std::vector<ComplexD> MesonField_ij; std::vector<ComplexD> MesonField_ij;
MesonField_ij.resize(nt); MesonField_ij.resize(nt);
auto &a2a1 = envGet(A2ABase, par().A2A1 + "_ret"); auto &a2a1 = envGet(A2ABase, par().A2A1 + "_class");
auto &a2a2 = envGet(A2ABase, par().A2A2 + "_ret"); auto &a2a2 = envGet(A2ABase, par().A2A2 + "_class");
envGetTmp(FermionField, w); envGetTmp(FermionField, w);
envGetTmp(FermionField, v); envGetTmp(FermionField, v);
@ -145,9 +165,12 @@ void TMesonFieldGmu<FImpl>::execute(void)
for (unsigned int j = 0; j < N; j++) for (unsigned int j = 0; j < N; j++)
{ {
a2a2.return_v(j, tmpv_5d, v); a2a2.return_v(j, tmpv_5d, v);
v = gamma_mu*v; for (unsigned int k = 0; k < result.size(); k++)
sliceInnerProductVector(MesonField_ij, w, v, Tp); {
result.MesonField[j][i] = MesonField_ij; v = gammaList[k]*v;
sliceInnerProductVector(MesonField_ij, w, v, Tp);
result[k].MesonField[i][j] = MesonField_ij;
}
} }
if (i % 10 == 0) if (i % 10 == 0)
{ {
@ -162,4 +185,4 @@ END_MODULE_NAMESPACE
END_HADRONS_NAMESPACE END_HADRONS_NAMESPACE
#endif // Hadrons_MContraction_A2AMeson_hpp_ #endif // Hadrons_MContraction_MesonFieldGm_hpp_

View File

@ -1,7 +0,0 @@
#include <Grid/Hadrons/Modules/MContraction/MesonFieldGmu.hpp>
using namespace Grid;
using namespace Hadrons;
using namespace MContraction;
template class Grid::Hadrons::MContraction::TMesonFieldGmu<FIMPL>;