1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-06-14 13:57:07 +01:00

Merge remote-tracking branch 'upstream/feature/hadrons' into feature/hadrons

This commit is contained in:
Vera Guelpers
2018-05-03 10:01:52 +01:00
47 changed files with 1071 additions and 372 deletions

View File

@ -119,7 +119,7 @@ void TWardIdentity<FImpl>::setup(void)
Ls_ = env().getObjectLs(par().q);
if (Ls_ != env().getObjectLs(par().action))
{
HADRON_ERROR(Size, "Ls mismatch between quark action and propagator");
HADRONS_ERROR(Size, "Ls mismatch between quark action and propagator");
}
envTmpLat(PropagatorField, "tmp");
envTmpLat(PropagatorField, "vector_WI");

View File

@ -177,7 +177,7 @@ void TGaugeProp<FImpl>::execute(void)
{
if (Ls_ != env().getObjectLs(par().source))
{
HADRON_ERROR(Size, "Ls mismatch between quark action and source");
HADRONS_ERROR(Size, "Ls mismatch between quark action and source");
}
else
{

View File

@ -49,19 +49,20 @@ public:
std::string, output);
};
class DivResult: Serializable
{
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(DivResult,
DiffType, type,
Complex, value);
};
template <typename SImpl>
class TDiv: public Module<DivPar>
{
public:
typedef typename SImpl::Field Field;
typedef typename SImpl::ComplexField ComplexField;
class Result: Serializable
{
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(Result,
DiffType, type,
Complex, value);
};
public:
// constructor
TDiv(const std::string name);
@ -112,7 +113,7 @@ void TDiv<SImpl>::setup(void)
{
if (par().op.size() != env().getNd())
{
HADRON_ERROR(Size, "the number of components differs from number of dimensions");
HADRONS_ERROR(Size, "the number of components differs from number of dimensions");
}
envCreateLat(ComplexField, getName());
}
@ -139,7 +140,7 @@ void TDiv<SImpl>::execute(void)
}
if (!par().output.empty())
{
Result r;
DivResult r;
r.type = par().type;
r.value = TensorRemove(sum(div));

View File

@ -54,6 +54,17 @@ public:
std::string, output);
};
class EMTResult: Serializable
{
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(EMTResult,
std::vector<std::vector<Complex>>, value,
double, m2,
double, lambda,
double, g,
double, xi);
};
template <typename SImpl>
class TEMT: public Module<EMTPar>
{
@ -155,13 +166,22 @@ void TEMT<SImpl>::execute(void)
LOG(Message) << " xi= " << par().xi << std::endl;
}
const unsigned int N = SImpl::Group::Dimension;
const unsigned int N = SImpl::Group::Dimension, nd = env().getNd();
auto &trphi2 = envGet(ComplexField, varName(par().phiPow, 2));
auto &trphi4 = envGet(ComplexField, varName(par().phiPow, 4));
auto &sumkin = envGet(ComplexField, varName(par().kinetic, "sum"));
EMTResult result;
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
for (unsigned int nu = mu; nu < env().getNd(); ++nu)
if (!par().output.empty())
{
result.m2 = par().m2;
result.g = par().g;
result.lambda = par().lambda;
result.xi = par().xi;
result.value.resize(nd, std::vector<Complex>(nd));
}
for (unsigned int mu = 0; mu < nd; ++mu)
for (unsigned int nu = mu; nu < nd; ++nu)
{
auto &out = envGet(ComplexField, varName(getName(), mu, nu));
auto &trkin = envGet(ComplexField, varName(par().kinetic, mu, nu));
@ -178,6 +198,15 @@ void TEMT<SImpl>::execute(void)
out -= sumkin + par().m2*trphi2 + par().lambda*trphi4;
}
out *= N/par().g;
if (!par().output.empty())
{
result.value[mu][nu] = TensorRemove(sum(out));
result.value[mu][nu] = result.value[nu][mu];
}
}
if (!par().output.empty())
{
saveResult(par().output, "emt", result);
}
}

View File

