2018-01-10 22:10:58 +00:00
|
|
|
/*************************************************************************************
|
|
|
|
|
|
|
|
Grid physics library, www.github.com/paboyle/Grid
|
|
|
|
|
2018-09-01 21:30:30 +01:00
|
|
|
Source file: Hadrons/Modules/MScalarSUN/TwoPoint.hpp
|
2018-01-10 22:10:58 +00:00
|
|
|
|
2019-02-05 18:55:24 +00:00
|
|
|
Copyright (C) 2015-2019
|
2018-01-10 22:10:58 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
*************************************************************************************/
|
|
|
|
/* END LEGAL */
|
|
|
|
#ifndef Hadrons_MScalarSUN_TwoPoint_hpp_
|
|
|
|
#define Hadrons_MScalarSUN_TwoPoint_hpp_
|
|
|
|
|
2018-08-28 15:00:40 +01:00
|
|
|
#include <Hadrons/Global.hpp>
|
|
|
|
#include <Hadrons/Module.hpp>
|
|
|
|
#include <Hadrons/ModuleFactory.hpp>
|
|
|
|
#include <Hadrons/Modules/MScalarSUN/Utils.hpp>
|
2018-01-10 22:10:58 +00:00
|
|
|
|
|
|
|
BEGIN_HADRONS_NAMESPACE
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* 2-pt functions for a given set of operators *
|
|
|
|
******************************************************************************/
|
|
|
|
BEGIN_MODULE_NAMESPACE(MScalarSUN)
|
|
|
|
|
|
|
|
class TwoPointPar: Serializable
|
|
|
|
{
|
|
|
|
public:
|
2018-04-24 19:52:12 +01:00
|
|
|
typedef std::pair<std::string, std::string> OpPair;
|
2018-01-10 22:10:58 +00:00
|
|
|
GRID_SERIALIZABLE_CLASS_MEMBERS(TwoPointPar,
|
2018-04-24 19:52:12 +01:00
|
|
|
std::vector<OpPair>, op,
|
2018-04-13 17:21:00 +01:00
|
|
|
std::vector<std::string>, mom,
|
2018-01-10 22:10:58 +00:00
|
|
|
std::string, output);
|
|
|
|
};
|
|
|
|
|
2018-04-26 17:32:37 +01:00
|
|
|
class TwoPointResult: Serializable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GRID_SERIALIZABLE_CLASS_MEMBERS(TwoPointResult,
|
|
|
|
std::string, sink,
|
|
|
|
std::string, source,
|
|
|
|
std::vector<int>, mom,
|
|
|
|
std::vector<Complex>, data);
|
|
|
|
};
|
|
|
|
|
2018-01-10 22:10:58 +00:00
|
|
|
template <typename SImpl>
|
|
|
|
class TTwoPoint: public Module<TwoPointPar>
|
|
|
|
{
|
|
|
|
public:
|
2018-05-01 14:02:31 +01:00
|
|
|
typedef typename SImpl::Field Field;
|
|
|
|
typedef typename SImpl::ComplexField ComplexField;
|
|
|
|
typedef std::vector<Complex> SlicedOp;
|
2018-01-10 22:10:58 +00:00
|
|
|
public:
|
|
|
|
// constructor
|
|
|
|
TTwoPoint(const std::string name);
|
|
|
|
// destructor
|
2018-04-24 17:20:25 +01:00
|
|
|
virtual ~TTwoPoint(void) {};
|
2018-01-10 22:10:58 +00:00
|
|
|
// dependency relation
|
|
|
|
virtual std::vector<std::string> getInput(void);
|
|
|
|
virtual std::vector<std::string> getOutput(void);
|
|
|
|
// setup
|
|
|
|
virtual void setup(void);
|
|
|
|
// execution
|
|
|
|
virtual void execute(void);
|
2018-04-13 17:21:00 +01:00
|
|
|
private:
|
|
|
|
std::vector<std::vector<int>> mom_;
|
2018-01-10 22:10:58 +00:00
|
|
|
};
|
|
|
|
|
2018-04-23 17:35:01 +01:00
|
|
|
MODULE_REGISTER_TMP(TwoPointSU2, TTwoPoint<ScalarNxNAdjImplR<2>>, MScalarSUN);
|
|
|
|
MODULE_REGISTER_TMP(TwoPointSU3, TTwoPoint<ScalarNxNAdjImplR<3>>, MScalarSUN);
|
|
|
|
MODULE_REGISTER_TMP(TwoPointSU4, TTwoPoint<ScalarNxNAdjImplR<4>>, MScalarSUN);
|
|
|
|
MODULE_REGISTER_TMP(TwoPointSU5, TTwoPoint<ScalarNxNAdjImplR<5>>, MScalarSUN);
|
|
|
|
MODULE_REGISTER_TMP(TwoPointSU6, TTwoPoint<ScalarNxNAdjImplR<6>>, MScalarSUN);
|
2018-01-10 22:10:58 +00:00
|
|
|
|
|
|
|
/******************************************************************************
|
2018-03-02 14:29:54 +00:00
|
|
|
* TTwoPoint implementation *
|
2018-01-10 22:10:58 +00:00
|
|
|
******************************************************************************/
|
|
|
|
// constructor /////////////////////////////////////////////////////////////////
|
|
|
|
template <typename SImpl>
|
|
|
|
TTwoPoint<SImpl>::TTwoPoint(const std::string name)
|
|
|
|
: Module<TwoPointPar>(name)
|
|
|
|
{}
|
|
|
|
|
|
|
|
// dependencies/products ///////////////////////////////////////////////////////
|
|
|
|
template <typename SImpl>
|
|
|
|
std::vector<std::string> TTwoPoint<SImpl>::getInput(void)
|
|
|
|
{
|
2018-04-24 19:52:12 +01:00
|
|
|
std::vector<std::string> in;
|
|
|
|
std::set<std::string> ops;
|
|
|
|
|
|
|
|
for (auto &p: par().op)
|
|
|
|
{
|
|
|
|
ops.insert(p.first);
|
|
|
|
ops.insert(p.second);
|
|
|
|
}
|
|
|
|
for (auto &o: ops)
|
|
|
|
{
|
|
|
|
in.push_back(o);
|
|
|
|
}
|
|
|
|
|
|
|
|
return in;
|
2018-01-10 22:10:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename SImpl>
|
|
|
|
std::vector<std::string> TTwoPoint<SImpl>::getOutput(void)
|
|
|
|
{
|
|
|
|
std::vector<std::string> out = {};
|
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
// setup ///////////////////////////////////////////////////////////////////////
|
|
|
|
template <typename SImpl>
|
|
|
|
void TTwoPoint<SImpl>::setup(void)
|
|
|
|
{
|
2018-04-13 17:21:00 +01:00
|
|
|
const unsigned int nd = env().getDim().size();
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2018-04-25 16:49:14 +01:00
|
|
|
HADRONS_ERROR(Size, "momentum number of components different from "
|
2018-04-13 17:21:00 +01:00
|
|
|
+ std::to_string(nd-1));
|
|
|
|
}
|
2018-09-04 18:24:07 +01:00
|
|
|
for (unsigned int j = 0; j < nd - 1; ++j)
|
|
|
|
{
|
|
|
|
mom_[i][j] = (mom_[i][j] + env().getDim(j)) % env().getDim(j);
|
|
|
|
}
|
2018-04-13 17:21:00 +01:00
|
|
|
}
|
|
|
|
envTmpLat(ComplexField, "ftBuf");
|
2018-01-10 22:10:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// execution ///////////////////////////////////////////////////////////////////
|
|
|
|
template <typename SImpl>
|
|
|
|
void TTwoPoint<SImpl>::execute(void)
|
|
|
|
{
|
2018-04-24 19:52:12 +01:00
|
|
|
LOG(Message) << "Computing 2-point functions" << std::endl;
|
|
|
|
for (auto &p: par().op)
|
2018-01-10 22:10:58 +00:00
|
|
|
{
|
2018-04-24 19:52:12 +01:00
|
|
|
LOG(Message) << " <" << p.first << " " << p.second << ">" << std::endl;
|
2018-01-10 22:10:58 +00:00
|
|
|
}
|
|
|
|
|
2018-05-01 14:02:31 +01:00
|
|
|
const unsigned int nd = env().getNd();
|
|
|
|
const unsigned int nt = env().getDim().back();
|
|
|
|
const unsigned int nop = par().op.size();
|
|
|
|
const unsigned int nmom = mom_.size();
|
|
|
|
double partVol = 1.;
|
2018-04-24 19:52:12 +01:00
|
|
|
std::vector<int> dMask(nd, 1);
|
|
|
|
std::set<std::string> ops;
|
2018-04-26 17:32:37 +01:00
|
|
|
std::vector<TwoPointResult> result;
|
2018-04-24 19:52:12 +01:00
|
|
|
std::map<std::string, std::vector<SlicedOp>> slicedOp;
|
2018-09-29 17:55:19 +01:00
|
|
|
FFT fft(envGetGrid(Field));
|
2018-05-01 14:02:31 +01:00
|
|
|
TComplex buf;
|
2018-04-13 17:21:00 +01:00
|
|
|
|
|
|
|
envGetTmp(ComplexField, ftBuf);
|
|
|
|
dMask[nd - 1] = 0;
|
2018-05-01 14:02:31 +01:00
|
|
|
for (unsigned int mu = 0; mu < nd - 1; ++mu)
|
|
|
|
{
|
|
|
|
partVol *= env().getDim()[mu];
|
|
|
|
}
|
2018-04-24 19:52:12 +01:00
|
|
|
for (auto &p: par().op)
|
|
|
|
{
|
|
|
|
ops.insert(p.first);
|
|
|
|
ops.insert(p.second);
|
|
|
|
}
|
|
|
|
for (auto &o: ops)
|
2018-01-10 22:10:58 +00:00
|
|
|
{
|
2018-04-24 19:52:12 +01:00
|
|
|
auto &op = envGet(ComplexField, o);
|
2018-01-10 22:10:58 +00:00
|
|
|
|
2018-04-24 19:52:12 +01:00
|
|
|
slicedOp[o].resize(nmom);
|
|
|
|
LOG(Message) << "Operator '" << o << "' FFT" << std::endl;
|
2018-05-01 14:02:31 +01:00
|
|
|
fft.FFT_dim_mask(ftBuf, op, dMask, FFT::forward);
|
2018-04-13 17:21:00 +01:00
|
|
|
for (unsigned int m = 0; m < nmom; ++m)
|
|
|
|
{
|
|
|
|
auto qt = mom_[m];
|
|
|
|
|
|
|
|
qt.resize(nd);
|
2018-04-24 19:52:12 +01:00
|
|
|
slicedOp[o][m].resize(nt);
|
2018-04-13 17:21:00 +01:00
|
|
|
for (unsigned int t = 0; t < nt; ++t)
|
|
|
|
{
|
|
|
|
qt[nd - 1] = t;
|
2018-05-01 14:02:31 +01:00
|
|
|
peekSite(buf, ftBuf, qt);
|
2018-05-03 16:19:17 +01:00
|
|
|
slicedOp[o][m][t] = TensorRemove(buf);
|
2018-04-13 17:21:00 +01:00
|
|
|
}
|
|
|
|
}
|
2018-01-10 22:10:58 +00:00
|
|
|
}
|
2018-04-13 17:21:00 +01:00
|
|
|
LOG(Message) << "Making contractions" << std::endl;
|
|
|
|
for (unsigned int m = 0; m < nmom; ++m)
|
2018-04-24 19:52:12 +01:00
|
|
|
for (auto &p: par().op)
|
2018-01-10 22:10:58 +00:00
|
|
|
{
|
2018-04-26 17:32:37 +01:00
|
|
|
TwoPointResult r;
|
2018-01-10 22:10:58 +00:00
|
|
|
|
2018-04-24 19:52:12 +01:00
|
|
|
r.sink = p.first;
|
|
|
|
r.source = p.second;
|
2018-04-13 17:21:00 +01:00
|
|
|
r.mom = mom_[m];
|
2018-05-03 16:19:17 +01:00
|
|
|
r.data = makeTwoPoint(slicedOp[p.first][m], slicedOp[p.second][m],
|
|
|
|
1./partVol);
|
2018-01-10 22:10:58 +00:00
|
|
|
result.push_back(r);
|
|
|
|
}
|
2018-01-23 17:26:50 +00:00
|
|
|
saveResult(par().output, "twopt", result);
|
2018-01-10 22:10:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
END_MODULE_NAMESPACE
|
|
|
|
|
|
|
|
END_HADRONS_NAMESPACE
|
|
|
|
|
|
|
|
#endif // Hadrons_MScalarSUN_TwoPoint_hpp_
|