mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-11-03 21:44:33 +00:00 
			
		
		
		
	changes requested for the pull request
This commit is contained in:
		@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
Grid physics library, www.github.com/paboyle/Grid 
 | 
			
		||||
 | 
			
		||||
Source file: extras/Hadrons/Modules/MContraction/SeqConserved.hpp
 | 
			
		||||
Source file: extras/Hadrons/Modules/MSource/SeqConserved.hpp
 | 
			
		||||
 | 
			
		||||
Copyright (C) 2015-2018
 | 
			
		||||
 | 
			
		||||
@@ -35,8 +35,6 @@ See the full license in the file "LICENSE" in the top level distribution directo
 | 
			
		||||
#include <Grid/Hadrons/Module.hpp>
 | 
			
		||||
#include <Grid/Hadrons/ModuleFactory.hpp>
 | 
			
		||||
 | 
			
		||||
#include <Grid/qcd/action/gauge/GaugeImplTypes.h>
 | 
			
		||||
 | 
			
		||||
BEGIN_HADRONS_NAMESPACE
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
@@ -100,6 +98,9 @@ protected:
 | 
			
		||||
    virtual void setup(void);
 | 
			
		||||
    // execution
 | 
			
		||||
    virtual void execute(void);
 | 
			
		||||
private:
 | 
			
		||||
    bool        SeqhasPhase_{false}; 
 | 
			
		||||
    std::string SeqmomphName_;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
MODULE_REGISTER_NS(SeqConserved, TSeqConserved<FIMPL>, MSource);
 | 
			
		||||
@@ -112,6 +113,7 @@ MODULE_REGISTER_NS(SeqConserved, TSeqConserved<FIMPL>, MSource);
 | 
			
		||||
template <typename FImpl>
 | 
			
		||||
TSeqConserved<FImpl>::TSeqConserved(const std::string name)
 | 
			
		||||
: Module<SeqConservedPar>(name)
 | 
			
		||||
, SeqmomphName_ (name + "_Seqmomph")
 | 
			
		||||
{}
 | 
			
		||||
 | 
			
		||||
// dependencies/products ///////////////////////////////////////////////////////
 | 
			
		||||
@@ -139,7 +141,7 @@ void TSeqConserved<FImpl>::setup(void)
 | 
			
		||||
    auto Ls_ = env().getObjectLs(par().action);
 | 
			
		||||
    envCreateLat(PropagatorField, getName(), Ls_);
 | 
			
		||||
    envTmpLat(PropagatorField, "src_tmp");
 | 
			
		||||
    envTmpLat(LatticeComplex, "mom_phase");
 | 
			
		||||
    envCacheLat(LatticeComplex, SeqmomphName_);
 | 
			
		||||
    envTmpLat(LatticeComplex, "coor");
 | 
			
		||||
    envTmpLat(LatticeComplex, "latt_compl");
 | 
			
		||||
}
 | 
			
		||||
