mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-09 21:50:45 +01:00
Hadrons: scalar SU(N) gradient
This commit is contained in:
parent
75113e6523
commit
a13106da0c
@ -69,6 +69,7 @@ See the full license in the file "LICENSE" in the top level distribution directo
|
|||||||
#include <Grid/Hadrons/Modules/MScalarSUN/TrPhi.hpp>
|
#include <Grid/Hadrons/Modules/MScalarSUN/TrPhi.hpp>
|
||||||
#include <Grid/Hadrons/Modules/MScalarSUN/Utils.hpp>
|
#include <Grid/Hadrons/Modules/MScalarSUN/Utils.hpp>
|
||||||
#include <Grid/Hadrons/Modules/MScalarSUN/TransProj.hpp>
|
#include <Grid/Hadrons/Modules/MScalarSUN/TransProj.hpp>
|
||||||
|
#include <Grid/Hadrons/Modules/MScalarSUN/Grad.hpp>
|
||||||
#include <Grid/Hadrons/Modules/MScalarSUN/TrKinetic.hpp>
|
#include <Grid/Hadrons/Modules/MScalarSUN/TrKinetic.hpp>
|
||||||
#include <Grid/Hadrons/Modules/MIO/LoadEigenPack.hpp>
|
#include <Grid/Hadrons/Modules/MIO/LoadEigenPack.hpp>
|
||||||
#include <Grid/Hadrons/Modules/MIO/LoadNersc.hpp>
|
#include <Grid/Hadrons/Modules/MIO/LoadNersc.hpp>
|
||||||
|
38
extras/Hadrons/Modules/MScalarSUN/Grad.cc
Normal file
38
extras/Hadrons/Modules/MScalarSUN/Grad.cc
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*************************************************************************************
|
||||||
|
|
||||||
|
Grid physics library, www.github.com/paboyle/Grid
|
||||||
|
|
||||||
|
Source file: extras/Hadrons/Modules/MScalarSUN/Grad.cc
|
||||||
|
|
||||||
|
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 */
|
||||||
|
#include <Grid/Hadrons/Modules/MScalarSUN/Grad.hpp>
|
||||||
|
|
||||||
|
using namespace Grid;
|
||||||
|
using namespace Hadrons;
|
||||||
|
using namespace MScalarSUN;
|
||||||
|
|
||||||
|
template class Grid::Hadrons::MScalarSUN::TGrad<ScalarNxNAdjImplR<2>>;
|
||||||
|
template class Grid::Hadrons::MScalarSUN::TGrad<ScalarNxNAdjImplR<3>>;
|
||||||
|
template class Grid::Hadrons::MScalarSUN::TGrad<ScalarNxNAdjImplR<4>>;
|
||||||
|
template class Grid::Hadrons::MScalarSUN::TGrad<ScalarNxNAdjImplR<5>>;
|
||||||
|
template class Grid::Hadrons::MScalarSUN::TGrad<ScalarNxNAdjImplR<6>>;
|
165
extras/Hadrons/Modules/MScalarSUN/Grad.hpp
Normal file
165
extras/Hadrons/Modules/MScalarSUN/Grad.hpp
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
/*************************************************************************************
|
||||||
|
|
||||||
|
Grid physics library, www.github.com/paboyle/Grid
|
||||||
|
|
||||||
|
Source file: extras/Hadrons/Modules/MScalarSUN/Grad.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_Grad_hpp_
|
||||||
|
#define Hadrons_MScalarSUN_Grad_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
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* Gradient of a complex field *
|
||||||
|
******************************************************************************/
|
||||||
|
BEGIN_MODULE_NAMESPACE(MScalarSUN)
|
||||||
|
|
||||||
|
class GradPar: Serializable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GRID_SERIALIZABLE_CLASS_MEMBERS(GradPar,
|
||||||
|
std::string, op,
|
||||||
|
DiffType, type,
|
||||||
|
std::string, output);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename SImpl>
|
||||||
|
class TGrad: public Module<GradPar>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef typename SImpl::Field Field;
|
||||||
|
typedef typename SImpl::ComplexField ComplexField;
|
||||||
|
class Result: Serializable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GRID_SERIALIZABLE_CLASS_MEMBERS(Result,
|
||||||
|
DiffType, type,
|
||||||
|
Complex, value);
|
||||||
|
};
|
||||||
|
public:
|
||||||
|
// constructor
|
||||||
|
TGrad(const std::string name);
|
||||||
|
// destructor
|
||||||
|
virtual ~TGrad(void) {};
|
||||||
|
// 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_TMP(GradSU2, TGrad<ScalarNxNAdjImplR<2>>, MScalarSUN);
|
||||||
|
MODULE_REGISTER_TMP(GradSU3, TGrad<ScalarNxNAdjImplR<3>>, MScalarSUN);
|
||||||
|
MODULE_REGISTER_TMP(GradSU4, TGrad<ScalarNxNAdjImplR<4>>, MScalarSUN);
|
||||||
|
MODULE_REGISTER_TMP(GradSU5, TGrad<ScalarNxNAdjImplR<5>>, MScalarSUN);
|
||||||
|
MODULE_REGISTER_TMP(GradSU6, TGrad<ScalarNxNAdjImplR<6>>, MScalarSUN);
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* TGrad implementation *
|
||||||
|
******************************************************************************/
|
||||||
|
// constructor /////////////////////////////////////////////////////////////////
|
||||||
|
template <typename SImpl>
|
||||||
|
TGrad<SImpl>::TGrad(const std::string name)
|
||||||
|
: Module<GradPar>(name)
|
||||||
|
{}
|
||||||
|
|
||||||
|
// dependencies/products ///////////////////////////////////////////////////////
|
||||||
|
template <typename SImpl>
|
||||||
|
std::vector<std::string> TGrad<SImpl>::getInput(void)
|
||||||
|
{
|
||||||
|
std::vector<std::string> in = {par().op};
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename SImpl>
|
||||||
|
std::vector<std::string> TGrad<SImpl>::getOutput(void)
|
||||||
|
{
|
||||||
|
std::vector<std::string> out;
|
||||||
|
const auto nd = env().getNd();
|
||||||
|
|
||||||
|
for (unsigned int mu = 0; mu < nd; ++mu)
|
||||||
|
{
|
||||||
|
out.push_back(varName(getName(), mu));
|
||||||
|
}
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// setup ///////////////////////////////////////////////////////////////////////
|
||||||
|
template <typename SImpl>
|
||||||
|
void TGrad<SImpl>::setup(void)
|
||||||
|
{
|
||||||
|
const auto nd = env().getNd();
|
||||||
|
|
||||||
|
for (unsigned int mu = 0; mu < nd; ++mu)
|
||||||
|
{
|
||||||
|
envCreateLat(ComplexField, varName(getName(), mu));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// execution ///////////////////////////////////////////////////////////////////
|
||||||
|
template <typename SImpl>
|
||||||
|
void TGrad<SImpl>::execute(void)
|
||||||
|
{
|
||||||
|
const auto nd = env().getNd();
|
||||||
|
|
||||||
|
LOG(Message) << "Computing the " << par().type << " gradient of '"
|
||||||
|
<< par().op << "'" << std::endl;
|
||||||
|
|
||||||
|
std::vector<Result> result;
|
||||||
|
auto &op = envGet(ComplexField, par().op);
|
||||||
|
|
||||||
|
for (unsigned int mu = 0; mu < nd; ++mu)
|
||||||
|
{
|
||||||
|
auto &der = envGet(ComplexField, varName(getName(), mu));
|
||||||
|
|
||||||
|
dmu(der, op, mu, par().type);
|
||||||
|
if (!par().output.empty())
|
||||||
|
{
|
||||||
|
Result r;
|
||||||
|
|
||||||
|
r.type = par().type;
|
||||||
|
r.value = TensorRemove(sum(der));
|
||||||
|
result.push_back(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (result.size() > 0)
|
||||||
|
{
|
||||||
|
saveResult(par().output, "grad", result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
END_MODULE_NAMESPACE
|
||||||
|
|
||||||
|
END_HADRONS_NAMESPACE
|
||||||
|
|
||||||
|
#endif // Hadrons_MScalarSUN_Grad_hpp_
|
@ -31,6 +31,7 @@ modules_cc =\
|
|||||||
Modules/MAction/WilsonClover.cc \
|
Modules/MAction/WilsonClover.cc \
|
||||||
Modules/MAction/DWF.cc \
|
Modules/MAction/DWF.cc \
|
||||||
Modules/MScalarSUN/TrPhi.cc \
|
Modules/MScalarSUN/TrPhi.cc \
|
||||||
|
Modules/MScalarSUN/Grad.cc \
|
||||||
Modules/MScalarSUN/TrMag.cc \
|
Modules/MScalarSUN/TrMag.cc \
|
||||||
Modules/MScalarSUN/TrKinetic.cc \
|
Modules/MScalarSUN/TrKinetic.cc \
|
||||||
Modules/MScalarSUN/EMT.cc \
|
Modules/MScalarSUN/EMT.cc \
|
||||||
@ -85,6 +86,7 @@ modules_hpp =\
|
|||||||
Modules/MScalarSUN/TrPhi.hpp \
|
Modules/MScalarSUN/TrPhi.hpp \
|
||||||
Modules/MScalarSUN/Utils.hpp \
|
Modules/MScalarSUN/Utils.hpp \
|
||||||
Modules/MScalarSUN/TransProj.hpp \
|
Modules/MScalarSUN/TransProj.hpp \
|
||||||
|
Modules/MScalarSUN/Grad.hpp \
|
||||||
Modules/MScalarSUN/TrKinetic.hpp \
|
Modules/MScalarSUN/TrKinetic.hpp \
|
||||||
Modules/MIO/LoadEigenPack.hpp \
|
Modules/MIO/LoadEigenPack.hpp \
|
||||||
Modules/MIO/LoadNersc.hpp \
|
Modules/MIO/LoadNersc.hpp \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user