mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-12 20:27:06 +01:00
Hadrons: moving Hadrons to root directory, build system improvements
This commit is contained in:
36
Hadrons/Modules/MContraction/A2AMesonField.cc
Normal file
36
Hadrons/Modules/MContraction/A2AMesonField.cc
Normal file
@ -0,0 +1,36 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules/MContraction/A2AMesonField.cc
|
||||
|
||||
Copyright (C) 2015-2018
|
||||
|
||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
||||
Author: paboyle <paboyle@ph.ed.ac.uk>
|
||||
|
||||
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 <Hadrons/Modules/MContraction/A2AMesonField.hpp>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace Hadrons;
|
||||
using namespace MContraction;
|
||||
|
||||
template class Grid::Hadrons::MContraction::TA2AMesonField<FIMPL>;
|
||||
template class Grid::Hadrons::MContraction::TA2AMesonField<ZFIMPL>;
|
486
Hadrons/Modules/MContraction/A2AMesonField.hpp
Normal file
486
Hadrons/Modules/MContraction/A2AMesonField.hpp
Normal file
@ -0,0 +1,486 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules/MContraction/A2AMesonField.hpp
|
||||
|
||||
Copyright (C) 2015-2018
|
||||
|
||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
||||
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
||||
Author: paboyle <paboyle@ph.ed.ac.uk>
|
||||
|
||||
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_MContraction_A2AMesonField_hpp_
|
||||
#define Hadrons_MContraction_A2AMesonField_hpp_
|
||||
|
||||
#include <Hadrons/Global.hpp>
|
||||
#include <Hadrons/Module.hpp>
|
||||
#include <Hadrons/ModuleFactory.hpp>
|
||||
#include <Hadrons/A2AVectors.hpp>
|
||||
#include <Hadrons/Modules/MSolver/A2AVectors.hpp>
|
||||
#include <Hadrons/Modules/MContraction/A2AMesonFieldKernels.hpp>
|
||||
|
||||
#define MF_PARALLEL_IO
|
||||
#ifndef MF_IO_TYPE
|
||||
#define MF_IO_TYPE ComplexF
|
||||
#endif
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* All-to-all meson field creation *
|
||||
******************************************************************************/
|
||||
BEGIN_MODULE_NAMESPACE(MContraction)
|
||||
|
||||
class A2AMesonFieldPar: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(A2AMesonFieldPar,
|
||||
int, cacheBlock,
|
||||
int, block,
|
||||
std::string, v,
|
||||
std::string, w,
|
||||
std::string, output,
|
||||
std::string, gammas,
|
||||
std::vector<std::string>, mom);
|
||||
};
|
||||
|
||||
template <typename FImpl>
|
||||
class TA2AMesonField : public Module<A2AMesonFieldPar>
|
||||
{
|
||||
public:
|
||||
FERM_TYPE_ALIASES(FImpl,);
|
||||
SOLVER_TYPE_ALIASES(FImpl,);
|
||||
typedef Eigen::TensorMap<Eigen::Tensor<Complex, 5, Eigen::RowMajor>> MesonField;
|
||||
typedef Eigen::TensorMap<Eigen::Tensor<MF_IO_TYPE, 5, Eigen::RowMajor>> MesonFieldIo;
|
||||
public:
|
||||
// constructor
|
||||
TA2AMesonField(const std::string name);
|
||||
// destructor
|
||||
virtual ~TA2AMesonField(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);
|
||||
private:
|
||||
// IO
|
||||
std::string ioname(unsigned int m, unsigned int g) const;
|
||||
std::string filename(unsigned int m, unsigned int g) const;
|
||||
void initFile(unsigned int m, unsigned int g);
|
||||
void saveBlock(const MesonFieldIo &mf,
|
||||
unsigned int m, unsigned int g,
|
||||
unsigned int i, unsigned int j);
|
||||
private:
|
||||
bool hasPhase_{false};
|
||||
std::string momphName_;
|
||||
std::vector<Gamma::Algebra> gamma_;
|
||||
std::vector<std::vector<double>> mom_;
|
||||
std::vector<std::pair<unsigned int, unsigned int>> nodeFile_;
|
||||
};
|
||||
|
||||
MODULE_REGISTER(A2AMesonField, ARG(TA2AMesonField<FIMPL>), MContraction);
|
||||
MODULE_REGISTER(ZA2AMesonField, ARG(TA2AMesonField<ZFIMPL>), MContraction);
|
||||
|
||||
/******************************************************************************
|
||||
* TA2AMesonField implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
TA2AMesonField<FImpl>::TA2AMesonField(const std::string name)
|
||||
: Module<A2AMesonFieldPar>(name)
|
||||
, momphName_(name + "_momph")
|
||||
{
|
||||
}
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
std::vector<std::string> TA2AMesonField<FImpl>::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in = {par().v, par().w};
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
template <typename FImpl>
|
||||
std::vector<std::string> TA2AMesonField<FImpl>::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out = {};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
void TA2AMesonField<FImpl>::setup(void)
|
||||
{
|
||||
gamma_.clear();
|
||||
mom_.clear();
|
||||
if (par().gammas == "all")
|
||||
{
|
||||
gamma_ = {
|
||||
Gamma::Algebra::Gamma5,
|
||||
Gamma::Algebra::Identity,
|
||||
Gamma::Algebra::GammaX,
|
||||
Gamma::Algebra::GammaY,
|
||||
Gamma::Algebra::GammaZ,
|
||||
Gamma::Algebra::GammaT,
|
||||
Gamma::Algebra::GammaXGamma5,
|
||||
Gamma::Algebra::GammaYGamma5,
|
||||
Gamma::Algebra::GammaZGamma5,
|
||||
Gamma::Algebra::GammaTGamma5,
|
||||
Gamma::Algebra::SigmaXY,
|
||||
Gamma::Algebra::SigmaXZ,
|
||||
Gamma::Algebra::SigmaXT,
|
||||
Gamma::Algebra::SigmaYZ,
|
||||
Gamma::Algebra::SigmaYT,
|
||||
Gamma::Algebra::SigmaZT
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
gamma_ = strToVec<Gamma::Algebra>(par().gammas);
|
||||
}
|
||||
for (auto &pstr: par().mom)
|
||||
{
|
||||
auto p = strToVec<Real>(pstr);
|
||||
|
||||
if (p.size() != env().getNd() - 1)
|
||||
{
|
||||
HADRONS_ERROR(Size, "Momentum has " + std::to_string(p.size())
|
||||
+ " components instead of "
|
||||
+ std::to_string(env().getNd() - 1));
|
||||
}
|
||||
mom_.push_back(p);
|
||||
}
|
||||
|
||||
envCache(std::vector<LatticeComplex>, momphName_, 1,
|
||||
par().mom.size(), env().getGrid());
|
||||
envTmpLat(LatticeComplex, "coor");
|
||||
// preallocate memory for meson field block
|
||||
auto tgp = env().getDim().back()*gamma_.size()*mom_.size();
|
||||
|
||||
envTmp(Vector<MF_IO_TYPE>, "mfBuf", 1, tgp*par().block*par().block);
|
||||
envTmp(Vector<Complex>, "mfCache", 1, tgp*par().cacheBlock*par().cacheBlock);
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
void TA2AMesonField<FImpl>::execute(void)
|
||||
{
|
||||
auto &v = envGet(std::vector<FermionField>, par().v);
|
||||
auto &w = envGet(std::vector<FermionField>, par().w);
|
||||
|
||||
int nt = env().getDim().back();
|
||||
int N_i = w.size();
|
||||
int N_j = v.size();
|
||||
int ngamma = gamma_.size();
|
||||
int nmom = mom_.size();
|
||||
int block = par().block;
|
||||
int cacheBlock = par().cacheBlock;
|
||||
|
||||
LOG(Message) << "Computing all-to-all meson fields" << std::endl;
|
||||
LOG(Message) << "W: '" << par().w << "' V: '" << par().v << "'" << std::endl;
|
||||
LOG(Message) << "Momenta:" << std::endl;
|
||||
for (auto &p: mom_)
|
||||
{
|
||||
LOG(Message) << " " << p << std::endl;
|
||||
}
|
||||
LOG(Message) << "Spin bilinears:" << std::endl;
|
||||
for (auto &g: gamma_)
|
||||
{
|
||||
LOG(Message) << " " << g << std::endl;
|
||||
}
|
||||
LOG(Message) << "Meson field size: " << nt << "*" << N_i << "*" << N_j
|
||||
<< " (filesize " << sizeString(nt*N_i*N_j*sizeof(MF_IO_TYPE))
|
||||
<< "/momentum/bilinear)" << std::endl;
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// Momentum setup
|
||||
///////////////////////////////////////////////
|
||||
auto &ph = envGet(std::vector<LatticeComplex>, momphName_);
|
||||
|
||||
if (!hasPhase_)
|
||||
{
|
||||
startTimer("Momentum phases");
|
||||
for (unsigned int j = 0; j < nmom; ++j)
|
||||
{
|
||||
Complex i(0.0,1.0);
|
||||
std::vector<Real> p;
|
||||
|
||||
envGetTmp(LatticeComplex, coor);
|
||||
ph[j] = zero;
|
||||
for(unsigned int mu = 0; mu < mom_[j].size(); mu++)
|
||||
{
|
||||
LatticeCoordinate(coor, mu);
|
||||
ph[j] = ph[j] + (mom_[j][mu]/env().getDim(mu))*coor;
|
||||
}
|
||||
ph[j] = exp((Real)(2*M_PI)*i*ph[j]);
|
||||
}
|
||||
hasPhase_ = true;
|
||||
stopTimer("Momentum phases");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// i,j is first loop over SchurBlock factors reusing 5D matrices
|
||||
// ii,jj is second loop over cacheBlock factors for high perf contractoin
|
||||
// iii,jjj are loops within cacheBlock
|
||||
// Total index is sum of these i+ii+iii etc...
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
double flops;
|
||||
double bytes;
|
||||
double vol = env().getVolume();
|
||||
double t_kernel = 0.0;
|
||||
double nodes = env().getGrid()->NodeCount();
|
||||
double tot_kernel;
|
||||
|
||||
envGetTmp(Vector<MF_IO_TYPE>, mfBuf);
|
||||
envGetTmp(Vector<Complex>, mfCache);
|
||||
|
||||
double t0 = usecond();
|
||||
int NBlock_i = N_i/block + (((N_i % block) != 0) ? 1 : 0);
|
||||
int NBlock_j = N_j/block + (((N_j % block) != 0) ? 1 : 0);
|
||||
|
||||
for(int i=0;i<N_i;i+=block)
|
||||
for(int j=0;j<N_j;j+=block)
|
||||
{
|
||||
// Get the W and V vectors for this block^2 set of terms
|
||||
int N_ii = MIN(N_i-i,block);
|
||||
int N_jj = MIN(N_j-j,block);
|
||||
|
||||
LOG(Message) << "Meson field block "
|
||||
<< j/block + NBlock_j*i/block + 1
|
||||
<< "/" << NBlock_i*NBlock_j << " [" << i <<" .. "
|
||||
<< i+N_ii-1 << ", " << j <<" .. " << j+N_jj-1 << "]"
|
||||
<< std::endl;
|
||||
|
||||
MesonFieldIo mfBlock(mfBuf.data(),nmom,ngamma,nt,N_ii,N_jj);
|
||||
|
||||
// Series of cache blocked chunks of the contractions within this block
|
||||
flops = 0.0;
|
||||
bytes = 0.0;
|
||||
for(int ii=0;ii<N_ii;ii+=cacheBlock)
|
||||
for(int jj=0;jj<N_jj;jj+=cacheBlock)
|
||||
{
|
||||
int N_iii = MIN(N_ii-ii,cacheBlock);
|
||||
int N_jjj = MIN(N_jj-jj,cacheBlock);
|
||||
MesonField mfCacheBlock(mfCache.data(),nmom,ngamma,nt,N_iii,N_jjj);
|
||||
|
||||
startTimer("contraction: total");
|
||||
makeMesonFieldBlock(mfCacheBlock, &w[i+ii], &v[j+jj], gamma_, ph,
|
||||
env().getNd() - 1, this);
|
||||
stopTimer("contraction: total");
|
||||
|
||||
// flops for general N_c & N_s
|
||||
flops += vol * ( 2 * 8.0 + 6.0 + 8.0*nmom) * N_iii*N_jjj*ngamma;
|
||||
bytes += vol * (12.0 * sizeof(Complex) ) * N_iii*N_jjj
|
||||
+ vol * ( 2.0 * sizeof(Complex) *nmom ) * N_iii*N_jjj* ngamma;
|
||||
|
||||
startTimer("cache copy");
|
||||
parallel_for_nest5(int m =0;m< nmom;m++)
|
||||
for(int g =0;g< ngamma;g++)
|
||||
for(int t =0;t< nt;t++)
|
||||
for(int iii=0;iii< N_iii;iii++)
|
||||
for(int jjj=0;jjj< N_jjj;jjj++)
|
||||
{
|
||||
mfBlock(m,g,t,ii+iii,jj+jjj) = mfCacheBlock(m,g,t,iii,jjj);
|
||||
}
|
||||
stopTimer("cache copy");
|
||||
}
|
||||
|
||||
// perf
|
||||
tot_kernel = getDTimer("contraction: colour trace & mom.")
|
||||
+ getDTimer("contraction: local space sum");
|
||||
t_kernel = tot_kernel - t_kernel;
|
||||
LOG(Message) << "Kernel perf " << flops/t_kernel/1.0e3/nodes
|
||||
<< " Gflop/s/node " << std::endl;
|
||||
LOG(Message) << "Kernel perf " << bytes/t_kernel*1.0e6/1024/1024/1024/nodes
|
||||
<< " GB/s/node " << std::endl;
|
||||
t_kernel = tot_kernel;
|
||||
|
||||
// IO
|
||||
if (!par().output.empty())
|
||||
{
|
||||
double blockSize, ioTime;
|
||||
unsigned int myRank = env().getGrid()->ThisRank(),
|
||||
nRank = env().getGrid()->RankCount();
|
||||
|
||||
LOG(Message) << "Writing block to disk" << std::endl;
|
||||
ioTime = -getDTimer("IO: write block");
|
||||
startTimer("IO: total");
|
||||
makeFileDir(filename(0, 0), env().getGrid());
|
||||
#ifdef MF_PARALLEL_IO
|
||||
env().getGrid()->Barrier();
|
||||
nodeFile_.clear();
|
||||
for(int f = myRank; f < nmom*ngamma; f += nRank)
|
||||
{
|
||||
std::pair<unsigned int, unsigned int> file;
|
||||
|
||||
file.first = f/ngamma;
|
||||
file.second = f % ngamma;
|
||||
nodeFile_.push_back(file);
|
||||
}
|
||||
// parallel IO
|
||||
for (auto &f: nodeFile_)
|
||||
{
|
||||
auto m = f.first, g = f.second;
|
||||
|
||||
if ((i == 0) and (j == 0))
|
||||
{
|
||||
startTimer("IO: file creation");
|
||||
initFile(m, g);
|
||||
stopTimer("IO: file creation");
|
||||
}
|
||||
startTimer("IO: write block");
|
||||
saveBlock(mfBlock, m, g, i, j);
|
||||
stopTimer("IO: write block");
|
||||
}
|
||||
env().getGrid()->Barrier();
|
||||
#else
|
||||
// serial IO
|
||||
for(int m = 0; m < nmom; m++)
|
||||
for(int g = 0; g < ngamma; g++)
|
||||
{
|
||||
if ((i == 0) and (j == 0))
|
||||
{
|
||||
startTimer("IO: file creation");
|
||||
if (env().getGrid()->IsBoss())
|
||||
{
|
||||
initFile(m, g);
|
||||
}
|
||||
stopTimer("IO: file creation");
|
||||
}
|
||||
startTimer("IO: write block");
|
||||
if (env().getGrid()->IsBoss())
|
||||
{
|
||||
saveBlock(mfBlock, m, g, i, j);
|
||||
}
|
||||
stopTimer("IO: write block");
|
||||
}
|
||||
#endif
|
||||
stopTimer("IO: total");
|
||||
blockSize = static_cast<double>(nmom*ngamma*nt*N_ii*N_jj*sizeof(MF_IO_TYPE));
|
||||
ioTime += getDTimer("IO: write block");
|
||||
LOG(Message) << "HDF5 IO done " << sizeString(blockSize) << " in "
|
||||
<< ioTime << " us ("
|
||||
<< blockSize/ioTime*1.0e6/1024/1024
|
||||
<< " MB/s)" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// IO
|
||||
template <typename FImpl>
|
||||
std::string TA2AMesonField<FImpl>::ioname(unsigned int m, unsigned int g) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
ss << gamma_[g] << "_";
|
||||
for (unsigned int mu = 0; mu < mom_[m].size(); ++mu)
|
||||
{
|
||||
ss << mom_[m][mu] << ((mu == mom_[m].size() - 1) ? "" : "_");
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
template <typename FImpl>
|
||||
std::string TA2AMesonField<FImpl>::filename(unsigned int m, unsigned int g) const
|
||||
{
|
||||
return par().output + "." + std::to_string(vm().getTrajectory())
|
||||
+ "/" + ioname(m, g) + ".h5";
|
||||
}
|
||||
|
||||
template <typename FImpl>
|
||||
void TA2AMesonField<FImpl>::initFile(unsigned int m, unsigned int g)
|
||||
{
|
||||
#ifdef HAVE_HDF5
|
||||
std::string f = filename(m, g);
|
||||
auto &v = envGet(std::vector<FermionField>, par().v);
|
||||
auto &w = envGet(std::vector<FermionField>, par().w);
|
||||
int nt = env().getDim().back();
|
||||
int N_i = w.size();
|
||||
int N_j = v.size();
|
||||
|
||||
Hdf5Writer writer(f);
|
||||
std::vector<hsize_t> dim = {static_cast<hsize_t>(nt),
|
||||
static_cast<hsize_t>(N_i),
|
||||
static_cast<hsize_t>(N_j)},
|
||||
chunk = {static_cast<hsize_t>(nt),
|
||||
static_cast<hsize_t>(par().block),
|
||||
static_cast<hsize_t>(par().block)};
|
||||
H5NS::DataSpace dataspace(dim.size(), dim.data());
|
||||
H5NS::DataSet dataset;
|
||||
H5NS::DSetCreatPropList plist;
|
||||
|
||||
push(writer, ioname(m, g));
|
||||
write(writer, "momentum", mom_[m]);
|
||||
write(writer, "gamma", gamma_[g]);
|
||||
auto &group = writer.getGroup();
|
||||
plist.setChunk(chunk.size(), chunk.data());
|
||||
dataset = group.createDataSet("mesonField", Hdf5Type<MF_IO_TYPE>::type(),
|
||||
dataspace, plist);
|
||||
#else
|
||||
HADRONS_ERROR(Implementation, "meson field I/O needs HDF5 library");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename FImpl>
|
||||
void TA2AMesonField<FImpl>::saveBlock(const MesonFieldIo &mf,
|
||||
unsigned int m, unsigned int g,
|
||||
unsigned int i, unsigned int j)
|
||||
{
|
||||
#ifdef HAVE_HDF5
|
||||
std::string f = filename(m, g);
|
||||
Hdf5Reader reader(f);
|
||||
hsize_t nt = mf.dimension(2),
|
||||
Ni = mf.dimension(3),
|
||||
Nj = mf.dimension(4);
|
||||
std::vector<hsize_t> count = {nt, Ni, Nj},
|
||||
offset = {0, static_cast<hsize_t>(i),
|
||||
static_cast<hsize_t>(j)},
|
||||
stride = {1, 1, 1},
|
||||
block = {1, 1, 1};
|
||||
H5NS::DataSpace memspace(count.size(), count.data()), dataspace;
|
||||
H5NS::DataSet dataset;
|
||||
size_t shift;
|
||||
|
||||
push(reader, ioname(m, g));
|
||||
auto &group = reader.getGroup();
|
||||
dataset = group.openDataSet("mesonField");
|
||||
dataspace = dataset.getSpace();
|
||||
dataspace.selectHyperslab(H5S_SELECT_SET, count.data(), offset.data(),
|
||||
stride.data(), block.data());
|
||||
shift = (m*mf.dimension(1) + g)*nt*Ni*Nj;
|
||||
dataset.write(mf.data() + shift, Hdf5Type<MF_IO_TYPE>::type(), memspace,
|
||||
dataspace);
|
||||
#else
|
||||
HADRONS_ERROR(Implementation, "meson field I/O needs HDF5 library");
|
||||
#endif
|
||||
}
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_MContraction_A2AMesonField_hpp_
|
224
Hadrons/Modules/MContraction/A2AMesonFieldKernels.hpp
Normal file
224
Hadrons/Modules/MContraction/A2AMesonFieldKernels.hpp
Normal file
@ -0,0 +1,224 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules/MContraction/A2AMesonFieldKernels.hpp
|
||||
|
||||
Copyright (C) 2015-2018
|
||||
|
||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
||||
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
||||
|
||||
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_MContraction_A2AMesonFieldKernels_hpp_
|
||||
#define Hadrons_MContraction_A2AMesonFieldKernels_hpp_
|
||||
|
||||
#include <Hadrons/Global.hpp>
|
||||
#include <Hadrons/Module.hpp>
|
||||
#include <Grid/Eigen/unsupported/CXX11/Tensor>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
BEGIN_MODULE_NAMESPACE(MContraction)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Cache blocked arithmetic routine
|
||||
// Could move to Grid ???
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
template <typename Field, typename MesonField>
|
||||
void makeMesonFieldBlock(MesonField &mat,
|
||||
const Field *lhs_wi,
|
||||
const Field *rhs_vj,
|
||||
std::vector<Gamma::Algebra> gamma,
|
||||
const std::vector<LatticeComplex> &mom,
|
||||
int orthogdim,
|
||||
ModuleBase *caller = nullptr)
|
||||
{
|
||||
typedef typename Field::vector_object vobj;
|
||||
typedef typename vobj::scalar_object sobj;
|
||||
typedef typename vobj::scalar_type scalar_type;
|
||||
typedef typename vobj::vector_type vector_type;
|
||||
|
||||
typedef iSpinMatrix<vector_type> SpinMatrix_v;
|
||||
typedef iSpinMatrix<scalar_type> SpinMatrix_s;
|
||||
|
||||
int Lblock = mat.dimension(3);
|
||||
int Rblock = mat.dimension(4);
|
||||
|
||||
GridBase *grid = lhs_wi[0]._grid;
|
||||
|
||||
const int Nd = grid->_ndimension;
|
||||
const int Nsimd = grid->Nsimd();
|
||||
|
||||
int Nt = grid->GlobalDimensions()[orthogdim];
|
||||
int Ngamma = gamma.size();
|
||||
int Nmom = mom.size();
|
||||
|
||||
int fd=grid->_fdimensions[orthogdim];
|
||||
int ld=grid->_ldimensions[orthogdim];
|
||||
int rd=grid->_rdimensions[orthogdim];
|
||||
|
||||
// will locally sum vectors first
|
||||
// sum across these down to scalars
|
||||
// splitting the SIMD
|
||||
int MFrvol = rd*Lblock*Rblock*Nmom;
|
||||
int MFlvol = ld*Lblock*Rblock*Nmom;
|
||||
|
||||
Vector<SpinMatrix_v > lvSum(MFrvol);
|
||||
parallel_for (int r = 0; r < MFrvol; r++)
|
||||
{
|
||||
lvSum[r] = zero;
|
||||
}
|
||||
|
||||
Vector<SpinMatrix_s > lsSum(MFlvol);
|
||||
parallel_for (int r = 0; r < MFlvol; r++)
|
||||
{
|
||||
lsSum[r]=scalar_type(0.0);
|
||||
}
|
||||
|
||||
int e1= grid->_slice_nblock[orthogdim];
|
||||
int e2= grid->_slice_block [orthogdim];
|
||||
int stride=grid->_slice_stride[orthogdim];
|
||||
|
||||
if (caller) caller->startTimer("contraction: colour trace & mom.");
|
||||
// Nested parallelism would be ok
|
||||
// Wasting cores here. Test case r
|
||||
parallel_for(int r=0;r<rd;r++)
|
||||
{
|
||||
int so=r*grid->_ostride[orthogdim]; // base offset for start of plane
|
||||
|
||||
for(int n=0;n<e1;n++)
|
||||
for(int b=0;b<e2;b++)
|
||||
{
|
||||
int ss= so+n*stride+b;
|
||||
|
||||
for(int i=0;i<Lblock;i++)
|
||||
{
|
||||
auto left = conjugate(lhs_wi[i]._odata[ss]);
|
||||
|
||||
for(int j=0;j<Rblock;j++)
|
||||
{
|
||||
SpinMatrix_v vv;
|
||||
auto right = rhs_vj[j]._odata[ss];
|
||||
|
||||
for(int s1=0;s1<Ns;s1++)
|
||||
for(int s2=0;s2<Ns;s2++)
|
||||
{
|
||||
vv()(s1,s2)() = left()(s2)(0) * right()(s1)(0)
|
||||
+ left()(s2)(1) * right()(s1)(1)
|
||||
+ left()(s2)(2) * right()(s1)(2);
|
||||
}
|
||||
|
||||
// After getting the sitewise product do the mom phase loop
|
||||
int base = Nmom*i+Nmom*Lblock*j+Nmom*Lblock*Rblock*r;
|
||||
|
||||
for ( int m=0;m<Nmom;m++)
|
||||
{
|
||||
int idx = m+base;
|
||||
auto phase = mom[m]._odata[ss];
|
||||
mac(&lvSum[idx],&vv,&phase);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (caller) caller->stopTimer("contraction: colour trace & mom.");
|
||||
|
||||
// Sum across simd lanes in the plane, breaking out orthog dir.
|
||||
if (caller) caller->startTimer("contraction: local space sum");
|
||||
parallel_for(int rt=0;rt<rd;rt++)
|
||||
{
|
||||
std::vector<int> icoor(Nd);
|
||||
std::vector<SpinMatrix_s> extracted(Nsimd);
|
||||
|
||||
for(int i=0;i<Lblock;i++)
|
||||
for(int j=0;j<Rblock;j++)
|
||||
for(int m=0;m<Nmom;m++)
|
||||
{
|
||||
|
||||
int ij_rdx = m+Nmom*i+Nmom*Lblock*j+Nmom*Lblock*Rblock*rt;
|
||||
|
||||
extract(lvSum[ij_rdx],extracted);
|
||||
for(int idx=0;idx<Nsimd;idx++)
|
||||
{
|
||||
grid->iCoorFromIindex(icoor,idx);
|
||||
|
||||
int ldx = rt+icoor[orthogdim]*rd;
|
||||
int ij_ldx = m+Nmom*i+Nmom*Lblock*j+Nmom*Lblock*Rblock*ldx;
|
||||
|
||||
lsSum[ij_ldx]=lsSum[ij_ldx]+extracted[idx];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (caller) caller->stopTimer("contraction: local space sum");
|
||||
|
||||
// ld loop and local only??
|
||||
if (caller) caller->startTimer("contraction: spin trace");
|
||||
int pd = grid->_processors[orthogdim];
|
||||
int pc = grid->_processor_coor[orthogdim];
|
||||
parallel_for_nest2(int lt=0;lt<ld;lt++)
|
||||
{
|
||||
for(int pt=0;pt<pd;pt++)
|
||||
{
|
||||
int t = lt + pt*ld;
|
||||
if (pt == pc)
|
||||
{
|
||||
for(int i=0;i<Lblock;i++)
|
||||
for(int j=0;j<Rblock;j++)
|
||||
for(int m=0;m<Nmom;m++)
|
||||
{
|
||||
int ij_dx = m+Nmom*i + Nmom*Lblock * j + Nmom*Lblock * Rblock * lt;
|
||||
|
||||
for(int mu=0;mu<Ngamma;mu++)
|
||||
{
|
||||
// this is a bit slow
|
||||
mat(m,mu,t,i,j) = trace(lsSum[ij_dx]*Gamma(gamma[mu]));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const scalar_type zz(0.0);
|
||||
|
||||
for(int i=0;i<Lblock;i++)
|
||||
for(int j=0;j<Rblock;j++)
|
||||
for(int mu=0;mu<Ngamma;mu++)
|
||||
for(int m=0;m<Nmom;m++)
|
||||
{
|
||||
mat(m,mu,t,i,j) =zz;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (caller) caller->stopTimer("contraction: spin trace");
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// This global sum is taking as much as 50% of time on 16 nodes
|
||||
// Vector size is 7 x 16 x 32 x 16 x 16 x sizeof(complex) = 2MB - 60MB depending on volume
|
||||
// Healthy size that should suffice
|
||||
////////////////////////////////////////////////////////////////////
|
||||
if (caller) caller->startTimer("contraction: global sum");
|
||||
grid->GlobalSumVector(&mat(0,0,0,0,0),Nmom*Ngamma*Nt*Lblock*Rblock);
|
||||
if (caller) caller->stopTimer("contraction: global sum");
|
||||
}
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif //Hadrons_MContraction_A2AMesonField_hpp_
|
35
Hadrons/Modules/MContraction/Baryon.cc
Normal file
35
Hadrons/Modules/MContraction/Baryon.cc
Normal file
@ -0,0 +1,35 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules/MContraction/Baryon.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 <Hadrons/Modules/MContraction/Baryon.hpp>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace Hadrons;
|
||||
using namespace MContraction;
|
||||
|
||||
template class Grid::Hadrons::MContraction::TBaryon<FIMPL,FIMPL,FIMPL>;
|
||||
|
140
Hadrons/Modules/MContraction/Baryon.hpp
Normal file
140
Hadrons/Modules/MContraction/Baryon.hpp
Normal file
@ -0,0 +1,140 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules/MContraction/Baryon.hpp
|
||||
|
||||
Copyright (C) 2015-2018
|
||||
|
||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
||||
Author: Lanny91 <andrew.lawson@gmail.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_MContraction_Baryon_hpp_
|
||||
#define Hadrons_MContraction_Baryon_hpp_
|
||||
|
||||
#include <Hadrons/Global.hpp>
|
||||
#include <Hadrons/Module.hpp>
|
||||
#include <Hadrons/ModuleFactory.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* Baryon *
|
||||
******************************************************************************/
|
||||
BEGIN_MODULE_NAMESPACE(MContraction)
|
||||
|
||||
class BaryonPar: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(BaryonPar,
|
||||
std::string, q1,
|
||||
std::string, q2,
|
||||
std::string, q3,
|
||||
std::string, output);
|
||||
};
|
||||
|
||||
template <typename FImpl1, typename FImpl2, typename FImpl3>
|
||||
class TBaryon: public Module<BaryonPar>
|
||||
{
|
||||
public:
|
||||
FERM_TYPE_ALIASES(FImpl1, 1);
|
||||
FERM_TYPE_ALIASES(FImpl2, 2);
|
||||
FERM_TYPE_ALIASES(FImpl3, 3);
|
||||
class Result: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(Result,
|
||||
std::vector<std::vector<std::vector<Complex>>>, corr);
|
||||
};
|
||||
public:
|
||||
// constructor
|
||||
TBaryon(const std::string name);
|
||||
// destructor
|
||||
virtual ~TBaryon(void) {};
|
||||
// dependency relation
|
||||
virtual std::vector<std::string> getInput(void);
|
||||
virtual std::vector<std::string> getOutput(void);
|
||||
protected:
|
||||
// setup
|
||||
virtual void setup(void);
|
||||
// execution
|
||||
virtual void execute(void);
|
||||
};
|
||||
|
||||
MODULE_REGISTER_TMP(Baryon, ARG(TBaryon<FIMPL, FIMPL, FIMPL>), MContraction);
|
||||
|
||||
/******************************************************************************
|
||||
* TBaryon implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl1, typename FImpl2, typename FImpl3>
|
||||
TBaryon<FImpl1, FImpl2, FImpl3>::TBaryon(const std::string name)
|
||||
: Module<BaryonPar>(name)
|
||||
{}
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
template <typename FImpl1, typename FImpl2, typename FImpl3>
|
||||
std::vector<std::string> TBaryon<FImpl1, FImpl2, FImpl3>::getInput(void)
|
||||
{
|
||||
std::vector<std::string> input = {par().q1, par().q2, par().q3};
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
template <typename FImpl1, typename FImpl2, typename FImpl3>
|
||||
std::vector<std::string> TBaryon<FImpl1, FImpl2, FImpl3>::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out = {};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl1, typename FImpl2, typename FImpl3>
|
||||
void TBaryon<FImpl1, FImpl2, FImpl3>::setup(void)
|
||||
{
|
||||
envTmpLat(LatticeComplex, "c");
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl1, typename FImpl2, typename FImpl3>
|
||||
void TBaryon<FImpl1, FImpl2, FImpl3>::execute(void)
|
||||
{
|
||||
LOG(Message) << "Computing baryon contractions '" << getName() << "' using"
|
||||
<< " quarks '" << par().q1 << "', '" << par().q2 << "', and '"
|
||||
<< par().q3 << "'" << std::endl;
|
||||
|
||||
auto &q1 = envGet(PropagatorField1, par().q1);
|
||||
auto &q2 = envGet(PropagatorField2, par().q2);
|
||||
auto &q3 = envGet(PropagatorField3, par().q2);
|
||||
envGetTmp(LatticeComplex, c);
|
||||
Result result;
|
||||
|
||||
// FIXME: do contractions
|
||||
|
||||
// saveResult(par().output, "meson", result);
|
||||
}
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_MContraction_Baryon_hpp_
|
35
Hadrons/Modules/MContraction/DiscLoop.cc
Normal file
35
Hadrons/Modules/MContraction/DiscLoop.cc
Normal file
@ -0,0 +1,35 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules/MContraction/DiscLoop.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 <Hadrons/Modules/MContraction/DiscLoop.hpp>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace Hadrons;
|
||||
using namespace MContraction;
|
||||
|
||||
template class Grid::Hadrons::MContraction::TDiscLoop<FIMPL>;
|
||||
|
143
Hadrons/Modules/MContraction/DiscLoop.hpp
Normal file
143
Hadrons/Modules/MContraction/DiscLoop.hpp
Normal file
@ -0,0 +1,143 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules/MContraction/DiscLoop.hpp
|
||||
|
||||
Copyright (C) 2015-2018
|
||||
|
||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
||||
Author: Lanny91 <andrew.lawson@gmail.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_MContraction_DiscLoop_hpp_
|
||||
#define Hadrons_MContraction_DiscLoop_hpp_
|
||||
|
||||
#include <Hadrons/Global.hpp>
|
||||
#include <Hadrons/Module.hpp>
|
||||
#include <Hadrons/ModuleFactory.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* DiscLoop *
|
||||
******************************************************************************/
|
||||
BEGIN_MODULE_NAMESPACE(MContraction)
|
||||
|
||||
class DiscLoopPar: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(DiscLoopPar,
|
||||
std::string, q_loop,
|
||||
Gamma::Algebra, gamma,
|
||||
std::string, output);
|
||||
};
|
||||
|
||||
template <typename FImpl>
|
||||
class TDiscLoop: public Module<DiscLoopPar>
|
||||
{
|
||||
FERM_TYPE_ALIASES(FImpl,);
|
||||
class Result: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(Result,
|
||||
Gamma::Algebra, gamma,
|
||||
std::vector<Complex>, corr);
|
||||
};
|
||||
public:
|
||||
// constructor
|
||||
TDiscLoop(const std::string name);
|
||||
// destructor
|
||||
virtual ~TDiscLoop(void) {};
|
||||
// dependency relation
|
||||
virtual std::vector<std::string> getInput(void);
|
||||
virtual std::vector<std::string> getOutput(void);
|
||||
protected:
|
||||
// setup
|
||||
virtual void setup(void);
|
||||
// execution
|
||||
virtual void execute(void);
|
||||
};
|
||||
|
||||
MODULE_REGISTER_TMP(DiscLoop, TDiscLoop<FIMPL>, MContraction);
|
||||
|
||||
/******************************************************************************
|
||||
* TDiscLoop implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
TDiscLoop<FImpl>::TDiscLoop(const std::string name)
|
||||
: Module<DiscLoopPar>(name)
|
||||
{}
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
std::vector<std::string> TDiscLoop<FImpl>::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in = {par().q_loop};
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
template <typename FImpl>
|
||||
std::vector<std::string> TDiscLoop<FImpl>::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out = {};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
void TDiscLoop<FImpl>::setup(void)
|
||||
{
|
||||
envTmpLat(LatticeComplex, "c");
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
void TDiscLoop<FImpl>::execute(void)
|
||||
{
|
||||
LOG(Message) << "Computing disconnected loop contraction '" << getName()
|
||||
<< "' using '" << par().q_loop << "' with " << par().gamma
|
||||
<< " insertion." << std::endl;
|
||||
|
||||
auto &q_loop = envGet(PropagatorField, par().q_loop);
|
||||
Gamma gamma(par().gamma);
|
||||
std::vector<TComplex> buf;
|
||||
Result result;
|
||||
|
||||
envGetTmp(LatticeComplex, c);
|
||||
c = trace(gamma*q_loop);
|
||||
sliceSum(c, buf, Tp);
|
||||
result.gamma = par().gamma;
|
||||
result.corr.resize(buf.size());
|
||||
for (unsigned int t = 0; t < buf.size(); ++t)
|
||||
{
|
||||
result.corr[t] = TensorRemove(buf[t]);
|
||||
}
|
||||
saveResult(par().output, "disc", result);
|
||||
}
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_MContraction_DiscLoop_hpp_
|
35
Hadrons/Modules/MContraction/Gamma3pt.cc
Normal file
35
Hadrons/Modules/MContraction/Gamma3pt.cc
Normal file
@ -0,0 +1,35 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules/MContraction/Gamma3pt.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 <Hadrons/Modules/MContraction/Gamma3pt.hpp>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace Hadrons;
|
||||
using namespace MContraction;
|
||||
|
||||
template class Grid::Hadrons::MContraction::TGamma3pt<FIMPL,FIMPL,FIMPL>;
|
||||
|
184
Hadrons/Modules/MContraction/Gamma3pt.hpp
Normal file
184
Hadrons/Modules/MContraction/Gamma3pt.hpp
Normal file
@ -0,0 +1,184 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules/MContraction/Gamma3pt.hpp
|
||||
|
||||
Copyright (C) 2015-2018
|
||||
|
||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
||||
Author: Lanny91 <andrew.lawson@gmail.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_MContraction_Gamma3pt_hpp_
|
||||
#define Hadrons_MContraction_Gamma3pt_hpp_
|
||||
|
||||
#include <Hadrons/Global.hpp>
|
||||
#include <Hadrons/Module.hpp>
|
||||
#include <Hadrons/ModuleFactory.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/*
|
||||
* 3pt contraction with gamma matrix insertion.
|
||||
*
|
||||
* Schematic:
|
||||
*
|
||||
* q2 q3
|
||||
* /----<------*------<----¬
|
||||
* / gamma \
|
||||
* / \
|
||||
* i * * f
|
||||
* \ /
|
||||
* \ /
|
||||
* \----------->----------/
|
||||
* q1
|
||||
*
|
||||
* trace(g5*q1*adj(q2)*g5*gamma*q3)
|
||||
*
|
||||
* options:
|
||||
* - q1: sink smeared propagator, source at i
|
||||
* - q2: propagator, source at i
|
||||
* - q3: propagator, source at f
|
||||
* - gamma: gamma matrix to insert
|
||||
* - tSnk: sink position for propagator q1.
|
||||
*
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* Gamma3pt *
|
||||
******************************************************************************/
|
||||
BEGIN_MODULE_NAMESPACE(MContraction)
|
||||
|
||||
class Gamma3ptPar: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(Gamma3ptPar,
|
||||
std::string, q1,
|
||||
std::string, q2,
|
||||
std::string, q3,
|
||||
Gamma::Algebra, gamma,
|
||||
unsigned int, tSnk,
|
||||
std::string, output);
|
||||
};
|
||||
|
||||
template <typename FImpl1, typename FImpl2, typename FImpl3>
|
||||
class TGamma3pt: public Module<Gamma3ptPar>
|
||||
{
|
||||
FERM_TYPE_ALIASES(FImpl1, 1);
|
||||
FERM_TYPE_ALIASES(FImpl2, 2);
|
||||
FERM_TYPE_ALIASES(FImpl3, 3);
|
||||
class Result: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(Result,
|
||||
Gamma::Algebra, gamma,
|
||||
std::vector<Complex>, corr);
|
||||
};
|
||||
public:
|
||||
// constructor
|
||||
TGamma3pt(const std::string name);
|
||||
// destructor
|
||||
virtual ~TGamma3pt(void) {};
|
||||
// dependency relation
|
||||
virtual std::vector<std::string> getInput(void);
|
||||
virtual std::vector<std::string> getOutput(void);
|
||||
protected:
|
||||
// setup
|
||||
virtual void setup(void);
|
||||
// execution
|
||||
virtual void execute(void);
|
||||
};
|
||||
|
||||
MODULE_REGISTER_TMP(Gamma3pt, ARG(TGamma3pt<FIMPL, FIMPL, FIMPL>), MContraction);
|
||||
|
||||
/******************************************************************************
|
||||
* TGamma3pt implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl1, typename FImpl2, typename FImpl3>
|
||||
TGamma3pt<FImpl1, FImpl2, FImpl3>::TGamma3pt(const std::string name)
|
||||
: Module<Gamma3ptPar>(name)
|
||||
{}
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
template <typename FImpl1, typename FImpl2, typename FImpl3>
|
||||
std::vector<std::string> TGamma3pt<FImpl1, FImpl2, FImpl3>::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in = {par().q1, par().q2, par().q3};
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
template <typename FImpl1, typename FImpl2, typename FImpl3>
|
||||
std::vector<std::string> TGamma3pt<FImpl1, FImpl2, FImpl3>::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out = {};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl1, typename FImpl2, typename FImpl3>
|
||||
void TGamma3pt<FImpl1, FImpl2, FImpl3>::setup(void)
|
||||
{
|
||||
envTmpLat(LatticeComplex, "c");
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl1, typename FImpl2, typename FImpl3>
|
||||
void TGamma3pt<FImpl1, FImpl2, FImpl3>::execute(void)
|
||||
{
|
||||
LOG(Message) << "Computing 3pt contractions '" << getName() << "' using"
|
||||
<< " quarks '" << par().q1 << "', '" << par().q2 << "' and '"
|
||||
<< par().q3 << "', with " << par().gamma << " insertion."
|
||||
<< std::endl;
|
||||
|
||||
// Initialise variables. q2 and q3 are normal propagators, q1 may be
|
||||
// sink smeared.
|
||||
auto &q1 = envGet(SlicedPropagator1, par().q1);
|
||||
auto &q2 = envGet(PropagatorField2, par().q2);
|
||||
auto &q3 = envGet(PropagatorField2, par().q3);
|
||||
Gamma g5(Gamma::Algebra::Gamma5);
|
||||
Gamma gamma(par().gamma);
|
||||
std::vector<TComplex> buf;
|
||||
Result result;
|
||||
|
||||
// Extract relevant timeslice of sinked propagator q1, then contract &
|
||||
// sum over all spacial positions of gamma insertion.
|
||||
SitePropagator1 q1Snk = q1[par().tSnk];
|
||||
envGetTmp(LatticeComplex, c);
|
||||
c = trace(g5*q1Snk*adj(q2)*(g5*gamma)*q3);
|
||||
sliceSum(c, buf, Tp);
|
||||
|
||||
result.gamma = par().gamma;
|
||||
result.corr.resize(buf.size());
|
||||
for (unsigned int t = 0; t < buf.size(); ++t)
|
||||
{
|
||||
result.corr[t] = TensorRemove(buf[t]);
|
||||
}
|
||||
saveResult(par().output, "gamma3pt", result);
|
||||
}
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_MContraction_Gamma3pt_hpp_
|
35
Hadrons/Modules/MContraction/Meson.cc
Normal file
35
Hadrons/Modules/MContraction/Meson.cc
Normal file
@ -0,0 +1,35 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules/MContraction/Meson.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 <Hadrons/Modules/MContraction/Meson.hpp>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace Hadrons;
|
||||
using namespace MContraction;
|
||||
|
||||
template class Grid::Hadrons::MContraction::TMeson<FIMPL,FIMPL>;
|
||||
|
249
Hadrons/Modules/MContraction/Meson.hpp
Normal file
249
Hadrons/Modules/MContraction/Meson.hpp
Normal file
@ -0,0 +1,249 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules/MContraction/Meson.hpp
|
||||
|
||||
Copyright (C) 2015-2018
|
||||
|
||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
||||
Author: Lanny91 <andrew.lawson@gmail.com>
|
||||
Author: Vera Guelpers <vmg1n14@soton.ac.uk>
|
||||
|
||||
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_MContraction_Meson_hpp_
|
||||
#define Hadrons_MContraction_Meson_hpp_
|
||||
|
||||
#include <Hadrons/Global.hpp>
|
||||
#include <Hadrons/Module.hpp>
|
||||
#include <Hadrons/ModuleFactory.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/*
|
||||
|
||||
Meson contractions
|
||||
-----------------------------
|
||||
|
||||
* options:
|
||||
- q1: input propagator 1 (string)
|
||||
- q2: input propagator 2 (string)
|
||||
- gammas: gamma products to insert at sink & source, pairs of gamma matrices
|
||||
(space-separated strings) in round brackets (i.e. (g_sink g_src)),
|
||||
in a sequence (e.g. "(Gamma5 Gamma5)(Gamma5 GammaT)").
|
||||
|
||||
Special values: "all" - perform all possible contractions.
|
||||
- sink: module to compute the sink to use in contraction (string).
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* TMeson *
|
||||
******************************************************************************/
|
||||
BEGIN_MODULE_NAMESPACE(MContraction)
|
||||
|
||||
typedef std::pair<Gamma::Algebra, Gamma::Algebra> GammaPair;
|
||||
|
||||
class MesonPar: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(MesonPar,
|
||||
std::string, q1,
|
||||
std::string, q2,
|
||||
std::string, gammas,
|
||||
std::string, sink,
|
||||
std::string, output);
|
||||
};
|
||||
|
||||
template <typename FImpl1, typename FImpl2>
|
||||
class TMeson: public Module<MesonPar>
|
||||
{
|
||||
public:
|
||||
FERM_TYPE_ALIASES(FImpl1, 1);
|
||||
FERM_TYPE_ALIASES(FImpl2, 2);
|
||||
FERM_TYPE_ALIASES(ScalarImplCR, Scalar);
|
||||
SINK_TYPE_ALIASES(Scalar);
|
||||
class Result: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(Result,
|
||||
Gamma::Algebra, gamma_snk,
|
||||
Gamma::Algebra, gamma_src,
|
||||
std::vector<Complex>, corr);
|
||||
};
|
||||
public:
|
||||
// constructor
|
||||
TMeson(const std::string name);
|
||||
// destructor
|
||||
virtual ~TMeson(void) {};
|
||||
// dependencies/products
|
||||
virtual std::vector<std::string> getInput(void);
|
||||
virtual std::vector<std::string> getOutput(void);
|
||||
virtual void parseGammaString(std::vector<GammaPair> &gammaList);
|
||||
protected:
|
||||
// execution
|
||||
virtual void setup(void);
|
||||
// execution
|
||||
virtual void execute(void);
|
||||
};
|
||||
|
||||
MODULE_REGISTER_TMP(Meson, ARG(TMeson<FIMPL, FIMPL>), MContraction);
|
||||
|
||||
/******************************************************************************
|
||||
* TMeson implementation *
|
||||
******************************************************************************/
|
||||
// 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)
|
||||
{
|
||||
std::vector<std::string> input = {par().q1, par().q2, par().sink};
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
template <typename FImpl1, typename FImpl2>
|
||||
std::vector<std::string> TMeson<FImpl1, FImpl2>::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> output = {};
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
template <typename FImpl1, typename FImpl2>
|
||||
void TMeson<FImpl1, FImpl2>::parseGammaString(std::vector<GammaPair> &gammaList)
|
||||
{
|
||||
gammaList.clear();
|
||||
// Determine gamma matrices to insert at source/sink.
|
||||
if (par().gammas.compare("all") == 0)
|
||||
{
|
||||
// Do all contractions.
|
||||
for (unsigned int i = 1; i < Gamma::nGamma; i += 2)
|
||||
{
|
||||
for (unsigned int j = 1; j < Gamma::nGamma; j += 2)
|
||||
{
|
||||
gammaList.push_back(std::make_pair((Gamma::Algebra)i,
|
||||
(Gamma::Algebra)j));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Parse individual contractions from input string.
|
||||
gammaList = strToVec<GammaPair>(par().gammas);
|
||||
}
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl1, typename FImpl2>
|
||||
void TMeson<FImpl1, FImpl2>::setup(void)
|
||||
{
|
||||
envTmpLat(LatticeComplex, "c");
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
#define mesonConnected(q1, q2, gSnk, gSrc) \
|
||||
(g5*(gSnk))*(q1)*(adj(gSrc)*g5)*adj(q2)
|
||||
|
||||
template <typename FImpl1, typename FImpl2>
|
||||
void TMeson<FImpl1, FImpl2>::execute(void)
|
||||
{
|
||||
LOG(Message) << "Computing meson contractions '" << getName() << "' using"
|
||||
<< " quarks '" << par().q1 << "' and '" << par().q2 << "'"
|
||||
<< std::endl;
|
||||
|
||||
std::vector<TComplex> buf;
|
||||
std::vector<Result> result;
|
||||
Gamma g5(Gamma::Algebra::Gamma5);
|
||||
std::vector<GammaPair> gammaList;
|
||||
int nt = env().getDim(Tp);
|
||||
|
||||
parseGammaString(gammaList);
|
||||
result.resize(gammaList.size());
|
||||
for (unsigned int i = 0; i < result.size(); ++i)
|
||||
{
|
||||
result[i].gamma_snk = gammaList[i].first;
|
||||
result[i].gamma_src = gammaList[i].second;
|
||||
result[i].corr.resize(nt);
|
||||
}
|
||||
if (envHasType(SlicedPropagator1, par().q1) and
|
||||
envHasType(SlicedPropagator2, par().q2))
|
||||
{
|
||||
auto &q1 = envGet(SlicedPropagator1, par().q1);
|
||||
auto &q2 = envGet(SlicedPropagator2, par().q2);
|
||||
|
||||
LOG(Message) << "(propagator already sinked)" << std::endl;
|
||||
for (unsigned int i = 0; i < result.size(); ++i)
|
||||
{
|
||||
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
|
||||
{
|
||||
auto &q1 = envGet(PropagatorField1, par().q1);
|
||||
auto &q2 = envGet(PropagatorField2, par().q2);
|
||||
|
||||
envGetTmp(LatticeComplex, c);
|
||||
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;
|
||||
|
||||
ns = vm().getModuleNamespace(env().getObjectModule(par().sink));
|
||||
if (ns == "MSource")
|
||||
{
|
||||
PropagatorField1 &sink = envGet(PropagatorField1, par().sink);
|
||||
|
||||
c = trace(mesonConnected(q1, q2, gSnk, gSrc)*sink);
|
||||
sliceSum(c, buf, Tp);
|
||||
}
|
||||
else if (ns == "MSink")
|
||||
{
|
||||
SinkFnScalar &sink = envGet(SinkFnScalar, par().sink);
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
saveResult(par().output, "meson", result);
|
||||
}
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_MContraction_Meson_hpp_
|
35
Hadrons/Modules/MContraction/WardIdentity.cc
Normal file
35
Hadrons/Modules/MContraction/WardIdentity.cc
Normal file
@ -0,0 +1,35 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules/MContraction/WardIdentity.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 <Hadrons/Modules/MContraction/WardIdentity.hpp>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace Hadrons;
|
||||
using namespace MContraction;
|
||||
|
||||
template class Grid::Hadrons::MContraction::TWardIdentity<FIMPL>;
|
||||
|
224
Hadrons/Modules/MContraction/WardIdentity.hpp
Normal file
224
Hadrons/Modules/MContraction/WardIdentity.hpp
Normal file
@ -0,0 +1,224 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules/MContraction/WardIdentity.hpp
|
||||
|
||||
Copyright (C) 2015-2018
|
||||
|
||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
||||
Author: Lanny91 <andrew.lawson@gmail.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_MContraction_WardIdentity_hpp_
|
||||
#define Hadrons_MContraction_WardIdentity_hpp_
|
||||
|
||||
#include <Hadrons/Global.hpp>
|
||||
#include <Hadrons/Module.hpp>
|
||||
#include <Hadrons/ModuleFactory.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/*
|
||||
Ward Identity contractions
|
||||
-----------------------------
|
||||
|
||||
* options:
|
||||
- q: propagator, 5D if available (string)
|
||||
- action: action module used for propagator solution (string)
|
||||
- mass: mass of quark (double)
|
||||
- test_axial: whether or not to test PCAC relation.
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* WardIdentity *
|
||||
******************************************************************************/
|
||||
BEGIN_MODULE_NAMESPACE(MContraction)
|
||||
|
||||
class WardIdentityPar: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(WardIdentityPar,
|
||||
std::string, q,
|
||||
std::string, action,
|
||||
double, mass,
|
||||
bool, test_axial);
|
||||
};
|
||||
|
||||
template <typename FImpl>
|
||||
class TWardIdentity: public Module<WardIdentityPar>
|
||||
{
|
||||
public:
|
||||
FERM_TYPE_ALIASES(FImpl,);
|
||||
public:
|
||||
// constructor
|
||||
TWardIdentity(const std::string name);
|
||||
// destructor
|
||||
virtual ~TWardIdentity(void) {};
|
||||
// dependency relation
|
||||
virtual std::vector<std::string> getInput(void);
|
||||
virtual std::vector<std::string> getOutput(void);
|
||||
protected:
|
||||
// setup
|
||||
virtual void setup(void);
|
||||
// execution
|
||||
virtual void execute(void);
|
||||
private:
|
||||
unsigned int Ls_;
|
||||
};
|
||||
|
||||
MODULE_REGISTER_TMP(WardIdentity, TWardIdentity<FIMPL>, MContraction);
|
||||
|
||||
/******************************************************************************
|
||||
* TWardIdentity implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
TWardIdentity<FImpl>::TWardIdentity(const std::string name)
|
||||
: Module<WardIdentityPar>(name)
|
||||
{}
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
std::vector<std::string> TWardIdentity<FImpl>::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in = {par().q, par().action};
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
template <typename FImpl>
|
||||
std::vector<std::string> TWardIdentity<FImpl>::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out = {};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
void TWardIdentity<FImpl>::setup(void)
|
||||
{
|
||||
Ls_ = env().getObjectLs(par().q);
|
||||
if (Ls_ != env().getObjectLs(par().action))
|
||||
{
|
||||
HADRONS_ERROR(Size, "Ls mismatch between quark action and propagator");
|
||||
}
|
||||
envTmpLat(PropagatorField, "tmp");
|
||||
envTmpLat(PropagatorField, "vector_WI");
|
||||
if (par().test_axial)
|
||||
{
|
||||
envTmpLat(PropagatorField, "psi");
|
||||
envTmpLat(LatticeComplex, "PP");
|
||||
envTmpLat(LatticeComplex, "axial_defect");
|
||||
envTmpLat(LatticeComplex, "PJ5q");
|
||||
}
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
void TWardIdentity<FImpl>::execute(void)
|
||||
{
|
||||
LOG(Message) << "Performing Ward Identity checks for quark '" << par().q
|
||||
<< "'." << std::endl;
|
||||
|
||||
auto &q = envGet(PropagatorField, par().q);
|
||||
auto &act = envGet(FMat, par().action);
|
||||
Gamma g5(Gamma::Algebra::Gamma5);
|
||||
|
||||
// Compute D_mu V_mu, D here is backward derivative.
|
||||
envGetTmp(PropagatorField, tmp);
|
||||
envGetTmp(PropagatorField, vector_WI);
|
||||
vector_WI = zero;
|
||||
for (unsigned int mu = 0; mu < Nd; ++mu)
|
||||
{
|
||||
act.ContractConservedCurrent(q, q, tmp, Current::Vector, mu);
|
||||
tmp -= Cshift(tmp, mu, -1);
|
||||
vector_WI += tmp;
|
||||
}
|
||||
|
||||
// Test ward identity D_mu V_mu = 0;
|
||||
LOG(Message) << "Vector Ward Identity check Delta_mu V_mu = "
|
||||
<< norm2(vector_WI) << std::endl;
|
||||
|
||||
if (par().test_axial)
|
||||
{
|
||||
envGetTmp(PropagatorField, psi);
|
||||
envGetTmp(LatticeComplex, PP);
|
||||
envGetTmp(LatticeComplex, axial_defect);
|
||||
envGetTmp(LatticeComplex, PJ5q);
|
||||
std::vector<TComplex> axial_buf;
|
||||
|
||||
// Compute <P|D_mu A_mu>, D is backwards derivative.
|
||||
axial_defect = zero;
|
||||
for (unsigned int mu = 0; mu < Nd; ++mu)
|
||||
{
|
||||
act.ContractConservedCurrent(q, q, tmp, Current::Axial, mu);
|
||||
tmp -= Cshift(tmp, mu, -1);
|
||||
axial_defect += trace(g5*tmp);
|
||||
}
|
||||
|
||||
// Get <P|J5q> for 5D (zero for 4D) and <P|P>.
|
||||
PJ5q = zero;
|
||||
if (Ls_ > 1)
|
||||
{
|
||||
// <P|P>
|
||||
ExtractSlice(tmp, q, 0, 0);
|
||||
psi = 0.5 * (tmp - g5*tmp);
|
||||
ExtractSlice(tmp, q, Ls_ - 1, 0);
|
||||
psi += 0.5 * (tmp + g5*tmp);
|
||||
PP = trace(adj(psi)*psi);
|
||||
|
||||
// <P|5Jq>
|
||||
ExtractSlice(tmp, q, Ls_/2 - 1, 0);
|
||||
psi = 0.5 * (tmp + g5*tmp);
|
||||
ExtractSlice(tmp, q, Ls_/2, 0);
|
||||
psi += 0.5 * (tmp - g5*tmp);
|
||||
PJ5q = trace(adj(psi)*psi);
|
||||
}
|
||||
else
|
||||
{
|
||||
PP = trace(adj(q)*q);
|
||||
}
|
||||
|
||||
// Test ward identity <P|D_mu A_mu> = 2m<P|P> + 2<P|J5q>
|
||||
LOG(Message) << "|D_mu A_mu|^2 = " << norm2(axial_defect) << std::endl;
|
||||
LOG(Message) << "|PP|^2 = " << norm2(PP) << std::endl;
|
||||
LOG(Message) << "|PJ5q|^2 = " << norm2(PJ5q) << std::endl;
|
||||
LOG(Message) << "Axial Ward Identity defect Delta_mu A_mu = "
|
||||
<< norm2(axial_defect) << std::endl;
|
||||
|
||||
// Axial defect by timeslice.
|
||||
axial_defect -= 2.*(par().mass*PP + PJ5q);
|
||||
LOG(Message) << "Check Axial defect by timeslice" << std::endl;
|
||||
sliceSum(axial_defect, axial_buf, Tp);
|
||||
for (int t = 0; t < axial_buf.size(); ++t)
|
||||
{
|
||||
LOG(Message) << "t = " << t << ": "
|
||||
<< TensorRemove(axial_buf[t]) << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_WardIdentity_hpp_
|
118
Hadrons/Modules/MContraction/WeakHamiltonian.hpp
Normal file
118
Hadrons/Modules/MContraction/WeakHamiltonian.hpp
Normal file
@ -0,0 +1,118 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules/MContraction/WeakHamiltonian.hpp
|
||||
|
||||
Copyright (C) 2015-2018
|
||||
|
||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
||||
Author: Lanny91 <andrew.lawson@gmail.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_MContraction_WeakHamiltonian_hpp_
|
||||
#define Hadrons_MContraction_WeakHamiltonian_hpp_
|
||||
|
||||
#include <Hadrons/Global.hpp>
|
||||
#include <Hadrons/Module.hpp>
|
||||
#include <Hadrons/ModuleFactory.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* WeakHamiltonian *
|
||||
******************************************************************************/
|
||||
BEGIN_MODULE_NAMESPACE(MContraction)
|
||||
|
||||
/*******************************************************************************
|
||||
* Utilities for contractions involving the Weak Hamiltonian.
|
||||
******************************************************************************/
|
||||
//// Sum and store correlator.
|
||||
#define MAKE_DIAG(exp, buf, res, n)\
|
||||
sliceSum(exp, buf, Tp);\
|
||||
res.name = (n);\
|
||||
res.corr.resize(buf.size());\
|
||||
for (unsigned int t = 0; t < buf.size(); ++t)\
|
||||
{\
|
||||
res.corr[t] = TensorRemove(buf[t]);\
|
||||
}
|
||||
|
||||
//// Contraction of mu index: use 'mu' variable in exp.
|
||||
#define SUM_MU(buf,exp)\
|
||||
buf = zero;\
|
||||
for (unsigned int mu = 0; mu < ndim; ++mu)\
|
||||
{\
|
||||
buf += exp;\
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
i_V = 0,
|
||||
i_A = 1,
|
||||
n_i = 2
|
||||
};
|
||||
|
||||
class WeakHamiltonianPar: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(WeakHamiltonianPar,
|
||||
std::string, q1,
|
||||
std::string, q2,
|
||||
std::string, q3,
|
||||
std::string, q4,
|
||||
unsigned int, tSnk,
|
||||
std::string, output);
|
||||
};
|
||||
|
||||
#define MAKE_WEAK_MODULE(modname)\
|
||||
class T##modname: public Module<WeakHamiltonianPar>\
|
||||
{\
|
||||
public:\
|
||||
FERM_TYPE_ALIASES(FIMPL,)\
|
||||
class Result: Serializable\
|
||||
{\
|
||||
public:\
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(Result,\
|
||||
std::string, name,\
|
||||
std::vector<Complex>, corr);\
|
||||
};\
|
||||
public:\
|
||||
/* constructor */ \
|
||||
T##modname(const std::string name);\
|
||||
/* destructor */ \
|
||||
virtual ~T##modname(void) {};\
|
||||
/* dependency relation */ \
|
||||
virtual std::vector<std::string> getInput(void);\
|
||||
virtual std::vector<std::string> getOutput(void);\
|
||||
public:\
|
||||
std::vector<std::string> VA_label = {"V", "A"};\
|
||||
protected:\
|
||||
/* setup */ \
|
||||
virtual void setup(void);\
|
||||
/* execution */ \
|
||||
virtual void execute(void);\
|
||||
};\
|
||||
MODULE_REGISTER(modname, T##modname, MContraction);
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_MContraction_WeakHamiltonian_hpp_
|
151
Hadrons/Modules/MContraction/WeakHamiltonianEye.cc
Normal file
151
Hadrons/Modules/MContraction/WeakHamiltonianEye.cc
Normal file
@ -0,0 +1,151 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules/MContraction/WeakHamiltonianEye.cc
|
||||
|
||||
Copyright (C) 2015-2018
|
||||
|
||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
||||
Author: Lanny91 <andrew.lawson@gmail.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 <Hadrons/Modules/MContraction/WeakHamiltonianEye.hpp>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace Hadrons;
|
||||
using namespace MContraction;
|
||||
|
||||
/*
|
||||
* Weak Hamiltonian current-current contractions, Eye-type.
|
||||
*
|
||||
* These contractions are generated by the Q1 and Q2 operators in the physical
|
||||
* basis (see e.g. Fig 3 of arXiv:1507.03094).
|
||||
*
|
||||
* Schematics: q4 |
|
||||
* /-<-¬ |
|
||||
* / \ | q2 q3
|
||||
* \ / | /----<------*------<----¬
|
||||
* q2 \ / q3 | / /-*-¬ \
|
||||
* /-----<-----* *-----<----¬ | / / \ \
|
||||
* i * H_W * f | i * \ / q4 * f
|
||||
* \ / | \ \->-/ /
|
||||
* \ / | \ /
|
||||
* \---------->---------/ | \----------->----------/
|
||||
* q1 | q1
|
||||
* |
|
||||
* Saucer (S) | Eye (E)
|
||||
*
|
||||
* S: trace(q3*g5*q1*adj(q2)*g5*gL[mu][p_1]*q4*gL[mu][p_2])
|
||||
* E: trace(q3*g5*q1*adj(q2)*g5*gL[mu][p_1])*trace(q4*gL[mu][p_2])
|
||||
*
|
||||
* Note q1 must be sink smeared.
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* TWeakHamiltonianEye implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
TWeakHamiltonianEye::TWeakHamiltonianEye(const std::string name)
|
||||
: Module<WeakHamiltonianPar>(name)
|
||||
{}
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
std::vector<std::string> TWeakHamiltonianEye::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in = {par().q1, par().q2, par().q3, par().q4};
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
std::vector<std::string> TWeakHamiltonianEye::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out = {};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
void TWeakHamiltonianEye::setup(void)
|
||||
{
|
||||
unsigned int ndim = env().getNd();
|
||||
|
||||
envTmpLat(LatticeComplex, "expbuf");
|
||||
envTmpLat(PropagatorField, "tmp1");
|
||||
envTmpLat(LatticeComplex, "tmp2");
|
||||
envTmp(std::vector<PropagatorField>, "S_body", 1, ndim, PropagatorField(env().getGrid()));
|
||||
envTmp(std::vector<PropagatorField>, "S_loop", 1, ndim, PropagatorField(env().getGrid()));
|
||||
envTmp(std::vector<LatticeComplex>, "E_body", 1, ndim, LatticeComplex(env().getGrid()));
|
||||
envTmp(std::vector<LatticeComplex>, "E_loop", 1, ndim, LatticeComplex(env().getGrid()));
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
void TWeakHamiltonianEye::execute(void)
|
||||
{
|
||||
LOG(Message) << "Computing Weak Hamiltonian (Eye type) contractions '"
|
||||
<< getName() << "' using quarks '" << par().q1 << "', '"
|
||||
<< par().q2 << ", '" << par().q3 << "' and '" << par().q4
|
||||
<< "'." << std::endl;
|
||||
|
||||
auto &q1 = envGet(SlicedPropagator, par().q1);
|
||||
auto &q2 = envGet(PropagatorField, par().q2);
|
||||
auto &q3 = envGet(PropagatorField, par().q3);
|
||||
auto &q4 = envGet(PropagatorField, par().q4);
|
||||
Gamma g5 = Gamma(Gamma::Algebra::Gamma5);
|
||||
std::vector<TComplex> corrbuf;
|
||||
std::vector<Result> result(n_eye_diag);
|
||||
unsigned int ndim = env().getNd();
|
||||
|
||||
envGetTmp(LatticeComplex, expbuf);
|
||||
envGetTmp(PropagatorField, tmp1);
|
||||
envGetTmp(LatticeComplex, tmp2);
|
||||
envGetTmp(std::vector<PropagatorField>, S_body);
|
||||
envGetTmp(std::vector<PropagatorField>, S_loop);
|
||||
envGetTmp(std::vector<LatticeComplex>, E_body);
|
||||
envGetTmp(std::vector<LatticeComplex>, E_loop);
|
||||
|
||||
// Get sink timeslice of q1.
|
||||
SitePropagator q1Snk = q1[par().tSnk];
|
||||
|
||||
// Setup for S-type contractions.
|
||||
for (int mu = 0; mu < ndim; ++mu)
|
||||
{
|
||||
S_body[mu] = MAKE_SE_BODY(q1Snk, q2, q3, GammaL(Gamma::gmu[mu]));
|
||||
S_loop[mu] = MAKE_SE_LOOP(q4, GammaL(Gamma::gmu[mu]));
|
||||
}
|
||||
|
||||
// Perform S-type contractions.
|
||||
SUM_MU(expbuf, trace(S_body[mu]*S_loop[mu]))
|
||||
MAKE_DIAG(expbuf, corrbuf, result[S_diag], "HW_S")
|
||||
|
||||
// Recycle sub-expressions for E-type contractions.
|
||||
for (unsigned int mu = 0; mu < ndim; ++mu)
|
||||
{
|
||||
E_body[mu] = trace(S_body[mu]);
|
||||
E_loop[mu] = trace(S_loop[mu]);
|
||||
}
|
||||
|
||||
// Perform E-type contractions.
|
||||
SUM_MU(expbuf, E_body[mu]*E_loop[mu])
|
||||
MAKE_DIAG(expbuf, corrbuf, result[E_diag], "HW_E")
|
||||
|
||||
// IO
|
||||
saveResult(par().output, "HW_Eye", result);
|
||||
}
|
59
Hadrons/Modules/MContraction/WeakHamiltonianEye.hpp
Normal file
59
Hadrons/Modules/MContraction/WeakHamiltonianEye.hpp
Normal file
@ -0,0 +1,59 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules/MContraction/WeakHamiltonianEye.hpp
|
||||
|
||||
Copyright (C) 2015-2018
|
||||
|
||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
||||
Author: Lanny91 <andrew.lawson@gmail.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_MContraction_WeakHamiltonianEye_hpp_
|
||||
#define Hadrons_MContraction_WeakHamiltonianEye_hpp_
|
||||
|
||||
#include <Hadrons/Modules/MContraction/WeakHamiltonian.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* WeakHamiltonianEye *
|
||||
******************************************************************************/
|
||||
BEGIN_MODULE_NAMESPACE(MContraction)
|
||||
|
||||
enum
|
||||
{
|
||||
S_diag = 0,
|
||||
E_diag = 1,
|
||||
n_eye_diag = 2
|
||||
};
|
||||
|
||||
// Saucer and Eye subdiagram contractions.
|
||||
#define MAKE_SE_BODY(Q_1, Q_2, Q_3, gamma) (Q_3*g5*Q_1*adj(Q_2)*g5*gamma)
|
||||
#define MAKE_SE_LOOP(Q_loop, gamma) (Q_loop*gamma)
|
||||
|
||||
MAKE_WEAK_MODULE(WeakHamiltonianEye)
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_MContraction_WeakHamiltonianEye_hpp_
|
148
Hadrons/Modules/MContraction/WeakHamiltonianNonEye.cc
Normal file
148
Hadrons/Modules/MContraction/WeakHamiltonianNonEye.cc
Normal file
@ -0,0 +1,148 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules/MContraction/WeakHamiltonianNonEye.cc
|
||||
|
||||
Copyright (C) 2015-2018
|
||||
|
||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
||||
Author: Lanny91 <andrew.lawson@gmail.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 <Hadrons/Modules/MContraction/WeakHamiltonianNonEye.hpp>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace Hadrons;
|
||||
using namespace MContraction;
|
||||
|
||||
/*
|
||||
* Weak Hamiltonian current-current contractions, Non-Eye-type.
|
||||
*
|
||||
* These contractions are generated by the Q1 and Q2 operators in the physical
|
||||
* basis (see e.g. Fig 3 of arXiv:1507.03094).
|
||||
*
|
||||
* Schematic:
|
||||
* q2 q3 | q2 q3
|
||||
* /--<--¬ /--<--¬ | /--<--¬ /--<--¬
|
||||
* / \ / \ | / \ / \
|
||||
* / \ / \ | / \ / \
|
||||
* / \ / \ | / \ / \
|
||||
* i * * H_W * f | i * * * H_W * f
|
||||
* \ * | | \ / \ /
|
||||
* \ / \ / | \ / \ /
|
||||
* \ / \ / | \ / \ /
|
||||
* \ / \ / | \-->--/ \-->--/
|
||||
* \-->--/ \-->--/ | q1 q4
|
||||
* q1 q4 |
|
||||
* Connected (C) | Wing (W)
|
||||
*
|
||||
* C: trace(q1*adj(q2)*g5*gL[mu]*q3*adj(q4)*g5*gL[mu])
|
||||
* W: trace(q1*adj(q2)*g5*gL[mu])*trace(q3*adj(q4)*g5*gL[mu])
|
||||
*
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* TWeakHamiltonianNonEye implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
TWeakHamiltonianNonEye::TWeakHamiltonianNonEye(const std::string name)
|
||||
: Module<WeakHamiltonianPar>(name)
|
||||
{}
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
std::vector<std::string> TWeakHamiltonianNonEye::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in = {par().q1, par().q2, par().q3, par().q4};
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
std::vector<std::string> TWeakHamiltonianNonEye::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out = {};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
void TWeakHamiltonianNonEye::setup(void)
|
||||
{
|
||||
unsigned int ndim = env().getNd();
|
||||
|
||||
envTmpLat(LatticeComplex, "expbuf");
|
||||
envTmpLat(PropagatorField, "tmp1");
|
||||
envTmpLat(LatticeComplex, "tmp2");
|
||||
envTmp(std::vector<PropagatorField>, "C_i_side_loop", 1, ndim, PropagatorField(env().getGrid()));
|
||||
envTmp(std::vector<PropagatorField>, "C_f_side_loop", 1, ndim, PropagatorField(env().getGrid()));
|
||||
envTmp(std::vector<LatticeComplex>, "W_i_side_loop", 1, ndim, LatticeComplex(env().getGrid()));
|
||||
envTmp(std::vector<LatticeComplex>, "W_f_side_loop", 1, ndim, LatticeComplex(env().getGrid()));
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
void TWeakHamiltonianNonEye::execute(void)
|
||||
{
|
||||
LOG(Message) << "Computing Weak Hamiltonian (Non-Eye type) contractions '"
|
||||
<< getName() << "' using quarks '" << par().q1 << "', '"
|
||||
<< par().q2 << ", '" << par().q3 << "' and '" << par().q4
|
||||
<< "'." << std::endl;
|
||||
|
||||
auto &q1 = envGet(PropagatorField, par().q1);
|
||||
auto &q2 = envGet(PropagatorField, par().q2);
|
||||
auto &q3 = envGet(PropagatorField, par().q3);
|
||||
auto &q4 = envGet(PropagatorField, par().q4);
|
||||
Gamma g5 = Gamma(Gamma::Algebra::Gamma5);
|
||||
std::vector<TComplex> corrbuf;
|
||||
std::vector<Result> result(n_noneye_diag);
|
||||
unsigned int ndim = env().getNd();
|
||||
|
||||
envGetTmp(LatticeComplex, expbuf);
|
||||
envGetTmp(PropagatorField, tmp1);
|
||||
envGetTmp(LatticeComplex, tmp2);
|
||||
envGetTmp(std::vector<PropagatorField>, C_i_side_loop);
|
||||
envGetTmp(std::vector<PropagatorField>, C_f_side_loop);
|
||||
envGetTmp(std::vector<LatticeComplex>, W_i_side_loop);
|
||||
envGetTmp(std::vector<LatticeComplex>, W_f_side_loop);
|
||||
|
||||
// Setup for C-type contractions.
|
||||
for (int mu = 0; mu < ndim; ++mu)
|
||||
{
|
||||
C_i_side_loop[mu] = MAKE_CW_SUBDIAG(q1, q2, GammaL(Gamma::gmu[mu]));
|
||||
C_f_side_loop[mu] = MAKE_CW_SUBDIAG(q3, q4, GammaL(Gamma::gmu[mu]));
|
||||
}
|
||||
|
||||
// Perform C-type contractions.
|
||||
SUM_MU(expbuf, trace(C_i_side_loop[mu]*C_f_side_loop[mu]))
|
||||
MAKE_DIAG(expbuf, corrbuf, result[C_diag], "HW_C")
|
||||
|
||||
// Recycle sub-expressions for W-type contractions.
|
||||
for (unsigned int mu = 0; mu < ndim; ++mu)
|
||||
{
|
||||
W_i_side_loop[mu] = trace(C_i_side_loop[mu]);
|
||||
W_f_side_loop[mu] = trace(C_f_side_loop[mu]);
|
||||
}
|
||||
|
||||
// Perform W-type contractions.
|
||||
SUM_MU(expbuf, W_i_side_loop[mu]*W_f_side_loop[mu])
|
||||
MAKE_DIAG(expbuf, corrbuf, result[W_diag], "HW_W")
|
||||
|
||||
// IO
|
||||
saveResult(par().output, "HW_NonEye", result);
|
||||
}
|
58
Hadrons/Modules/MContraction/WeakHamiltonianNonEye.hpp
Normal file
58
Hadrons/Modules/MContraction/WeakHamiltonianNonEye.hpp
Normal file
@ -0,0 +1,58 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules/MContraction/WeakHamiltonianNonEye.hpp
|
||||
|
||||
Copyright (C) 2015-2018
|
||||
|
||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
||||
Author: Lanny91 <andrew.lawson@gmail.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_MContraction_WeakHamiltonianNonEye_hpp_
|
||||
#define Hadrons_MContraction_WeakHamiltonianNonEye_hpp_
|
||||
|
||||
#include <Hadrons/Modules/MContraction/WeakHamiltonian.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* WeakHamiltonianNonEye *
|
||||
******************************************************************************/
|
||||
BEGIN_MODULE_NAMESPACE(MContraction)
|
||||
|
||||
enum
|
||||
{
|
||||
W_diag = 0,
|
||||
C_diag = 1,
|
||||
n_noneye_diag = 2
|
||||
};
|
||||
|
||||
// Wing and Connected subdiagram contractions
|
||||
#define MAKE_CW_SUBDIAG(Q_1, Q_2, gamma) (Q_1*adj(Q_2)*g5*gamma)
|
||||
|
||||
MAKE_WEAK_MODULE(WeakHamiltonianNonEye)
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_MContraction_WeakHamiltonianNonEye_hpp_
|
142
Hadrons/Modules/MContraction/WeakNeutral4ptDisc.cc
Normal file
142
Hadrons/Modules/MContraction/WeakNeutral4ptDisc.cc
Normal file
@ -0,0 +1,142 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules/MContraction/WeakNeutral4ptDisc.cc
|
||||
|
||||
Copyright (C) 2015-2018
|
||||
|
||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
||||
Author: Lanny91 <andrew.lawson@gmail.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 <Hadrons/Modules/MContraction/WeakNeutral4ptDisc.hpp>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace Hadrons;
|
||||
using namespace MContraction;
|
||||
|
||||
/*
|
||||
* Weak Hamiltonian + current contractions, disconnected topology for neutral
|
||||
* mesons.
|
||||
*
|
||||
* These contractions are generated by operators Q_1,...,10 of the dS=1 Weak
|
||||
* Hamiltonian in the physical basis and an additional current J (see e.g.
|
||||
* Fig 11 of arXiv:1507.03094).
|
||||
*
|
||||
* Schematic:
|
||||
*
|
||||
* q2 q4 q3
|
||||
* /--<--¬ /---<--¬ /---<--¬
|
||||
* / \ / \ / \
|
||||
* i * * H_W | J * * f
|
||||
* \ / \ / \ /
|
||||
* \--->---/ \-------/ \------/
|
||||
* q1
|
||||
*
|
||||
* options
|
||||
* - q1: input propagator 1 (string)
|
||||
* - q2: input propagator 2 (string)
|
||||
* - q3: input propagator 3 (string), assumed to be sequential propagator
|
||||
* - q4: input propagator 4 (string), assumed to be a loop
|
||||
*
|
||||
* type 1: trace(q1*adj(q2)*g5*gL[mu])*trace(loop*gL[mu])*trace(q3*g5)
|
||||
* type 2: trace(q1*adj(q2)*g5*gL[mu]*loop*gL[mu])*trace(q3*g5)
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* TWeakNeutral4ptDisc implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
TWeakNeutral4ptDisc::TWeakNeutral4ptDisc(const std::string name)
|
||||
: Module<WeakHamiltonianPar>(name)
|
||||
{}
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
std::vector<std::string> TWeakNeutral4ptDisc::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in = {par().q1, par().q2, par().q3, par().q4};
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
std::vector<std::string> TWeakNeutral4ptDisc::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out = {};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
void TWeakNeutral4ptDisc::setup(void)
|
||||
{
|
||||
unsigned int ndim = env().getNd();
|
||||
|
||||
envTmpLat(LatticeComplex, "expbuf");
|
||||
envTmpLat(PropagatorField, "tmp");
|
||||
envTmpLat(LatticeComplex, "curr");
|
||||
envTmp(std::vector<PropagatorField>, "meson", 1, ndim, PropagatorField(env().getGrid()));
|
||||
envTmp(std::vector<PropagatorField>, "loop", 1, ndim, PropagatorField(env().getGrid()));
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
void TWeakNeutral4ptDisc::execute(void)
|
||||
{
|
||||
LOG(Message) << "Computing Weak Hamiltonian neutral disconnected contractions '"
|
||||
<< getName() << "' using quarks '" << par().q1 << "', '"
|
||||
<< par().q2 << ", '" << par().q3 << "' and '" << par().q4
|
||||
<< "'." << std::endl;
|
||||
|
||||
auto &q1 = envGet(PropagatorField, par().q1);
|
||||
auto &q2 = envGet(PropagatorField, par().q2);
|
||||
auto &q3 = envGet(PropagatorField, par().q3);
|
||||
auto &q4 = envGet(PropagatorField, par().q4);
|
||||
Gamma g5 = Gamma(Gamma::Algebra::Gamma5);
|
||||
std::vector<TComplex> corrbuf;
|
||||
std::vector<Result> result(n_neut_disc_diag);
|
||||
unsigned int ndim = env().getNd();
|
||||
|
||||
envGetTmp(LatticeComplex, expbuf);
|
||||
envGetTmp(PropagatorField, tmp);
|
||||
envGetTmp(LatticeComplex, curr);
|
||||
envGetTmp(std::vector<PropagatorField>, meson);
|
||||
envGetTmp(std::vector<PropagatorField>, loop);
|
||||
|
||||
// Setup for type 1 contractions.
|
||||
for (int mu = 0; mu < ndim; ++mu)
|
||||
{
|
||||
meson[mu] = MAKE_DISC_MESON(q1, q2, GammaL(Gamma::gmu[mu]));
|
||||
loop[mu] = MAKE_DISC_LOOP(q4, GammaL(Gamma::gmu[mu]));
|
||||
}
|
||||
curr = MAKE_DISC_CURR(q3, GammaL(Gamma::Algebra::Gamma5));
|
||||
|
||||
// Perform type 1 contractions.
|
||||
SUM_MU(expbuf, trace(meson[mu]*loop[mu]))
|
||||
expbuf *= curr;
|
||||
MAKE_DIAG(expbuf, corrbuf, result[neut_disc_1_diag], "HW_disc0_1")
|
||||
|
||||
// Perform type 2 contractions.
|
||||
SUM_MU(expbuf, trace(meson[mu])*trace(loop[mu]))
|
||||
expbuf *= curr;
|
||||
MAKE_DIAG(expbuf, corrbuf, result[neut_disc_2_diag], "HW_disc0_2")
|
||||
|
||||
// IO
|
||||
saveResult(par().output, "HW_disc0", result);
|
||||
}
|
60
Hadrons/Modules/MContraction/WeakNeutral4ptDisc.hpp
Normal file
60
Hadrons/Modules/MContraction/WeakNeutral4ptDisc.hpp
Normal file
@ -0,0 +1,60 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules/MContraction/WeakNeutral4ptDisc.hpp
|
||||
|
||||
Copyright (C) 2015-2018
|
||||
|
||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
||||
Author: Lanny91 <andrew.lawson@gmail.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_MContraction_WeakNeutral4ptDisc_hpp_
|
||||
#define Hadrons_MContraction_WeakNeutral4ptDisc_hpp_
|
||||
|
||||
#include <Hadrons/Modules/MContraction/WeakHamiltonian.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* WeakNeutral4ptDisc *
|
||||
******************************************************************************/
|
||||
BEGIN_MODULE_NAMESPACE(MContraction)
|
||||
|
||||
enum
|
||||
{
|
||||
neut_disc_1_diag = 0,
|
||||
neut_disc_2_diag = 1,
|
||||
n_neut_disc_diag = 2
|
||||
};
|
||||
|
||||
// Neutral 4pt disconnected subdiagram contractions.
|
||||
#define MAKE_DISC_MESON(Q_1, Q_2, gamma) (Q_1*adj(Q_2)*g5*gamma)
|
||||
#define MAKE_DISC_LOOP(Q_LOOP, gamma) (Q_LOOP*gamma)
|
||||
#define MAKE_DISC_CURR(Q_c, gamma) (trace(Q_c*gamma))
|
||||
|
||||
MAKE_WEAK_MODULE(WeakNeutral4ptDisc)
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_MContraction_WeakNeutral4ptDisc_hpp_
|
Reference in New Issue
Block a user