2018-03-05 19:58:40 +00:00
|
|
|
/*************************************************************************************
|
|
|
|
|
|
|
|
Grid physics library, www.github.com/paboyle/Grid
|
|
|
|
|
|
|
|
Source file: extras/Hadrons/Modules/MScalarSUN/ShiftProbe.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 */
|
|
|
|
#ifndef Hadrons_MScalarSUN_ShiftProbe_hpp_
|
|
|
|
#define Hadrons_MScalarSUN_ShiftProbe_hpp_
|
|
|
|
|
|
|
|
#include <Grid/Hadrons/Global.hpp>
|
|
|
|
#include <Grid/Hadrons/Module.hpp>
|
|
|
|
#include <Grid/Hadrons/ModuleFactory.hpp>
|
|
|
|
#include <Grid/Hadrons/Modules/MScalarSUN/Utils.hpp>
|
|
|
|
|
|
|
|
BEGIN_HADRONS_NAMESPACE
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* Ward identity phi^n probe with fields at different positions *
|
|
|
|
******************************************************************************/
|
|
|
|
BEGIN_MODULE_NAMESPACE(MScalarSUN)
|
|
|
|
|
|
|
|
typedef std::pair<unsigned int, unsigned int> ShiftPair;
|
|
|
|
|
|
|
|
class ShiftProbePar: Serializable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GRID_SERIALIZABLE_CLASS_MEMBERS(ShiftProbePar,
|
|
|
|
std::string, field,
|
|
|
|
std::string, shifts,
|
|
|
|
std::string, output);
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename SImpl>
|
|
|
|
class TShiftProbe: public Module<ShiftProbePar>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
typedef typename SImpl::Field Field;
|
|
|
|
typedef typename SImpl::ComplexField ComplexField;
|
|
|
|
class Result: Serializable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GRID_SERIALIZABLE_CLASS_MEMBERS(Result,
|
|
|
|
std::string, op,
|
|
|
|
Complex , value);
|
|
|
|
};
|
|
|
|
public:
|
|
|
|
// constructor
|
|
|
|
TShiftProbe(const std::string name);
|
|
|
|
// destructor
|
|
|
|
virtual ~TShiftProbe(void) = default;
|
|
|
|
// 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);
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_REGISTER_NS(ShiftProbeSU2, TShiftProbe<ScalarNxNAdjImplR<2>>, MScalarSUN);
|
|
|
|
MODULE_REGISTER_NS(ShiftProbeSU3, TShiftProbe<ScalarNxNAdjImplR<3>>, MScalarSUN);
|
|
|
|
MODULE_REGISTER_NS(ShiftProbeSU4, TShiftProbe<ScalarNxNAdjImplR<4>>, MScalarSUN);
|
|
|
|
MODULE_REGISTER_NS(ShiftProbeSU5, TShiftProbe<ScalarNxNAdjImplR<5>>, MScalarSUN);
|
|
|
|
MODULE_REGISTER_NS(ShiftProbeSU6, TShiftProbe<ScalarNxNAdjImplR<6>>, MScalarSUN);
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* TShiftProbe implementation *
|
|
|
|
******************************************************************************/
|
|
|
|
// constructor /////////////////////////////////////////////////////////////////
|
|
|
|
template <typename SImpl>
|
|
|
|
TShiftProbe<SImpl>::TShiftProbe(const std::string name)
|
|
|
|
: Module<ShiftProbePar>(name)
|
|
|
|
{}
|
|
|
|
|
|
|
|
// dependencies/products ///////////////////////////////////////////////////////
|
|
|
|
template <typename SImpl>
|
|
|
|
std::vector<std::string> TShiftProbe<SImpl>::getInput(void)
|
|
|
|
{
|
|
|
|
std::vector<std::string> in = {par().field};
|
|
|
|
|
|
|
|
return in;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename SImpl>
|
|
|
|
std::vector<std::string> TShiftProbe<SImpl>::getOutput(void)
|
|
|
|
{
|
|
|
|
std::vector<std::string> out = {getName()};
|
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
// setup ///////////////////////////////////////////////////////////////////////
|
|
|
|
template <typename SImpl>
|
|
|
|
void TShiftProbe<SImpl>::setup(void)
|
|
|
|
{
|
|
|
|
envTmpLat(Field, "acc");
|
2018-03-09 21:56:27 +00:00
|
|
|
envCreateLat(ComplexField, getName());
|
2018-03-05 19:58:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// execution ///////////////////////////////////////////////////////////////////
|
|
|
|
template <typename SImpl>
|
|
|
|
void TShiftProbe<SImpl>::execute(void)
|
|
|
|
{
|
|
|
|
LOG(Message) << "Creating shift probe for shifts " << par().shifts
|
|
|
|
<< std::endl;
|
|
|
|
|
|
|
|
std::vector<ShiftPair> shift;
|
|
|
|
unsigned int sign;
|
|
|
|
auto &phi = envGet(Field, par().field);
|
|
|
|
auto &probe = envGet(ComplexField, getName());
|
|
|
|
|
|
|
|
shift = strToVec<ShiftPair>(par().shifts);
|
|
|
|
if (shift.size() % 2 != 0)
|
|
|
|
{
|
|
|
|
HADRON_ERROR(Size, "the number of shifts is odd");
|
|
|
|
}
|
|
|
|
sign = (shift.size() % 4 == 0) ? 1 : -1;
|
|
|
|
for (auto &s: shift)
|
|
|
|
{
|
|
|
|
if (s.first >= env().getNd())
|
|
|
|
{
|
|
|
|
HADRON_ERROR(Size, "dimension to large for shift <"
|
|
|
|
+ std::to_string(s.first) + " "
|
|
|
|
+ std::to_string(s.second) + ">" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
envGetTmp(Field, acc);
|
|
|
|
acc = 1.;
|
|
|
|
for (unsigned int i = 0; i < shift.size(); ++i)
|
|
|
|
{
|
|
|
|
if (shift[i].second == 0)
|
|
|
|
{
|
|
|
|
acc *= phi;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
acc *= Cshift(phi, shift[i].first, shift[i].second);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
probe = sign*trace(acc);
|
|
|
|
}
|
|
|
|
|
|
|
|
END_MODULE_NAMESPACE
|
|
|
|
|
|
|
|
END_HADRONS_NAMESPACE
|
|
|
|
|
|
|
|
#endif // Hadrons_MScalarSUN_ShiftProbe_hpp_
|