@ -49,19 +49,20 @@ public:
std::string, output);
};
class GradResult: Serializable
{
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(GradResult,
DiffType, type,
std::vector<Complex>, value);
};
template <typename SImpl>
class TGrad: public Module<GradPar>
{
public:
typedef typename SImpl::Field Field;
typedef typename SImpl::ComplexField ComplexField;
class Result: Serializable
{
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(Result,
DiffType, type,
Complex, value);
};
public:
// constructor
TGrad(const std::string name);
@ -130,14 +131,18 @@ void TGrad<SImpl>::setup(void)
template <typename SImpl>
void TGrad<SImpl>::execute(void)
{
const auto nd = env().getNd();
LOG(Message) << "Computing the " << par().type << " gradient of '"
<< par().op << "'" << std::endl;
std::vector<Result> result;
auto &op = envGet(ComplexField, par().op);
const unsigned int nd = env().getNd();
GradResult result;
auto &op = envGet(ComplexField, par().op);
if (!par().output.empty())
{
result.type = par().type;
result.value.resize(nd);
}
for (unsigned int mu = 0; mu < nd; ++mu)
{
auto &der = envGet(ComplexField, varName(getName(), mu));
@ -145,14 +150,10 @@ void TGrad<SImpl>::execute(void)
dmu(der, op, mu, par().type);
if (!par().output.empty())
{
Result r;
r.type = par().type;
r.value = TensorRemove(sum(der));
result.push_back(r);
result.value[mu] = TensorRemove(sum(der));
}
}
if (result.size() > 0)
if (!par().output.empty())
{
saveResult(par().output, "grad", result);
}

View File

@ -51,20 +51,20 @@ public:
std::string, output);
};
class ShiftProbeResult: Serializable
{
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(ShiftProbeResult,
std::string, shifts,
Complex, value);
};
template <typename SImpl>
class TShiftProbe: public Module<ShiftProbePar>
{
public:
typedef typename SImpl::Field Field;
typedef typename SImpl::ComplexField ComplexField;
class Result: Serializable
{
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(Result,
std::string, op,
Complex , value);
};
public:
// constructor
TShiftProbe(const std::string name);
@ -134,14 +134,14 @@ void TShiftProbe<SImpl>::execute(void)
shift = strToVec<ShiftPair>(par().shifts);
if (shift.size() % 2 != 0)
{
HADRON_ERROR(Size, "the number of shifts is odd");
HADRONS_ERROR(Size, "the number of shifts is odd");
}
sign = (shift.size() % 4 == 0) ? 1 : -1;
for (auto &s: shift)
{
if (s.first >= env().getNd())
{
HADRON_ERROR(Size, "dimension to large for shift <"
HADRONS_ERROR(Size, "dimension to large for shift <"
+ std::to_string(s.first) + " "
+ std::to_string(s.second) + ">" );
}
@ -160,6 +160,14 @@ void TShiftProbe<SImpl>::execute(void)
}
}
probe = real(sign*trace(acc));
if (!par().output.empty())
{
ShiftProbeResult r;
r.shifts = par().shifts;
r.value = TensorRemove(sum(probe));
saveResult(par().output, "probe", r);
}
}
END_MODULE_NAMESPACE

View File

