#ifndef Hadrons_MSource_Gauss_hpp_ #define Hadrons_MSource_Gauss_hpp_ #include #include #include BEGIN_HADRONS_NAMESPACE /****************************************************************************** * Gauss * * result[n] = 1/(sqrt(2*pi)*width)^dim * * * exp(-|n-position|^2/(2*width^2)) * * 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, double, width); }; template class TGauss: public Module { BASIC_TYPE_ALIASES(FImpl,); public: // constructor TGauss(const std::string name); // destructor virtual ~TGauss(void) {}; // dependency relation virtual std::vector getInput(void); virtual std::vector getOutput(void); // setup virtual void setup(void); // execution virtual void execute(void); private: std::vector position_; }; MODULE_REGISTER_TMP(Gauss, TGauss, MSource); /****************************************************************************** * TGauss implementation * ******************************************************************************/ // constructor ///////////////////////////////////////////////////////////////// template TGauss::TGauss(const std::string name) : Module(name) {} // dependencies/products /////////////////////////////////////////////////////// template std::vector TGauss::getInput(void) { std::vector in; return in; } template std::vector TGauss::getOutput(void) { std::vector out = {getName()}; return out; } // setup /////////////////////////////////////////////////////////////////////// template void TGauss::setup(void) { position_ = strToVec(par().position); if(position_.size() != env().getNd()-1) { HADRONS_ERROR(Size, std::string("position has ") + std::to_string(position_.size()) + " instead of " + std::to_string(env().getNd()-1) + " components"); } envCreateLat(ComplexField, getName()); envTmpLat(ComplexField, "component"); } // execution /////////////////////////////////////////////////////////////////// template void TGauss::execute(void) { auto &rho = envGet(ComplexField, getName()); envGetTmp(ComplexField, component); const int dim=env().getNd()-1; const double fact=-0.5/std::pow(par().width,2); const Complex i(0.0, 1.0); rho=zero; for(int mu=0; mu(std::pow(sqrt(2*M_PI)*par().width,dim)); } END_MODULE_NAMESPACE END_HADRONS_NAMESPACE #endif // Hadrons_MSource_Gauss_hpp_