diff --git a/extras/Hadrons/Modules/MScalar/ChargedProp.cc b/extras/Hadrons/Modules/MScalar/ChargedProp.cc index 1137c6f0..1cd0cae6 100644 --- a/extras/Hadrons/Modules/MScalar/ChargedProp.cc +++ b/extras/Hadrons/Modules/MScalar/ChargedProp.cc @@ -1,4 +1,5 @@ #include +#include using namespace Grid; using namespace Hadrons; @@ -15,7 +16,7 @@ TChargedProp::TChargedProp(const std::string name) // dependencies/products /////////////////////////////////////////////////////// std::vector TChargedProp::getInput(void) { - std::vector in; + std::vector in = {par().source, par().emField}; return in; } @@ -30,11 +31,72 @@ std::vector TChargedProp::getOutput(void) // setup /////////////////////////////////////////////////////////////////////// void TChargedProp::setup(void) { - + freeMomPropName_ = FREEMOMPROP(par().mass); + shiftedMomPropName_.clear(); + for (unsigned int mu = 0; mu < env().getNd(); ++mu) + { + shiftedMomPropName_.push_back(freeMomPropName_ + "_" + + std::to_string(mu)); + } + if (!env().hasRegisteredObject(freeMomPropName_)) + { + env().registerLattice(freeMomPropName_); + } + if (!env().hasRegisteredObject(shiftedMomPropName_[0])) + { + for (unsigned int mu = 0; mu < env().getNd(); ++mu) + { + env().registerLattice(shiftedMomPropName_[mu]); + } + } + env().registerLattice(getName()); + } // execution /////////////////////////////////////////////////////////////////// void TChargedProp::execute(void) { - + ScalarField &prop = *env().createLattice(getName()); + ScalarField &source = *env().getObject(par().source); + ScalarField *freeMomProp; + std::vector shiftedMomProp; + Complex ci(0.0,1.0); + + if (!env().hasCreatedObject(freeMomPropName_)) + { + LOG(Message) << "Caching momentum space free scalar propagator" + << " (mass= " << par().mass << ")..." << std::endl; + freeMomProp = env().createLattice(freeMomPropName_); + Scalar::MomentumSpacePropagator(*freeMomProp, par().mass); + } + else + { + freeMomProp = env().getObject(freeMomPropName_); + } + if (!env().hasCreatedObject(shiftedMomPropName_[0])) + { + std::vector &l = env().getGrid()->_fdimensions; + + LOG(Message) << "Caching shifted momentum space free scalar propagator" + << " (mass= " << par().mass << ")..." << std::endl; + for (unsigned int mu = 0; mu < env().getNd(); ++mu) + { + Real twoPiL = M_PI*2./l[mu]; + + shiftedMomProp.push_back( + env().createLattice(shiftedMomPropName_[mu])); + LatticeCoordinate(*(shiftedMomProp[mu]), mu); + *(shiftedMomProp[mu]) = exp(ci*twoPiL*(*(shiftedMomProp[mu]))) + *(*freeMomProp); + } + } + else + { + for (unsigned int mu = 0; mu < env().getNd(); ++mu) + { + shiftedMomProp.push_back( + env().getObject(shiftedMomPropName_[mu])); + } + } + } diff --git a/extras/Hadrons/Modules/MScalar/ChargedProp.hpp b/extras/Hadrons/Modules/MScalar/ChargedProp.hpp index 7a60c2ad..91ea2355 100644 --- a/extras/Hadrons/Modules/MScalar/ChargedProp.hpp +++ b/extras/Hadrons/Modules/MScalar/ChargedProp.hpp @@ -16,11 +16,16 @@ class ChargedPropPar: Serializable { public: GRID_SERIALIZABLE_CLASS_MEMBERS(ChargedPropPar, - unsigned int, i); + std::string, emField, + std::string, source, + double, mass, + std::string, output); }; class TChargedProp: public Module { +public: + SCALAR_TYPE_ALIASES(SIMPL,); public: // constructor TChargedProp(const std::string name); @@ -33,6 +38,9 @@ public: virtual void setup(void); // execution virtual void execute(void); +private: + std::string freeMomPropName_; + std::vector shiftedMomPropName_; }; MODULE_REGISTER_NS(ChargedProp, TChargedProp, MScalar);