2018-03-02 14:14:11 +00:00
|
|
|
/*************************************************************************************
|
|
|
|
|
|
|
|
Grid physics library, www.github.com/paboyle/Grid
|
|
|
|
|
2018-09-01 21:30:30 +01:00
|
|
|
Source file: Hadrons/Modules/MScalarSUN/TrKinetic.hpp
|
2018-03-02 14:14:11 +00:00
|
|
|
|
2019-02-05 18:55:24 +00:00
|
|
|
Copyright (C) 2015-2019
|
2018-03-02 14:14:11 +00:00
|
|
|
|
2018-03-02 14:29:54 +00:00
|
|
|
Author: Antonin Portelli <antonin.portelli@me.com>
|
2018-03-02 14:14:11 +00:00
|
|
|
|
|
|
|
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_TrKinetic_hpp_
|
|
|
|
#define Hadrons_MScalarSUN_TrKinetic_hpp_
|
|
|
|
|
2018-08-28 15:00:40 +01:00
|
|
|
#include <Hadrons/Global.hpp>
|
|
|
|
#include <Hadrons/Module.hpp>
|
|
|
|
#include <Hadrons/ModuleFactory.hpp>
|
|
|
|
#include <Hadrons/Modules/MScalarSUN/Utils.hpp>
|
2018-03-02 14:14:11 +00:00
|
|
|
|
|
|
|
BEGIN_HADRONS_NAMESPACE
|
|
|
|
|
|
|
|
/******************************************************************************
|
2018-03-02 14:30:45 +00:00
|
|
|
* Trace of kinetic term *
|
2018-03-02 14:14:11 +00:00
|
|
|
******************************************************************************/
|
|
|
|
BEGIN_MODULE_NAMESPACE(MScalarSUN)
|
|
|
|
|
|
|
|
class TrKineticPar: Serializable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GRID_SERIALIZABLE_CLASS_MEMBERS(TrKineticPar,
|
|
|
|
std::string, field,
|
|
|
|
DiffType, type,
|
|
|
|
std::string, output);
|
|
|
|
};
|
|
|
|
|
2018-04-26 17:32:37 +01:00
|
|
|
class TrKineticResult: Serializable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GRID_SERIALIZABLE_CLASS_MEMBERS(TrKineticResult,
|
|
|
|
std::vector<std::vector<Complex>>, value,
|
|
|
|
DiffType, type);
|
|
|
|
};
|
|
|
|
|
2018-03-02 14:14:11 +00:00
|
|
|
template <typename SImpl>
|
|
|
|
class TTrKinetic: public Module<TrKineticPar>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef typename SImpl::Field Field;
|
|
|
|
typedef typename SImpl::ComplexField ComplexField;
|
|
|
|
public:
|
|
|
|
// constructor
|
|
|
|
TTrKinetic(const std::string name);
|
|
|
|
// destructor
|
2018-04-24 17:20:25 +01:00
|
|
|
virtual ~TTrKinetic(void) {};
|
2018-03-02 14:14:11 +00:00
|
|
|
// dependency relation
|
|
|
|
virtual std::vector<std::string> getInput(void);
|
|
|
|
virtual std::vector<std::string> getOutput(void);
|
|
|
|
// setup
|
|
|
|
virtual void setup(void);
|
|
|
|
// execution
|
|
|
|
virtual void execute(void);
|
|
|
|
};
|
|
|
|
|
2018-04-23 17:35:01 +01:00
|
|
|
MODULE_REGISTER_TMP(TrKineticSU2, TTrKinetic<ScalarNxNAdjImplR<2>>, MScalarSUN);
|
|
|
|
MODULE_REGISTER_TMP(TrKineticSU3, TTrKinetic<ScalarNxNAdjImplR<3>>, MScalarSUN);
|
|
|
|
MODULE_REGISTER_TMP(TrKineticSU4, TTrKinetic<ScalarNxNAdjImplR<4>>, MScalarSUN);
|
|
|
|
MODULE_REGISTER_TMP(TrKineticSU5, TTrKinetic<ScalarNxNAdjImplR<5>>, MScalarSUN);
|
|
|
|
MODULE_REGISTER_TMP(TrKineticSU6, TTrKinetic<ScalarNxNAdjImplR<6>>, MScalarSUN);
|
2018-03-02 14:14:11 +00:00
|
|
|
|
|
|
|
/******************************************************************************
|
2018-03-02 14:30:45 +00:00
|
|
|
* TTrKinetic implementation *
|
2018-03-02 14:14:11 +00:00
|
|
|
******************************************************************************/
|
|
|
|
// constructor /////////////////////////////////////////////////////////////////
|
|
|
|
template <typename SImpl>
|
|
|
|
TTrKinetic<SImpl>::TTrKinetic(const std::string name)
|
|
|
|
: Module<TrKineticPar>(name)
|
|
|
|
{}
|
|
|
|
|
|
|
|
// dependencies/products ///////////////////////////////////////////////////////
|
|
|
|
template <typename SImpl>
|
|
|
|
std::vector<std::string> TTrKinetic<SImpl>::getInput(void)
|
|
|
|
{
|
|
|
|
std::vector<std::string> in = {par().field};
|
|
|
|
|
|
|
|
return in;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename SImpl>
|
|
|
|
std::vector<std::string> TTrKinetic<SImpl>::getOutput(void)
|
|
|
|
{
|
|
|
|
std::vector<std::string> out ;
|
|
|
|
|
|
|
|
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
|
|
|
for (unsigned int nu = mu; nu < env().getNd(); ++nu)
|
|
|
|
{
|
2018-03-02 17:34:23 +00:00
|
|
|
out.push_back(varName(getName(), mu, nu));
|
2018-03-02 14:14:11 +00:00
|
|
|
}
|
2018-04-24 19:51:22 +01:00
|
|
|
out.push_back(varName(getName(), "sum"));
|
2018-03-02 14:14:11 +00:00
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
// setup ///////////////////////////////////////////////////////////////////////
|
|
|
|
template <typename SImpl>
|
|
|
|
void TTrKinetic<SImpl>::setup(void)
|
|
|
|
{
|
|
|
|
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
|
|
|
for (unsigned int nu = mu; nu < env().getNd(); ++nu)
|
|
|
|
{
|
2018-03-02 17:34:23 +00:00
|
|
|
envCreateLat(ComplexField, varName(getName(), mu, nu));
|
2018-03-02 14:14:11 +00:00
|
|
|
}
|
2018-04-24 19:51:22 +01:00
|
|
|
envCreateLat(ComplexField, varName(getName(), "sum"));
|
2018-09-29 17:55:19 +01:00
|
|
|
envTmp(std::vector<Field>, "der", 1, env().getNd(), envGetGrid(Field));
|
2018-03-02 14:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// execution ///////////////////////////////////////////////////////////////////
|
|
|
|
template <typename SImpl>
|
|
|
|
void TTrKinetic<SImpl>::execute(void)
|
|
|
|
{
|
|
|
|
LOG(Message) << "Computing tr(d_mu phi*d_nu phi) using " << par().type
|
|
|
|
<< " derivative" << std::endl;
|
|
|
|
|
2018-04-26 17:32:37 +01:00
|
|
|
const unsigned int nd = env().getNd();
|
|
|
|
TrKineticResult result;
|
|
|
|
auto &phi = envGet(Field, par().field);
|
|
|
|
auto &sumkin = envGet(ComplexField, varName(getName(), "sum"));
|
2018-03-02 14:14:11 +00:00
|
|
|
|
|
|
|
envGetTmp(std::vector<Field>, der);
|
2018-12-13 05:11:34 +00:00
|
|
|
sumkin = Zero();
|
2018-04-26 17:32:37 +01:00
|
|
|
if (!par().output.empty())
|
|
|
|
{
|
|
|
|
result.type = par().type;
|
|
|
|
result.value.resize(nd, std::vector<Complex>(nd));
|
|
|
|
}
|
|
|
|
for (unsigned int mu = 0; mu < nd; ++mu)
|
2018-03-02 14:14:11 +00:00
|
|
|
{
|
2018-03-02 17:34:23 +00:00
|
|
|
dmu(der[mu], phi, mu, par().type);
|
2018-03-02 14:14:11 +00:00
|
|
|
}
|
2018-04-26 17:32:37 +01:00
|
|
|
for (unsigned int mu = 0; mu < nd; ++mu)
|
|
|
|
for (unsigned int nu = mu; nu < nd; ++nu)
|
2018-03-02 14:14:11 +00:00
|
|
|
{
|
2018-03-02 17:34:23 +00:00
|
|
|
auto &out = envGet(ComplexField, varName(getName(), mu, nu));
|
2018-03-02 14:14:11 +00:00
|
|
|
|
|
|
|
out = -trace(der[mu]*der[nu]);
|
2018-04-24 19:51:22 +01:00
|
|
|
if (mu == nu)
|
2018-03-02 14:14:11 +00:00
|
|
|
{
|
2018-04-24 19:51:22 +01:00
|
|
|
sumkin += out;
|
|
|
|
}
|
2018-04-26 17:32:37 +01:00
|
|
|
if (!par().output.empty())
|
2018-04-24 19:51:22 +01:00
|
|
|
{
|
2018-04-26 17:32:37 +01:00
|
|
|
result.value[mu][nu] = TensorRemove(sum(out));
|
|
|
|
result.value[mu][nu] = result.value[nu][mu];
|
2018-04-24 19:51:22 +01:00
|
|
|
}
|
2018-03-02 14:14:11 +00:00
|
|
|
}
|
2018-04-26 17:32:37 +01:00
|
|
|
saveResult(par().output, "trkinetic", result);
|
2018-03-02 14:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
END_MODULE_NAMESPACE
|
|
|
|
|
|
|
|
END_HADRONS_NAMESPACE
|
|
|
|
|
|
|
|
#endif // Hadrons_MScalarSUN_TrKinetic_hpp_
|