1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-14 01:35:36 +00:00

Hadrons: scalar SU(N) 2-pt functions with momentum

This commit is contained in:
Antonin Portelli 2018-04-13 18:21:00 +02:00
parent 17f57e85d1
commit 4573b34cac

View File

@ -45,6 +45,7 @@ class TwoPointPar: Serializable
public: public:
GRID_SERIALIZABLE_CLASS_MEMBERS(TwoPointPar, GRID_SERIALIZABLE_CLASS_MEMBERS(TwoPointPar,
std::vector<std::string>, op, std::vector<std::string>, op,
std::vector<std::string>, mom,
std::string, output); std::string, output);
}; };
@ -54,12 +55,15 @@ class TTwoPoint: public Module<TwoPointPar>
public: public:
typedef typename SImpl::Field Field; typedef typename SImpl::Field Field;
typedef typename SImpl::ComplexField ComplexField; typedef typename SImpl::ComplexField ComplexField;
typedef std::vector<TComplex> SlicedOp;
class Result: Serializable class Result: Serializable
{ {
public: public:
GRID_SERIALIZABLE_CLASS_MEMBERS(Result, GRID_SERIALIZABLE_CLASS_MEMBERS(Result,
std::string, sink, std::string, sink,
std::string, source, std::string, source,
std::vector<int>, mom,
std::vector<Complex>, data); std::vector<Complex>, data);
}; };
public: public:
@ -79,6 +83,8 @@ private:
template <class SinkSite, class SourceSite> template <class SinkSite, class SourceSite>
std::vector<Complex> makeTwoPoint(const std::vector<SinkSite> &sink, std::vector<Complex> makeTwoPoint(const std::vector<SinkSite> &sink,
const std::vector<SourceSite> &source); const std::vector<SourceSite> &source);
private:
std::vector<std::vector<int>> mom_;
}; };
MODULE_REGISTER_NS(TwoPointSU2, TTwoPoint<ScalarNxNAdjImplR<2>>, MScalarSUN); MODULE_REGISTER_NS(TwoPointSU2, TTwoPoint<ScalarNxNAdjImplR<2>>, MScalarSUN);
@ -115,9 +121,19 @@ std::vector<std::string> TTwoPoint<SImpl>::getOutput(void)
template <typename SImpl> template <typename SImpl>
void TTwoPoint<SImpl>::setup(void) void TTwoPoint<SImpl>::setup(void)
{ {
const unsigned int nt = env().getDim().back(); const unsigned int nd = env().getDim().size();
envTmp(std::vector<std::vector<TComplex>>, "slicedOp", 1, par().op.size(),
std::vector<TComplex>(nt)); mom_.resize(par().mom.size());
for (unsigned int i = 0; i < mom_.size(); ++i)
{
mom_[i] = strToVec<int>(par().mom[i]);
if (mom_[i].size() != nd - 1)
{
HADRON_ERROR(Size, "momentum number of components different from "
+ std::to_string(nd-1));
}
}
envTmpLat(ComplexField, "ftBuf");
} }
// execution /////////////////////////////////////////////////////////////////// // execution ///////////////////////////////////////////////////////////////////
@ -131,23 +147,47 @@ void TTwoPoint<SImpl>::execute(void)
} }
const unsigned int nd = env().getDim().size(); const unsigned int nd = env().getDim().size();
const unsigned int nt = env().getDim().back();
const unsigned int nop = par().op.size();
const unsigned int nmom = mom_.size();
std::vector<int> dMask(nd, 1);
std::vector<Result> result; std::vector<Result> result;
std::vector<std::vector<SlicedOp>> slicedOp(nop);
FFT fft(env().getGrid());
envGetTmp(std::vector<std::vector<TComplex>>, slicedOp); envGetTmp(ComplexField, ftBuf);
for (unsigned int i = 0; i < par().op.size(); ++i) dMask[nd - 1] = 0;
for (unsigned int i = 0; i < nop; ++i)
{ {
auto &op = envGet(ComplexField, par().op[i]); auto &op = envGet(ComplexField, par().op[i]);
sliceSum(op, slicedOp[i], nd - 1); slicedOp[i].resize(nmom);
LOG(Message) << "Operator '" << par().op[i] << "' FFT" << std::endl;
fft.FFT_dim_mask(ftBuf, op, dMask, FFT::forward);
for (unsigned int m = 0; m < nmom; ++m)
{
auto qt = mom_[m];
qt.resize(nd);
slicedOp[i][m].resize(nt);
for (unsigned int t = 0; t < nt; ++t)
{
qt[nd - 1] = t;
peekSite(slicedOp[i][m][t], ftBuf, qt);
} }
for (unsigned int i = 0; i < par().op.size(); ++i) }
for (unsigned int j = 0; j < par().op.size(); ++j) }
LOG(Message) << "Making contractions" << std::endl;
for (unsigned int m = 0; m < nmom; ++m)
for (unsigned int i = 0; i < nop; ++i)
for (unsigned int j = 0; j < nop; ++j)
{ {
Result r; Result r;
r.sink = par().op[i]; r.sink = par().op[i];
r.source = par().op[j]; r.source = par().op[j];
r.data = makeTwoPoint(slicedOp[i], slicedOp[j]); r.mom = mom_[m];
r.data = makeTwoPoint(slicedOp[i][m], slicedOp[j][m]);
result.push_back(r); result.push_back(r);
} }
saveResult(par().output, "twopt", result); saveResult(par().output, "twopt", result);
@ -169,7 +209,7 @@ std::vector<Complex> TTwoPoint<SImpl>::makeTwoPoint(
{ {
for (unsigned int t = 0; t < nt; ++t) for (unsigned int t = 0; t < nt; ++t)
{ {
res[dt] += TensorRemove(trace(sink[(t+dt)%nt]*source[t])); res[dt] += TensorRemove(trace(sink[(t+dt)%nt]*adj(source[t])));
} }
res[dt] *= 1./static_cast<double>(nt); res[dt] *= 1./static_cast<double>(nt);
} }