/************************************************************************************* Grid physics library, www.github.com/paboyle/Grid Source file: extras/Hadrons/Modules/MSource/Z2.hpp Copyright (C) 2015 Copyright (C) 2016 Author: Antonin Portelli 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_MSource_Z2_hpp_ #define Hadrons_MSource_Z2_hpp_ #include #include #include BEGIN_HADRONS_NAMESPACE /* Z_2 stochastic source ----------------------------- * src_x = eta_x * theta(x_3 - tA) * theta(tB - x_3) the eta_x are independent uniform random numbers in {+/- 1 +/- i} * options: - tA: begin timeslice (integer) - tB: end timesilce (integer) */ /****************************************************************************** * Z2 stochastic source * ******************************************************************************/ BEGIN_MODULE_NAMESPACE(MSource) class Z2Par: Serializable { public: GRID_SERIALIZABLE_CLASS_MEMBERS(Z2Par, unsigned int, tA, unsigned int, tB); }; template class TZ2: public Module { public: FERM_TYPE_ALIASES(FImpl,); public: // constructor TZ2(const std::string name); // destructor virtual ~TZ2(void) = default; // dependency relation virtual std::vector getInput(void); virtual std::vector getOutput(void); protected: // setup virtual void setup(void); // execution virtual void execute(void); }; MODULE_REGISTER_NS(Z2, TZ2, MSource); MODULE_REGISTER_NS(ScalarZ2, TZ2, MSource); /****************************************************************************** * TZ2 template implementation * ******************************************************************************/ // constructor ///////////////////////////////////////////////////////////////// template TZ2::TZ2(const std::string name) : Module(name) {} // dependencies/products /////////////////////////////////////////////////////// template std::vector TZ2::getInput(void) { std::vector in; return in; } template std::vector TZ2::getOutput(void) { std::vector out = {getName()}; return out; } // setup /////////////////////////////////////////////////////////////////////// template void TZ2::setup(void) { env().template registerLattice(getName()); } // execution /////////////////////////////////////////////////////////////////// template void TZ2::execute(void) { Lattice> t(env().getGrid()); LatticeComplex eta(env().getGrid()); Complex shift(1., 1.); if (par().tA == par().tB) { LOG(Message) << "Generating Z_2 wall source at t= " << par().tA << std::endl; } else { LOG(Message) << "Generating Z_2 band for " << par().tA << " <= t <= " << par().tB << std::endl; } PropagatorField &src = *env().template createLattice(getName()); LatticeCoordinate(t, Tp); bernoulli(*env().get4dRng(), eta); eta = (2.*eta - shift)*(1./::sqrt(2.)); eta = where((t >= par().tA) and (t <= par().tB), eta, 0.*eta); src = 1.; src = src*eta; } END_MODULE_NAMESPACE END_HADRONS_NAMESPACE #endif // Hadrons_MSource_Z2_hpp_