1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-04-09 21:50:45 +01:00

Hadrons: scalar SU(N) result handling improvement

This commit is contained in:
Antonin Portelli 2018-04-26 17:32:37 +01:00
parent cc6eb51e3e
commit d47484717e
9 changed files with 156 additions and 124 deletions

View File

@ -49,19 +49,20 @@ public:
std::string, output); std::string, output);
}; };
class DivResult: Serializable
{
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(DivResult,
DiffType, type,
Complex, value);
};
template <typename SImpl> template <typename SImpl>
class TDiv: public Module<DivPar> class TDiv: public Module<DivPar>
{ {
public: public:
typedef typename SImpl::Field Field; typedef typename SImpl::Field Field;
typedef typename SImpl::ComplexField ComplexField; typedef typename SImpl::ComplexField ComplexField;
class Result: Serializable
{
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(Result,
DiffType, type,
Complex, value);
};
public: public:
// constructor // constructor
TDiv(const std::string name); TDiv(const std::string name);
@ -139,7 +140,7 @@ void TDiv<SImpl>::execute(void)
} }
if (!par().output.empty()) if (!par().output.empty())
{ {
Result r; DivResult r;
r.type = par().type; r.type = par().type;
r.value = TensorRemove(sum(div)); r.value = TensorRemove(sum(div));

View File

@ -54,6 +54,17 @@ public:
std::string, output); 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> template <typename SImpl>
class TEMT: public Module<EMTPar> class TEMT: public Module<EMTPar>
{ {
@ -155,13 +166,22 @@ void TEMT<SImpl>::execute(void)
LOG(Message) << " xi= " << par().xi << std::endl; 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 &trphi2 = envGet(ComplexField, varName(par().phiPow, 2));
auto &trphi4 = envGet(ComplexField, varName(par().phiPow, 4)); auto &trphi4 = envGet(ComplexField, varName(par().phiPow, 4));
auto &sumkin = envGet(ComplexField, varName(par().kinetic, "sum")); auto &sumkin = envGet(ComplexField, varName(par().kinetic, "sum"));
EMTResult result;
for (unsigned int mu = 0; mu < env().getNd(); ++mu) if (!par().output.empty())
for (unsigned int nu = mu; nu < env().getNd(); ++nu) {
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 &out = envGet(ComplexField, varName(getName(), mu, nu));
auto &trkin = envGet(ComplexField, varName(par().kinetic, 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 -= sumkin + par().m2*trphi2 + par().lambda*trphi4;
} }
out *= N/par().g; 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); std::string, output);
}; };
class GradResult: Serializable
{
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(GradResult,
DiffType, type,
std::vector<Complex>, value);
};
template <typename SImpl> template <typename SImpl>
class TGrad: public Module<GradPar> class TGrad: public Module<GradPar>
{ {
public: public:
typedef typename SImpl::Field Field; typedef typename SImpl::Field Field;
typedef typename SImpl::ComplexField ComplexField; typedef typename SImpl::ComplexField ComplexField;
class Result: Serializable
{
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(Result,
DiffType, type,
Complex, value);
};
public: public:
// constructor // constructor
TGrad(const std::string name); TGrad(const std::string name);
@ -130,14 +131,18 @@ void TGrad<SImpl>::setup(void)
template <typename SImpl> template <typename SImpl>
void TGrad<SImpl>::execute(void) void TGrad<SImpl>::execute(void)
{ {
const auto nd = env().getNd();
LOG(Message) << "Computing the " << par().type << " gradient of '" LOG(Message) << "Computing the " << par().type << " gradient of '"
<< par().op << "'" << std::endl; << par().op << "'" << std::endl;
std::vector<Result> result; const unsigned int nd = env().getNd();
auto &op = envGet(ComplexField, par().op); 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) for (unsigned int mu = 0; mu < nd; ++mu)
{ {
auto &der = envGet(ComplexField, varName(getName(), mu)); auto &der = envGet(ComplexField, varName(getName(), mu));
@ -145,14 +150,10 @@ void TGrad<SImpl>::execute(void)
dmu(der, op, mu, par().type); dmu(der, op, mu, par().type);
if (!par().output.empty()) if (!par().output.empty())
{ {
Result r; result.value[mu] = TensorRemove(sum(der));
r.type = par().type;
r.value = TensorRemove(sum(der));
result.push_back(r);
} }
} }
if (result.size() > 0) if (!par().output.empty())
{ {
saveResult(par().output, "grad", result); saveResult(par().output, "grad", result);
} }

View File

@ -51,20 +51,20 @@ public:
std::string, output); std::string, output);
}; };
class ShiftProbeResult: Serializable
{
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(ShiftProbeResult,
std::string, shifts,
Complex, value);
};
template <typename SImpl> template <typename SImpl>
class TShiftProbe: public Module<ShiftProbePar> class TShiftProbe: public Module<ShiftProbePar>
{ {
public: public:
typedef typename SImpl::Field Field; typedef typename SImpl::Field Field;
typedef typename SImpl::ComplexField ComplexField; typedef typename SImpl::ComplexField ComplexField;
class Result: Serializable
{
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(Result,
std::string, op,
Complex , value);
};
public: public:
// constructor // constructor
TShiftProbe(const std::string name); TShiftProbe(const std::string name);
@ -160,6 +160,14 @@ void TShiftProbe<SImpl>::execute(void)
} }
} }
probe = real(sign*trace(acc)); 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 END_MODULE_NAMESPACE

View File

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

View File

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

View File

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

View File

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

View File

@ -50,6 +50,16 @@ public:
std::string, output); 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> template <typename SImpl>
class TTwoPoint: public Module<TwoPointPar> class TTwoPoint: public Module<TwoPointPar>
{ {
@ -57,16 +67,6 @@ public:
typedef typename SImpl::Field Field; typedef typename SImpl::Field Field;
typedef typename SImpl::ComplexField ComplexField; typedef typename SImpl::ComplexField ComplexField;
typedef std::vector<TComplex> SlicedOp; 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);
};
public: public:
// constructor // constructor
TTwoPoint(const std::string name); TTwoPoint(const std::string name);
@ -166,7 +166,7 @@ void TTwoPoint<SImpl>::execute(void)
const unsigned int nmom = mom_.size(); const unsigned int nmom = mom_.size();
std::vector<int> dMask(nd, 1); std::vector<int> dMask(nd, 1);
std::set<std::string> ops; std::set<std::string> ops;
std::vector<Result> result; std::vector<TwoPointResult> result;
std::map<std::string, std::vector<SlicedOp>> slicedOp; std::map<std::string, std::vector<SlicedOp>> slicedOp;
FFT fft(env().getGrid()); FFT fft(env().getGrid());
@ -201,7 +201,7 @@ void TTwoPoint<SImpl>::execute(void)
for (unsigned int m = 0; m < nmom; ++m) for (unsigned int m = 0; m < nmom; ++m)
for (auto &p: par().op) for (auto &p: par().op)
{ {
Result r; TwoPointResult r;
r.sink = p.first; r.sink = p.first;
r.source = p.second; r.source = p.second;