/************************************************************************************* Grid physics library, www.github.com/paboyle/Grid Source file: extras/Hadrons/Modules/MScalarSUN/EMT.hpp Copyright (C) 2015-2018 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_MScalarSUN_EMT_hpp_ #define Hadrons_MScalarSUN_EMT_hpp_ #include #include #include #include BEGIN_HADRONS_NAMESPACE /****************************************************************************** * Energy-momentum tensor * ******************************************************************************/ BEGIN_MODULE_NAMESPACE(MScalarSUN) class EMTPar: Serializable { public: GRID_SERIALIZABLE_CLASS_MEMBERS(EMTPar, std::string, kinetic, std::string, phiPow, std::string, improvement, double , m2, double , lambda, double , g, double , xi, std::string, output); }; template class TEMT: public Module { public: typedef typename SImpl::Field Field; typedef typename SImpl::ComplexField ComplexField; public: // constructor TEMT(const std::string name); // destructor virtual ~TEMT(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(EMTSU2, TEMT>, MScalarSUN); MODULE_REGISTER_NS(EMTSU3, TEMT>, MScalarSUN); MODULE_REGISTER_NS(EMTSU4, TEMT>, MScalarSUN); MODULE_REGISTER_NS(EMTSU5, TEMT>, MScalarSUN); MODULE_REGISTER_NS(EMTSU6, TEMT>, MScalarSUN); /****************************************************************************** * TEMT implementation * ******************************************************************************/ // constructor ///////////////////////////////////////////////////////////////// template TEMT::TEMT(const std::string name) : Module(name) {} // dependencies/products /////////////////////////////////////////////////////// template std::vector TEMT::getInput(void) { std::vector in; for (unsigned int mu = 0; mu < env().getNd(); ++mu) for (unsigned int nu = mu; nu < env().getNd(); ++nu) { in.push_back(varName(par().kinetic, mu, nu)); in.push_back(varName(par().improvement, mu, nu)); } in.push_back(varName(par().phiPow, 2)); in.push_back(varName(par().phiPow, 4)); return in; } template std::vector TEMT::getOutput(void) { std::vector out; for (unsigned int mu = 0; mu < env().getNd(); ++mu) for (unsigned int nu = mu; nu < env().getNd(); ++nu) { out.push_back(varName(getName(), mu, nu)); } return out; } // setup /////////////////////////////////////////////////////////////////////// template void TEMT::setup(void) { for (unsigned int mu = 0; mu < env().getNd(); ++mu) for (unsigned int nu = mu; nu < env().getNd(); ++nu) { envCreateLat(ComplexField, varName(getName(), mu, nu)); } envTmpLat(ComplexField, "sumkin"); } // execution /////////////////////////////////////////////////////////////////// template void TEMT::execute(void) { LOG(Message) << "Computing energy-momentum tensor" << std::endl; LOG(Message) << " kinetic terms: '" << par().kinetic << "'" << std::endl; LOG(Message) << " tr(phi^n): '" << par().phiPow << "'" << std::endl; LOG(Message) << " improvement: '" << par().improvement << "'" << std::endl; LOG(Message) << " m^2= " << par().m2 << std::endl; LOG(Message) << " lambda= " << par().lambda << std::endl; LOG(Message) << " g= " << par().g << std::endl; LOG(Message) << " xi= " << par().xi << std::endl; const unsigned int N = SImpl::Group::Dimension; auto &trphi2 = envGet(ComplexField, varName(par().phiPow, 2)); auto &trphi4 = envGet(ComplexField, varName(par().phiPow, 4)); envGetTmp(ComplexField, sumkin); sumkin = zero; for (unsigned int mu = 0; mu < env().getNd(); ++mu) { auto &trkin = envGet(ComplexField, varName(par().kinetic, mu, mu)); sumkin += trkin; } for (unsigned int mu = 0; mu < env().getNd(); ++mu) for (unsigned int nu = mu; nu < env().getNd(); ++nu) { auto &out = envGet(ComplexField, varName(getName(), mu, nu)); auto &trkin = envGet(ComplexField, varName(par().kinetic, mu, nu)); auto &imp = envGet(ComplexField, varName(par().improvement, mu, nu)); out = 2.*trkin + par().xi*imp; if (mu == nu) { out -= sumkin + par().m2*trphi2 + par().lambda*trphi4; } out *= N/par().g; } } END_MODULE_NAMESPACE END_HADRONS_NAMESPACE #endif // Hadrons_MScalarSUN_EMT_hpp_