1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-09-20 09:15:38 +01:00

Hadrons: first cleaning/integration of A2A/meson fields

This commit is contained in:
Antonin Portelli 2018-08-06 12:11:52 +01:00
parent d2650e89bd
commit 3f0f92cda6
7 changed files with 89 additions and 113 deletions

View File

@ -51,6 +51,16 @@ class A2AModesSchurDiagTwo
v_high_4d.resize(size_4d, grid_4d);
}
int get_Nh(void) const
{
return Nh;
}
int get_Nl(void) const
{
return Nl;
}
void high_modes(Field &source_5d, Field &w_source_5d, Field &source_4d, int i)
{
int i5d;

View File

@ -142,7 +142,6 @@ void TimeDilutedSpinColorDiagonalNoise<FImpl>::generateNoise(GridParallelRNG &rn
LatticeCoordinate(tLat, nd - 1);
bernoulli(rng, eta);
eta = (2.*eta - shift)*(1./::sqrt(2.));
std::cout << eta << std::endl;
for (unsigned int t = 0; t < nt_; ++t)
{
etaCut = where((tLat == t), eta, 0.*eta);
@ -154,7 +153,6 @@ void TimeDilutedSpinColorDiagonalNoise<FImpl>::generateNoise(GridParallelRNG &rn
{
noise[i] = zero;
pokeColour(noise[i], etas, c);
std::cout << noise[i] << std::endl;
i++;
}
}

View File

@ -24,8 +24,6 @@ class A2AMesonFieldPar : Serializable
int, cacheBlock,
int, schurBlock,
int, Nmom,
int, N,
int, Nl,
std::string, A2A,
std::string, output);
};
@ -82,9 +80,7 @@ TA2AMesonField<FImpl>::TA2AMesonField(const std::string name)
template <typename FImpl>
std::vector<std::string> TA2AMesonField<FImpl>::getInput(void)
{
std::vector<std::string> in = {par().A2A + "_class"};
in.push_back(par().A2A + "_w_high_4d");
in.push_back(par().A2A + "_v_high_4d");
std::vector<std::string> in = {par().A2A};
return in;
}
@ -102,18 +98,17 @@ std::vector<std::string> TA2AMesonField<FImpl>::getOutput(void)
template <typename FImpl>
void TA2AMesonField<FImpl>::setup(void)
{
auto &a2a = envGet(A2ABase, par().A2A + "_class");
int nt = env().getDim(Tp);
int Nl = par().Nl;
int N = par().N;
int Ls_ = env().getObjectLs(par().A2A + "_class");
auto &a2a = envGet(A2ABase, par().A2A);
int Ls = env().getObjectLs(par().A2A);
// Four D fields
envTmp(std::vector<FermionField>, "w", 1, par().schurBlock, FermionField(env().getGrid(1)));
envTmp(std::vector<FermionField>, "v", 1, par().schurBlock, FermionField(env().getGrid(1)));
envTmp(std::vector<FermionField>, "w", 1, par().schurBlock,
FermionField(env().getGrid()));
envTmp(std::vector<FermionField>, "v", 1, par().schurBlock,
FermionField(env().getGrid()));
// 5D tmp
envTmpLat(FermionField, "tmp_5d", Ls_);
envTmpLat(FermionField, "tmp_5d", Ls);
}
@ -305,7 +300,7 @@ void TA2AMesonField<FImpl>::execute(void)
{
LOG(Message) << "Computing A2A meson field" << std::endl;
auto &a2a = envGet(A2ABase, par().A2A + "_class");
auto &a2a = envGet(A2ABase, par().A2A);
// 2+6+4+4 = 16 gammas
// Ordering defined here
@ -335,8 +330,9 @@ void TA2AMesonField<FImpl>::execute(void)
int nx = env().getDim(Xp);
int ny = env().getDim(Yp);
int nz = env().getDim(Zp);
int N = par().N;
int Nl = par().Nl;
int Nl = a2a.get_Nl();
int N = Nl + a2a.get_Nh();
int ngamma = gammas.size();
int schurBlock = par().schurBlock;
@ -407,7 +403,6 @@ void TA2AMesonField<FImpl>::execute(void)
int N_iii = MIN(N_ii-ii,cacheBlock);
int N_jjj = MIN(N_jj-jj,cacheBlock);
Eigen::Tensor<ComplexD,5> mesonFieldBlocked(nmom,ngamma,nt,N_iii,N_jjj);
t_contr-=usecond();

View File

@ -5,3 +5,4 @@ using namespace Hadrons;
using namespace MNoise;
template class Grid::Hadrons::MNoise::TTimeDilutedSpinColorDiagonal<FIMPL>;
template class Grid::Hadrons::MNoise::TTimeDilutedSpinColorDiagonal<ZFIMPL>;

View File

@ -31,6 +31,7 @@ public:
};
MODULE_REGISTER_TMP(TimeDilutedSpinColorDiagonal, TTimeDilutedSpinColorDiagonal<FIMPL>, MNoise);
MODULE_REGISTER_TMP(ZTimeDilutedSpinColorDiagonal, TTimeDilutedSpinColorDiagonal<ZFIMPL>, MNoise);
/******************************************************************************
* TTimeDilutedSpinColorDiagonal implementation *

View File

@ -4,5 +4,5 @@ using namespace Grid;
using namespace Hadrons;
using namespace MSolver;
template class Grid::Hadrons::MSolver::TA2AVectors<FIMPL, HADRONS_DEFAULT_LANCZOS_NBASIS>;
template class Grid::Hadrons::MSolver::TA2AVectors<ZFIMPL, HADRONS_DEFAULT_LANCZOS_NBASIS>;
template class Grid::Hadrons::MSolver::TA2AVectors<FIMPL, FermionEigenPack<FIMPL>>;
template class Grid::Hadrons::MSolver::TA2AVectors<ZFIMPL, FermionEigenPack<ZFIMPL>>;

View File

@ -7,6 +7,7 @@
#include <Grid/Hadrons/Solver.hpp>
#include <Grid/Hadrons/EigenPack.hpp>
#include <Grid/Hadrons/AllToAllVectors.hpp>
#include <Grid/Hadrons/DilutedNoise.hpp>
BEGIN_HADRONS_NAMESPACE
@ -21,26 +22,20 @@ public:
GRID_SERIALIZABLE_CLASS_MEMBERS(A2AVectorsPar,
bool, return_5d,
int, Nl,
int, N,
std::vector<std::string>, sources,
std::string, noise,
std::string, action,
std::string, eigenPack,
std::string, solver);
};
template <typename FImpl, int nBasis>
template <typename FImpl, typename Pack>
class TA2AVectors : public Module<A2AVectorsPar>
{
public:
public:
FERM_TYPE_ALIASES(FImpl,);
SOLVER_TYPE_ALIASES(FImpl,);
typedef FermionEigenPack<FImpl> EPack;
typedef CoarseFermionEigenPack<FImpl, nBasis> CoarseEPack;
typedef A2AModesSchurDiagTwo<typename FImpl::FermionField, FMat, Solver> A2ABase;
public:
typedef A2AModesSchurDiagTwo<FermionField, FMat, Solver> A2ABase;
public:
// constructor
TA2AVectors(const std::string name);
// destructor
@ -53,46 +48,37 @@ class TA2AVectors : public Module<A2AVectorsPar>
virtual void setup(void);
// execution
virtual void execute(void);
private:
unsigned int Ls_;
std::string className_;
};
MODULE_REGISTER_TMP(A2AVectors, ARG(TA2AVectors<FIMPL, HADRONS_DEFAULT_LANCZOS_NBASIS>), MSolver);
MODULE_REGISTER_TMP(ZA2AVectors, ARG(TA2AVectors<ZFIMPL, HADRONS_DEFAULT_LANCZOS_NBASIS>), MSolver);
MODULE_REGISTER_TMP(A2AVectors,
ARG(TA2AVectors<FIMPL, FermionEigenPack<FIMPL>>), MSolver);
MODULE_REGISTER_TMP(ZA2AVectors,
ARG(TA2AVectors<ZFIMPL, FermionEigenPack<ZFIMPL>>), MSolver);
/******************************************************************************
* TA2AVectors implementation *
******************************************************************************/
// constructor /////////////////////////////////////////////////////////////////
template <typename FImpl, int nBasis>
TA2AVectors<FImpl, nBasis>::TA2AVectors(const std::string name)
template <typename FImpl, typename Pack>
TA2AVectors<FImpl, Pack>::TA2AVectors(const std::string name)
: Module<A2AVectorsPar>(name)
, className_ (name + "_class")
{}
// dependencies/products ///////////////////////////////////////////////////////
template <typename FImpl, int nBasis>
std::vector<std::string> TA2AVectors<FImpl, nBasis>::getInput(void)
template <typename FImpl, typename Pack>
std::vector<std::string> TA2AVectors<FImpl, Pack>::getInput(void)
{
int Nl = par().Nl;
std::string sub_string = "";
if (Nl > 0) sub_string = "_subtract";
std::vector<std::string> in = {par().solver + sub_string};
int n = par().sources.size();
for (unsigned int t = 0; t < n; t += 1)
{
in.push_back(par().sources[t]);
}
std::vector<std::string> in = {par().solver + sub_string, par().noise};
return in;
}
template <typename FImpl, int nBasis>
std::vector<std::string> TA2AVectors<FImpl, nBasis>::getReference(void)
template <typename FImpl, typename Pack>
std::vector<std::string> TA2AVectors<FImpl, Pack>::getReference(void)
{
std::vector<std::string> ref = {par().action};
@ -104,22 +90,21 @@ std::vector<std::string> TA2AVectors<FImpl, nBasis>::getReference(void)
return ref;
}
template <typename FImpl, int nBasis>
std::vector<std::string> TA2AVectors<FImpl, nBasis>::getOutput(void)
template <typename FImpl, typename Pack>
std::vector<std::string> TA2AVectors<FImpl, Pack>::getOutput(void)
{
std::vector<std::string> out = {getName(), className_};
std::vector<std::string> out = {getName()};
return out;
}
// setup ///////////////////////////////////////////////////////////////////////
template <typename FImpl, int nBasis>
void TA2AVectors<FImpl, nBasis>::setup(void)
template <typename FImpl, typename Pack>
void TA2AVectors<FImpl, Pack>::setup(void)
{
int N = par().N;
int Nl = par().Nl;
int Nh = N - Nl;
bool return_5d = par().return_5d;
bool return_5d = par().return_5d;
auto &noise = envGet(DilutedNoise<FImpl>, par().noise);
int Ls;
std::string sub_string = "";
@ -139,94 +124,80 @@ void TA2AVectors<FImpl, nBasis>::setup(void)
if (Nl > 0)
{
// Low modes
auto &epack = envGet(EPack, par().eigenPack);
auto &epack = envGet(Pack, par().eigenPack);
LOG(Message) << "Creating a2a vectors " << getName() <<
" using eigenpack '" << par().eigenPack << "' ("
<< epack.evec.size() << " modes)" <<
" and " << Nh << " high modes." << std::endl;
" and " << noise.size() << " high modes." << std::endl;
evec = &epack.evec;
eval = &epack.eval;
}
else
{
LOG(Message) << "Creating a2a vectors " << getName() <<
" using " << Nh << " high modes only." << std::endl;
" using " << noise.size() << " high modes only." << std::endl;
}
envCreate(A2ABase, className_, Ls,
evec, eval,
action,
solver,
Nl, Nh,
return_5d);
envCreate(A2ABase, getName(), Ls, evec, eval, action, solver, Nl, noise.size(),
return_5d);
}
// execution ///////////////////////////////////////////////////////////////////
template <typename FImpl, int nBasis>
void TA2AVectors<FImpl, nBasis>::execute(void)
template <typename FImpl, typename Pack>
void TA2AVectors<FImpl, Pack>::execute(void)
{
auto &action = envGet(FMat, par().action);
auto &noise = envGet(DilutedNoise<FImpl>, par().noise);
int Nt = env().getDim(Tp);
int Nc = FImpl::Dimension;
int Ls_;
int Ls;
int Nl = par().Nl;
std::string sub_string = "";
if (Nl > 0) sub_string = "_subtract";
Ls_ = env().getObjectLs(par().solver + sub_string);
Ls = env().getObjectLs(par().solver + sub_string);
auto &a2areturn = envGet(A2ABase, className_);
auto &a2areturn = envGet(A2ABase, getName());
// High modes
auto sources = par().sources;
int Nsrc = par().sources.size();
envGetTmp(FermionField, ferm_src);
envGetTmp(FermionField, unphys_ferm);
envGetTmp(FermionField, tmp);
int N_count = 0;
for (unsigned int s = 0; s < Ns; ++s)
for (unsigned int c = 0; c < Nc; ++c)
for (unsigned int T = 0; T < Nsrc; T++)
for (unsigned int i = 0; i < noise.size(); i++)
{
LOG(Message) << "A2A src for noise vector " << i << std::endl;
// source conversion for 4D sources
if (!env().isObject5d(par().noise))
{
auto &prop_src = envGet(PropagatorField, sources[T]);
LOG(Message) << "A2A src for s = " << s << " , c = " << c << ", T = " << T << std::endl;
// source conversion for 4D sources
if (!env().isObject5d(sources[T]))
if (Ls == 1)
{
if (Ls_ == 1)
{
PropToFerm<FImpl>(ferm_src, prop_src, s, c);
tmp = ferm_src;
}
else
{
PropToFerm<FImpl>(tmp, prop_src, s, c);
action.ImportPhysicalFermionSource(tmp, ferm_src);
action.ImportUnphysicalFermion(tmp, unphys_ferm);
}
ferm_src = noise[i];
tmp = ferm_src;
}
// source conversion for 5D sources
else
{
if (Ls_ != env().getObjectLs(sources[T]))
{
HADRONS_ERROR(Size, "Ls mismatch between quark action and source");
}
else
{
PropToFerm<FImpl>(ferm_src, prop_src, s, c);
action.ExportPhysicalFermionSolution(ferm_src, tmp);
unphys_ferm = ferm_src;
}
tmp = noise[i];
action.ImportPhysicalFermionSource(noise[i], ferm_src);
action.ImportUnphysicalFermion(noise[i], unphys_ferm);
}
LOG(Message) << "a2areturn.high_modes Ncount = " << N_count << std::endl;
a2areturn.high_modes(ferm_src, unphys_ferm, tmp, N_count);
N_count++;
}
// source conversion for 5D sources
else
{
if (Ls != env().getObjectLs(par().noise))
{
HADRONS_ERROR(Size, "Ls mismatch between quark action and source");
}
else
{
ferm_src = noise[i];
action.ExportPhysicalFermionSolution(ferm_src, tmp);
unphys_ferm = ferm_src;
}
}
LOG(Message) << "solveHighMode i = " << i << std::endl;
a2areturn.high_modes(ferm_src, unphys_ferm, tmp, i);
}
}
END_MODULE_NAMESPACE