1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-10 07:55:35 +00:00

BROKEN: Adapted scalarVP, UnitEm and VPCounterTerms modules to new Hadrons. Currently getting an assertion error from Communicator_mpi3.cc when I try to run.

This commit is contained in:
James Harrison 2018-01-26 16:33:48 +00:00
parent 90dffc73c8
commit 3db7a5387b
9 changed files with 292 additions and 289 deletions

View File

@ -55,14 +55,14 @@ std::vector<std::string> TUnitEm::getOutput(void)
// setup ///////////////////////////////////////////////////////////////////////
void TUnitEm::setup(void)
{
env().registerLattice<EmField>(getName());
envCreateLat(EmField, getName());
}
// execution ///////////////////////////////////////////////////////////////////
void TUnitEm::execute(void)
{
PhotonR photon(0, 0, 0); // Just chose arbitrary input values here
EmField &a = *env().createLattice<EmField>(getName());
auto &a = envGet(EmField, getName());
LOG(Message) << "Generating unit EM potential..." << std::endl;
photon.UnitField(a);
}

View File

@ -52,6 +52,7 @@ public:
// dependency relation
virtual std::vector<std::string> getInput(void);
virtual std::vector<std::string> getOutput(void);
protected:
// setup
virtual void setup(void);
// execution

View File

@ -145,16 +145,16 @@ void TChargedProp::execute(void)
for (unsigned int i_p = 0; i_p < par().outputMom.size(); ++i_p)
{
std::vector<int> mom = strToVec<int>(par().outputMom[i_p]);
std::string filename = par().output + "_" + std::to_string(mom[0])
+ std::to_string(mom[1])
+ std::to_string(mom[2])
+ "." +
std::to_string(vm().getTrajectory());
std::string filename = par().output + "_"
+ std::to_string(mom[0])
+ std::to_string(mom[1])
+ std::to_string(mom[2]);
LOG(Message) << "Saving (" << par().outputMom[i_p] << ") momentum projection to '"
<< filename << "'..." << std::endl;
LOG(Message) << "Saving (" << par().outputMom[i_p]
<< ") momentum projection to '" << filename << "'..."
<< std::endl;
std::vector<Complex> result, result0, resultQ, resultSun, resultTad;
std::vector<Complex> result, result0, resultQ, resultSun, resultTad;
result.resize(env().getGrid()->_fdimensions[env().getNd()-1]);
result0.resize(result.size());
resultQ.resize(result.size());
@ -189,13 +189,13 @@ void TChargedProp::execute(void)
peekSite(site, propTad, whichmom);
resultTad[t]=TensorRemove(site);
}
saveResult(par().output, "charge", q);
saveResult(par().output, "mass", par().mass);
saveResult(par().output, "prop", result);
saveResult(par().output, "prop_0", result0);
saveResult(par().output, "prop_Q", resultQ);
saveResult(par().output, "prop_Sun", resultSun);
saveResult(par().output, "prop_Tad", resultTad);
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);
}
}
@ -231,7 +231,8 @@ void TChargedProp::makeCaches(void)
}
if (!prop0Done_)
{
LOG(Message) << "Caching position-space free scalar propagator..." << std::endl;
LOG(Message) << "Caching position-space free scalar propagator..."
<< std::endl;
fft.FFT_all_dim(prop0, GFSrc, FFT::backward);
}
if (!phasesDone_)

View File

@ -75,7 +75,8 @@ private:
void momD1(ScalarField &s, FFT &fft);
void momD2(ScalarField &s, FFT &fft);
private:
bool freeMomPropDone_, GFSrcDone_, prop0Done_, phasesDone_;
bool freeMomPropDone_, GFSrcDone_, prop0Done_,
phasesDone_;
std::string freeMomPropName_, GFSrcName_, prop0Name_,
propQName_, propSunName_, propTadName_, fftName_;
std::vector<std::string> phaseName_;

View File

