1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-06-16 06:47:06 +01:00

Hadrons: templatisation of the fermion implementation

This commit is contained in:
2016-12-05 16:47:29 +09:00
parent 7ae734103e
commit d1f7c6b94e
18 changed files with 483 additions and 638 deletions

View File

@ -1,7 +1,7 @@
/*******************************************************************************
Grid physics library, www.github.com/paboyle/Grid
Source file: programs/Hadrons/Meson.hpp
Source file: programs/Hadrons/TMeson.hpp
Copyright (C) 2015
@ -35,7 +35,7 @@ directory.
BEGIN_HADRONS_NAMESPACE
/******************************************************************************
* Meson *
* TMeson *
******************************************************************************/
BEGIN_MODULE_NAMESPACE(MContraction)
@ -48,8 +48,12 @@ public:
std::string, output);
};
class Meson: public Module<MesonPar>
template <typename FImpl1, typename FImpl2>
class TMeson: public Module<MesonPar>
{
public:
TYPE_ALIASES(FImpl1, 1);
TYPE_ALIASES(FImpl2, 2);
public:
class Result: Serializable
{
@ -59,9 +63,9 @@ public:
};
public:
// constructor
Meson(const std::string name);
TMeson(const std::string name);
// destructor
virtual ~Meson(void) = default;
virtual ~TMeson(void) = default;
// dependencies/products
virtual std::vector<std::string> getInput(void);
virtual std::vector<std::string> getOutput(void);
@ -69,6 +73,73 @@ public:
virtual void execute(void);
};
/******************************************************************************
* TMeson implementation *
******************************************************************************/
// constructor /////////////////////////////////////////////////////////////////
template <typename FImpl1, typename FImpl2>
TMeson<FImpl1, FImpl2>::TMeson(const std::string name)
: Module<MesonPar>(name)
{}
// dependencies/products ///////////////////////////////////////////////////////
template <typename FImpl1, typename FImpl2>
std::vector<std::string> TMeson<FImpl1, FImpl2>::getInput(void)
{
std::vector<std::string> input = {par().q1, par().q2};
return input;
}
template <typename FImpl1, typename FImpl2>
std::vector<std::string> TMeson<FImpl1, FImpl2>::getOutput(void)
{
std::vector<std::string> output = {getName()};
return output;
}
// execution ///////////////////////////////////////////////////////////////////
template <typename FImpl1, typename FImpl2>
void TMeson<FImpl1, FImpl2>::execute(void)
{
LOG(Message) << "Computing meson contraction '" << getName() << "' using"
<< " quarks '" << par().q1 << "' and '" << par().q2 << "'"
<< std::endl;
XmlWriter writer(par().output);
PropagatorField1 &q1 = *env().template getObject<PropagatorField1>(par().q1);
PropagatorField2 &q2 = *env().template getObject<PropagatorField2>(par().q2);
LatticeComplex c(env().getGrid());
SpinMatrix g[Ns*Ns], g5;
std::vector<TComplex> buf;
Result result;
g5 = makeGammaProd(Ns*Ns - 1);
result.corr.resize(Ns*Ns);
for (unsigned int i = 0; i < Ns*Ns; ++i)
{
g[i] = makeGammaProd(i);
}
for (unsigned int iSink = 0; iSink < Ns*Ns; ++iSink)
{
result.corr[iSink].resize(Ns*Ns);
for (unsigned int iSrc = 0; iSrc < Ns*Ns; ++iSrc)
{
c = trace(g[iSink]*q1*g[iSrc]*g5*adj(q2)*g5);
sliceSum(c, buf, Tp);
result.corr[iSink][iSrc].resize(buf.size());
for (unsigned int t = 0; t < buf.size(); ++t)
{
result.corr[iSink][iSrc][t] = TensorRemove(buf[t]);
}
}
}
write(writer, "meson", result);
}
typedef TMeson<FIMPL, FIMPL> Meson;
END_MODULE_NAMESPACE
MODULE_REGISTER_NS(Meson, MContraction);