@@ -152,37 +154,45 @@ void TSeqConserved<FImpl>::execute(void)
 | 
			
		||||
    {
 | 
			
		||||
        LOG(Message) << "Generating sequential source with conserved "
 | 
			
		||||
                     << par().curr_type << " current at " 
 | 
			
		||||
		     << "t = " << par().tA << std::endl;
 | 
			
		||||
		     << "t = " << par().tA << " summed over the indices " 
 | 
			
		||||
		     << par().mu_min << " <= mu <= " << par().mu_max 
 | 
			
		||||
		     << std::endl;
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        LOG(Message) << "Generating sequential source with conserved "
 | 
			
		||||
                     << par().curr_type << " current for " 
 | 
			
		||||
                     << par().tA << " <= t <= " 
 | 
			
		||||
                     << par().tB << std::endl;
 | 
			
		||||
                     << par().tB << " summed over the indices " 
 | 
			
		||||
		     << par().mu_min << " <= mu <= " << par().mu_max
 | 
			
		||||
	             << std::endl;
 | 
			
		||||
    }
 | 
			
		||||
    auto &src = envGet(PropagatorField, getName());
 | 
			
		||||
    envGetTmp(PropagatorField, src_tmp);
 | 
			
		||||
    src_tmp = src;
 | 
			
		||||
    auto &q   = envGet(PropagatorField, par().q);
 | 
			
		||||
    auto &mat = envGet(FMat, par().action);
 | 
			
		||||
    envGetTmp(LatticeComplex, mom_phase);
 | 
			
		||||
    envGetTmp(LatticeComplex, coor);
 | 
			
		||||
    envGetTmp(LatticeComplex, latt_compl);
 | 
			
		||||
 | 
			
		||||
    src = zero;
 | 
			
		||||
 | 
			
		||||
    //exp(ipx)
 | 
			
		||||
    auto &mom_phase = envGet(LatticeComplex, SeqmomphName_);
 | 
			
		||||
    if (!SeqhasPhase_)
 | 
			
		||||
    {    
 | 
			
		||||
        std::vector<Real> mom = strToVec<Real>(par().mom);
 | 
			
		||||
        mom_phase = zero;
 | 
			
		||||
        Complex           i(0.0,1.0);
 | 
			
		||||
        envGetTmp(LatticeComplex, coor);
 | 
			
		||||
        for(unsigned int mu = 0; mu < env().getNd(); mu++)
 | 
			
		||||
        {
 | 
			
		||||
            LatticeCoordinate(coor, mu);
 | 
			
		||||
            mom_phase = mom_phase + (mom[mu]/env().getGrid()->_fdimensions[mu])*coor;
 | 
			
		||||
        }
 | 
			
		||||
        mom_phase = exp((Real)(2*M_PI)*i*mom_phase);
 | 
			
		||||
    LOG(Message) << "Inserting momentum " << mom << std::endl;
 | 
			
		||||
        SeqhasPhase_ = true;
 | 
			
		||||
    }
 | 
			
		||||
    LOG(Message) << "Inserting momentum " << strToVec<Real>(par().mom) << std::endl;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -49,5 +49,5 @@ modules_hpp =\
 | 
			
		||||
  Modules/MScalarSUN/TwoPoint.hpp \
 | 
			
		||||
  Modules/MScalarSUN/TrPhi.hpp \
 | 
			
		||||
  Modules/MIO/LoadNersc.hpp \
 | 
			
		||||
Modules/MIO/LoadBinary.hpp
 | 
			
		||||
  Modules/MIO/LoadBinary.hpp
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -127,7 +127,7 @@ namespace Grid {
 | 
			
		||||
                                       unsigned int mu,
 | 
			
		||||
                                       unsigned int tmin, 
 | 
			
		||||
                                       unsigned int tmax,
 | 
			
		||||
				       Lattice<iSinglet<Simd>> &lattice_cmplx)=0;
 | 
			
		||||
				       ComplexField &lattice_cmplx)=0;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -413,7 +413,7 @@ void ImprovedStaggeredFermion<Impl>::SeqConservedCurrent(PropagatorField &q_in,
 | 
			
		||||
                                              unsigned int mu,
 | 
			
		||||
                                              unsigned int tmin, 
 | 
			
		||||
                                              unsigned int tmax,
 | 
			
		||||
					      Lattice<iSinglet<Simd>> &lattice_cmplx)
 | 
			
		||||
					      ComplexField &lattice_cmplx)
 | 
			
		||||
{
 | 
			
		||||
    assert(0);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -172,7 +172,7 @@ class ImprovedStaggeredFermion : public StaggeredKernels<Impl>, public ImprovedS
 | 
			
		||||
                           unsigned int mu,
 | 
			
		||||
                           unsigned int tmin, 
 | 
			
		||||
                           unsigned int tmax,
 | 
			
		||||
			   Lattice<iSinglet<Simd>> &lattice_cmplx);
 | 
			
		||||
			   ComplexField &lattice_cmplx);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
typedef ImprovedStaggeredFermion<StaggeredImplF> ImprovedStaggeredFermionF;
 | 
			
		||||
 
 | 
			
		||||
@@ -425,7 +425,7 @@ void ImprovedStaggeredFermion5D<Impl>::SeqConservedCurrent(PropagatorField &q_in
 | 
			
		||||
                                              unsigned int mu,
 | 
			
		||||
                                              unsigned int tmin, 
 | 
			
		||||
                                              unsigned int tmax,
 | 
			
		||||
					      Lattice<iSinglet<Simd>> &lattice_cmplx)
 | 
			
		||||
					      ComplexField &lattice_cmplx)
 | 
			
		||||
{
 | 
			
		||||
    assert(0);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -184,7 +184,7 @@ namespace QCD {
 | 
			
		||||
                             unsigned int mu,
 | 
			
		||||
                             unsigned int tmin, 
 | 
			
		||||
                             unsigned int tmax,
 | 
			
		||||
                 	     Lattice<iSinglet<Simd>> &lattice_cmplx);
 | 
			
		||||
                 	     ComplexField &lattice_cmplx);
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
}}
 | 
			
		||||
 
 | 
			
		||||