@ -9,12 +9,15 @@ using namespace MScalar;
/*
* Scalar QED vacuum polarisation up to O(alpha)
*
* Conserved vector 2-point function diagram notation:
* _______
* / \
* U_nu * * U_mu
* \_______/
*
* _______
* / \ ( adj(S(a\hat{nu}|x)) U_mu(x) S(0|x+a\hat{mu}) U_nu(0) )
* Diagram notation: U_nu * * U_mu = 2 Re( - )
* \_______/ ( adj(S(a\hat{nu}|x+a\hat{mu})) adj(U_mu(x)) S(0|x) U_nu(0) )
*
* ( adj(S(a\hat{nu}|x)) U_mu(x) S(0|x+a\hat{mu}) U_nu(0) )
* = 2 Re( - )
* ( adj(S(a\hat{nu}|x+a\hat{mu})) adj(U_mu(x)) S(0|x) U_nu(0) )
*
*
* _______
@ -89,12 +92,13 @@ TScalarVP::TScalarVP(const std::string name)
// dependencies/products ///////////////////////////////////////////////////////
std::vector<std::string> TScalarVP::getInput(void)
{
prop0Name_ = par().scalarProp + "_0";
propQName_ = par().scalarProp + "_Q";
propSunName_ = par().scalarProp + "_Sun";
propTadName_ = par().scalarProp + "_Tad";
std::vector<std::string> in = {par().emField, propQName_, propSunName_,
propTadName_};
std::vector<std::string> in = {par().emField, prop0Name_, propQName_,
propSunName_, propTadName_};
return in;
}
@ -105,7 +109,7 @@ std::vector<std::string> TScalarVP::getOutput(void)
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
{
out.push_back(getName() + "_propQ_" + std::to_string(mu));
// out.push_back(getName() + "_propQ_" + std::to_string(mu));
for (unsigned int nu = 0; nu < env().getNd(); ++nu)
{
@ -120,14 +124,13 @@ std::vector<std::string> TScalarVP::getOutput(void)
// setup ///////////////////////////////////////////////////////////////////////
void TScalarVP::setup(void)
{
freeMomPropName_ = FREEMOMPROP(static_cast<TChargedProp *>(env().getModule(par().scalarProp))->par().mass);
GFSrcName_ = "_" + par().scalarProp + "_DinvSrc";
prop0Name_ = par().scalarProp + "_0";
freeMomPropName_ = FREEMOMPROP(static_cast<TChargedProp *>(vm().getModule(par().scalarProp))->par().mass);
GFSrcName_ = par().scalarProp + "_DinvSrc";
fftName_ = par().scalarProp + "_fft";
phaseName_.clear();
muPropQName_.clear();
vpTensorName_.clear();
momPhaseName_.clear();
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
{
phaseName_.push_back("_shiftphase_" + std::to_string(mu));
@ -141,109 +144,111 @@ void TScalarVP::setup(void)
}
vpTensorName_.push_back(vpTensorName_mu);
}
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));
}
}
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
{
env().registerLattice<ScalarField>(muPropQName_[mu]);
envCreateLat(ScalarField, muPropQName_[mu]);
for (unsigned int nu = 0; nu < env().getNd(); ++nu)
{
env().registerLattice<ScalarField>(vpTensorName_[mu][nu]);
envCreateLat(ScalarField, vpTensorName_[mu][nu]);
}
}
if (!par().output.empty())
{
momPhasesDone_ = env().hasCreatedObject(momPhaseName_[0]);
for (unsigned int i_p = 0; i_p < par().outputMom.size(); ++i_p)
{
envCacheLat(ScalarField, momPhaseName_[i_p]);
}
}
envTmpLat(ScalarField, "buf");
envTmpLat(ScalarField, "result");
envTmpLat(ScalarField, "Amu");
envTmpLat(ScalarField, "Usnk");
envTmpLat(ScalarField, "tmpProp");
}
// execution ///////////////////////////////////////////////////////////////////
void TScalarVP::execute(void)
{
// Get objects cached by ChargedProp module
Complex ci(0.0,1.0);
FFT fft(env().getGrid());
Real q = static_cast<TChargedProp *>(env().getModule(par().scalarProp))->par().charge;
// CACHING ANALYTIC EXPRESSIONS
makeCaches();
freeMomProp_ = env().getObject<ScalarField>(freeMomPropName_);
Complex ci(0.0,1.0);
Real q = static_cast<TChargedProp *>(vm().getModule(par().scalarProp))->par().charge;
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_);
phase_.clear();
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
{
phase_.push_back(env().getObject<ScalarField>(phaseName_[mu]));
auto &phmu = envGet(ScalarField, phaseName_[mu]);
phase_.push_back(&phmu);
}
GFSrc_ = env().getObject<ScalarField>(GFSrcName_);
prop0_ = env().getObject<ScalarField>(prop0Name_);
// Propagator from unshifted source
ScalarField &propQ = *env().getObject<ScalarField>(propQName_);
ScalarField &propSun = *env().getObject<ScalarField>(propSunName_);
ScalarField &propTad = *env().getObject<ScalarField>(propTadName_);
// Propagators from shifted sources
// PROPAGATORS FROM SHIFTED SOURCES
LOG(Message) << "Computing O(q) charged scalar propagators..."
<< std::endl;
std::vector<ScalarField> muPropQ;
std::vector<ScalarField *> muPropQ;
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
{
muPropQ.push_back(*env().createLattice<ScalarField>(muPropQName_[mu]));
auto &propmu = envGet(ScalarField, muPropQName_[mu]);
// -G*momD1*G*F*tau_mu*Src (momD1 = F*D1*Finv)
muPropQ[mu] = adj(*phase_[mu])*(*GFSrc_);
momD1(muPropQ[mu], fft);
muPropQ[mu] = -(*freeMomProp_)*muPropQ[mu];
fft.FFT_all_dim(muPropQ[mu], muPropQ[mu], FFT::backward);
propmu = adj(*phase_[mu])*GFSrc;
momD1(propmu, fft);
propmu = -G*propmu;
fft.FFT_all_dim(propmu, propmu, FFT::backward);
muPropQ.push_back(&propmu);
}
// CONTRACTIONS
ScalarField prop1(env().getGrid()), prop2(env().getGrid());
EmField &A = *env().getObject<EmField>(par().emField);
ScalarField Amu(env().getGrid()), U_snk(env().getGrid());
ScalarField tmp_vp1(env().getGrid()), tmp_vp2(env().getGrid());
TComplex Anu0, U_src;
auto &A = envGet(EmField, par().emField);
envGetTmp(ScalarField, buf);
envGetTmp(ScalarField, result);
envGetTmp(ScalarField, Amu);
envGetTmp(ScalarField, Usnk);
envGetTmp(ScalarField, tmpProp);
TComplex Anu0, Usrc;
std::vector<int> coor0 = {0, 0, 0, 0};
std::vector<std::vector<ScalarField> > vpTensor;
std::vector<std::vector<ScalarField *> > vpTensor;
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
{
std::vector<ScalarField> vpTensor_mu;
std::vector<ScalarField *> vpTensor_mu;
for (unsigned int nu = 0; nu < env().getNd(); ++nu)
{
vpTensor_mu.push_back(*env().createLattice<ScalarField>(vpTensorName_[mu][nu]));
auto &vpmunu = envGet(ScalarField, vpTensorName_[mu][nu]);
vpTensor_mu.push_back(&vpmunu);
}
vpTensor.push_back(vpTensor_mu);
}
// Open output files if necessary
std::vector<CorrWriter *> writer;
std::vector<ScalarField> momphases;
// Prepare output files if necessary
if (!par().output.empty())
{
LOG(Message) << "Preparing output files..." << std::endl;
for (unsigned int i_p = 0; i_p < par().outputMom.size(); ++i_p)
{
std::vector<int> mom = strToVec<int>(par().outputMom[i_p]);
// Open output files
std::string filename = par().output + "_"
+ std::to_string(mom[0])
+ std::to_string(mom[1])
+ std::to_string(mom[2]) + "."
+ std::to_string(env().getTrajectory());
if (env().getGrid()->IsBoss())
{
CorrWriter *writer_i = new CorrWriter(filename);
writer.push_back(writer_i);
write(*writer[i_p], "charge", q);
write(*writer[i_p], "mass", static_cast<TChargedProp *>(env().getModule(par().scalarProp))->par().mass);
}
// Calculate phase factors
tmp_vp1 = Complex(1.0,0.0);
for (unsigned int j = 0; j < env().getNd()-1; ++j)
{
for (unsigned int momcount = 0; momcount < mom[j]; ++momcount)
{
tmp_vp1 = tmp_vp1*(*phase_[j]);
}
}
tmp_vp1 = adj(tmp_vp1);
momphases.push_back(tmp_vp1);
+ std::to_string(mom[2]);
saveResult(filename, "charge", q);
saveResult(filename, "mass", static_cast<TChargedProp *>(vm().getModule(par().scalarProp))->par().mass);
}
}
@ -259,142 +264,156 @@ void TScalarVP::execute(void)
Amu = peekLorentz(A, mu);
// free
prop1 = *prop0_; // S_0(0|x)
prop2 = Cshift(*prop0_, nu, -1); // S_0(0|x-a\hat{\nu})
tmpProp = Cshift(prop0, nu, -1); // S_0(0|x-a\hat{\nu})
// = S_0(a\hat{\nu}|x)
U_src = Complex(1.0,0.0);
vpContraction(tmp_vp1, prop1, prop2, U_src, mu);
vpTensor[mu][nu] = tmp_vp1;
Usrc = Complex(1.0,0.0);
vpContraction(buf, prop0, tmpProp, Usrc, mu);
*vpTensor[mu][nu] = buf;
// Output if necessary
if (!par().output.empty())
{
writeVP(writer, tmp_vp1, momphases,
writeVP(buf,
"Pi_free_"+std::to_string(mu)+"_"+std::to_string(nu));
}
// srcT
tmp_vp2 = tmp_vp1 * (-0.5)*q*q*Anu0*Anu0;
vpTensor[mu][nu] += tmp_vp2;
result = buf * (-0.5)*q*q*Anu0*Anu0;
*vpTensor[mu][nu] += result;
// Output if necessary
if (!par().output.empty())
{
writeVP(writer, tmp_vp2, momphases,
writeVP(result,
"Pi_srcT_"+std::to_string(mu)+"_"+std::to_string(nu));
}
// snkT
tmp_vp2 = tmp_vp1 * (-0.5)*q*q*Amu*Amu;
vpTensor[mu][nu] += tmp_vp2;
result = buf * (-0.5)*q*q*Amu*Amu;
*vpTensor[mu][nu] += result;
// Output if necessary
if (!par().output.empty())
{
writeVP(writer, tmp_vp2, momphases,
writeVP(result,
"Pi_snkT_"+std::to_string(mu)+"_"+std::to_string(nu));
}
// S
prop1 = *prop0_; // S_0(0|x)
prop2 = Cshift(*prop0_, nu, -1); // S_0(a\hat{\nu}|x)
U_src = ci*q*Anu0;
U_snk = ci*q*Amu;
vpContraction(tmp_vp1, prop1, prop2, U_src, U_snk, mu);
vpTensor[mu][nu] += tmp_vp1;
tmpProp = Cshift(prop0, nu, -1); // S_0(a\hat{\nu}|x)
Usrc = ci*Anu0;
Usnk = ci*Amu;
vpContraction(result, prop0, tmpProp, Usrc, Usnk, mu);
result = q*q*result;
*vpTensor[mu][nu] += result;
// Output if necessary
if (!par().output.empty())
{
writeVP(writer, tmp_vp1, momphases,
writeVP(result,
"Pi_S_"+std::to_string(mu)+"_"+std::to_string(nu));
}
// 4C
prop1 = q*propQ; // q*S_1(0|x)
prop2 = Cshift(*prop0_, nu, -1); // S_0(a\hat{\nu}|x)
U_src = Complex(1.0,0.0);
U_snk = ci*q*Amu;
vpContraction(tmp_vp1, prop1, prop2, U_src, U_snk, mu);
U_src = ci*q*Anu0;
vpContraction(tmp_vp2, prop1, prop2, U_src, mu);
tmp_vp1 += tmp_vp2;
prop1 = *prop0_; // S_0(0|x)
prop2 = q*muPropQ[nu]; // q*S_1(a\hat{\nu}|x)
vpContraction(tmp_vp2, prop1, prop2, U_src, mu);
tmp_vp1 += tmp_vp2;
U_src = Complex(1.0,0.0);
U_snk = ci*q*Amu;
vpContraction(tmp_vp2, prop1, prop2, U_src, U_snk, mu);
tmp_vp1 += tmp_vp2;
vpTensor[mu][nu] += tmp_vp1;
tmpProp = Cshift(prop0, nu, -1); // S_0(a\hat{\nu}|x)
Usrc = Complex(1.0,0.0);
Usnk = ci*Amu;
vpContraction(result, propQ, tmpProp, Usrc, Usnk, mu);
Usrc = ci*Anu0;
vpContraction(buf, propQ, tmpProp, Usrc, mu);
result += buf;
vpContraction(buf, prop0, *muPropQ[nu], Usrc, mu);
result += buf;
Usrc = Complex(1.0,0.0);
Usnk = ci*Amu;
vpContraction(buf, prop0, *muPropQ[nu], Usrc, Usnk, mu);
result += buf;
result = q*q*result;
*vpTensor[mu][nu] += result;
// Output if necessary
if (!par().output.empty())
{
writeVP(writer, tmp_vp1, momphases,
writeVP(result,
"Pi_4C_"+std::to_string(mu)+"_"+std::to_string(nu));
}
// X
prop1 = q*propQ; // q*S_1(0|x)
prop2 = q*muPropQ[nu]; // q*S_1(a\hat{\nu}|x)
U_src = Complex(1.0,0.0);
vpContraction(tmp_vp1, prop1, prop2, U_src, mu);
vpTensor[mu][nu] += tmp_vp1;
Usrc = Complex(1.0,0.0);
vpContraction(result, propQ, *muPropQ[nu], Usrc, mu);
result = q*q*result;
*vpTensor[mu][nu] += result;
// Output if necessary
if (!par().output.empty())
{
writeVP(writer, tmp_vp1, momphases,
writeVP(result,
"Pi_X_"+std::to_string(mu)+"_"+std::to_string(nu));
}
// 2E
prop1 = q*q*propSun; // q^2*S_\Sigma(0|x)
prop2 = Cshift(*prop0_, nu, -1); // S_0(a\hat{\nu}|x)
U_src = Complex(1.0,0.0);
vpContraction(tmp_vp1, prop1, prop2, U_src, mu);
prop1 = *prop0_; // S_0(0|x)
prop2 = q*q*Cshift(propSun, nu, -1); // q^2*S_\Sigma(0|x-a\hat{\nu})
tmpProp = Cshift(prop0, nu, -1); // S_0(a\hat{\nu}|x)
Usrc = Complex(1.0,0.0);
vpContraction(result, propSun, tmpProp, Usrc, mu);
tmpProp = Cshift(propSun, nu, -1); // S_\Sigma(0|x-a\hat{\nu})
//(Note: <S(0|x-a\hat{\nu})> = <S(a\hat{\nu}|x)>)
vpContraction(tmp_vp2, prop1, prop2, U_src, mu);
tmp_vp1 += tmp_vp2;
vpTensor[mu][nu] += tmp_vp1;
vpContraction(buf, prop0, tmpProp, Usrc, mu);
result += buf;
result = q*q*result;
*vpTensor[mu][nu] += result;
// Output if necessary
if (!par().output.empty())
{
writeVP(writer, tmp_vp1, momphases,
writeVP(result,
"Pi_2E_"+std::to_string(mu)+"_"+std::to_string(nu));
}
// 2T
prop1 = q*q*propTad; // q^2*S_T(0|x)
prop2 = Cshift(*prop0_, nu, -1); // S_0(a\hat{\nu}|x)
U_src = Complex(1.0,0.0);
vpContraction(tmp_vp1, prop1, prop2, U_src, mu);
prop1 = *prop0_; // S_0(0|x)
prop2 = q*q*Cshift(propTad, nu, -1); // q^2*S_T(0|x-a\hat{\nu})
vpContraction(tmp_vp2, prop1, prop2, U_src, mu);
tmp_vp1 += tmp_vp2;
vpTensor[mu][nu] += tmp_vp1;
tmpProp = Cshift(prop0, nu, -1); // S_0(a\hat{\nu}|x)
Usrc = Complex(1.0,0.0);
vpContraction(result, propTad, tmpProp, Usrc, mu);
tmpProp = Cshift(propTad, nu, -1); // S_T(0|x-a\hat{\nu})
vpContraction(buf, prop0, tmpProp, Usrc, mu);
result += buf;
result = q*q*result;
*vpTensor[mu][nu] += result;
// Output if necessary
if (!par().output.empty())
{
writeVP(writer, tmp_vp1, momphases,
writeVP(result,
"Pi_2T_"+std::to_string(mu)+"_"+std::to_string(nu));
}
// Output full VP if necessary
if (!par().output.empty())
{
writeVP(writer, vpTensor[mu][nu], momphases,
writeVP(*vpTensor[mu][nu],
"Pi_"+std::to_string(mu)+"_"+std::to_string(nu));
}
}
}
if (!par().output.empty())
}
void TScalarVP::makeCaches(void)
{
envGetTmp(ScalarField, buf);
if ( (!par().output.empty()) && (!momPhasesDone_) )
{
LOG(Message) << "Caching phases for momentum projections..."
<< std::endl;
std::vector<int> &l = env().getGrid()->_fdimensions;
Complex ci(0.0,1.0);
// Calculate phase factors
for (unsigned int i_p = 0; i_p < par().outputMom.size(); ++i_p)
{
if (env().getGrid()->IsBoss())
std::vector<int> mom = strToVec<int>(par().outputMom[i_p]);
auto &momph_ip = envGet(ScalarField, momPhaseName_[i_p]);
momph_ip = zero;
for (unsigned int j = 0; j < env().getNd()-1; ++j)
{
delete writer[i_p];
Real twoPiL = M_PI*2./l[j];
LatticeCoordinate(buf, j);
buf = mom[j]*twoPiL*buf;
momph_ip = momph_ip + buf;
}
momph_ip = exp(-ci*momph_ip);
momPhase_.push_back(&momph_ip);
}
}
}
@ -419,38 +438,40 @@ void TScalarVP::vpContraction(ScalarField &vp,
vp = 2.0*real(vp);
}
void TScalarVP::writeVP(const std::vector<CorrWriter *> &writers, const ScalarField &vp,
const std::vector<ScalarField> &momphases, std::string dsetName)
void TScalarVP::writeVP(const ScalarField &vp, std::string dsetName)
{
std::vector<TComplex> vecBuf;
std::vector<Complex> result;
ScalarField vpPhase(env().getGrid());
envGetTmp(ScalarField, buf);
for (unsigned int i_p = 0; i_p < momphases.size(); ++i_p)
for (unsigned int i_p = 0; i_p < par().outputMom.size(); ++i_p)
{
vpPhase = vp*momphases[i_p];
sliceSum(vpPhase, vecBuf, Tp);
std::vector<int> mom = strToVec<int>(par().outputMom[i_p]);
std::string filename = par().output + "_"
+ std::to_string(mom[0])
+ std::to_string(mom[1])
+ std::to_string(mom[2]);
buf = vp*(*momPhase_[i_p]);
sliceSum(buf, vecBuf, Tp);
result.resize(vecBuf.size());
for (unsigned int t = 0; t < vecBuf.size(); ++t)
{
result[t] = TensorRemove(vecBuf[t]);
}
if (env().getGrid()->IsBoss())
{
write(*writers[i_p], dsetName, result);
}
saveResult(filename, dsetName, result);
}
}
void TScalarVP::momD1(ScalarField &s, FFT &fft)
{
EmField &A = *env().getObject<EmField>(par().emField);
ScalarField buf(env().getGrid()), result(env().getGrid()),
Amu(env().getGrid());
auto &A = envGet(EmField, par().emField);
Complex ci(0.0,1.0);
result = zero;
envGetTmp(ScalarField, buf);
envGetTmp(ScalarField, result);
envGetTmp(ScalarField, Amu);
result = zero;
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
{
Amu = peekLorentz(A, mu);

View File

@ -8,7 +8,7 @@
BEGIN_HADRONS_NAMESPACE
/******************************************************************************
* ScalarVP *
* Scalar vacuum polarisation *
******************************************************************************/
BEGIN_MODULE_NAMESPACE(MScalar)
@ -36,11 +36,13 @@ public:
// dependency relation
virtual std::vector<std::string> getInput(void);
virtual std::vector<std::string> getOutput(void);
protected:
// setup
virtual void setup(void);
// execution
virtual void execute(void);
private:
void makeCaches(void);
// conserved vector two-point contraction
void vpContraction(ScalarField &vp,
ScalarField &prop_0_x, ScalarField &prop_nu_x,
@ -50,22 +52,22 @@ private:
ScalarField &prop_0_x, ScalarField &prop_nu_x,
TComplex u_src, int mu);
// write momentum-projected vacuum polarisation to file(s)
void writeVP(const std::vector<CorrWriter *> &writers,
const ScalarField &vp,
const std::vector<ScalarField> &momphases,
std::string dsetName);
void writeVP(const ScalarField &vp, std::string dsetName);
// momentum-space Delta_1 insertion
void momD1(ScalarField &s, FFT &fft);
private:
bool momPhasesDone_;
std::string freeMomPropName_, GFSrcName_,
prop0Name_, propQName_,
propSunName_, propTadName_;
std::vector<std::string> phaseName_, muPropQName_;
propSunName_, propTadName_,
fftName_;
std::vector<std::string> phaseName_, muPropQName_,
momPhaseName_;
std::vector<std::vector<std::string> > vpTensorName_;
ScalarField *freeMomProp_, *GFSrc_,
*prop0_;
std::vector<ScalarField *> phase_;
EmField *A;
// ScalarField *freeMomProp_, *GFSrc_,
// *prop0_;
std::vector<ScalarField *> phase_, momPhase_;
// EmField *A;
};
MODULE_REGISTER_NS(ScalarVP, TScalarVP, MScalar);

