2018-01-10 11:29:49 +00:00
|
|
|
/*************************************************************************************
|
|
|
|
|
|
|
|
Grid physics library, www.github.com/paboyle/Grid
|
|
|
|
|
|
|
|
Source file: extras/Hadrons/Modules/MScalarSUN/TrPhi.hpp
|
|
|
|
|
|
|
|
Copyright (C) 2015-2018
|
|
|
|
|
|
|
|
Author: Antonin Portelli <antonin.portelli@me.com>
|
|
|
|
|
|
|
|
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 */
|
2018-01-10 11:01:03 +00:00
|
|
|
#ifndef Hadrons_MScalarSUN_TrPhi_hpp_
|
|
|
|
#define Hadrons_MScalarSUN_TrPhi_hpp_
|
|
|
|
|
|
|
|
#include <Grid/Hadrons/Global.hpp>
|
|
|
|
#include <Grid/Hadrons/Module.hpp>
|
|
|
|
#include <Grid/Hadrons/ModuleFactory.hpp>
|
2018-03-02 17:34:23 +00:00
|
|
|
#include <Grid/Hadrons/Modules/MScalarSUN/Utils.hpp>
|
2018-01-10 11:01:03 +00:00
|
|
|
|
|
|
|
BEGIN_HADRONS_NAMESPACE
|
|
|
|
|
|
|
|
/******************************************************************************
|
2018-03-02 14:29:54 +00:00
|
|
|
* Trace of powers of a scalar field *
|
2018-01-10 11:01:03 +00:00
|
|
|
******************************************************************************/
|
|
|
|
BEGIN_MODULE_NAMESPACE(MScalarSUN)
|
|
|
|
|
|
|
|
class TrPhiPar: Serializable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GRID_SERIALIZABLE_CLASS_MEMBERS(TrPhiPar,
|
|
|
|
std::string, field,
|
|
|
|
unsigned int, maxPow,
|
|
|
|
std::string, output);
|
|
|
|
};
|
|
|
|
|
2018-04-26 17:32:37 +01:00
|
|
|
class TrPhiResult: Serializable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GRID_SERIALIZABLE_CLASS_MEMBERS(TrPhiResult,
|
|
|
|
std::string, op,
|
|
|
|
Real, value);
|
|
|
|
};
|
|
|
|
|
2018-01-10 11:01:03 +00:00
|
|
|
template <typename SImpl>
|
|
|
|
class TTrPhi: public Module<TrPhiPar>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef typename SImpl::Field Field;
|
|
|
|
typedef typename SImpl::ComplexField ComplexField;
|
2018-04-26 17:32:37 +01:00
|
|
|
|
2018-01-10 11:01:03 +00:00
|
|
|
public:
|
|
|
|
// constructor
|
|
|
|
TTrPhi(const std::string name);
|
|
|
|
// destructor
|
2018-04-24 17:20:25 +01:00
|
|
|
virtual ~TTrPhi(void) {};
|
2018-01-10 11:01:03 +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(TrPhiSU2, TTrPhi<ScalarNxNAdjImplR<2>>, MScalarSUN);
|
|
|
|
MODULE_REGISTER_TMP(TrPhiSU3, TTrPhi<ScalarNxNAdjImplR<3>>, MScalarSUN);
|
|
|
|
MODULE_REGISTER_TMP(TrPhiSU4, TTrPhi<ScalarNxNAdjImplR<4>>, MScalarSUN);
|
|
|
|
MODULE_REGISTER_TMP(TrPhiSU5, TTrPhi<ScalarNxNAdjImplR<5>>, MScalarSUN);
|
|
|
|
MODULE_REGISTER_TMP(TrPhiSU6, TTrPhi<ScalarNxNAdjImplR<6>>, MScalarSUN);
|
2018-01-10 11:01:03 +00:00
|
|
|
|
|
|
|
/******************************************************************************
|
2018-01-10 11:29:49 +00:00
|
|
|
* TTrPhi implementation *
|
2018-01-10 11:01:03 +00:00
|
|
|
******************************************************************************/
|
|
|
|
// constructor /////////////////////////////////////////////////////////////////
|
|
|
|
template <typename SImpl>
|
|
|
|
TTrPhi<SImpl>::TTrPhi(const std::string name)
|
|
|
|
: Module<TrPhiPar>(name)
|
|
|
|
{}
|
|
|
|
|
|
|
|
// dependencies/products ///////////////////////////////////////////////////////
|
|
|
|
template <typename SImpl>
|
|
|
|
std::vector<std::string> TTrPhi<SImpl>::getInput(void)
|
|
|
|
{
|
|
|
|
std::vector<std::string> in = {par().field};
|
|
|
|
|
|
|
|
return in;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename SImpl>
|
|
|
|
std::vector<std::string> TTrPhi<SImpl>::getOutput(void)
|
|
|
|
{
|
|
|
|
std::vector<std::string> out;
|
|
|
|
|
|
|
|
for (unsigned int n = 2; n <= par().maxPow; n += 2)
|
|
|
|
{
|
2018-03-02 17:34:23 +00:00
|
|
|
out.push_back(varName(getName(), n));
|
2018-01-10 11:01:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
// setup ///////////////////////////////////////////////////////////////////////
|
|
|
|
template <typename SImpl>
|
|
|
|
void TTrPhi<SImpl>::setup(void)
|
|
|
|
{
|
|
|
|
if (par().maxPow < 2)
|
|
|
|
{
|
2018-04-25 16:49:14 +01:00
|
|
|
HADRONS_ERROR(Size, "'maxPow' should be at least equal to 2");
|
2018-01-10 11:01:03 +00:00
|
|
|
}
|
|
|
|
envTmpLat(Field, "phi2");
|
|
|
|
envTmpLat(Field, "buf");
|
|
|
|
for (unsigned int n = 2; n <= par().maxPow; n += 2)
|
|
|
|
{
|
2018-03-02 17:34:23 +00:00
|
|
|
envCreateLat(ComplexField, varName(getName(), n));
|
2018-01-10 11:01:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// execution ///////////////////////////////////////////////////////////////////
|
|
|
|
template <typename SImpl>
|
|
|
|
void TTrPhi<SImpl>::execute(void)
|
|
|
|
{
|
|
|
|
LOG(Message) << "Computing tr(phi^n) for n even up to " << par().maxPow
|
2018-03-02 14:29:54 +00:00
|
|
|
<< std::endl;
|
2018-01-10 11:01:03 +00:00
|
|
|
|
2018-04-26 17:32:37 +01:00
|
|
|
std::vector<TrPhiResult> result;
|
|
|
|
auto &phi = envGet(Field, par().field);
|
2018-01-10 11:01:03 +00:00
|
|
|
|
|
|
|
envGetTmp(Field, phi2);
|
|
|
|
envGetTmp(Field, buf);
|
|
|
|
buf = 1.;
|
|
|
|
phi2 = -phi*phi;
|
|
|
|
for (unsigned int n = 2; n <= par().maxPow; n += 2)
|
|
|
|
{
|
2018-03-02 17:34:23 +00:00
|
|
|
auto &phin = envGet(ComplexField, varName(getName(), n));
|
2018-01-10 11:01:03 +00:00
|
|
|
|
|
|
|
buf = buf*phi2;
|
|
|
|
phin = trace(buf);
|
|
|
|
if (!par().output.empty())
|
|
|
|
{
|
2018-04-26 17:32:37 +01:00
|
|
|
TrPhiResult r;
|
2018-01-10 11:01:03 +00:00
|
|
|
|
2018-01-10 11:29:49 +00:00
|
|
|
r.op = "tr(phi^" + std::to_string(n) + ")";
|
|
|
|
r.value = TensorRemove(sum(phin)).real();
|
2018-01-10 11:01:03 +00:00
|
|
|
result.push_back(r);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (result.size() > 0)
|
|
|
|
{
|
2018-01-23 17:26:50 +00:00
|
|
|
saveResult(par().output, "trphi", result);
|
2018-01-10 11:01:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
END_MODULE_NAMESPACE
|
|
|
|
|
|
|
|
END_HADRONS_NAMESPACE
|
|
|
|
|
|
|
|
#endif // Hadrons_MScalarSUN_TrPhi_hpp_
|