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)
|
|
|
|
{
|
2017-03-24 17:13:55 +00:00
|
|
|
std::vector<std::string> out = {getName(), getName()+"_0", getName()+"_D1",
|
|
|
|
getName()+"_D1D1", getName()+"_D2"};
|
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-01-12 20:44:23 +00:00
|
|
|
GFSrcName_ = "_" + getName() + "_DinvSrc";
|
2017-03-24 17:13:55 +00:00
|
|
|
prop0Name_ = getName() + "_0";
|
|
|
|
propD1Name_ = getName() + "_D1";
|
|
|
|
propD1D1Name_ = getName() + "_D1D1";
|
|
|
|
propD2Name_ = getName() + "_D2";
|
2017-01-11 18:40:43 +00:00
|
|
|
if (!env().hasRegisteredObject(freeMomPropName_))
|
|
|
|
{
|
|
|
|
env().registerLattice<ScalarField>(freeMomPropName_);
|
|
|
|
}
|
2017-01-12 20:44:23 +00:00
|
|
|
if (!env().hasRegisteredObject(phaseName_[0]))
|
2017-01-11 18:40:43 +00:00
|
|
|
{
|
|
|
|
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
|
|
|
{
|
2017-01-12 20:44:23 +00:00
|
|
|
env().registerLattice<ScalarField>(phaseName_[mu]);
|
2017-01-11 18:40:43 +00:00
|
|
|
}
|
|
|
|
}
|
2017-01-12 20:44:23 +00:00
|
|
|
if (!env().hasRegisteredObject(GFSrcName_))
|
|
|
|
{
|
|
|
|
env().registerLattice<ScalarField>(GFSrcName_);
|
|
|
|
}
|
2017-03-24 17:13:55 +00:00
|
|
|
if (!env().hasRegisteredObject(prop0Name_))
|
|
|
|
{
|
|
|
|
env().registerLattice<ScalarField>(prop0Name_);
|
|
|
|
}
|
2017-01-11 18:40:43 +00:00
|
|
|
env().registerLattice<ScalarField>(getName());
|
2017-03-24 17:13:55 +00:00
|
|
|
env().registerLattice<ScalarField>(propD1Name_);
|
|
|
|
env().registerLattice<ScalarField>(propD1D1Name_);
|
|
|
|
env().registerLattice<ScalarField>(propD2Name_);
|
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-01-11 18:40:43 +00:00
|
|
|
ScalarField &source = *env().getObject<ScalarField>(par().source);
|
2017-01-12 20:44:23 +00:00
|
|
|
Complex ci(0.0,1.0);
|
|
|
|
FFT fft(env().getGrid());
|
2017-01-11 18:40:43 +00:00
|
|
|
|
2017-03-24 17:13:55 +00:00
|
|
|
// cache momentum-space free scalar propagator
|
2017-01-11 18:40:43 +00:00
|
|
|
if (!env().hasCreatedObject(freeMomPropName_))
|
|
|
|
{
|
|
|
|
LOG(Message) << "Caching momentum space free scalar propagator"
|
|
|
|
<< " (mass= " << par().mass << ")..." << std::endl;
|
2017-01-12 20:44:23 +00:00
|
|
|
freeMomProp_ = env().createLattice<ScalarField>(freeMomPropName_);
|
|
|
|
Scalar<SIMPL>::MomentumSpacePropagator(*freeMomProp_, par().mass);
|
2017-01-11 18:40:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-01-12 20:44:23 +00:00
|
|
|
freeMomProp_ = env().getObject<ScalarField>(freeMomPropName_);
|
2017-01-11 18:40:43 +00:00
|
|
|
}
|
2017-01-13 13:30:56 +00:00
|
|
|
// cache G*F*src
|
|
|
|
if (!env().hasCreatedObject(GFSrcName_))
|
|
|
|
|
|
|
|
{
|
|
|
|
GFSrc_ = env().createLattice<ScalarField>(GFSrcName_);
|
|
|
|
fft.FFT_all_dim(*GFSrc_, source, FFT::forward);
|
|
|
|
*GFSrc_ = (*freeMomProp_)*(*GFSrc_);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GFSrc_ = env().getObject<ScalarField>(GFSrcName_);
|
|
|
|
}
|
2017-04-10 16:33:54 +01:00
|
|
|
// cache position-space free scalar propagator
|
2017-03-24 17:13:55 +00:00
|
|
|
if (!env().hasCreatedObject(prop0Name_))
|
|
|
|
{
|
|
|
|
prop0_ = env().createLattice<ScalarField>(prop0Name_);
|
|
|
|
*prop0_ = *GFSrc_;
|
|
|
|
fft.FFT_all_dim(*prop0_, *prop0_, FFT::backward);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
prop0_ = env().getObject<ScalarField>(prop0Name_);
|
|
|
|
}
|
2017-01-12 20:44:23 +00:00
|
|
|
// cache phases
|
|
|
|
if (!env().hasCreatedObject(phaseName_[0]))
|
2017-01-11 18:40:43 +00:00
|
|
|
{
|
|
|
|
std::vector<int> &l = env().getGrid()->_fdimensions;
|
|
|
|
|
2017-01-13 13:30:56 +00:00
|
|
|
LOG(Message) << "Caching shift phases..." << std::endl;
|
2017-01-11 18:40:43 +00:00
|
|
|
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
|
|
|
{
|
|
|
|
Real twoPiL = M_PI*2./l[mu];
|
|
|
|
|
2017-01-12 20:44:23 +00:00
|
|
|
phase_.push_back(env().createLattice<ScalarField>(phaseName_[mu]));
|
|
|
|
LatticeCoordinate(*(phase_[mu]), mu);
|
|
|
|
*(phase_[mu]) = exp(ci*twoPiL*(*(phase_[mu])));
|
2017-01-11 18:40:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
|
|
|
{
|
2017-01-12 20:44:23 +00:00
|
|
|
phase_.push_back(env().getObject<ScalarField>(phaseName_[mu]));
|
2017-01-11 18:40:43 +00:00
|
|
|
}
|
|
|
|
}
|
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;
|
|
|
|
|
|
|
|
ScalarField &prop = *env().createLattice<ScalarField>(getName());
|
2017-03-24 17:13:55 +00:00
|
|
|
ScalarField &propD1 = *env().createLattice<ScalarField>(propD1Name_);
|
|
|
|
ScalarField &propD1D1 = *env().createLattice<ScalarField>(propD1D1Name_);
|
|
|
|
ScalarField &propD2 = *env().createLattice<ScalarField>(propD2Name_);
|
2017-01-12 20:44:23 +00:00
|
|
|
ScalarField buf(env().getGrid());
|
|
|
|
ScalarField &GFSrc = *GFSrc_, &G = *freeMomProp_;
|
|
|
|
double q = par().charge;
|
|
|
|
|
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;
|
|
|
|
fft.FFT_all_dim(propD1, buf, 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-03-24 17:13:55 +00:00
|
|
|
propD1D1 = G*buf;
|
|
|
|
fft.FFT_all_dim(propD1D1, propD1D1, 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;
|
|
|
|
fft.FFT_all_dim(propD2, buf, FFT::backward);
|
2017-01-23 17:27:50 +00:00
|
|
|
|
2017-03-24 17:13:55 +00:00
|
|
|
// full charged scalar propagator
|
|
|
|
prop = (*prop0_) + q*propD1 + q*q*propD1D1 + q*q*propD2;
|
2017-01-13 13:30:56 +00:00
|
|
|
|
|
|
|
// OUTPUT IF NECESSARY
|
|
|
|
if (!par().output.empty())
|
|
|
|
{
|
|
|
|
std::string filename = par().output + "." +
|
|
|
|
std::to_string(env().getTrajectory());
|
|
|
|
|
|
|
|
LOG(Message) << "Saving zero-momentum projection to '"
|
|
|
|
<< filename << "'..." << std::endl;
|
|
|
|
|
2017-01-28 02:12:35 +00:00
|
|
|
CorrWriter writer(filename);
|
2017-01-13 13:30:56 +00:00
|
|
|
std::vector<TComplex> vecBuf;
|
|
|
|
std::vector<Complex> result;
|
|
|
|
|
2017-03-24 17:13:55 +00:00
|
|
|
write(writer, "charge", q);
|
|
|
|
|
|
|
|
// Write full propagator
|
2017-01-13 13:30:56 +00:00
|
|
|
sliceSum(prop, vecBuf, Tp);
|
|
|
|
result.resize(vecBuf.size());
|
|
|
|
for (unsigned int t = 0; t < vecBuf.size(); ++t)
|
|
|
|
{
|
|
|
|
result[t] = TensorRemove(vecBuf[t]);
|
|
|
|
}
|
|
|
|
write(writer, "prop", result);
|
2017-03-24 17:13:55 +00:00
|
|
|
|
|
|
|
// Write free propagator
|
|
|
|
sliceSum(*prop0_, vecBuf, Tp);
|
|
|
|
for (unsigned int t = 0; t < vecBuf.size(); ++t)
|
|
|
|
{
|
|
|
|
result[t] = TensorRemove(vecBuf[t]);
|
|
|
|
}
|
|
|
|
write(writer, "prop_0", result);
|
|
|
|
|
|
|
|
// Write propagator D1 term
|
|
|
|
sliceSum(propD1, vecBuf, Tp);
|
|
|
|
for (unsigned int t = 0; t < vecBuf.size(); ++t)
|
|
|
|
{
|
|
|
|
result[t] = TensorRemove(vecBuf[t]);
|
|
|
|
}
|
|
|
|
write(writer, "prop_D1", result);
|
|
|
|
|
|
|
|
// Write propagator D1D1 term
|
|
|
|
sliceSum(propD1D1, vecBuf, Tp);
|
|
|
|
for (unsigned int t = 0; t < vecBuf.size(); ++t)
|
|
|
|
{
|
|
|
|
result[t] = TensorRemove(vecBuf[t]);
|
|
|
|
}
|
|
|
|
write(writer, "prop_D1D1", result);
|
|
|
|
|
|
|
|
// Write propagator D2 term
|
|
|
|
sliceSum(propD2, vecBuf, Tp);
|
|
|
|
for (unsigned int t = 0; t < vecBuf.size(); ++t)
|
|
|
|
{
|
|
|
|
result[t] = TensorRemove(vecBuf[t]);
|
|
|
|
}
|
|
|
|
write(writer, "prop_D2", result);
|
2017-01-13 13:30:56 +00:00
|
|
|
}
|
2017-01-12 20:44:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TChargedProp::momD1(ScalarField &s, FFT &fft)
|
|
|
|
{
|
|
|
|
EmField &A = *env().getObject<EmField>(par().emField);
|
2017-01-27 12:22:48 +00:00
|
|
|
ScalarField buf(env().getGrid()), result(env().getGrid()),
|
|
|
|
Amu(env().getGrid());
|
2017-01-12 20:44:23 +00:00
|
|
|
Complex ci(0.0,1.0);
|
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);
|
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)
|
|
|
|
{
|
|
|
|
EmField &A = *env().getObject<EmField>(par().emField);
|
2017-01-27 12:22:48 +00:00
|
|
|
ScalarField buf(env().getGrid()), result(env().getGrid()),
|
|
|
|
Amu(env().getGrid());
|
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
|
|
|
}
|