mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-13 04:37:05 +01:00
Merge branch 'develop' of github.com:fionnoh/Grid into feature/A2A_current_insertion
Peter's GPU branch changes merged with A2A CI code
This commit is contained in:
@ -122,10 +122,8 @@ void TWilson<FImpl>::setup(void)
|
||||
{
|
||||
implParams.twist_n_2pi_L = strToVec<Real>(par().twist);
|
||||
}
|
||||
LOG(Message) << "Fermion boundary conditions: " << implParams.boundary_phases
|
||||
<< std::endl;
|
||||
LOG(Message) << "Twists: " << implParams.twist_n_2pi_L
|
||||
<< std::endl;
|
||||
LOG(Message) << "Fermion boundary conditions: " << implParams.boundary_phases << std::endl;
|
||||
LOG(Message) << "Twists: " << implParams.twist_n_2pi_L << std::endl;
|
||||
if (implParams.boundary_phases.size() != env().getNd())
|
||||
{
|
||||
HADRONS_ERROR(Size, "Wrong number of boundary phase");
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
double , M5,
|
||||
double , b,
|
||||
double , c,
|
||||
std::vector<std::complex<double>>, omega,
|
||||
std::vector<std::complex<double> >, omega,
|
||||
std::string , boundary,
|
||||
std::string , twist);
|
||||
};
|
||||
@ -126,6 +126,8 @@ void TZMobiusDWF<FImpl>::setup(void)
|
||||
auto &grb5 = *envGetRbGrid(FermionField, par().Ls);
|
||||
auto omega = par().omega;
|
||||
typename ZMobiusFermion<FImpl>::ImplParams implParams;
|
||||
|
||||
|
||||
if (!par().boundary.empty())
|
||||
{
|
||||
implParams.boundary_phases = strToVec<Complex>(par().boundary);
|
||||
@ -134,10 +136,8 @@ void TZMobiusDWF<FImpl>::setup(void)
|
||||
{
|
||||
implParams.twist_n_2pi_L = strToVec<Real>(par().twist);
|
||||
}
|
||||
LOG(Message) << "Fermion boundary conditions: " << implParams.boundary_phases
|
||||
<< std::endl;
|
||||
LOG(Message) << "Twists: " << implParams.twist_n_2pi_L
|
||||
<< std::endl;
|
||||
LOG(Message) << "Fermion boundary conditions: " << implParams.boundary_phases << std::endl;
|
||||
LOG(Message) << "Twists: " << implParams.twist_n_2pi_L << std::endl;
|
||||
if (implParams.boundary_phases.size() != env().getNd())
|
||||
{
|
||||
HADRONS_ERROR(Size, "Wrong number of boundary phase");
|
||||
@ -146,9 +146,17 @@ void TZMobiusDWF<FImpl>::setup(void)
|
||||
{
|
||||
HADRONS_ERROR(Size, "Wrong number of twist");
|
||||
}
|
||||
envCreateDerived(FMat, ZMobiusFermion<FImpl>, getName(), par().Ls, U, g5,
|
||||
grb5, g4, grb4, par().mass, par().M5, omega,
|
||||
par().b, par().c, implParams);
|
||||
|
||||
assert(par().Ls==omega.size());
|
||||
int Ls=par().Ls;
|
||||
std::vector<ComplexD> _omega(Ls);
|
||||
for(int i=0;i<Ls;i++){
|
||||
_omega[i] = omega[i];
|
||||
}
|
||||
envCreateDerived(FMat, ZMobiusFermion<FImpl>, getName(), par().Ls,
|
||||
U, g5, grb5, g4, grb4,
|
||||
par().mass, par().M5,
|
||||
_omega, par().b, par().c, implParams);
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
|
@ -174,6 +174,7 @@ void TA2AAslashField<FImpl, PhotonImpl>::setup(void)
|
||||
template <typename FImpl, typename PhotonImpl>
|
||||
void TA2AAslashField<FImpl, PhotonImpl>::execute(void)
|
||||
{
|
||||
#ifndef GRID_NVCC
|
||||
auto &left = envGet(std::vector<FermionField>, par().left);
|
||||
auto &right = envGet(std::vector<FermionField>, par().right);
|
||||
|
||||
@ -237,6 +238,7 @@ void TA2AAslashField<FImpl, PhotonImpl>::execute(void)
|
||||
|
||||
envGetTmp(Computation, computation);
|
||||
computation.execute(left, right, kernel, ionameFn, filenameFn, metadataFn);
|
||||
#endif
|
||||
}
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
@ -109,7 +109,7 @@ void TA2ALoop<FImpl>::execute(void)
|
||||
auto &left = envGet(std::vector<FermionField>, par().left);
|
||||
auto &right = envGet(std::vector<FermionField>, par().right);
|
||||
|
||||
loop = zero;
|
||||
loop = Zero();
|
||||
for (unsigned int i = 0; i < left.size(); ++i)
|
||||
{
|
||||
loop += outerProduct(left[i], right[i]);
|
||||
|
@ -258,7 +258,7 @@ void TA2AMesonField<FImpl>::execute(void)
|
||||
std::vector<Real> p;
|
||||
|
||||
envGetTmp(ComplexField, coor);
|
||||
ph[j] = zero;
|
||||
ph[j] = Zero();
|
||||
for(unsigned int mu = 0; mu < mom_[j].size(); mu++)
|
||||
{
|
||||
LatticeCoordinate(coor, mu);
|
||||
|
@ -156,7 +156,7 @@ void TWeakMesonDecayKl2<FImpl>::execute(void)
|
||||
std::vector<SpinMatrix> res_summed;
|
||||
Result r;
|
||||
|
||||
auto &res = envGet(PropagatorField, getName()); res = zero;
|
||||
auto &res = envGet(PropagatorField, getName()); res = Zero();
|
||||
auto &q1 = envGet(PropagatorField, par().q1);
|
||||
auto &q2 = envGet(PropagatorField, par().q2);
|
||||
auto &lepton = envGet(PropagatorField, par().lepton);
|
||||
@ -166,7 +166,7 @@ void TWeakMesonDecayKl2<FImpl>::execute(void)
|
||||
|
||||
for (unsigned int mu = 0; mu < 4; ++mu)
|
||||
{
|
||||
c = zero;
|
||||
c = Zero();
|
||||
//hadronic part: trace(q1*adj(q2)*g5*gL[mu])
|
||||
c = trace(q1*adj(q2)*g5*GammaL(Gamma::gmu[mu]));
|
||||
prop_buf = 1.;
|
||||
|
@ -219,7 +219,7 @@ void TEMLepton<FImpl>::execute(void)
|
||||
// 5D source if action is 5d
|
||||
mat.ImportPhysicalFermionSource(tmp, source);
|
||||
}
|
||||
sol = zero;
|
||||
sol = Zero();
|
||||
mat.FreePropagator(source,sol,mass,boundary,twist);
|
||||
if (Ls_ == 1)
|
||||
{
|
||||
@ -257,14 +257,14 @@ void TEMLepton<FImpl>::execute(void)
|
||||
proptmp = where( tlat < tl, boundary[Tp]*proptmp, proptmp);
|
||||
|
||||
// i*A_mu*gamma_mu
|
||||
sourcetmp = zero;
|
||||
sourcetmp = Zero();
|
||||
for(unsigned int mu=0;mu<=3;mu++)
|
||||
{
|
||||
Gamma gmu(Gamma::gmu[mu]);
|
||||
sourcetmp += ci * PeekIndex<LorentzIndex>(stoch_photon, mu) * (gmu * proptmp );
|
||||
}
|
||||
|
||||
proptmp = zero;
|
||||
proptmp = Zero();
|
||||
|
||||
//sequential propagator from i*Aslash*S
|
||||
LOG(Message) << "Sequential propagator for t= " << tl << std::endl;
|
||||
@ -281,7 +281,7 @@ void TEMLepton<FImpl>::execute(void)
|
||||
// 5D source if action is 5d
|
||||
mat.ImportPhysicalFermionSource(tmp, source);
|
||||
}
|
||||
sol = zero;
|
||||
sol = Zero();
|
||||
mat.FreePropagator(source,sol,mass,boundary,twist);
|
||||
if (Ls_ == 1)
|
||||
{
|
||||
|
@ -167,7 +167,7 @@ void TFreeProp<FImpl>::execute(void)
|
||||
PropToFerm<FImpl>(source, fullSrc, s, c);
|
||||
}
|
||||
}
|
||||
sol = zero;
|
||||
sol = Zero();
|
||||
std::vector<double> twist = strToVec<double>(par().twist);
|
||||
if(twist.size() != Nd)
|
||||
{
|
||||
|
@ -174,8 +174,8 @@ void TGaugeProp<FImpl>::execute(void)
|
||||
PropToFerm<FImpl>(source, fullSrc, s, c);
|
||||
}
|
||||
}
|
||||
sol = Zero();
|
||||
LOG(Message) << "Solve" << std::endl;
|
||||
sol = zero;
|
||||
solver(sol, source);
|
||||
LOG(Message) << "Export solution" << std::endl;
|
||||
FermToProp<FImpl>(prop, sol, s, c);
|
||||
|
@ -177,7 +177,7 @@ void TLoadEigenPack<Pack, GImpl>::execute(void)
|
||||
for (unsigned int i = 0; i < par().size; i++)
|
||||
{
|
||||
LOG(Message) << "Applying gauge transformation to eigenvector i = " << i << "/" << par().size << std::endl;
|
||||
epack.evec[i].checkerboard = Odd;
|
||||
epack.evec[i].Checkerboard() = Odd;
|
||||
epack.evec[i] = tmpXformOdd * epack.evec[i];
|
||||
}
|
||||
stopTimer("Transform application");
|
||||
|
@ -109,8 +109,6 @@ template <typename FImpl1, typename FImpl2>
|
||||
std::vector<std::string> TAmputate<FImpl1, FImpl2>::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> output = {getName()};
|
||||
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
@ -118,15 +116,16 @@ std::vector<std::string> TAmputate<FImpl1, FImpl2>::getOutput(void)
|
||||
template <typename Fimpl1, typename Fimpl2>
|
||||
SpinColourMatrix TAmputate<Fimpl1, Fimpl2>::invertspincolmat(SpinColourMatrix &scmat)
|
||||
{
|
||||
Eigen::MatrixXcf scmat_2d(Ns*Nc,Ns*Nc);
|
||||
Eigen::MatrixXcd scmat_2d(Ns*Nc,Ns*Nc);
|
||||
for(int ic=0; ic<Nc; ic++){
|
||||
for(int jc=0; jc<Nc; jc++){
|
||||
for(int is=0; is<Ns; is++){
|
||||
for(int js=0; js<Ns; js++){
|
||||
scmat_2d(Ns*ic+is,Ns*jc+js) = scmat()(is,js)(ic,jc);
|
||||
auto z =scmat()(is,js)(ic,jc);;
|
||||
scmat_2d(Ns*ic+is,Ns*jc+js) = std::complex<double>(real(z),imag(z));
|
||||
}}
|
||||
}}
|
||||
Eigen::MatrixXcf scmat_2d_inv = scmat_2d.inverse();
|
||||
Eigen::MatrixXcd scmat_2d_inv = scmat_2d.inverse();
|
||||
SpinColourMatrix scmat_inv;
|
||||
for(int ic=0; ic<Nc; ic++){
|
||||
for(int jc=0; jc<Nc; jc++){
|
||||
@ -163,8 +162,8 @@ void TAmputate<FImpl1, FImpl2>::execute(void)
|
||||
read(reader,"vertex", vertex);
|
||||
LOG(Message) << "vertex read" << std::endl;
|
||||
|
||||
pdotxin=zero;
|
||||
pdotxout=zero;
|
||||
pdotxin=Zero();
|
||||
pdotxout=Zero();
|
||||
for (unsigned int mu = 0; mu < 4; ++mu)
|
||||
{
|
||||
Real TwoPiL = M_PI * 2.0/ latt_size[mu];
|
||||
|
@ -129,7 +129,7 @@ LatticeSpinColourMatrix TBilinear<FImpl1, FImpl2>::PhaseProps(LatticeSpinColourM
|
||||
LatticeComplex pdotx(grid), coor(grid);
|
||||
std::vector<int> latt_size = grid->_fdimensions;
|
||||
Complex Ci(0.0,1.0);
|
||||
pdotx=zero;
|
||||
pdotx=Zero();
|
||||
for (unsigned int mu = 0; mu < 4; ++mu)
|
||||
{
|
||||
Real TwoPiL = M_PI * 2.0/ latt_size[mu];
|
||||
@ -187,8 +187,8 @@ q = (p1-p2)
|
||||
|
||||
//
|
||||
|
||||
pdotxin=zero;
|
||||
pdotxout=zero;
|
||||
pdotxin=Zero();
|
||||
pdotxout=Zero();
|
||||
for (unsigned int mu = 0; mu < 4; ++mu)
|
||||
{
|
||||
Real TwoPiL = M_PI * 2.0/ latt_size[mu];
|
||||
|
@ -116,41 +116,30 @@ std::vector<std::string> TFourQuark<FImpl1, FImpl2>::getOutput(void)
|
||||
template <typename FImpl1, typename FImpl2>
|
||||
void TFourQuark<FImpl1, FImpl2>::tensorprod(LatticeSpinColourSpinColourMatrix &lret, LatticeSpinColourMatrix a, LatticeSpinColourMatrix b)
|
||||
{
|
||||
#if 0
|
||||
parallel_for(auto site=lret.begin();site<lret.end();site++) {
|
||||
for (int si; si < 4; ++si){
|
||||
for(int sj; sj <4; ++sj){
|
||||
for (int ci; ci < 3; ++ci){
|
||||
for (int cj; cj < 3; ++cj){
|
||||
for (int sk; sk < 4; ++sk){
|
||||
for(int sl; sl <4; ++sl){
|
||||
for (int ck; ck < 3; ++ck){
|
||||
for (int cl; cl < 3; ++cl){
|
||||
lret[site]()(si,sj)(ci,cj)(sk,sl)(ck,cl)=a[site]()(si,sj)(ci,cj)*b[site]()(sk,sl)(ck,cl);
|
||||
}}
|
||||
}}
|
||||
}}
|
||||
}}
|
||||
}
|
||||
#else
|
||||
// FIXME ; is there a general need for this construct ? In which case we should encapsulate the
|
||||
// below loops in a helper function.
|
||||
//LOG(Message) << "sp co mat a is - " << a << std::endl;
|
||||
//LOG(Message) << "sp co mat b is - " << b << std::endl;
|
||||
parallel_for(auto site=lret.begin();site<lret.end();site++) {
|
||||
vTComplex left;
|
||||
auto lret_v = lret.View();
|
||||
auto a_v = a.View();
|
||||
auto b_v = b.View();
|
||||
#ifdef GRID_NVCC
|
||||
#warning "NVCC problem: Removed impossibly slow compile of simple NPR host code in FourQuark.hpp"
|
||||
#else
|
||||
thread_foreach( site,lret_v,{
|
||||
vTComplex left;
|
||||
for(int si=0; si < Ns; ++si){
|
||||
for(int sj=0; sj < Ns; ++sj){
|
||||
for (int ci=0; ci < Nc; ++ci){
|
||||
for (int cj=0; cj < Nc; ++cj){
|
||||
//LOG(Message) << "si, sj, ci, cj - " << si << ", " << sj << ", "<< ci << ", "<< cj << std::endl;
|
||||
left()()() = a[site]()(si,sj)(ci,cj);
|
||||
left()()() = a_v[site]()(si,sj)(ci,cj);
|
||||
//LOG(Message) << left << std::endl;
|
||||
lret[site]()(si,sj)(ci,cj)=left()*b[site]();
|
||||
lret_v[site]()(si,sj)(ci,cj)=left()*b_v[site]();
|
||||
}}
|
||||
}}
|
||||
}
|
||||
#endif
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -168,6 +157,7 @@ void TFourQuark<FImpl1, FImpl2>::setup(void)
|
||||
template <typename FImpl1, typename FImpl2>
|
||||
void TFourQuark<FImpl1, FImpl2>::execute(void)
|
||||
{
|
||||
#ifndef GRID_NVCC
|
||||
|
||||
/*********************************************************************************
|
||||
|
||||
@ -219,8 +209,8 @@ We have up to 256 of these including the offdiag (G1 != G2).
|
||||
//Sout = Grid::QCD::PropUtils::PhaseProps(Sout,pout);
|
||||
|
||||
//find p.x for in and out so phase can be accounted for in propagators
|
||||
pdotxin=zero;
|
||||
pdotxout=zero;
|
||||
pdotxin=Zero();
|
||||
pdotxout=Zero();
|
||||
for (unsigned int mu = 0; mu < 4; ++mu)
|
||||
{
|
||||
Real TwoPiL = M_PI * 2.0/ latt_size[mu];
|
||||
@ -231,7 +221,6 @@ We have up to 256 of these including the offdiag (G1 != G2).
|
||||
Sin = Sin*exp(-Ci*pdotxin); //phase corrections
|
||||
Sout = Sout*exp(-Ci*pdotxout);
|
||||
|
||||
|
||||
//Set up Gammas
|
||||
std::vector<Gamma> gammavector;
|
||||
for( int i=1; i<Gamma::nGamma; i+=2){
|
||||
@ -239,7 +228,7 @@ We have up to 256 of these including the offdiag (G1 != G2).
|
||||
gammavector.push_back(Gamma(gam));
|
||||
}
|
||||
|
||||
lret = zero;
|
||||
lret = Zero();
|
||||
if (fullbasis == true){ // all combinations of mu and nu
|
||||
result.fourquark.resize(Gamma::nGamma/2*Gamma::nGamma/2);
|
||||
for( int mu=0; mu<Gamma::nGamma/2; mu++){
|
||||
@ -248,7 +237,7 @@ We have up to 256 of these including the offdiag (G1 != G2).
|
||||
LatticeSpinColourMatrix bilinear_nu(env().getGrid());
|
||||
bilinear_nu = g5*adj(Sout)*g5*gammavector[nu]*Sin;
|
||||
LOG(Message) << "bilinear_nu for nu = " << nu << " is - " << bilinear_mu << std::endl;
|
||||
result.fourquark[mu*Gamma::nGamma/2 + nu] = zero;
|
||||
result.fourquark[mu*Gamma::nGamma/2 + nu] = Zero();
|
||||
tensorprod(lret,bilinear_mu,bilinear_nu);
|
||||
result.fourquark[mu*Gamma::nGamma/2 + nu] = sum(lret);
|
||||
}
|
||||
@ -259,12 +248,13 @@ We have up to 256 of these including the offdiag (G1 != G2).
|
||||
//for( int mu=0; mu<Gamma::nGamma/2; mu++ ){
|
||||
bilinear_mu = g5*adj(Sout)*g5*gammavector[mu]*Sin;
|
||||
//LOG(Message) << "bilinear_mu for mu = " << mu << " is - " << bilinear_mu << std::endl;
|
||||
result.fourquark[mu] = zero;
|
||||
result.fourquark[mu] = Zero();
|
||||
tensorprod(lret,bilinear_mu,bilinear_mu); //tensor outer product
|
||||
result.fourquark[mu] = sum(lret);
|
||||
}
|
||||
}
|
||||
write(writer, "fourquark", result.fourquark);
|
||||
#endif
|
||||
}
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
@ -149,7 +149,7 @@ void TChargedProp::execute(void)
|
||||
<< RESULT_FILE_NAME(par().output, vm().getTrajectory()) << "'..."
|
||||
<< std::endl;
|
||||
result.projection.resize(par().outputMom.size());
|
||||
result.lattice_size = env().getGrid()->_fdimensions;
|
||||
result.lattice_size = env().getGrid()->FullDimensions().toVector();
|
||||
result.mass = par().mass;
|
||||
result.charge = q;
|
||||
siteCoor.resize(env().getNd());
|
||||
@ -160,11 +160,11 @@ void TChargedProp::execute(void)
|
||||
LOG(Message) << "Calculating (" << par().outputMom[i_p]
|
||||
<< ") momentum projection" << std::endl;
|
||||
|
||||
result.projection[i_p].corr_0.resize(env().getGrid()->_fdimensions[env().getNd()-1]);
|
||||
result.projection[i_p].corr.resize(env().getGrid()->_fdimensions[env().getNd()-1]);
|
||||
result.projection[i_p].corr_Q.resize(env().getGrid()->_fdimensions[env().getNd()-1]);
|
||||
result.projection[i_p].corr_Sun.resize(env().getGrid()->_fdimensions[env().getNd()-1]);
|
||||
result.projection[i_p].corr_Tad.resize(env().getGrid()->_fdimensions[env().getNd()-1]);
|
||||
result.projection[i_p].corr_0.resize(env().getGrid()->FullDimensions()[env().getNd()-1]);
|
||||
result.projection[i_p].corr.resize(env().getGrid()->FullDimensions()[env().getNd()-1]);
|
||||
result.projection[i_p].corr_Q.resize(env().getGrid()->FullDimensions()[env().getNd()-1]);
|
||||
result.projection[i_p].corr_Sun.resize(env().getGrid()->FullDimensions()[env().getNd()-1]);
|
||||
result.projection[i_p].corr_Tad.resize(env().getGrid()->FullDimensions()[env().getNd()-1]);
|
||||
|
||||
for (unsigned int j = 0; j < env().getNd()-1; ++j)
|
||||
{
|
||||
@ -226,7 +226,7 @@ void TChargedProp::makeCaches(void)
|
||||
}
|
||||
if (!phasesDone_)
|
||||
{
|
||||
std::vector<int> &l = env().getGrid()->_fdimensions;
|
||||
auto l = env().getGrid()->FullDimensions();
|
||||
Complex ci(0.0,1.0);
|
||||
|
||||
LOG(Message) << "Caching shift phases..." << std::endl;
|
||||
@ -259,7 +259,7 @@ void TChargedProp::momD1(ScalarField &s, FFT &fft)
|
||||
envGetTmp(ScalarField, result);
|
||||
envGetTmp(ScalarField, Amu);
|
||||
|
||||
result = zero;
|
||||
result = Zero();
|
||||
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
||||
{
|
||||
Amu = peekLorentz(A, mu);
|
||||
@ -289,7 +289,7 @@ void TChargedProp::momD2(ScalarField &s, FFT &fft)
|
||||
envGetTmp(ScalarField, result);
|
||||
envGetTmp(ScalarField, Amu);
|
||||
|
||||
result = zero;
|
||||
result = Zero();
|
||||
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
||||
{
|
||||
Amu = peekLorentz(A, mu);
|
||||
|
@ -132,7 +132,7 @@ void TDiv<SImpl>::execute(void)
|
||||
std::cout << std::endl;
|
||||
|
||||
auto &div = envGet(ComplexField, getName());
|
||||
div = zero;
|
||||
div = Zero();
|
||||
for (unsigned int mu = 0; mu < nd; ++mu)
|
||||
{
|
||||
auto &op = envGet(ComplexField, par().op[mu]);
|
||||
|
@ -154,7 +154,7 @@ void TStochFreeField<SImpl>::execute(void)
|
||||
LOG(Message) << "Generating random momentum-space field" << std::endl;
|
||||
envGetTmp(Field, phift);
|
||||
envGetTmp(ComplexField, ca);
|
||||
phift = zero;
|
||||
phift = Zero();
|
||||
for (int a = 0; a < Nadj; ++a)
|
||||
{
|
||||
Site ta;
|
||||
|
@ -142,7 +142,7 @@ void TTrKinetic<SImpl>::execute(void)
|
||||
auto &sumkin = envGet(ComplexField, varName(getName(), "sum"));
|
||||
|
||||
envGetTmp(std::vector<Field>, der);
|
||||
sumkin = zero;
|
||||
sumkin = Zero();
|
||||
if (!par().output.empty())
|
||||
{
|
||||
result.type = par().type;
|
||||
|
@ -37,3 +37,4 @@ template class Grid::Hadrons::MScalarSUN::TTransProj<ScalarNxNAdjImplR<4>>;
|
||||
template class Grid::Hadrons::MScalarSUN::TTransProj<ScalarNxNAdjImplR<5>>;
|
||||
template class Grid::Hadrons::MScalarSUN::TTransProj<ScalarNxNAdjImplR<6>>;
|
||||
|
||||
|
||||
|
@ -145,7 +145,7 @@ void TTransProj<SImpl>::execute(void)
|
||||
envGetTmp(ComplexField, buf1);
|
||||
envGetTmp(ComplexField, buf2);
|
||||
envGetTmp(ComplexField, lap);
|
||||
lap = zero;
|
||||
lap = Zero();
|
||||
if (!par().output.empty())
|
||||
{
|
||||
result.type = par().type;
|
||||
|
@ -128,7 +128,7 @@ void TPoint<FImpl>::execute(void)
|
||||
|
||||
envGetTmp(LatticeComplex, coor);
|
||||
p = strToVec<Real>(par().mom);
|
||||
ph = zero;
|
||||
ph = Zero();
|
||||
for(unsigned int mu = 0; mu < p.size(); mu++)
|
||||
{
|
||||
LatticeCoordinate(coor, mu);
|
||||
|
@ -156,7 +156,7 @@ void TA2AAslashVectors<FImpl>::execute(void)
|
||||
<< par().vector << " and the photon field " << par().emField << std::endl;
|
||||
for(unsigned int i=0; i<Nmodes; i++)
|
||||
{
|
||||
v4dtmp = zero;
|
||||
v4dtmp = Zero();
|
||||
startTimer("Multiply Aslash");
|
||||
for(unsigned int mu=0;mu<=3;mu++)
|
||||
{
|
||||
|
@ -68,6 +68,7 @@ private:
|
||||
class OperatorFunctionWrapper: public OperatorFunction<Field>
|
||||
{
|
||||
public:
|
||||
using OperatorFunction<Field>::operator();
|
||||
OperatorFunctionWrapper(LinearFunction<Field> &fn): fn_(fn) {};
|
||||
virtual ~OperatorFunctionWrapper(void) = default;
|
||||
virtual void operator()(LinearOperatorBase<Field> &op,
|
||||
|
7
Hadrons/Modules/MSource/Convolution.cc
Normal file
7
Hadrons/Modules/MSource/Convolution.cc
Normal file
@ -0,0 +1,7 @@
|
||||
#include <Hadrons/Modules/MSource/Convolution.hpp>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace Hadrons;
|
||||
using namespace MSource;
|
||||
|
||||
template class Grid::Hadrons::MSource::TConvolution<FIMPL>;
|
130
Hadrons/Modules/MSource/Convolution.hpp
Normal file
130
Hadrons/Modules/MSource/Convolution.hpp
Normal file
@ -0,0 +1,130 @@
|
||||
#ifndef Hadrons_MSource_Convolution_hpp_
|
||||
#define Hadrons_MSource_Convolution_hpp_
|
||||
|
||||
#include <Hadrons/Global.hpp>
|
||||
#include <Hadrons/Module.hpp>
|
||||
#include <Hadrons/ModuleFactory.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* Convolution *
|
||||
******************************************************************************/
|
||||
BEGIN_MODULE_NAMESPACE(MSource)
|
||||
|
||||
class ConvolutionPar: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(ConvolutionPar,
|
||||
std::string, field,
|
||||
std::string, filter,
|
||||
std::string, mom);
|
||||
};
|
||||
|
||||
template <typename FImpl>
|
||||
class TConvolution: public Module<ConvolutionPar>
|
||||
{
|
||||
public:
|
||||
FERM_TYPE_ALIASES(FImpl,);
|
||||
public:
|
||||
// constructor
|
||||
TConvolution(const std::string name);
|
||||
// destructor
|
||||
virtual ~TConvolution(void) {};
|
||||
// dependency relation
|
||||
virtual std::vector<std::string> getInput(void);
|
||||
virtual std::vector<std::string> getOutput(void);
|
||||
// setup
|
||||
virtual void setup(void);
|
||||
// execution
|
||||
virtual void execute(void);
|
||||
private:
|
||||
std::vector<int> mom_;
|
||||
};
|
||||
|
||||
MODULE_REGISTER_TMP(Convolution, TConvolution<FIMPL>, MSource);
|
||||
|
||||
/******************************************************************************
|
||||
* TConvolution implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
TConvolution<FImpl>::TConvolution(const std::string name)
|
||||
: Module<ConvolutionPar>(name)
|
||||
{}
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
std::vector<std::string> TConvolution<FImpl>::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in = {par().field, par().filter};
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
template <typename FImpl>
|
||||
std::vector<std::string> TConvolution<FImpl>::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out = {getName()};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
void TConvolution<FImpl>::setup(void)
|
||||
{
|
||||
mom_ = strToVec<int>(par().mom);
|
||||
if(mom_.size() != env().getNd()) {
|
||||
HADRONS_ERROR(Size, std::string("momentum has ")
|
||||
+ std::to_string(mom_.size()) + " instead of "
|
||||
+ std::to_string(env().getNd()) + " components");
|
||||
}
|
||||
|
||||
envCreateLat(PropagatorField, getName());
|
||||
envTmpLat(ComplexField, "momfield");
|
||||
envTmp(FFT, "fft", 1, env().getGrid());
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
void TConvolution<FImpl>::execute(void)
|
||||
{
|
||||
auto &filter = envGet(ComplexField, par().filter);
|
||||
auto &field = envGet(PropagatorField, par().field);
|
||||
auto &out = envGet(PropagatorField, getName());
|
||||
envGetTmp(ComplexField, momfield);
|
||||
envGetTmp(FFT, fft);
|
||||
|
||||
std::vector<int> mask(env().getNd(), 1);
|
||||
mask.back()=0; //transform only the spatial dimensions
|
||||
|
||||
startTimer("Fourier transform");
|
||||
fft.FFT_dim_mask(momfield, filter, mask, FFT::forward);
|
||||
fft.FFT_dim_mask(out, field, mask, FFT::forward);
|
||||
stopTimer("Fourier transform");
|
||||
|
||||
startTimer("momentum-space multiplication");
|
||||
out=momfield*out;
|
||||
stopTimer("momentum-space multiplication");
|
||||
|
||||
startTimer("inserting momentum");
|
||||
for(int mu=0; mu<env().getNd(); mu++)
|
||||
{
|
||||
if(mom_[mu]!=0)
|
||||
{
|
||||
out=Cshift(out, mu, -mom_[mu]);
|
||||
}
|
||||
}
|
||||
stopTimer("inserting momentum");
|
||||
|
||||
startTimer("Fourier transform");
|
||||
fft.FFT_dim_mask(out, out, mask, FFT::backward);
|
||||
stopTimer("Fourier transform");
|
||||
}
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_MSource_Convolution_hpp_
|
8
Hadrons/Modules/MSource/Gauss.cc
Normal file
8
Hadrons/Modules/MSource/Gauss.cc
Normal file
@ -0,0 +1,8 @@
|
||||
#include <Hadrons/Modules/MSource/Gauss.hpp>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace Hadrons;
|
||||
using namespace MSource;
|
||||
|
||||
template class Grid::Hadrons::MSource::TGauss<FIMPL>;
|
||||
template class Grid::Hadrons::MSource::TGauss<ScalarImplCR>;
|
173
Hadrons/Modules/MSource/Gauss.hpp
Normal file
173
Hadrons/Modules/MSource/Gauss.hpp
Normal file
@ -0,0 +1,173 @@
|
||||
#ifndef Hadrons_MSource_Gauss_hpp_
|
||||
#define Hadrons_MSource_Gauss_hpp_
|
||||
|
||||
#include <Hadrons/Global.hpp>
|
||||
#include <Hadrons/Module.hpp>
|
||||
#include <Hadrons/ModuleFactory.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* Gauss *
|
||||
* result[n] = 1/(sqrt(2*pi)*width)^dim *
|
||||
* * exp(-|n-position|^2/(2*width^2)) *
|
||||
* * exp(i*2*pi/L*mom*n) *
|
||||
* where: *
|
||||
* n=(n[0],n[1],...,n[dim-1]) (lattice coordinate) *
|
||||
* dim=Nd-1 *
|
||||
******************************************************************************/
|
||||
BEGIN_MODULE_NAMESPACE(MSource)
|
||||
|
||||
class GaussPar: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(GaussPar,
|
||||
std::string, position,
|
||||
std::string, mom,
|
||||
Integer, tA,
|
||||
Integer, tB,
|
||||
double, width);
|
||||
};
|
||||
|
||||
template <typename FImpl>
|
||||
class TGauss: public Module<GaussPar>
|
||||
{
|
||||
BASIC_TYPE_ALIASES(FImpl,);
|
||||
public:
|
||||
// constructor
|
||||
TGauss(const std::string name);
|
||||
// destructor
|
||||
virtual ~TGauss(void) {};
|
||||
// dependency relation
|
||||
virtual std::vector<std::string> getInput(void);
|
||||
virtual std::vector<std::string> getOutput(void);
|
||||
// setup
|
||||
virtual void setup(void);
|
||||
// execution
|
||||
virtual void execute(void);
|
||||
private:
|
||||
std::vector<int> position_;
|
||||
std::vector<int> mom_;
|
||||
};
|
||||
|
||||
MODULE_REGISTER_TMP(Gauss, TGauss<FIMPL>, MSource);
|
||||
MODULE_REGISTER_TMP(ScalarGauss, TGauss<ScalarImplCR>, MSource);
|
||||
|
||||
/******************************************************************************
|
||||
* TGauss implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
TGauss<FImpl>::TGauss(const std::string name)
|
||||
: Module<GaussPar>(name)
|
||||
{}
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
std::vector<std::string> TGauss<FImpl>::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
template <typename FImpl>
|
||||
std::vector<std::string> TGauss<FImpl>::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out = {getName()};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
void TGauss<FImpl>::setup(void)
|
||||
{
|
||||
auto parse_vector = [](const std::string &vec, int dim,
|
||||
const std::string &desc)
|
||||
{
|
||||
std::vector<int> res = strToVec<int>(vec);
|
||||
if(res.size() != dim) {
|
||||
HADRONS_ERROR(Size, desc + " has "
|
||||
+ std::to_string(res.size()) + " instead of "
|
||||
+ std::to_string(dim) + " components");
|
||||
}
|
||||
return res;
|
||||
};
|
||||
position_ = parse_vector(par().position, env().getNd()-1, "position");
|
||||
mom_ = parse_vector(par().mom, env().getNd(), "momentum");
|
||||
|
||||
envCreateLat(PropagatorField, getName());
|
||||
envTmpLat(ComplexField, "component");
|
||||
envTmpLat(ComplexField, "ScalarRho");
|
||||
envTmp(LatticeInteger, "compHelper", 1, envGetGrid(ComplexField));
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
void TGauss<FImpl>::execute(void)
|
||||
{
|
||||
auto &rho = envGet(PropagatorField, getName());
|
||||
envGetTmp(ComplexField, component);
|
||||
envGetTmp(ComplexField, ScalarRho);
|
||||
envGetTmp(LatticeInteger, compHelper);
|
||||
const int dim=env().getNd()-1;
|
||||
const Real fact=-0.5/std::pow(par().width,2);
|
||||
const Complex i(0.0, 1.0);
|
||||
const Real Pi(M_PI);
|
||||
const SitePropagator idMat=[](){ SitePropagator s; s=1.; return s; }();
|
||||
|
||||
ScalarRho=Zero();
|
||||
for(int mu=0; mu<dim; mu++) {
|
||||
assert(env().getDim(mu)%2==0);
|
||||
assert(position_[mu]>=0 && position_[mu]<env().getDim(mu));
|
||||
|
||||
const int Lmu=env().getDim(mu);
|
||||
const int LmuHalf=Lmu/2;
|
||||
const int posMu=position_[mu];
|
||||
|
||||
LatticeCoordinate(component, mu);
|
||||
LatticeCoordinate(compHelper, mu);
|
||||
|
||||
//spatial dimensions of momentum phase
|
||||
ScalarRho+=(i*(mom_[mu]*2*Pi/Lmu))*component;
|
||||
|
||||
//Gauss distribution
|
||||
component-=Complex(posMu);
|
||||
if(posMu<LmuHalf)
|
||||
{
|
||||
component=where((compHelper>Integer(posMu+LmuHalf)),
|
||||
component-Complex(Lmu),
|
||||
component);
|
||||
}
|
||||
else
|
||||
{
|
||||
component=where((compHelper<=Integer(posMu-LmuHalf)),
|
||||
component+Complex(Lmu),
|
||||
component);
|
||||
}
|
||||
ScalarRho+=component*component*fact;
|
||||
}
|
||||
|
||||
//time component of momentum phase
|
||||
LatticeCoordinate(component, dim);
|
||||
ScalarRho+=(i*(mom_.at(dim)*2*Pi/env().getDim(dim)))*component;
|
||||
|
||||
//compute scalar result
|
||||
ScalarRho=exp(ScalarRho)*Complex(std::pow(sqrt(2*Pi)*par().width,-dim));
|
||||
|
||||
//select time slices
|
||||
LatticeCoordinate(compHelper, dim);
|
||||
ScalarRho=where((compHelper>=par().tA && compHelper<=par().tB),
|
||||
ScalarRho,
|
||||
0.*ScalarRho);
|
||||
|
||||
//compute output field rho
|
||||
rho=ScalarRho*idMat;
|
||||
}
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_MSource_Gauss_hpp_
|
@ -126,7 +126,7 @@ void TMomentum<FImpl>::execute(void)
|
||||
LOG(Message) << " " << std::endl;
|
||||
//get the momentum from parameters
|
||||
p = strToVec<Real>(par().mom);
|
||||
C = zero;
|
||||
C = Zero();
|
||||
LOG(Message) << "momentum converted from string - " << std::to_string(p[0]) <<std::to_string(p[1]) <<std::to_string(p[2]) << std::to_string(p[3]) << std::endl;
|
||||
for(int mu=0;mu<4;mu++){
|
||||
Real TwoPiL = M_PI * 2.0/ latt_size[mu];
|
||||
|
@ -132,7 +132,7 @@ void TPoint<FImpl>::execute(void)
|
||||
+ " components (must have " + std::to_string(env().getNd()) + ")");
|
||||
}
|
||||
id = 1.;
|
||||
src = zero;
|
||||
src = Zero();
|
||||
pokeSite(id, src, position);
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ void TSeqAslash<FImpl>::execute(void)
|
||||
<< par().tA << " <= t <= " << par().tB
|
||||
<< " using the photon field " << par().emField << std::endl;
|
||||
}
|
||||
auto &src = envGet(PropagatorField, getName()); src=zero;
|
||||
auto &src = envGet(PropagatorField, getName()); src=Zero();
|
||||
auto &q = envGet(PropagatorField, par().q);
|
||||
auto &ph = envGet(LatticeComplex, momphName_);
|
||||
auto &t = envGet(Lattice<iScalar<vInteger>>, tName_);
|
||||
@ -160,7 +160,7 @@ void TSeqAslash<FImpl>::execute(void)
|
||||
|
||||
envGetTmp(LatticeComplex, coor);
|
||||
p = strToVec<Real>(par().mom);
|
||||
ph = zero;
|
||||
ph = Zero();
|
||||
for(unsigned int mu = 0; mu < env().getNd(); mu++)
|
||||
{
|
||||
LatticeCoordinate(coor, mu);
|
||||
|
@ -141,7 +141,7 @@ void TSeqConserved<FImpl>::setup(void)
|
||||
{
|
||||
auto Ls_ = env().getObjectLs(par().action);
|
||||
envCreateLat(PropagatorField, getName(), Ls_);
|
||||
envTmpLat(PropagatorField, "src_tmp");
|
||||
envTmpLat(PropagatorField, "src_tmp",Ls_);
|
||||
envCacheLat(LatticeComplex, SeqmomphName_);
|
||||
envTmpLat(LatticeComplex, "coor");
|
||||
envTmpLat(LatticeComplex, "latt_compl");
|
||||
@ -175,14 +175,14 @@ void TSeqConserved<FImpl>::execute(void)
|
||||
auto &mat = envGet(FMat, par().action);
|
||||
envGetTmp(LatticeComplex, latt_compl);
|
||||
|
||||
src = zero;
|
||||
src = Zero();
|
||||
|
||||
//exp(ipx)
|
||||
auto &mom_phase = envGet(LatticeComplex, SeqmomphName_);
|
||||
if (!SeqhasPhase_)
|
||||
{
|
||||
std::vector<Real> mom = strToVec<Real>(par().mom);
|
||||
mom_phase = zero;
|
||||
mom_phase = Zero();
|
||||
Complex i(0.0,1.0);
|
||||
envGetTmp(LatticeComplex, coor);
|
||||
for(unsigned int mu = 0; mu < env().getNd(); mu++)
|
||||
|
@ -159,7 +159,7 @@ void TSeqGamma<FImpl>::execute(void)
|
||||
|
||||
envGetTmp(LatticeComplex, coor);
|
||||
p = strToVec<Real>(par().mom);
|
||||
ph = zero;
|
||||
ph = Zero();
|
||||
for(unsigned int mu = 0; mu < env().getNd(); mu++)
|
||||
{
|
||||
LatticeCoordinate(coor, mu);
|
||||
|
@ -142,7 +142,7 @@ void TWall<FImpl>::execute(void)
|
||||
|
||||
envGetTmp(LatticeComplex, coor);
|
||||
p = strToVec<Real>(par().mom);
|
||||
ph = zero;
|
||||
ph = Zero();
|
||||
for(unsigned int mu = 0; mu < env().getNd(); mu++)
|
||||
{
|
||||
LatticeCoordinate(coor, mu);
|
||||
|
Reference in New Issue
Block a user