View File

@ -37,39 +37,58 @@ void TVPCounterTerms::setup(void)
{
phaseName_.push_back("_shiftphase_" + std::to_string(mu));
}
GFSrcName_ = "_" + getName() + "_DinvSrc";
phatsqName_ = "_" + getName() + "_pHatSquared";
GFSrcName_ = getName() + "_DinvSrc";
phatsqName_ = getName() + "_pHatSquared";
prop0Name_ = getName() + "_freeProp";
twoscalarName_ = getName() + "_2scalarProp";
twoscalarVertexName_ = getName() + "_2scalarProp_withvertex";
psquaredName_ = getName() + "_psquaredProp";
env().registerLattice<ScalarField>(freeMomPropName_);
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_);
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
{
env().registerLattice<ScalarField>(phaseName_[mu]);
envCreateLat(ScalarField, phaseName_[mu]);
}
env().registerLattice<ScalarField>(phatsqName_);
env().registerLattice<ScalarField>(GFSrcName_);
env().registerLattice<ScalarField>(prop0Name_);
env().registerLattice<ScalarField>(twoscalarName_);
env().registerLattice<ScalarField>(twoscalarVertexName_);
env().registerLattice<ScalarField>(psquaredName_);
envCreateLat(ScalarField, phatsqName_);
envCreateLat(ScalarField, GFSrcName_);
envCreateLat(ScalarField, prop0Name_);
envCreateLat(ScalarField, twoscalarName_);
envCreateLat(ScalarField, twoscalarVertexName_);
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]);
}
}
envTmpLat(ScalarField, "buf");
envTmpLat(ScalarField, "tmp_vp");
envTmpLat(ScalarField, "vpPhase");
}
// execution ///////////////////////////////////////////////////////////////////
void TVPCounterTerms::execute(void)
{
ScalarField &source = *env().getObject<ScalarField>(par().source);
auto &source = envGet(ScalarField, par().source);
Complex ci(0.0,1.0);
FFT fft(env().getGrid());
ScalarField buf(env().getGrid()), tmp_vp(env().getGrid());
envGetTmp(ScalarField, buf);
envGetTmp(ScalarField, tmp_vp);
// Momentum-space free scalar propagator
ScalarField &G = *env().createLattice<ScalarField>(freeMomPropName_);
auto &G = envGet(ScalarField, freeMomPropName_);
SIMPL::MomentumSpacePropagator(G, par().mass);
// Phases and hat{p}^2
ScalarField &phatsq = *env().createLattice<ScalarField>(phatsqName_);
auto &phatsq = envGet(ScalarField, phatsqName_);
std::vector<int> &l = env().getGrid()->_fdimensions;
LOG(Message) << "Calculating shift phases..." << std::endl;
@ -77,28 +96,29 @@ void TVPCounterTerms::execute(void)
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
{
Real twoPiL = M_PI*2./l[mu];
phase_.push_back(env().createLattice<ScalarField>(phaseName_[mu]));
auto &phmu = envGet(ScalarField, phaseName_[mu]);
LatticeCoordinate(buf, mu);
*(phase_[mu]) = exp(ci*twoPiL*buf);
phmu = exp(ci*twoPiL*buf);
phase_.push_back(&phmu);
buf = 2.*sin(.5*twoPiL*buf);
phatsq = phatsq + buf*buf;
}
// G*F*src
ScalarField &GFSrc = *env().createLattice<ScalarField>(GFSrcName_);
auto &GFSrc = envGet(ScalarField, GFSrcName_);
fft.FFT_all_dim(GFSrc, source, FFT::forward);
GFSrc = G*GFSrc;
// Position-space free scalar propagator
ScalarField &prop0 = *env().createLattice<ScalarField>(prop0Name_);
auto &prop0 = envGet(ScalarField, prop0Name_);
prop0 = GFSrc;
fft.FFT_all_dim(prop0, prop0, FFT::backward);
// Propagators for counter-terms
ScalarField &twoscalarProp = *env().createLattice<ScalarField>(twoscalarName_);
ScalarField &twoscalarVertexProp = *env().createLattice<ScalarField>(twoscalarVertexName_);
ScalarField &psquaredProp = *env().createLattice<ScalarField>(psquaredName_);
auto &twoscalarProp = envGet(ScalarField, twoscalarName_);
auto &twoscalarVertexProp = envGet(ScalarField, twoscalarVertexName_);
auto &psquaredProp = envGet(ScalarField, psquaredName_);
twoscalarProp = G*GFSrc;
fft.FFT_all_dim(twoscalarProp, twoscalarProp, FFT::backward);
@ -115,12 +135,7 @@ void TVPCounterTerms::execute(void)
psquaredProp = G*phatsq*GFSrc;
fft.FFT_all_dim(psquaredProp, psquaredProp, FFT::backward);
// Open output files if necessary
std::vector<TComplex> vecBuf;
std::vector<Complex> result;
ScalarField vpPhase(env().getGrid());
std::vector<CorrWriter *> writer;
std::vector<ScalarField> momphases;
// Prepare output files if necessary
if (!par().output.empty())
{
LOG(Message) << "Preparing output files..." << std::endl;
@ -131,29 +146,21 @@ void TVPCounterTerms::execute(void)
// Open output files
std::string filename = par().output + "_" + std::to_string(mom[0])
+ std::to_string(mom[1])
+ std::to_string(mom[2])
+ "." +
std::to_string(env().getTrajectory());
if (env().getGrid()->IsBoss())
{
CorrWriter *writer_i = new CorrWriter(filename);
writer.push_back(writer_i);
write(*writer[i_p], "mass", par().mass);
}
+ std::to_string(mom[2]);
saveResult(filename, "mass", par().mass);
// Calculate phase factors
vpPhase = Complex(1.0,0.0);
auto &momph_ip = envGet(ScalarField, momPhaseName_[i_p]);
momph_ip = Complex(1.0,0.0);
for (unsigned int j = 0; j < env().getNd()-1; ++j)
{
for (unsigned int momcount = 0; momcount < mom[j]; ++momcount)
{
vpPhase = vpPhase*(*phase_[j]);
momph_ip = momph_ip*(*phase_[j]);
}
}
vpPhase = adj(vpPhase);
momphases.push_back(vpPhase);
momph_ip = adj(momph_ip);
momPhase_.push_back(&momph_ip);
}
}
@ -171,22 +178,7 @@ void TVPCounterTerms::execute(void)
// Output if necessary
if (!par().output.empty())
{
for (unsigned int i_p = 0; i_p < par().outputMom.size(); ++i_p)
{
vpPhase = tmp_vp*momphases[i_p];
sliceSum(vpPhase, vecBuf, Tp);
result.resize(vecBuf.size());
for (unsigned int t = 0; t < vecBuf.size(); ++t)
{
result[t] = TensorRemove(vecBuf[t]);
}
if (env().getGrid()->IsBoss())
{
write(*writer[i_p],
"NoVertex_"+std::to_string(mu)+"_"+std::to_string(nu),
result);
}
}
writeVP(tmp_vp, "NoVertex_"+std::to_string(mu)+"_"+std::to_string(nu));
}
// Three-scalar loop (tadpole vertex)
@ -197,22 +189,7 @@ void TVPCounterTerms::execute(void)
// Output if necessary
if (!par().output.empty())
{
for (unsigned int i_p = 0; i_p < par().outputMom.size(); ++i_p)
{
vpPhase = tmp_vp*momphases[i_p];
sliceSum(vpPhase, vecBuf, Tp);
result.resize(vecBuf.size());
for (unsigned int t = 0; t < vecBuf.size(); ++t)
{
result[t] = TensorRemove(vecBuf[t]);
}
if (env().getGrid()->IsBoss())
{
write(*writer[i_p],
"TadVertex_"+std::to_string(mu)+"_"+std::to_string(nu),
result);
}
}
writeVP(tmp_vp, "TadVertex_"+std::to_string(mu)+"_"+std::to_string(nu));
}
// Three-scalar loop (hat{p}^2 insertion)
@ -223,35 +200,32 @@ void TVPCounterTerms::execute(void)
// Output if necessary
if (!par().output.empty())
{
for (unsigned int i_p = 0; i_p < par().outputMom.size(); ++i_p)
{
vpPhase = tmp_vp*momphases[i_p];
sliceSum(vpPhase, vecBuf, Tp);
result.resize(vecBuf.size());
for (unsigned int t = 0; t < vecBuf.size(); ++t)
{
result[t] = TensorRemove(vecBuf[t]);
}
if (env().getGrid()->IsBoss())
{
write(*writer[i_p],
"pSquaredInsertion_"+std::to_string(mu)+"_"+std::to_string(nu),
result);
}
}
}
}
}
// Close output files if necessary
if (!par().output.empty())
{
for (unsigned int i_p = 0; i_p < par().outputMom.size(); ++i_p)
{
if (env().getGrid()->IsBoss())
{
delete writer[i_p];
writeVP(tmp_vp, "pSquaredInsertion_"+std::to_string(mu)+"_"+std::to_string(nu));
}
}
}
}
void TVPCounterTerms::writeVP(const ScalarField &vp, std::string dsetName)
{
std::vector<TComplex> vecBuf;
std::vector<Complex> result;
envGetTmp(ScalarField, vpPhase);
for (unsigned int i_p = 0; i_p < par().outputMom.size(); ++i_p)
{
std::vector<int> mom = strToVec<int>(par().outputMom[i_p]);
std::string filename = par().output + "_"
+ std::to_string(mom[0])
+ std::to_string(mom[1])
+ std::to_string(mom[2]);
vpPhase = vp*(*momPhase_[i_p]);
sliceSum(vpPhase, vecBuf, Tp);
result.resize(vecBuf.size());
for (unsigned int t = 0; t < vecBuf.size(); ++t)
{
result[t] = TensorRemove(vecBuf[t]);
}
saveResult(filename, dsetName, result);
}
}

View File

@ -34,16 +34,19 @@ public:
// dependency relation
virtual std::vector<std::string> getInput(void);
virtual std::vector<std::string> getOutput(void);
protected:
// setup
virtual void setup(void);
// execution
virtual void execute(void);
private:
void writeVP(const ScalarField &vp, std::string dsetName);
private:
std::string freeMomPropName_, GFSrcName_, phatsqName_, prop0Name_,
twoscalarName_, twoscalarVertexName_,
psquaredName_, psquaredVertexName_;
std::vector<std::string> phaseName_;
std::vector<ScalarField *> phase_;
std::vector<std::string> phaseName_, momPhaseName_;
std::vector<ScalarField *> phase_, momPhase_;
};
MODULE_REGISTER_NS(VPCounterTerms, TVPCounterTerms, MScalar);

View File

@ -10,7 +10,7 @@ modules_cc =\
Modules/MScalar/ChargedProp.cc \
Modules/MScalar/FreeProp.cc \
Modules/MScalar/ScalarVP.cc \
Modules/MScalar/VPCounterTerms.cc
Modules/MScalar/VPCounterTerms.cc \
Modules/MIO/LoadNersc.cc
modules_hpp =\