2018-08-07 18:40:48 +01:00
|
|
|
/*************************************************************************************
|
|
|
|
|
|
|
|
Grid physics library, www.github.com/paboyle/Grid
|
|
|
|
|
2018-09-01 21:30:30 +01:00
|
|
|
Source file: Hadrons/Modules/MScalar/VPCounterTerms.cc
|
2018-08-07 18:40:48 +01:00
|
|
|
|
|
|
|
Copyright (C) 2015-2018
|
|
|
|
|
2018-08-14 12:15:24 +01:00
|
|
|
Author: Antonin Portelli <antonin.portelli@me.com>
|
2018-08-07 18:40:48 +01:00
|
|
|
Author: James Harrison <jch1g10@soton.ac.uk>
|
|
|
|
|
|
|
|
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 */
|
2018-08-28 15:00:40 +01:00
|
|
|
#include <Hadrons/Modules/MScalar/VPCounterTerms.hpp>
|
|
|
|
#include <Hadrons/Modules/MScalar/Scalar.hpp>
|
2017-12-13 17:31:01 +00:00
|
|
|
|
|
|
|
using namespace Grid;
|
|
|
|
using namespace Hadrons;
|
|
|
|
using namespace MScalar;
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* TVPCounterTerms implementation *
|
|
|
|
******************************************************************************/
|
|
|
|
// constructor /////////////////////////////////////////////////////////////////
|
|
|
|
TVPCounterTerms::TVPCounterTerms(const std::string name)
|
|
|
|
: Module<VPCounterTermsPar>(name)
|
|
|
|
{}
|
|
|
|
|
|
|
|
// dependencies/products ///////////////////////////////////////////////////////
|
|
|
|
std::vector<std::string> TVPCounterTerms::getInput(void)
|
|
|
|
{
|
|
|
|
std::vector<std::string> in = {par().source};
|
|
|
|
|
|
|
|
return in;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::string> TVPCounterTerms::getOutput(void)
|
|
|
|
{
|
|
|
|
std::vector<std::string> out;
|
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
// setup ///////////////////////////////////////////////////////////////////////
|
|
|
|
void TVPCounterTerms::setup(void)
|
|
|
|
{
|
|
|
|
freeMomPropName_ = FREEMOMPROP(par().mass);
|
|
|
|
phaseName_.clear();
|
|
|
|
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
|
|
|
{
|
|
|
|
phaseName_.push_back("_shiftphase_" + std::to_string(mu));
|
|
|
|
}
|
2018-01-26 16:33:48 +00:00
|
|
|
GFSrcName_ = getName() + "_DinvSrc";
|
|
|
|
phatsqName_ = getName() + "_pHatSquared";
|
2017-12-13 17:31:01 +00:00
|
|
|
prop0Name_ = getName() + "_freeProp";
|
|
|
|
twoscalarName_ = getName() + "_2scalarProp";
|
|
|
|
psquaredName_ = getName() + "_psquaredProp";
|
2018-01-26 16:33:48 +00:00
|
|
|
if (!par().output.empty())
|
|
|
|
{
|
|
|
|
for (unsigned int i_p = 0; i_p < par().outputMom.size(); ++i_p)
|
|
|
|
{
|
|
|
|
momPhaseName_.push_back("_momentumphase_" + std::to_string(i_p));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
envCreateLat(ScalarField, freeMomPropName_);
|
2017-12-13 17:31:01 +00:00
|
|
|
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
|
|
|
{
|
2018-01-26 16:33:48 +00:00
|
|
|
envCreateLat(ScalarField, phaseName_[mu]);
|
|
|
|
}
|
|
|
|
envCreateLat(ScalarField, phatsqName_);
|
|
|
|
envCreateLat(ScalarField, GFSrcName_);
|
|
|
|
envCreateLat(ScalarField, prop0Name_);
|
|
|
|
envCreateLat(ScalarField, twoscalarName_);
|
|
|
|
envCreateLat(ScalarField, psquaredName_);
|
|
|
|
if (!par().output.empty())
|
|
|
|
{
|
|
|
|
for (unsigned int i_p = 0; i_p < par().outputMom.size(); ++i_p)
|
|
|
|
{
|
|
|
|
envCacheLat(ScalarField, momPhaseName_[i_p]);
|
|
|
|
}
|
2017-12-13 17:31:01 +00:00
|
|
|
}
|
2018-01-26 16:33:48 +00:00
|
|
|
envTmpLat(ScalarField, "buf");
|
|
|
|
envTmpLat(ScalarField, "tmp_vp");
|
|
|
|
envTmpLat(ScalarField, "vpPhase");
|
2017-12-13 17:31:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// execution ///////////////////////////////////////////////////////////////////
|
|
|
|
void TVPCounterTerms::execute(void)
|
|
|
|
{
|
2018-01-26 16:33:48 +00:00
|
|
|
auto &source = envGet(ScalarField, par().source);
|
2017-12-13 17:31:01 +00:00
|
|
|
Complex ci(0.0,1.0);
|
|
|
|
FFT fft(env().getGrid());
|
2018-01-26 16:33:48 +00:00
|
|
|
envGetTmp(ScalarField, buf);
|
|
|
|
envGetTmp(ScalarField, tmp_vp);
|
2017-12-13 17:31:01 +00:00
|
|
|
|
|
|
|
// Momentum-space free scalar propagator
|
2018-01-26 16:33:48 +00:00
|
|
|
auto &G = envGet(ScalarField, freeMomPropName_);
|
2017-12-13 17:31:01 +00:00
|
|
|
SIMPL::MomentumSpacePropagator(G, par().mass);
|
|
|
|
|
|
|
|
// Phases and hat{p}^2
|
2018-01-26 16:33:48 +00:00
|
|
|
auto &phatsq = envGet(ScalarField, phatsqName_);
|
2017-12-13 17:31:01 +00:00
|
|
|
std::vector<int> &l = env().getGrid()->_fdimensions;
|
|
|
|
|
|
|
|
LOG(Message) << "Calculating shift phases..." << std::endl;
|
|
|
|
phatsq = zero;
|
|
|
|
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
|
|
|
{
|
|
|
|
Real twoPiL = M_PI*2./l[mu];
|
2018-01-26 16:33:48 +00:00
|
|
|
auto &phmu = envGet(ScalarField, phaseName_[mu]);
|
|
|
|
|
2017-12-13 17:31:01 +00:00
|
|
|
LatticeCoordinate(buf, mu);
|
2018-01-26 16:33:48 +00:00
|
|
|
phmu = exp(ci*twoPiL*buf);
|
|
|
|
phase_.push_back(&phmu);
|
2017-12-13 17:31:01 +00:00
|
|
|
buf = 2.*sin(.5*twoPiL*buf);
|
|
|
|
phatsq = phatsq + buf*buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
// G*F*src
|
2018-01-26 16:33:48 +00:00
|
|
|
auto &GFSrc = envGet(ScalarField, GFSrcName_);
|
2017-12-13 17:31:01 +00:00
|
|
|
fft.FFT_all_dim(GFSrc, source, FFT::forward);
|
|
|
|
GFSrc = G*GFSrc;
|
|
|
|
|
|
|
|
// Position-space free scalar propagator
|
2018-01-26 16:33:48 +00:00
|
|
|
auto &prop0 = envGet(ScalarField, prop0Name_);
|
2017-12-13 17:31:01 +00:00
|
|
|
prop0 = GFSrc;
|
|
|
|
fft.FFT_all_dim(prop0, prop0, FFT::backward);
|
|
|
|
|
|
|
|
// Propagators for counter-terms
|
2018-01-26 16:33:48 +00:00
|
|
|
auto &twoscalarProp = envGet(ScalarField, twoscalarName_);
|
|
|
|
auto &psquaredProp = envGet(ScalarField, psquaredName_);
|
2017-12-13 17:31:01 +00:00
|
|
|
|
|
|
|
twoscalarProp = G*GFSrc;
|
|
|
|
fft.FFT_all_dim(twoscalarProp, twoscalarProp, FFT::backward);
|
|
|
|
|
|
|
|
psquaredProp = G*phatsq*GFSrc;
|
|
|
|
fft.FFT_all_dim(psquaredProp, psquaredProp, FFT::backward);
|
|
|
|
|
2018-02-08 20:40:45 +00:00
|
|
|
// Prepare output data structure if necessary
|
|
|
|
Result outputData;
|
2017-12-13 17:31:01 +00:00
|
|
|
if (!par().output.empty())
|
|
|
|
{
|
2018-02-08 20:40:45 +00:00
|
|
|
outputData.projection.resize(par().outputMom.size());
|
|
|
|
outputData.lattice_size = env().getGrid()->_fdimensions;
|
|
|
|
outputData.mass = par().mass;
|
2017-12-13 17:31:01 +00:00
|
|
|
for (unsigned int i_p = 0; i_p < par().outputMom.size(); ++i_p)
|
|
|
|
{
|
2018-02-08 20:40:45 +00:00
|
|
|
outputData.projection[i_p].momentum = strToVec<int>(par().outputMom[i_p]);
|
|
|
|
outputData.projection[i_p].twoScalar.resize(env().getNd());
|
|
|
|
outputData.projection[i_p].threeScalar.resize(env().getNd());
|
|
|
|
outputData.projection[i_p].pSquaredInsertion.resize(env().getNd());
|
|
|
|
for (unsigned int nu = 0; nu < env().getNd(); ++nu)
|
|
|
|
{
|
|
|
|
outputData.projection[i_p].twoScalar[nu].resize(env().getNd());
|
|
|
|
outputData.projection[i_p].threeScalar[nu].resize(env().getNd());
|
|
|
|
outputData.projection[i_p].pSquaredInsertion[nu].resize(env().getNd());
|
|
|
|
}
|
2017-12-13 17:31:01 +00:00
|
|
|
// Calculate phase factors
|
2018-01-26 16:33:48 +00:00
|
|
|
auto &momph_ip = envGet(ScalarField, momPhaseName_[i_p]);
|
2018-02-08 20:40:45 +00:00
|
|
|
momph_ip = zero;
|
2017-12-13 17:31:01 +00:00
|
|
|
for (unsigned int j = 0; j < env().getNd()-1; ++j)
|
|
|
|
{
|
2018-02-08 20:40:45 +00:00
|
|
|
Real twoPiL = M_PI*2./l[j];
|
|
|
|
LatticeCoordinate(buf, j);
|
|
|
|
buf = outputData.projection[i_p].momentum[j]*twoPiL*buf;
|
|
|
|
momph_ip = momph_ip + buf;
|
2017-12-13 17:31:01 +00:00
|
|
|
}
|
2018-02-08 20:40:45 +00:00
|
|
|
momph_ip = exp(-ci*momph_ip);
|
2018-01-26 16:33:48 +00:00
|
|
|
momPhase_.push_back(&momph_ip);
|
2017-12-13 17:31:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Contractions
|
|
|
|
for (unsigned int nu = 0; nu < env().getNd(); ++nu)
|
|
|
|
{
|
|
|
|
buf = adj(Cshift(prop0, nu, -1));
|
|
|
|
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
|
|
|
{
|
2018-02-08 20:40:45 +00:00
|
|
|
// Two-scalar loop
|
|
|
|
tmp_vp = buf * Cshift(prop0, mu, 1);
|
|
|
|
tmp_vp -= Cshift(buf, mu, 1) * prop0;
|
2017-12-13 17:31:01 +00:00
|
|
|
tmp_vp = 2.0*real(tmp_vp);
|
|
|
|
// Output if necessary
|
|
|
|
if (!par().output.empty())
|
|
|
|
{
|
2018-02-08 20:40:45 +00:00
|
|
|
for (unsigned int i_p = 0; i_p < par().outputMom.size(); ++i_p)
|
|
|
|
{
|
|
|
|
project(outputData.projection[i_p].twoScalar[mu][nu],
|
|
|
|
tmp_vp, i_p);
|
|
|
|
}
|
2017-12-13 17:31:01 +00:00
|
|
|
}
|
|
|
|
|
2018-02-08 20:40:45 +00:00
|
|
|
// Three-scalar loop (no vertex)
|
|
|
|
tmp_vp = buf * Cshift(twoscalarProp, mu, 1);
|
|
|
|
tmp_vp -= Cshift(buf, mu, 1) * twoscalarProp;
|
2017-12-13 17:31:01 +00:00
|
|
|
tmp_vp = 2.0*real(tmp_vp);
|
|
|
|
// Output if necessary
|
|
|
|
if (!par().output.empty())
|
|
|
|
{
|
2018-02-08 20:40:45 +00:00
|
|
|
for (unsigned int i_p = 0; i_p < par().outputMom.size(); ++i_p)
|
|
|
|
{
|
|
|
|
project(outputData.projection[i_p].threeScalar[mu][nu],
|
|
|
|
tmp_vp, i_p);
|
|
|
|
}
|
2017-12-13 17:31:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Three-scalar loop (hat{p}^2 insertion)
|
|
|
|
tmp_vp = buf * Cshift(psquaredProp, mu, 1);
|
|
|
|
tmp_vp -= Cshift(buf, mu, 1) * psquaredProp;
|
|
|
|
tmp_vp = 2.0*real(tmp_vp);
|
|
|
|
// Output if necessary
|
|
|
|
if (!par().output.empty())
|
|
|
|
{
|
2018-02-08 20:40:45 +00:00
|
|
|
for (unsigned int i_p = 0; i_p < par().outputMom.size(); ++i_p)
|
|
|
|
{
|
|
|
|
project(outputData.projection[i_p].pSquaredInsertion[mu][nu],
|
|
|
|
tmp_vp, i_p);
|
|
|
|
}
|
2017-12-13 17:31:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-02-08 20:40:45 +00:00
|
|
|
|
|
|
|
// OUTPUT IF NECESSARY
|
|
|
|
if (!par().output.empty())
|
|
|
|
{
|
|
|
|
LOG(Message) << "Saving momentum-projected correlators to '"
|
2018-11-19 15:45:04 +00:00
|
|
|
<< RESULT_FILE_NAME(par().output, vm().getTrajectory()) << "'..."
|
2018-02-08 20:40:45 +00:00
|
|
|
<< std::endl;
|
|
|
|
saveResult(par().output, "scalar_loops", outputData);
|
|
|
|
}
|
2018-01-26 16:33:48 +00:00
|
|
|
}
|
2017-12-13 17:31:01 +00:00
|
|
|
|
2018-02-08 20:40:45 +00:00
|
|
|
void TVPCounterTerms::project(std::vector<Complex> &projection, const ScalarField &vp, int i_p)
|
2018-01-26 16:33:48 +00:00
|
|
|
{
|
|
|
|
std::vector<TComplex> vecBuf;
|
|
|
|
envGetTmp(ScalarField, vpPhase);
|
|
|
|
|
2018-02-08 20:40:45 +00:00
|
|
|
vpPhase = vp*(*momPhase_[i_p]);
|
|
|
|
sliceSum(vpPhase, vecBuf, Tp);
|
|
|
|
projection.resize(vecBuf.size());
|
|
|
|
for (unsigned int t = 0; t < vecBuf.size(); ++t)
|
2017-12-13 17:31:01 +00:00
|
|
|
{
|
2018-02-08 20:40:45 +00:00
|
|
|
projection[t] = TensorRemove(vecBuf[t]);
|
2017-12-13 17:31:01 +00:00
|
|
|
}
|
|
|
|
}
|