/************************************************************************************* Grid physics library, www.github.com/paboyle/Grid Source file: extras/Hadrons/Modules/MScalarSUN/TrMag.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_TrMag_hpp_ #define Hadrons_MScalarSUN_TrMag_hpp_ #include #include #include BEGIN_HADRONS_NAMESPACE /****************************************************************************** * Module to compute tr(mag^n) * ******************************************************************************/ BEGIN_MODULE_NAMESPACE(MScalarSUN) class TrMagPar: Serializable { public: GRID_SERIALIZABLE_CLASS_MEMBERS(TrMagPar, std::string, field, unsigned int, maxPow, std::string, output); }; template class TTrMag: public Module { public: typedef typename SImpl::Field Field; typedef typename SImpl::ComplexField ComplexField; class Result: Serializable { public: GRID_SERIALIZABLE_CLASS_MEMBERS(Result, std::string, op, Real, value); }; public: // constructor TTrMag(const std::string name); // destructor virtual ~TTrMag(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(TrMagSU2, TTrMag>, MScalarSUN); MODULE_REGISTER_NS(TrMagSU3, TTrMag>, MScalarSUN); MODULE_REGISTER_NS(TrMagSU4, TTrMag>, MScalarSUN); MODULE_REGISTER_NS(TrMagSU5, TTrMag>, MScalarSUN); MODULE_REGISTER_NS(TrMagSU6, TTrMag>, MScalarSUN); /****************************************************************************** * TTrMag implementation * ******************************************************************************/ // constructor ///////////////////////////////////////////////////////////////// template TTrMag::TTrMag(const std::string name) : Module(name) {} // dependencies/products /////////////////////////////////////////////////////// template std::vector TTrMag::getInput(void) { std::vector in = {par().field}; return in; } template std::vector TTrMag::getOutput(void) { std::vector out = {}; return out; } // setup /////////////////////////////////////////////////////////////////////// template void TTrMag::setup(void) {} // execution /////////////////////////////////////////////////////////////////// template void TTrMag::execute(void) { LOG(Message) << "Computing tr(mag^n) for n even up to " << par().maxPow << "..." << std::endl; std::vector result; ResultWriter writer(RESULT_FILE_NAME(par().output)); auto &phi = envGet(Field, par().field); auto m2 = sum(phi), mn = m2; m2 = -m2*m2; mn = 1.; for (unsigned int n = 2; n <= par().maxPow; n += 2) { Result r; mn = mn*m2; r.op = "tr(mag^" + std::to_string(n) + ")"; r.value = TensorRemove(trace(mn)).real(); result.push_back(r); } write(writer, "trmag", result); } END_MODULE_NAMESPACE END_HADRONS_NAMESPACE #endif // Hadrons_MScalarSUN_TrMag_hpp_