@ -49,19 +49,20 @@ public:
std::string, output);
};
class TrKineticResult: Serializable
{
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(TrKineticResult,
std::vector<std::vector<Complex>>, value,
DiffType, type);
};
template <typename SImpl>
class TTrKinetic: public Module<TrKineticPar>
{
public:
typedef typename SImpl::Field Field;
typedef typename SImpl::ComplexField ComplexField;
class Result: Serializable
{
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(Result,
std::string, op,
Complex , value);
};
public:
// constructor
TTrKinetic(const std::string name);
@ -135,18 +136,24 @@ void TTrKinetic<SImpl>::execute(void)
LOG(Message) << "Computing tr(d_mu phi*d_nu phi) using " << par().type
<< " derivative" << std::endl;
std::vector<Result> result;
auto &phi = envGet(Field, par().field);
auto &sumkin = envGet(ComplexField, varName(getName(), "sum"));
const unsigned int nd = env().getNd();
TrKineticResult result;
auto &phi = envGet(Field, par().field);
auto &sumkin = envGet(ComplexField, varName(getName(), "sum"));
envGetTmp(std::vector<Field>, der);
sumkin = zero;
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
if (!par().output.empty())
{
result.type = par().type;
result.value.resize(nd, std::vector<Complex>(nd));
}
for (unsigned int mu = 0; mu < nd; ++mu)
{
dmu(der[mu], phi, mu, par().type);
}
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
for (unsigned int nu = mu; nu < env().getNd(); ++nu)
for (unsigned int mu = 0; mu < nd; ++mu)
for (unsigned int nu = mu; nu < nd; ++nu)
{
auto &out = envGet(ComplexField, varName(getName(), mu, nu));
@ -155,32 +162,13 @@ void TTrKinetic<SImpl>::execute(void)
{
sumkin += out;
}
}
if (!par().output.empty())
{
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
for (unsigned int nu = mu; nu < env().getNd(); ++nu)
if (!par().output.empty())
{
auto &out = envGet(ComplexField, varName(getName(), mu, nu));
Result r;
r.op = "tr(d_" + std::to_string(mu) + "phi*d_"
+ std::to_string(nu) + "phi)";
r.value = TensorRemove(sum(out));
result.push_back(r);
}
{
Result r;
r.op = "sum_mu tr(d_mu phi*d_mu phi)";
r.value = TensorRemove(sum(sumkin));
result.push_back(r);
result.value[mu][nu] = TensorRemove(sum(out));
result.value[mu][nu] = result.value[nu][mu];
}
}
if (result.size() > 0)
{
saveResult(par().output, "trkinetic", result);
}
saveResult(par().output, "trkinetic", result);
}
END_MODULE_NAMESPACE

View File

