2016-12-15 18:26:39 +00:00
|
|
|
/*************************************************************************************
|
|
|
|
|
2016-02-25 12:07:21 +00:00
|
|
|
Grid physics library, www.github.com/paboyle/Grid
|
|
|
|
|
2016-12-15 18:26:39 +00:00
|
|
|
Source file: extras/Hadrons/Modules/MContraction/Meson.hpp
|
2016-02-25 12:07:21 +00:00
|
|
|
|
|
|
|
Copyright (C) 2015
|
2016-12-15 18:26:39 +00:00
|
|
|
Copyright (C) 2016
|
2017-01-30 17:09:04 +00:00
|
|
|
Copyright (C) 2017
|
2016-02-25 12:07:21 +00:00
|
|
|
|
|
|
|
Author: Antonin Portelli <antonin.portelli@me.com>
|
2017-01-19 22:18:42 +00:00
|
|
|
Andrew Lawson <andrew.lawson1991@gmail.com>
|
2016-02-25 12:07:21 +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.
|
|
|
|
|
2016-12-15 18:26:39 +00:00
|
|
|
See the full license in the file "LICENSE" in the top level distribution directory
|
|
|
|
*************************************************************************************/
|
|
|
|
/* END LEGAL */
|
2015-12-23 14:21:35 +00:00
|
|
|
|
2017-06-06 17:45:30 +01:00
|
|
|
#ifndef Hadrons_MContraction_Meson_hpp_
|
|
|
|
#define Hadrons_MContraction_Meson_hpp_
|
2015-12-23 14:21:35 +00:00
|
|
|
|
2016-11-28 07:02:15 +00:00
|
|
|
#include <Grid/Hadrons/Global.hpp>
|
|
|
|
#include <Grid/Hadrons/Module.hpp>
|
|
|
|
#include <Grid/Hadrons/ModuleFactory.hpp>
|
2015-12-23 14:21:35 +00:00
|
|
|
|
|
|
|
BEGIN_HADRONS_NAMESPACE
|
|
|
|
|
2017-01-19 22:18:42 +00:00
|
|
|
/*
|
|
|
|
|
|
|
|
Meson contractions
|
|
|
|
-----------------------------
|
|
|
|
|
|
|
|
* options:
|
|
|
|
- q1: input propagator 1 (string)
|
|
|
|
- q2: input propagator 2 (string)
|
2017-01-20 16:38:50 +00:00
|
|
|
- gammas: gamma products to insert at sink & source, pairs of gamma matrices
|
2017-02-06 14:08:59 +00:00
|
|
|
(space-separated strings) in angled brackets (i.e. <g_sink g_src>),
|
|
|
|
in a sequence (e.g. "<Gamma5 Gamma5><Gamma5 GammaT>").
|
2017-01-19 22:18:42 +00:00
|
|
|
|
|
|
|
Special values: "all" - perform all possible contractions.
|
2017-06-22 15:09:45 +01:00
|
|
|
- sink: module to compute the sink to use in contraction (string).
|
2017-01-30 17:09:04 +00:00
|
|
|
*/
|
2017-01-19 22:18:42 +00:00
|
|
|
|
2015-12-23 14:21:35 +00:00
|
|
|
/******************************************************************************
|
2016-12-05 07:47:29 +00:00
|
|
|
* TMeson *
|
2015-12-23 14:21:35 +00:00
|
|
|
******************************************************************************/
|
2016-12-05 05:29:32 +00:00
|
|
|
BEGIN_MODULE_NAMESPACE(MContraction)
|
|
|
|
|
2017-02-01 09:27:00 +00:00
|
|
|
typedef std::pair<Gamma::Algebra, Gamma::Algebra> GammaPair;
|
2017-01-20 16:38:50 +00:00
|
|
|
|
2016-12-05 05:29:32 +00:00
|
|
|
class MesonPar: Serializable
|
2016-05-12 11:59:28 +01:00
|
|
|
{
|
2016-12-05 05:29:32 +00:00
|
|
|
public:
|
|
|
|
GRID_SERIALIZABLE_CLASS_MEMBERS(MesonPar,
|
|
|
|
std::string, q1,
|
|
|
|
std::string, q2,
|
2017-01-19 22:18:42 +00:00
|
|
|
std::string, gammas,
|
2017-06-06 17:45:30 +01:00
|
|
|
std::string, sink,
|
2016-12-05 05:29:32 +00:00
|
|
|
std::string, output);
|
|
|
|
};
|
|
|
|
|
2016-12-05 07:47:29 +00:00
|
|
|
template <typename FImpl1, typename FImpl2>
|
|
|
|
class TMeson: public Module<MesonPar>
|
2016-12-05 05:29:32 +00:00
|
|
|
{
|
2016-12-05 07:47:29 +00:00
|
|
|
public:
|
2017-06-06 17:45:30 +01:00
|
|
|
FERM_TYPE_ALIASES(FImpl1, 1);
|
|
|
|
FERM_TYPE_ALIASES(FImpl2, 2);
|
|
|
|
FERM_TYPE_ALIASES(ScalarImplCR, Scalar);
|
|
|
|
SINK_TYPE_ALIASES(Scalar);
|
2016-12-05 05:29:32 +00:00
|
|
|
class Result: Serializable
|
2016-05-02 02:31:40 +01:00
|
|
|
{
|
|
|
|
public:
|
2016-12-05 05:29:32 +00:00
|
|
|
GRID_SERIALIZABLE_CLASS_MEMBERS(Result,
|
2017-02-01 09:27:00 +00:00
|
|
|
Gamma::Algebra, gamma_snk,
|
|
|
|
Gamma::Algebra, gamma_src,
|
2017-01-20 16:38:50 +00:00
|
|
|
std::vector<Complex>, corr);
|
2016-05-02 02:31:40 +01:00
|
|
|
};
|
2016-12-05 05:29:32 +00:00
|
|
|
public:
|
|
|
|
// constructor
|
2016-12-05 07:47:29 +00:00
|
|
|
TMeson(const std::string name);
|
2016-12-05 05:29:32 +00:00
|
|
|
// destructor
|
2016-12-05 07:47:29 +00:00
|
|
|
virtual ~TMeson(void) = default;
|
2016-12-05 05:29:32 +00:00
|
|
|
// dependencies/products
|
|
|
|
virtual std::vector<std::string> getInput(void);
|
2017-12-12 13:08:01 +00:00
|
|
|
virtual std::vector<std::string> getReference(void);
|
2016-12-05 05:29:32 +00:00
|
|
|
virtual std::vector<std::string> getOutput(void);
|
2017-01-20 16:38:50 +00:00
|
|
|
virtual void parseGammaString(std::vector<GammaPair> &gammaList);
|
2017-12-03 18:46:18 +00:00
|
|
|
protected:
|
2016-12-05 05:29:32 +00:00
|
|
|
// execution
|
|
|
|
virtual void execute(void);
|
|
|
|
};
|
|
|
|
|
2016-12-14 17:59:45 +00:00
|
|
|
MODULE_REGISTER_NS(Meson, ARG(TMeson<FIMPL, FIMPL>), MContraction);
|
|
|
|
|
2016-12-05 07:47:29 +00:00
|
|
|
/******************************************************************************
|
2016-12-06 03:12:59 +00:00
|
|
|
* TMeson implementation *
|
2016-12-05 07:47:29 +00:00
|
|
|
******************************************************************************/
|
|
|
|
// constructor /////////////////////////////////////////////////////////////////
|
|
|
|
template <typename FImpl1, typename FImpl2>
|
|
|
|
TMeson<FImpl1, FImpl2>::TMeson(const std::string name)
|
|
|
|
: Module<MesonPar>(name)
|
|
|
|
{}
|
|
|
|
|
|
|
|
// dependencies/products ///////////////////////////////////////////////////////
|
|
|
|
template <typename FImpl1, typename FImpl2>
|
|
|
|
std::vector<std::string> TMeson<FImpl1, FImpl2>::getInput(void)
|
|
|
|
{
|
2017-06-06 17:45:30 +01:00
|
|
|
std::vector<std::string> input = {par().q1, par().q2, par().sink};
|
2016-12-05 07:47:29 +00:00
|
|
|
|
|
|
|
return input;
|
|
|
|
}
|
|
|
|
|
2017-12-12 13:08:01 +00:00
|
|
|
template <typename FImpl1, typename FImpl2>
|
|
|
|
std::vector<std::string> TMeson<FImpl1, FImpl2>::getReference(void)
|
|
|
|
{
|
|
|
|
std::vector<std::string> ref = {};
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2016-12-05 07:47:29 +00:00
|
|
|
template <typename FImpl1, typename FImpl2>
|
|
|
|
std::vector<std::string> TMeson<FImpl1, FImpl2>::getOutput(void)
|
|
|
|
{
|
2017-12-12 19:32:58 +00:00
|
|
|
std::vector<std::string> output = {};
|
2016-12-05 07:47:29 +00:00
|
|
|
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
2017-01-19 22:18:42 +00:00
|
|
|
template <typename FImpl1, typename FImpl2>
|
2017-01-20 16:38:50 +00:00
|
|
|
void TMeson<FImpl1, FImpl2>::parseGammaString(std::vector<GammaPair> &gammaList)
|
2017-01-19 22:18:42 +00:00
|
|
|
{
|
2017-05-29 12:57:33 +01:00
|
|
|
gammaList.clear();
|
2017-01-19 22:18:42 +00:00
|
|
|
// Determine gamma matrices to insert at source/sink.
|
|
|
|
if (par().gammas.compare("all") == 0)
|
|
|
|
{
|
|
|
|
// Do all contractions.
|
2017-02-01 09:27:00 +00:00
|
|
|
for (unsigned int i = 1; i < Gamma::nGamma; i += 2)
|
2017-01-19 22:18:42 +00:00
|
|
|
{
|
2017-02-01 09:27:00 +00:00
|
|
|
for (unsigned int j = 1; j < Gamma::nGamma; j += 2)
|
2017-01-20 16:38:50 +00:00
|
|
|
{
|
2017-02-01 09:27:00 +00:00
|
|
|
gammaList.push_back(std::make_pair((Gamma::Algebra)i,
|
|
|
|
(Gamma::Algebra)j));
|
2017-01-20 16:38:50 +00:00
|
|
|
}
|
2017-01-19 22:18:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Parse individual contractions from input string.
|
2017-01-20 16:38:50 +00:00
|
|
|
gammaList = strToVec<GammaPair>(par().gammas);
|
2017-01-19 22:18:42 +00:00
|
|
|
}
|
2017-12-13 19:41:41 +00:00
|
|
|
envTmpLat(LatticeComplex, "c");
|
2017-01-19 22:18:42 +00:00
|
|
|
}
|
|
|
|
|
2016-12-05 07:47:29 +00:00
|
|
|
// execution ///////////////////////////////////////////////////////////////////
|
2017-06-06 17:45:30 +01:00
|
|
|
#define mesonConnected(q1, q2, gSnk, gSrc) \
|
|
|
|
(g5*(gSnk))*(q1)*(adj(gSrc)*g5)*adj(q2)
|
|
|
|
|
2016-12-05 07:47:29 +00:00
|
|
|
template <typename FImpl1, typename FImpl2>
|
|
|
|
void TMeson<FImpl1, FImpl2>::execute(void)
|
|
|
|
{
|
2016-12-05 08:26:36 +00:00
|
|
|
LOG(Message) << "Computing meson contractions '" << getName() << "' using"
|
|
|
|
<< " quarks '" << par().q1 << "' and '" << par().q2 << "'"
|
|
|
|
<< std::endl;
|
2016-12-05 07:47:29 +00:00
|
|
|
|
2017-06-06 17:45:30 +01:00
|
|
|
CorrWriter writer(par().output);
|
2017-01-20 16:38:50 +00:00
|
|
|
std::vector<TComplex> buf;
|
|
|
|
std::vector<Result> result;
|
2017-06-06 17:45:30 +01:00
|
|
|
Gamma g5(Gamma::Algebra::Gamma5);
|
|
|
|
std::vector<GammaPair> gammaList;
|
|
|
|
int nt = env().getDim(Tp);
|
2017-01-30 17:09:04 +00:00
|
|
|
|
2017-01-20 16:38:50 +00:00
|
|
|
parseGammaString(gammaList);
|
|
|
|
result.resize(gammaList.size());
|
|
|
|
for (unsigned int i = 0; i < result.size(); ++i)
|
2016-12-05 07:47:29 +00:00
|
|
|
{
|
2017-01-20 16:38:50 +00:00
|
|
|
result[i].gamma_snk = gammaList[i].first;
|
|
|
|
result[i].gamma_src = gammaList[i].second;
|
2017-06-06 17:45:30 +01:00
|
|
|
result[i].corr.resize(nt);
|
|
|
|
}
|
2017-12-03 18:45:15 +00:00
|
|
|
if (envHasType(SlicedPropagator1, par().q1) and
|
|
|
|
envHasType(SlicedPropagator2, par().q2))
|
2017-06-06 17:45:30 +01:00
|
|
|
{
|
2017-12-13 19:41:41 +00:00
|
|
|
auto &q1 = envGet(SlicedPropagator1, par().q1);
|
|
|
|
auto &q2 = envGet(SlicedPropagator2, par().q2);
|
2017-06-06 17:45:30 +01:00
|
|
|
|
|
|
|
LOG(Message) << "(propagator already sinked)" << std::endl;
|
|
|
|
for (unsigned int i = 0; i < result.size(); ++i)
|
2016-12-05 07:47:29 +00:00
|
|
|
{
|
2017-06-06 17:45:30 +01:00
|
|
|
Gamma gSnk(gammaList[i].first);
|
|
|
|
Gamma gSrc(gammaList[i].second);
|
|
|
|
|
|
|
|
for (unsigned int t = 0; t < buf.size(); ++t)
|
|
|
|
{
|
|
|
|
result[i].corr[t] = TensorRemove(trace(mesonConnected(q1[t], q2[t], gSnk, gSrc)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-13 19:41:41 +00:00
|
|
|
auto &q1 = envGet(PropagatorField1, par().q1);
|
|
|
|
auto &q2 = envGet(PropagatorField2, par().q2);
|
2017-06-06 17:45:30 +01:00
|
|
|
|
2017-12-13 19:41:41 +00:00
|
|
|
envGetTmp(LatticeComplex, c);
|
2017-06-06 17:45:30 +01:00
|
|
|
LOG(Message) << "(using sink '" << par().sink << "')" << std::endl;
|
|
|
|
for (unsigned int i = 0; i < result.size(); ++i)
|
|
|
|
{
|
|
|
|
Gamma gSnk(gammaList[i].first);
|
|
|
|
Gamma gSrc(gammaList[i].second);
|
|
|
|
std::string ns;
|
|
|
|
|
2017-12-05 14:31:59 +00:00
|
|
|
ns = vm().getModuleNamespace(env().getObjectModule(par().sink));
|
2017-06-06 17:45:30 +01:00
|
|
|
if (ns == "MSource")
|
|
|
|
{
|
2017-12-01 19:38:23 +00:00
|
|
|
PropagatorField1 &sink = envGet(PropagatorField1, par().sink);
|
2017-06-06 17:45:30 +01:00
|
|
|
|
|
|
|
c = trace(mesonConnected(q1, q2, gSnk, gSrc)*sink);
|
|
|
|
sliceSum(c, buf, Tp);
|
|
|
|
}
|
|
|
|
else if (ns == "MSink")
|
|
|
|
{
|
2017-12-01 19:38:23 +00:00
|
|
|
SinkFnScalar &sink = envGet(SinkFnScalar, par().sink);
|
2017-06-06 17:45:30 +01:00
|
|
|
|
|
|
|
c = trace(mesonConnected(q1, q2, gSnk, gSrc));
|
|
|
|
buf = sink(c);
|
|
|
|
}
|
|
|
|
for (unsigned int t = 0; t < buf.size(); ++t)
|
|
|
|
{
|
|
|
|
result[i].corr[t] = TensorRemove(buf[t]);
|
|
|
|
}
|
2016-12-05 07:47:29 +00:00
|
|
|
}
|
|
|
|
}
|
2017-02-08 12:29:33 +00:00
|
|
|
write(writer, "meson", result);
|
2016-12-05 07:47:29 +00:00
|
|
|
}
|
|
|
|
|
2016-12-05 05:29:32 +00:00
|
|
|
END_MODULE_NAMESPACE
|
2015-12-23 14:21:35 +00:00
|
|
|
|
|
|
|
END_HADRONS_NAMESPACE
|
|
|
|
|
2017-06-06 17:45:30 +01:00
|
|
|
#endif // Hadrons_MContraction_Meson_hpp_
|