2017-12-26 13:16:47 +00:00
|
|
|
/*************************************************************************************
|
|
|
|
|
|
|
|
Grid physics library, www.github.com/paboyle/Grid
|
|
|
|
|
|
|
|
Source file: extras/Hadrons/Modules/MScalar/ChargedProp.cc
|
|
|
|
|
|
|
|
Copyright (C) 2015-2018
|
|
|
|
|
|
|
|
Author: Antonin Portelli <antonin.portelli@me.com>
|
|
|
|
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 */
|
2016-12-29 21:44:58 +00:00
|
|
|
#include <Grid/Hadrons/Modules/MScalar/ChargedProp.hpp>
|
2017-01-11 18:40:43 +00:00
|
|
|
#include <Grid/Hadrons/Modules/MScalar/Scalar.hpp>
|
2016-12-29 21:44:58 +00:00
|
|
|
|
|
|
|
using namespace Grid;
|
|
|
|
using namespace Hadrons;
|
|
|
|
using namespace MScalar;
|
|
|
|
|
|
|
|
/******************************************************************************
|
2017-01-12 18:17:44 +00:00
|
|
|
* TChargedProp implementation *
|
2016-12-29 21:44:58 +00:00
|
|
|
******************************************************************************/
|
|
|
|
// constructor /////////////////////////////////////////////////////////////////
|
|
|
|
TChargedProp::TChargedProp(const std::string name)
|
|
|
|
: Module<ChargedPropPar>(name)
|
|
|
|
{}
|
|
|
|
|
|
|
|
// dependencies/products ///////////////////////////////////////////////////////
|
|
|
|
std::vector<std::string> TChargedProp::getInput(void)
|
|
|
|
{
|
2017-01-11 18:40:43 +00:00
|
|
|
std::vector<std::string> in = {par().source, par().emField};
|
2016-12-29 21:44:58 +00:00
|
|
|
|
|
|
|
return in;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::string> TChargedProp::getOutput(void)
|
|
|
|
{
|
2018-01-24 16:41:44 +00:00
|
|
|
std::vector<std::string> out = {getName(), getName()+"_0", getName()+"_Q",
|
2017-06-08 17:43:39 +01:00
|
|
|
getName()+"_Sun", getName()+"_Tad"};
|
2016-12-29 21:44:58 +00:00
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
// setup ///////////////////////////////////////////////////////////////////////
|
|
|
|
void TChargedProp::setup(void)
|
|
|
|
{
|
2017-01-11 18:40:43 +00:00
|
|
|
freeMomPropName_ = FREEMOMPROP(par().mass);
|
2017-01-12 20:44:23 +00:00
|
|
|
phaseName_.clear();
|
2017-01-11 18:40:43 +00:00
|
|
|
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
|
|
|
{
|
2017-01-13 13:30:56 +00:00
|
|
|
phaseName_.push_back("_shiftphase_" + std::to_string(mu));
|
2017-01-11 18:40:43 +00:00
|
|
|
}
|
2017-12-21 11:39:07 +00:00
|
|
|
GFSrcName_ = getName() + "_DinvSrc";
|
2018-01-24 16:41:44 +00:00
|
|
|
prop0Name_ = getName() + "_0";
|
2017-06-08 17:43:39 +01:00
|
|
|
propQName_ = getName() + "_Q";
|
|
|
|
propSunName_ = getName() + "_Sun";
|
|
|
|
propTadName_ = getName() + "_Tad";
|
2017-12-21 11:39:07 +00:00
|
|
|
fftName_ = getName() + "_fft";
|
|
|
|
|
|
|
|
freeMomPropDone_ = env().hasCreatedObject(freeMomPropName_);
|
|
|
|
GFSrcDone_ = env().hasCreatedObject(GFSrcName_);
|
|
|
|
phasesDone_ = env().hasCreatedObject(phaseName_[0]);
|
2018-01-24 16:41:44 +00:00
|
|
|
prop0Done_ = env().hasCreatedObject(prop0Name_);
|
2017-12-21 11:39:07 +00:00
|
|
|
envCacheLat(ScalarField, freeMomPropName_);
|
|
|
|
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
2017-03-24 17:13:55 +00:00
|
|
|
{
|
2017-12-21 11:39:07 +00:00
|
|
|
envCacheLat(ScalarField, phaseName_[mu]);
|
2017-03-24 17:13:55 +00:00
|
|
|
}
|
2017-12-21 11:39:07 +00:00
|
|
|
envCacheLat(ScalarField, GFSrcName_);
|
2018-01-24 16:41:44 +00:00
|
|
|
envCacheLat(ScalarField, prop0Name_);
|
2017-12-21 11:39:07 +00:00
|
|
|
envCreateLat(ScalarField, getName());
|
2018-01-24 16:41:44 +00:00
|
|
|
envCreateLat(ScalarField, propQName_);
|
|
|
|
envCreateLat(ScalarField, propSunName_);
|
|
|
|
envCreateLat(ScalarField, propTadName_);
|
2017-12-21 11:39:07 +00:00
|
|
|
envTmpLat(ScalarField, "buf");
|
|
|
|
envTmpLat(ScalarField, "result");
|
|
|
|
envTmpLat(ScalarField, "Amu");
|
|
|
|
envCache(FFT, fftName_, 1, env().getGrid());
|
2016-12-29 21:44:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// execution ///////////////////////////////////////////////////////////////////
|
|
|
|
void TChargedProp::execute(void)
|
|
|
|
{
|
2017-01-12 20:44:23 +00:00
|
|
|
// CACHING ANALYTIC EXPRESSIONS
|
2017-12-21 11:39:07 +00:00
|
|
|
makeCaches();
|
2017-01-13 13:30:56 +00:00
|
|
|
|
2017-01-12 20:44:23 +00:00
|
|
|
// PROPAGATOR CALCULATION
|
2017-01-13 13:30:56 +00:00
|
|
|
LOG(Message) << "Computing charged scalar propagator"
|
|
|
|
<< " (mass= " << par().mass
|
|
|
|
<< ", charge= " << par().charge << ")..." << std::endl;
|
|
|
|
|
2018-01-24 16:41:44 +00:00
|
|
|
auto &prop = envGet(ScalarField, getName());
|
|
|
|
auto &prop0 = envGet(ScalarField, prop0Name_);
|
|
|
|
auto &propQ = envGet(ScalarField, propQName_);
|
|
|
|
auto &propSun = envGet(ScalarField, propSunName_);
|
|
|
|
auto &propTad = envGet(ScalarField, propTadName_);
|
|
|
|
auto &GFSrc = envGet(ScalarField, GFSrcName_);
|
|
|
|
auto &G = envGet(ScalarField, freeMomPropName_);
|
|
|
|
auto &fft = envGet(FFT, fftName_);
|
|
|
|
double q = par().charge;
|
2017-12-21 11:39:07 +00:00
|
|
|
envGetTmp(ScalarField, buf);
|
|
|
|
|
2017-03-24 17:13:55 +00:00
|
|
|
// -G*momD1*G*F*Src (momD1 = F*D1*Finv)
|
2017-01-12 20:44:23 +00:00
|
|
|
buf = GFSrc;
|
|
|
|
momD1(buf, fft);
|
2017-03-24 17:13:55 +00:00
|
|
|
buf = -G*buf;
|
2017-11-07 14:46:39 +00:00
|
|
|
fft.FFT_dim(propQ, buf, env().getNd()-1, FFT::backward);
|
2017-01-23 17:27:50 +00:00
|
|
|
|
2017-03-24 17:13:55 +00:00
|
|
|
// G*momD1*G*momD1*G*F*Src (here buf = G*momD1*G*F*Src)
|
|
|
|
buf = -buf;
|
2017-01-12 20:44:23 +00:00
|
|
|
momD1(buf, fft);
|
2017-06-08 17:43:39 +01:00
|
|
|
propSun = G*buf;
|
2017-11-07 14:46:39 +00:00
|
|
|
fft.FFT_dim(propSun, propSun, env().getNd()-1, FFT::backward);
|
2017-01-23 17:27:50 +00:00
|
|
|
|
2017-03-24 17:13:55 +00:00
|
|
|
// -G*momD2*G*F*Src (momD2 = F*D2*Finv)
|
2017-01-12 20:44:23 +00:00
|
|
|
buf = GFSrc;
|
|
|
|
momD2(buf, fft);
|
2017-03-24 17:13:55 +00:00
|
|
|
buf = -G*buf;
|
2017-11-07 14:46:39 +00:00
|
|
|
fft.FFT_dim(propTad, buf, env().getNd()-1, FFT::backward);
|
2017-11-03 18:46:16 +00:00
|
|
|
|
2017-11-07 14:46:39 +00:00
|
|
|
// full charged scalar propagator
|
|
|
|
buf = GFSrc;
|
|
|
|
fft.FFT_dim(buf, buf, env().getNd()-1, FFT::backward);
|
|
|
|
prop = buf + q*propQ + q*q*propSun + q*q*propTad;
|
|
|
|
|
2017-01-13 13:30:56 +00:00
|
|
|
// OUTPUT IF NECESSARY
|
|
|
|
if (!par().output.empty())
|
|
|
|
{
|
2017-06-12 18:27:32 +01:00
|
|
|
for (unsigned int i_p = 0; i_p < par().outputMom.size(); ++i_p)
|
|
|
|
{
|
|
|
|
std::vector<int> mom = strToVec<int>(par().outputMom[i_p]);
|
2018-01-26 16:33:48 +00:00
|
|
|
std::string filename = par().output + "_"
|
|
|
|
+ std::to_string(mom[0])
|
|
|
|
+ std::to_string(mom[1])
|
|
|
|
+ std::to_string(mom[2]);
|
2017-06-12 18:27:32 +01:00
|
|
|
|
2018-01-26 16:33:48 +00:00
|
|
|
LOG(Message) << "Saving (" << par().outputMom[i_p]
|
|
|
|
<< ") momentum projection to '" << filename << "'..."
|
|
|
|
<< std::endl;
|
2017-03-24 17:13:55 +00:00
|
|
|
|
2018-01-26 16:33:48 +00:00
|
|
|
std::vector<Complex> result, result0, resultQ, resultSun, resultTad;
|
2017-11-07 14:46:39 +00:00
|
|
|
result.resize(env().getGrid()->_fdimensions[env().getNd()-1]);
|
2018-01-24 16:41:44 +00:00
|
|
|
result0.resize(result.size());
|
|
|
|
resultQ.resize(result.size());
|
|
|
|
resultSun.resize(result.size());
|
|
|
|
resultTad.resize(result.size());
|
2017-11-03 09:22:41 +00:00
|
|
|
|
2017-11-07 14:46:39 +00:00
|
|
|
TComplex site;
|
|
|
|
std::vector<int> whichmom;
|
|
|
|
whichmom.resize(env().getNd());
|
2017-11-03 18:46:16 +00:00
|
|
|
|
|
|
|
for (unsigned int j = 0; j < env().getNd()-1; ++j)
|
|
|
|
{
|
2017-11-07 14:46:39 +00:00
|
|
|
whichmom[j] = mom[j];
|
2017-11-03 18:46:16 +00:00
|
|
|
}
|
|
|
|
|
2018-01-24 16:41:44 +00:00
|
|
|
for (unsigned int t = 0; t < result.size(); ++t)
|
2017-11-03 18:46:16 +00:00
|
|
|
{
|
2017-11-07 14:46:39 +00:00
|
|
|
whichmom[env().getNd()-1] = t;
|
|
|
|
// Write full propagator
|
|
|
|
peekSite(site, prop, whichmom);
|
|
|
|
result[t]=TensorRemove(site);
|
|
|
|
// Write free propagator
|
|
|
|
peekSite(site, buf, whichmom);
|
|
|
|
result0[t]=TensorRemove(site);
|
|
|
|
// Write propagator O(q) term
|
|
|
|
peekSite(site, propQ, whichmom);
|
|
|
|
resultQ[t]=TensorRemove(site);
|
|
|
|
// Write propagator sunset term
|
|
|
|
peekSite(site, propSun, whichmom);
|
|
|
|
resultSun[t]=TensorRemove(site);
|
|
|
|
// Write propagator tadpole term
|
|
|
|
peekSite(site, propTad, whichmom);
|
|
|
|
resultTad[t]=TensorRemove(site);
|
2017-11-03 18:46:16 +00:00
|
|
|
}
|
2018-01-26 16:33:48 +00:00
|
|
|
saveResult(filename, "charge", q);
|
|
|
|
saveResult(filename, "mass", par().mass);
|
|
|
|
saveResult(filename, "prop", result);
|
|
|
|
saveResult(filename, "prop_0", result0);
|
|
|
|
saveResult(filename, "prop_Q", resultQ);
|
|
|
|
saveResult(filename, "prop_Sun", resultSun);
|
|
|
|
saveResult(filename, "prop_Tad", resultTad);
|
2017-03-24 17:13:55 +00:00
|
|
|
}
|
2017-01-13 13:30:56 +00:00
|
|
|
}
|
2017-11-07 14:46:39 +00:00
|
|
|
|
|
|
|
std::vector<int> mask(env().getNd(),1);
|
|
|
|
mask[env().getNd()-1] = 0;
|
|
|
|
fft.FFT_dim_mask(prop, prop, mask, FFT::backward);
|
|
|
|
fft.FFT_dim_mask(propQ, propQ, mask, FFT::backward);
|
|
|
|
fft.FFT_dim_mask(propSun, propSun, mask, FFT::backward);
|
|
|
|
fft.FFT_dim_mask(propTad, propTad, mask, FFT::backward);
|
2017-01-12 20:44:23 +00:00
|
|
|
}
|
|
|
|
|
2017-12-21 11:39:07 +00:00
|
|
|
void TChargedProp::makeCaches(void)
|
|
|
|
{
|
|
|
|
auto &freeMomProp = envGet(ScalarField, freeMomPropName_);
|
|
|
|
auto &GFSrc = envGet(ScalarField, GFSrcName_);
|
2018-01-24 16:41:44 +00:00
|
|
|
auto &prop0 = envGet(ScalarField, prop0Name_);
|
2017-12-21 11:39:07 +00:00
|
|
|
auto &fft = envGet(FFT, fftName_);
|
|
|
|
|
|
|
|
if (!freeMomPropDone_)
|
|
|
|
{
|
2018-01-24 16:41:44 +00:00
|
|
|
LOG(Message) << "Caching momentum-space free scalar propagator"
|
2017-12-21 11:39:07 +00:00
|
|
|
<< " (mass= " << par().mass << ")..." << std::endl;
|
|
|
|
SIMPL::MomentumSpacePropagator(freeMomProp, par().mass);
|
|
|
|
}
|
|
|
|
if (!GFSrcDone_)
|
|
|
|
{
|
|
|
|
FFT fft(env().getGrid());
|
|
|
|
auto &source = envGet(ScalarField, par().source);
|
|
|
|
|
|
|
|
LOG(Message) << "Caching G*F*src..." << std::endl;
|
|
|
|
fft.FFT_all_dim(GFSrc, source, FFT::forward);
|
|
|
|
GFSrc = freeMomProp*GFSrc;
|
|
|
|
}
|
2018-01-24 16:41:44 +00:00
|
|
|
if (!prop0Done_)
|
|
|
|
{
|
2018-01-26 16:33:48 +00:00
|
|
|
LOG(Message) << "Caching position-space free scalar propagator..."
|
|
|
|
<< std::endl;
|
2018-01-24 16:41:44 +00:00
|
|
|
fft.FFT_all_dim(prop0, GFSrc, FFT::backward);
|
|
|
|
}
|
2017-12-21 11:39:07 +00:00
|
|
|
if (!phasesDone_)
|
|
|
|
{
|
|
|
|
std::vector<int> &l = env().getGrid()->_fdimensions;
|
|
|
|
Complex ci(0.0,1.0);
|
|
|
|
|
|
|
|
LOG(Message) << "Caching shift phases..." << std::endl;
|
|
|
|
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
|
|
|
{
|
|
|
|
Real twoPiL = M_PI*2./l[mu];
|
|
|
|
auto &phmu = envGet(ScalarField, phaseName_[mu]);
|
|
|
|
|
|
|
|
LatticeCoordinate(phmu, mu);
|
|
|
|
phmu = exp(ci*twoPiL*phmu);
|
|
|
|
phase_.push_back(&phmu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-12 20:44:23 +00:00
|
|
|
void TChargedProp::momD1(ScalarField &s, FFT &fft)
|
|
|
|
{
|
2017-12-21 11:39:07 +00:00
|
|
|
auto &A = envGet(EmField, par().emField);
|
2017-01-12 20:44:23 +00:00
|
|
|
Complex ci(0.0,1.0);
|
2017-01-23 17:27:50 +00:00
|
|
|
|
2017-12-21 11:39:07 +00:00
|
|
|
envGetTmp(ScalarField, buf);
|
|
|
|
envGetTmp(ScalarField, result);
|
|
|
|
envGetTmp(ScalarField, Amu);
|
2017-01-23 17:27:50 +00:00
|
|
|
|
2017-12-21 11:39:07 +00:00
|
|
|
result = zero;
|
2017-01-12 20:44:23 +00:00
|
|
|
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
|
|
|
{
|
|
|
|
Amu = peekLorentz(A, mu);
|
2017-01-27 12:22:48 +00:00
|
|
|
buf = (*phase_[mu])*s;
|
|
|
|
fft.FFT_all_dim(buf, buf, FFT::backward);
|
|
|
|
buf = Amu*buf;
|
2017-01-12 20:44:23 +00:00
|
|
|
fft.FFT_all_dim(buf, buf, FFT::forward);
|
2017-01-27 12:22:48 +00:00
|
|
|
result = result - ci*buf;
|
2017-01-12 20:44:23 +00:00
|
|
|
}
|
2017-01-27 12:22:48 +00:00
|
|
|
fft.FFT_all_dim(s, s, FFT::backward);
|
2017-01-12 20:44:23 +00:00
|
|
|
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
|
|
|
{
|
|
|
|
Amu = peekLorentz(A, mu);
|
2017-01-27 12:22:48 +00:00
|
|
|
buf = Amu*s;
|
2017-01-12 20:44:23 +00:00
|
|
|
fft.FFT_all_dim(buf, buf, FFT::forward);
|
2017-01-27 12:22:48 +00:00
|
|
|
result = result + ci*adj(*phase_[mu])*buf;
|
2017-01-12 20:44:23 +00:00
|
|
|
}
|
2017-01-23 17:27:50 +00:00
|
|
|
|
|
|
|
s = result;
|
2017-01-12 20:44:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TChargedProp::momD2(ScalarField &s, FFT &fft)
|
|
|
|
{
|
2017-12-21 11:39:07 +00:00
|
|
|
auto &A = envGet(EmField, par().emField);
|
|
|
|
|
|
|
|
envGetTmp(ScalarField, buf);
|
|
|
|
envGetTmp(ScalarField, result);
|
|
|
|
envGetTmp(ScalarField, Amu);
|
2017-01-23 17:27:50 +00:00
|
|
|
|
|
|
|
result = zero;
|
2017-01-12 20:44:23 +00:00
|
|
|
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
|
|
|
{
|
|
|
|
Amu = peekLorentz(A, mu);
|
|
|
|
buf = (*phase_[mu])*s;
|
|
|
|
fft.FFT_all_dim(buf, buf, FFT::backward);
|
|
|
|
buf = Amu*Amu*buf;
|
|
|
|
fft.FFT_all_dim(buf, buf, FFT::forward);
|
2017-01-23 17:27:50 +00:00
|
|
|
result = result + .5*buf;
|
2017-01-12 20:44:23 +00:00
|
|
|
}
|
2017-01-27 12:22:48 +00:00
|
|
|
fft.FFT_all_dim(s, s, FFT::backward);
|
|
|
|
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
|
|
|
{
|
|
|
|
Amu = peekLorentz(A, mu);
|
|
|
|
buf = Amu*Amu*s;
|
|
|
|
fft.FFT_all_dim(buf, buf, FFT::forward);
|
|
|
|
result = result + .5*adj(*phase_[mu])*buf;
|
|
|
|
}
|
2017-01-23 17:27:50 +00:00
|
|
|
|
|
|
|
s = result;
|
2016-12-29 21:44:58 +00:00
|
|
|
}
|