1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-14 01:35:36 +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 /////////////////////////////////////////////////////////////////////// // setup ///////////////////////////////////////////////////////////////////////
void TUnitEm::setup(void) void TUnitEm::setup(void)
{ {
env().registerLattice<EmField>(getName()); envCreateLat(EmField, getName());
} }
// execution /////////////////////////////////////////////////////////////////// // execution ///////////////////////////////////////////////////////////////////
void TUnitEm::execute(void) void TUnitEm::execute(void)
{ {
PhotonR photon(0, 0, 0); // Just chose arbitrary input values here 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; LOG(Message) << "Generating unit EM potential..." << std::endl;
photon.UnitField(a); photon.UnitField(a);
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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