@ -49,19 +49,20 @@ public:
std::string, output);
};
class TrMagResult: Serializable
{
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(TrMagResult,
std::string, op,
Real, value);
};
template <typename SImpl>
class TTrMag: public Module<TrMagPar>
{
public:
typedef typename SImpl::Field Field;
typedef typename SImpl::ComplexField ComplexField;
class Result: Serializable
{
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(Result,
std::string, op,
Real, value);
};
public:
// constructor
TTrMag(const std::string name);
@ -120,8 +121,8 @@ void TTrMag<SImpl>::execute(void)
LOG(Message) << "Computing tr(mag^n) for n even up to " << par().maxPow
<< std::endl;
std::vector<Result> result;
auto &phi = envGet(Field, par().field);
std::vector<TrMagResult> result;
auto &phi = envGet(Field, par().field);
auto m2 = sum(phi), mn = m2;
@ -129,7 +130,7 @@ void TTrMag<SImpl>::execute(void)
mn = 1.;
for (unsigned int n = 2; n <= par().maxPow; n += 2)
{
Result r;
TrMagResult r;
mn = mn*m2;
r.op = "tr(mag^" + std::to_string(n) + ")";

View File

@ -49,19 +49,21 @@ public:
std::string, output);
};
class TrPhiResult: Serializable
{
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(TrPhiResult,
std::string, op,
Real, value);
};
template <typename SImpl>
class TTrPhi: public Module<TrPhiPar>
{
public:
typedef typename SImpl::Field Field;
typedef typename SImpl::ComplexField ComplexField;
class Result: Serializable
{
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(Result,
std::string, op,
Real, value);
};
public:
// constructor
TTrPhi(const std::string name);
@ -119,7 +121,7 @@ void TTrPhi<SImpl>::setup(void)
{
if (par().maxPow < 2)
{
HADRON_ERROR(Size, "'maxPow' should be at least equal to 2");
HADRONS_ERROR(Size, "'maxPow' should be at least equal to 2");
}
envTmpLat(Field, "phi2");
envTmpLat(Field, "buf");
@ -136,8 +138,8 @@ void TTrPhi<SImpl>::execute(void)
LOG(Message) << "Computing tr(phi^n) for n even up to " << par().maxPow
<< std::endl;
std::vector<Result> result;
auto &phi = envGet(Field, par().field);
std::vector<TrPhiResult> result;
auto &phi = envGet(Field, par().field);
envGetTmp(Field, phi2);
envGetTmp(Field, buf);
@ -151,7 +153,7 @@ void TTrPhi<SImpl>::execute(void)
phin = trace(buf);
if (!par().output.empty())
{
Result r;
TrPhiResult r;
r.op = "tr(phi^" + std::to_string(n) + ")";
r.value = TensorRemove(sum(phin)).real();

View File

@ -49,19 +49,20 @@ public:
std::string, output);
};
class TransProjResult: Serializable
{
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(TransProjResult,
std::vector<std::vector<Complex>>, value,
DiffType, type);
};
template <typename SImpl>
class TTransProj: public Module<TransProjPar>
{
public:
typedef typename SImpl::Field Field;
typedef typename SImpl::ComplexField ComplexField;
class Result: Serializable
{
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(Result,
std::string, op,
Complex , value);
};
public:
// constructor
TTransProj(const std::string name);
@ -137,21 +138,27 @@ void TTransProj<SImpl>::execute(void)
<< par().type << " derivatives and op= '" << par().op
<< "'" << std::endl;
std::vector<Result> result;
auto &op = envGet(ComplexField, par().op);
const unsigned int nd = env().getNd();
TransProjResult result;
auto &op = envGet(ComplexField, par().op);
envGetTmp(ComplexField, buf1);
envGetTmp(ComplexField, buf2);
envGetTmp(ComplexField, lap);
lap = zero;
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
if (!par().output.empty())
{
result.type = par().type;
result.value.resize(nd, std::vector<Complex>(nd));
}
for (unsigned int mu = 0; mu < nd; ++mu)
{
dmu(buf1, op, mu, par().type);
dmu(buf2, buf1, mu, par().type);
lap += buf2;
}
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
for (unsigned int nu = mu; nu < env().getNd(); ++nu)
for (unsigned int mu = 0; mu < nd; ++mu)
for (unsigned int nu = mu; nu < nd; ++nu)
{
auto &out = envGet(ComplexField, varName(getName(), mu, nu));
dmu(buf1, op, mu, par().type);
@ -163,16 +170,11 @@ void TTransProj<SImpl>::execute(void)
}
if (!par().output.empty())
{
Result r;
r.op = "(delta_" + std::to_string(mu) + "," + std::to_string(nu)
+ " d^2 - d_" + std::to_string(mu) + "*d_"
+ std::to_string(nu) + ")*op";
r.value = TensorRemove(sum(out));
result.push_back(r);
result.value[mu][nu] = TensorRemove(sum(out));
result.value[mu][nu] = result.value[nu][mu];
}
}
if (result.size() > 0)
if (!par().output.empty())
{
saveResult(par().output, "transproj", result);
}

View File

@ -50,23 +50,23 @@ public:
std::string, output);
};
class TwoPointResult: Serializable
{
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(TwoPointResult,
std::string, sink,
std::string, source,
std::vector<int>, mom,
std::vector<Complex>, data);
};
template <typename SImpl>
class TTwoPoint: public Module<TwoPointPar>
{
public:
typedef typename SImpl::Field Field;
typedef typename SImpl::ComplexField ComplexField;
typedef std::vector<TComplex> SlicedOp;
class Result: Serializable
{
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(Result,
std::string, sink,
std::string, source,
std::vector<int>, mom,
std::vector<Complex>, data);
};
typedef typename SImpl::Field Field;
typedef typename SImpl::ComplexField ComplexField;
typedef std::vector<Complex> SlicedOp;
public:
// constructor
TTwoPoint(const std::string name);
@ -143,7 +143,7 @@ void TTwoPoint<SImpl>::setup(void)
mom_[i] = strToVec<int>(par().mom[i]);
if (mom_[i].size() != nd - 1)
{
HADRON_ERROR(Size, "momentum number of components different from "
HADRONS_ERROR(Size, "momentum number of components different from "
+ std::to_string(nd-1));
}
}
@ -160,18 +160,24 @@ void TTwoPoint<SImpl>::execute(void)
LOG(Message) << " <" << p.first << " " << p.second << ">" << std::endl;
}
const unsigned int nd = env().getDim().size();
const unsigned int nt = env().getDim().back();
const unsigned int nop = par().op.size();
const unsigned int nmom = mom_.size();
const unsigned int nd = env().getNd();
const unsigned int nt = env().getDim().back();
const unsigned int nop = par().op.size();
const unsigned int nmom = mom_.size();
double partVol = 1.;
std::vector<int> dMask(nd, 1);
std::set<std::string> ops;
std::vector<Result> result;
std::vector<TwoPointResult> result;
std::map<std::string, std::vector<SlicedOp>> slicedOp;
FFT fft(env().getGrid());
TComplex buf;
envGetTmp(ComplexField, ftBuf);
dMask[nd - 1] = 0;
for (unsigned int mu = 0; mu < nd - 1; ++mu)
{
partVol *= env().getDim()[mu];
}
for (auto &p: par().op)
{
ops.insert(p.first);
@ -183,7 +189,7 @@ void TTwoPoint<SImpl>::execute(void)
slicedOp[o].resize(nmom);
LOG(Message) << "Operator '" << o << "' FFT" << std::endl;
fft.FFT_dim_mask(ftBuf, op, dMask, FFT::backward);
fft.FFT_dim_mask(ftBuf, op, dMask, FFT::forward);
for (unsigned int m = 0; m < nmom; ++m)
{
auto qt = mom_[m];
@ -193,7 +199,8 @@ void TTwoPoint<SImpl>::execute(void)
for (unsigned int t = 0; t < nt; ++t)
{
qt[nd - 1] = t;
peekSite(slicedOp[o][m][t], ftBuf, qt);
peekSite(buf, ftBuf, qt);
slicedOp[o][m][t] = TensorRemove(buf)/partVol;
}
}
}
@ -201,7 +208,7 @@ void TTwoPoint<SImpl>::execute(void)
for (unsigned int m = 0; m < nmom; ++m)
for (auto &p: par().op)
{
Result r;
TwoPointResult r;
r.sink = p.first;
r.source = p.second;
@ -228,7 +235,7 @@ std::vector<Complex> TTwoPoint<SImpl>::makeTwoPoint(
{
for (unsigned int t = 0; t < nt; ++t)
{
res[dt] += TensorRemove(trace(sink[(t+dt)%nt]*adj(source[t])));
res[dt] += sink[(t+dt)%nt]*adj(source[t]);
}
res[dt] *= 1./static_cast<double>(nt);
}

View File

@ -44,7 +44,7 @@ inline void dmu(Field &out, const Field &in, const unsigned int mu, const DiffTy
if (mu >= env.getNd())
{
HADRON_ERROR(Range, "Derivative direction out of range");
HADRONS_ERROR(Range, "Derivative direction out of range");
}
switch(type)
{
@ -58,7 +58,7 @@ inline void dmu(Field &out, const Field &in, const unsigned int mu, const DiffTy
out = 0.5*(Cshift(in, mu, 1) - Cshift(in, mu, -1));
break;
default:
HADRON_ERROR(Argument, "Derivative type invalid");
HADRONS_ERROR(Argument, "Derivative type invalid");
break;
}
}
@ -70,7 +70,7 @@ inline void dmuAcc(Field &out, const Field &in, const unsigned int mu, const Dif
if (mu >= env.getNd())
{
HADRON_ERROR(Range, "Derivative direction out of range");
HADRONS_ERROR(Range, "Derivative direction out of range");
}
switch(type)
{
@ -84,7 +84,7 @@ inline void dmuAcc(Field &out, const Field &in, const unsigned int mu, const Dif
out += 0.5*(Cshift(in, mu, 1) - Cshift(in, mu, -1));
break;
default:
HADRON_ERROR(Argument, "Derivative type invalid");
HADRONS_ERROR(Argument, "Derivative type invalid");
break;
}
}

View File

@ -127,7 +127,7 @@ void TRBPrecCG<FImpl, nBasis>::setup(void)
{
if (par().maxIteration == 0)
{
HADRON_ERROR(Argument, "zero maximum iteration");
HADRONS_ERROR(Argument, "zero maximum iteration");
}
LOG(Message) << "setting up Schur red-black preconditioned CG for"

View File

@ -123,7 +123,7 @@ void TTestSeqConserved<FImpl>::setup(void)
auto Ls = env().getObjectLs(par().q);
if (Ls != env().getObjectLs(par().action))
{
HADRON_ERROR(Size, "Ls mismatch between quark action and propagator");
HADRONS_ERROR(Size, "Ls mismatch between quark action and propagator");
}
envTmpLat(PropagatorField, "tmp");
envTmpLat(LatticeComplex, "c");