@@ -407,75 +407,6 @@ void WilsonFermion<Impl>::ContractConservedCurrent(PropagatorField &q_in_1,
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//template <class Impl>
 | 
			
		||||
//void WilsonFermion<Impl>::SeqConservedCurrent(PropagatorField &q_in, 
 | 
			
		||||
//                                              PropagatorField &q_out,
 | 
			
		||||
//                                              Current curr_type,
 | 
			
		||||
//                                              unsigned int mu,
 | 
			
		||||
//                                              std::vector<Real> mom,
 | 
			
		||||
//                                              unsigned int tmin, 
 | 
			
		||||
//                                              unsigned int tmax)
 | 
			
		||||
//{
 | 
			
		||||
//    conformable(_grid, q_in._grid);
 | 
			
		||||
//    conformable(_grid, q_out._grid);
 | 
			
		||||
//    Lattice<iSinglet<Simd>> ph(_grid), coor(_grid);
 | 
			
		||||
//    Complex i(0.0,1.0);
 | 
			
		||||
//    PropagatorField tmpFwd(_grid), tmpBwd(_grid), tmp(_grid);
 | 
			
		||||
//    unsigned int tshift = (mu == Tp) ? 1 : 0;
 | 
			
		||||
//    unsigned int LLt    = GridDefaultLatt()[Tp];
 | 
			
		||||
//
 | 
			
		||||
//    // Momentum projection
 | 
			
		||||
//    ph = zero;
 | 
			
		||||
//    for(unsigned int mu = 0; mu < Nd - 1; mu++)
 | 
			
		||||
//    {
 | 
			
		||||
//        LatticeCoordinate(coor, mu);
 | 
			
		||||
//        ph = ph + mom[mu]*coor*((1./(_grid->_fdimensions[mu])));
 | 
			
		||||
//    }
 | 
			
		||||
//    ph = exp((Real)(2*M_PI)*i*ph);
 | 
			
		||||
//
 | 
			
		||||
//    q_out = zero;
 | 
			
		||||
//    LatticeInteger coords(_grid);
 | 
			
		||||
//    LatticeCoordinate(coords, Tp);
 | 
			
		||||
//
 | 
			
		||||
//    // Need q(x + mu) and q(x - mu).
 | 
			
		||||
//    tmp = Cshift(q_in, mu, 1);
 | 
			
		||||
//    tmpFwd = tmp*ph;
 | 
			
		||||
//    tmp = ph*q_in;
 | 
			
		||||
//    tmpBwd = Cshift(tmp, mu, -1);
 | 
			
		||||
//
 | 
			
		||||
//    parallel_for (unsigned int sU = 0; sU < Umu._grid->oSites(); ++sU)
 | 
			
		||||
//    {
 | 
			
		||||
//        // Compute the sequential conserved current insertion only if our simd
 | 
			
		||||
//        // object contains a timeslice we need.
 | 
			
		||||
//        vInteger t_mask   = ((coords._odata[sU] >= tmin) &&
 | 
			
		||||
//                             (coords._odata[sU] <= tmax));
 | 
			
		||||
//        Integer timeSlices = Reduce(t_mask);
 | 
			
		||||
//
 | 
			
		||||
//        if (timeSlices > 0)
 | 
			
		||||
//        {
 | 
			
		||||
//            Kernels::SeqConservedCurrentSiteFwd(tmpFwd._odata[sU], 
 | 
			
		||||
//                                                q_out._odata[sU], 
 | 
			
		||||
//                                                Umu, sU, mu, t_mask);
 | 
			
		||||
//        }
 | 
			
		||||
//
 | 
			
		||||
//        // Repeat for backward direction.
 | 
			
		||||
//        t_mask     = ((coords._odata[sU] >= (tmin + tshift)) && 
 | 
			
		||||
//                      (coords._odata[sU] <= (tmax + tshift)));
 | 
			
		||||
//
 | 
			
		||||
//	//if tmax = LLt-1 (last timeslice) include timeslice 0 if the time is shifted (mu=3)	
 | 
			
		||||
//	unsigned int t0 = 0;
 | 
			
		||||
//	if((tmax==LLt-1) && (tshift==1)) t_mask = (t_mask || (coords._odata[sU] == t0 ));
 | 
			
		||||
//
 | 
			
		||||
//        timeSlices = Reduce(t_mask);
 | 
			
		||||
//
 | 
			
		||||
//        if (timeSlices > 0)
 | 
			
		||||
//        {
 | 
			
		||||
//            Kernels::SeqConservedCurrentSiteBwd(tmpBwd._odata[sU], 
 | 
			
		||||
//                                                q_out._odata[sU], 
 | 
			
		||||
//                                                Umu, sU, mu, t_mask);
 | 
			
		||||
//        }
 | 
			
		||||
//    }
 | 
			
		||||
//}
 | 
			
		||||
 | 
			
		||||
template <class Impl>
 | 
			
		||||
void WilsonFermion<Impl>::SeqConservedCurrent(PropagatorField &q_in, 
 | 
			
		||||
@@ -484,7 +415,7 @@ void WilsonFermion<Impl>::SeqConservedCurrent(PropagatorField &q_in,
 | 
			
		||||
                                              unsigned int mu,
 | 
			
		||||
                                              unsigned int tmin, 
 | 
			
		||||
                                              unsigned int tmax,
 | 
			
		||||
					      Lattice<iSinglet<Simd>> &lattice_cmplx)
 | 
			
		||||
					      ComplexField &lattice_cmplx)
 | 
			
		||||
{
 | 
			
		||||
    conformable(_grid, q_in._grid);
 | 
			
		||||
    conformable(_grid, q_out._grid);
 | 
			
		||||
 
 | 
			
		||||
@@ -180,7 +180,7 @@ class WilsonFermion : public WilsonKernels<Impl>, public WilsonFermionStatic {
 | 
			
		||||
                             unsigned int mu,
 | 
			
		||||
                             unsigned int tmin, 
 | 
			
		||||
                             unsigned int tmax,
 | 
			
		||||
			     Lattice<iSinglet<Simd>> &lattice_cmplx);
 | 
			
		||||
			     ComplexField &lattice_cmplx);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
typedef WilsonFermion<WilsonImplF> WilsonFermionF;
 | 
			
		||||
 
 | 
			
		||||
@@ -779,98 +779,6 @@ void WilsonFermion5D<Impl>::ContractConservedCurrent(PropagatorField &q_in_1,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//template <class Impl>
 | 
			
		||||
//void WilsonFermion5D<Impl>::SeqConservedCurrent(PropagatorField &q_in, 
 | 
			
		||||
//                                                PropagatorField &q_out,
 | 
			
		||||
//                                                Current curr_type, 
 | 
			
		||||
//                                                unsigned int mu,
 | 
			
		||||
//                                                std::vector<Real> mom,
 | 
			
		||||
//                                                unsigned int tmin, 
 | 
			
		||||
//                                                unsigned int tmax)
 | 
			
		||||
//{
 | 
			
		||||
//    conformable(q_in._grid, FermionGrid());
 | 
			
		||||
//    conformable(q_in._grid, q_out._grid);
 | 
			
		||||
//    Lattice<iSinglet<Simd>> ph(FermionGrid()), coor(FermionGrid());
 | 
			
		||||
//    PropagatorField tmpFwd(FermionGrid()), tmpBwd(FermionGrid()),
 | 
			
		||||
//                    tmp(FermionGrid());
 | 
			
		||||
//    Complex i(0.0, 1.0);
 | 
			
		||||
//    unsigned int tshift = (mu == Tp) ? 1 : 0;
 | 
			
		||||
//    unsigned int LLs = q_in._grid->_rdimensions[0];
 | 
			
		||||
//    unsigned int LLt    = GridDefaultLatt()[Tp];
 | 
			
		||||
//
 | 
			
		||||
//    // Momentum projection.
 | 
			
		||||
//    ph = zero;
 | 
			
		||||
//    for(unsigned int nu = 0; nu < Nd - 1; nu++)
 | 
			
		||||
//    {
 | 
			
		||||
//        // Shift coordinate lattice index by 1 to account for 5th dimension.
 | 
			
		||||
//        LatticeCoordinate(coor, nu + 1);
 | 
			
		||||
//        ph = ph + mom[nu]*coor*((1./(_FourDimGrid->_fdimensions[nu])));
 | 
			
		||||
//    }
 | 
			
		||||
//    ph = exp((Real)(2*M_PI)*i*ph);
 | 
			
		||||
//
 | 
			
		||||
//    q_out = zero;
 | 
			
		||||
//    LatticeInteger coords(_FourDimGrid);
 | 
			
		||||
//    LatticeCoordinate(coords, Tp);
 | 
			
		||||
//
 | 
			
		||||
//
 | 
			
		||||
//    // Need q(x + mu, s) and q(x - mu, s). 5D lattice so shift 4D coordinate mu
 | 
			
		||||
//    // by one.
 | 
			
		||||
//    tmp = Cshift(q_in, mu + 1, 1);
 | 
			
		||||
//    tmpFwd = tmp*ph;
 | 
			
		||||
//    tmp = ph*q_in;
 | 
			
		||||
//    tmpBwd = Cshift(tmp, mu + 1, -1);
 | 
			
		||||
//
 | 
			
		||||
//    parallel_for (unsigned int sU = 0; sU < Umu._grid->oSites(); ++sU)
 | 
			
		||||
//    {
 | 
			
		||||
//        // Compute the sequential conserved current insertion only if our simd
 | 
			
		||||
//        // object contains a timeslice we need.
 | 
			
		||||
//        vInteger t_mask   = ((coords._odata[sU] >= tmin) &&
 | 
			
		||||
//                             (coords._odata[sU] <= tmax));
 | 
			
		||||
//        Integer timeSlices = Reduce(t_mask);
 | 
			
		||||
//
 | 
			
		||||
//        if (timeSlices > 0)
 | 
			
		||||
//        {
 | 
			
		||||
//            unsigned int sF = sU * LLs;
 | 
			
		||||
//            for (unsigned int s = 0; s < LLs; ++s)
 | 
			
		||||
//            {
 | 
			
		||||
//                bool axial_sign = ((curr_type == Current::Axial) && (s < (LLs / 2)));
 | 
			
		||||
//		bool tadpole_sign = (curr_type == Current::Tadpole);
 | 
			
		||||
//		bool switch_sgn = tadpole_sign || axial_sign;
 | 
			
		||||
//
 | 
			
		||||
//                Kernels::SeqConservedCurrentSiteFwd(tmpFwd._odata[sF], 
 | 
			
		||||
//                                                    q_out._odata[sF], Umu, sU,
 | 
			
		||||
//                                                    mu, t_mask, switch_sgn);
 | 
			
		||||
//                ++sF;
 | 
			
		||||
//            }
 | 
			
		||||
//        }
 | 
			
		||||
//
 | 
			
		||||
//        // Repeat for backward direction.
 | 
			
		||||
//        t_mask     = ((coords._odata[sU] >= (tmin + tshift)) && 
 | 
			
		||||
//                      (coords._odata[sU] <= (tmax + tshift)));
 | 
			
		||||
//
 | 
			
		||||
//	//if tmax = LLt-1 (last timeslice) include timeslice 0 if the time is shifted (mu=3)	
 | 
			
		||||
//	unsigned int t0 = 0;
 | 
			
		||||
//	if((tmax==LLt-1) && (tshift==1)) t_mask = (t_mask || (coords._odata[sU] == t0 ));
 | 
			
		||||
//
 | 
			
		||||
//        timeSlices = Reduce(t_mask);
 | 
			
		||||
//
 | 
			
		||||
//        if (timeSlices > 0)
 | 
			
		||||
//        {
 | 
			
		||||
//            unsigned int sF = sU * LLs;
 | 
			
		||||
//            for (unsigned int s = 0; s < LLs; ++s)
 | 
			
		||||
//            {
 | 
			
		||||
//                bool axial_sign = ((curr_type == Current::Axial) && (s < (LLs / 2)));
 | 
			
		||||
//                Kernels::SeqConservedCurrentSiteBwd(tmpBwd._odata[sF], 
 | 
			
		||||
//                                                    q_out._odata[sF], Umu, sU,
 | 
			
		||||
//                                                    mu, t_mask, axial_sign);
 | 
			
		||||
//                ++sF;
 | 
			
		||||
//            }
 | 
			
		||||
//        }
 | 
			
		||||
//    }
 | 
			
		||||
//}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
template <class Impl>
 | 
			
		||||
void WilsonFermion5D<Impl>::SeqConservedCurrent(PropagatorField &q_in, 
 | 
			
		||||
@@ -879,7 +787,7 @@ void WilsonFermion5D<Impl>::SeqConservedCurrent(PropagatorField &q_in,
 | 
			
		||||
                                                unsigned int mu,
 | 
			
		||||
                                                unsigned int tmin, 
 | 
			
		||||
                                                unsigned int tmax,
 | 
			
		||||
						Lattice<iSinglet<Simd>> &lattice_cmplx)
 | 
			
		||||
						ComplexField &lattice_cmplx)
 | 
			
		||||
{
 | 
			
		||||
    conformable(q_in._grid, FermionGrid());
 | 
			
		||||
    conformable(q_in._grid, q_out._grid);
 | 
			
		||||
 
 | 
			
		||||
@@ -228,7 +228,7 @@ namespace QCD {
 | 
			
		||||
                             unsigned int mu,
 | 
			
		||||
                             unsigned int tmin, 
 | 
			
		||||
                             unsigned int tmax,
 | 
			
		||||
			     Lattice<iSinglet<Simd>> &lattice_cmplx);
 | 
			
		||||
			     ComplexField &lattice_cmplx);
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
}}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user