/************************************************************************************* Grid physics library, www.github.com/paboyle/Grid Source file: Hadrons/Modules/MGauge/Electrify.hpp Copyright (C) 2015-2018 Author: Vera Guelpers 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_MGauge_Electrify_hpp_ #define Hadrons_MGauge_Electrify_hpp_ #include #include #include BEGIN_HADRONS_NAMESPACE /****************************************************************************** * Electrify gauge * ******************************************************************************/ BEGIN_MODULE_NAMESPACE(MGauge) /**************************************************************************** * Electrify a gauge field: * * Ue_mu(x) = U_mu(x)*exp(ieqA_mu(x)) * * with * * - gauge: U_mu(x): gauge field * - emField: A_mu(x): electromagnetic photon field * - e: value for the elementary charge * - q: charge in units of e * *****************************************************************************/ class ElectrifyPar: Serializable { public: GRID_SERIALIZABLE_CLASS_MEMBERS(ElectrifyPar, std::string, gauge, std::string, emField, double, e, double, charge); }; template class TElectrify: public Module { public: GAUGE_TYPE_ALIASES(GImpl,); public: typedef PhotonR::GaugeField EmField; public: // constructor TElectrify(const std::string name); // destructor virtual ~TElectrify(void) {}; // dependencies/products virtual std::vector getInput(void); virtual std::vector getOutput(void); protected: // setup virtual void setup(void); // execution virtual void execute(void); }; MODULE_REGISTER_TMP(Electrify, TElectrify, MGauge); /****************************************************************************** * TElectrify implementation * ******************************************************************************/ // constructor ///////////////////////////////////////////////////////////////// template TElectrify::TElectrify(const std::string name) : Module(name) {} // dependencies/products /////////////////////////////////////////////////////// template std::vector TElectrify::getInput(void) { std::vector in = {par().gauge, par().emField}; return in; } template std::vector TElectrify::getOutput(void) { std::vector out = {getName()}; return out; } // setup /////////////////////////////////////////////////////////////////////// template void TElectrify::setup(void) { envCreateLat(GaugeField, getName()); envTmpLat(LatticeComplex, "eiAmu"); } // execution /////////////////////////////////////////////////////////////////// template void TElectrify::execute(void) { LOG(Message) << "Electrify the gauge field " << par().gauge << " using the photon field " << par().emField << " with charge e*q= " << par().e << "*" << par().charge << std::endl; auto &Ue = envGet(GaugeField, getName()); auto &U = envGet(GaugeField, par().gauge); auto &A = envGet(EmField, par().emField); envGetTmp(LatticeComplex, eiAmu); Complex i(0.0,1.0); for(unsigned int mu = 0; mu < env().getNd(); mu++) { eiAmu = exp(i * (Real)(par().e * par().charge) * PeekIndex(A, mu)); PokeIndex(Ue, PeekIndex(U, mu) * eiAmu, mu); } } END_MODULE_NAMESPACE END_HADRONS_NAMESPACE #endif // Hadrons_MGauge_Electrify_hpp_