/************************************************************************************* Grid physics library, www.github.com/paboyle/Grid Source file: extras/Hadrons/Modules/MContraction/SeqConserved.hpp Copyright (C) 2017 Author: Andrew Lawson This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. See the full license in the file "LICENSE" in the top level distribution directory *************************************************************************************/ /* END LEGAL */ #ifndef Hadrons_SeqConserved_hpp_ #define Hadrons_SeqConserved_hpp_ #include #include #include BEGIN_HADRONS_NAMESPACE /* Sequential source ----------------------------- * src_x = q_x * theta(x_3 - tA) * theta(tB - x_3) * J_mu * exp(i x.mom) * options: - q: input propagator (string) - action: fermion action used for propagator q (string) - tA: begin timeslice (integer) - tB: end timesilce (integer) - curr_type: type of conserved current to insert (Current) - mu: Lorentz index of current to insert (integer) - mom: momentum insertion, space-separated float sequence (e.g ".1 .2 1. 0.") */ /****************************************************************************** * SeqConserved * ******************************************************************************/ BEGIN_MODULE_NAMESPACE(MSource) class SeqConservedPar: Serializable { public: GRID_SERIALIZABLE_CLASS_MEMBERS(SeqConservedPar, std::string, q, std::string, action, unsigned int, tA, unsigned int, tB, Current, curr_type, unsigned int, mu, std::string, mom); }; template class TSeqConserved: public Module { public: FERM_TYPE_ALIASES(FImpl,); public: // constructor TSeqConserved(const std::string name); // destructor virtual ~TSeqConserved(void) = default; // dependency relation virtual std::vector getInput(void); virtual std::vector getOutput(void); // setup virtual void setup(void); // execution virtual void execute(void); }; MODULE_REGISTER_NS(SeqConserved, TSeqConserved, MSource); /****************************************************************************** * TSeqConserved implementation * ******************************************************************************/ // constructor ///////////////////////////////////////////////////////////////// template TSeqConserved::TSeqConserved(const std::string name) : Module(name) {} // dependencies/products /////////////////////////////////////////////////////// template std::vector TSeqConserved::getInput(void) { std::vector in = {par().q, par().action}; return in; } template std::vector TSeqConserved::getOutput(void) { std::vector out = {getName()}; return out; } // setup /////////////////////////////////////////////////////////////////////// template void TSeqConserved::setup(void) { auto Ls_ = env().getObjectLs(par().action); env().template registerLattice(getName(), Ls_); } // execution /////////////////////////////////////////////////////////////////// template void TSeqConserved::execute(void) { if (par().tA == par().tB) { LOG(Message) << "Generating sequential source with conserved " << par().curr_type << " current insertion (mu = " << par().mu << ") at " << "t = " << par().tA << std::endl; } else { LOG(Message) << "Generating sequential source with conserved " << par().curr_type << " current insertion (mu = " << par().mu << ") for " << par().tA << " <= t <= " << par().tB << std::endl; } PropagatorField &src = *env().template createLattice(getName()); PropagatorField &q = *env().template getObject(par().q); FMat &mat = *(env().template getObject(par().action)); std::vector mom = strToVec(par().mom); mat.SeqConservedCurrent(q, src, par().curr_type, par().mu, mom, par().tA, par().tB); } END_MODULE_NAMESPACE END_HADRONS_NAMESPACE #endif // Hadrons_SeqConserved_hpp_