mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-10 07:55:35 +00:00
Hadrons: all modules are now ported, more tests need to be done
This commit is contained in:
parent
65d4f17976
commit
67c3fa0f5f
@ -28,33 +28,33 @@ See the full license in the file "LICENSE" in the top level distribution directo
|
||||
*************************************************************************************/
|
||||
/* END LEGAL */
|
||||
|
||||
#include <Grid/Hadrons/Modules/MAction/DWF.hpp>
|
||||
#include <Grid/Hadrons/Modules/MAction/Wilson.hpp>
|
||||
#include <Grid/Hadrons/Modules/MContraction/Baryon.hpp>
|
||||
#include <Grid/Hadrons/Modules/MContraction/DiscLoop.hpp>
|
||||
#include <Grid/Hadrons/Modules/MContraction/Gamma3pt.hpp>
|
||||
#include <Grid/Hadrons/Modules/MContraction/Meson.hpp>
|
||||
#include <Grid/Hadrons/Modules/MContraction/WardIdentity.hpp>
|
||||
#include <Grid/Hadrons/Modules/MContraction/WeakHamiltonian.hpp>
|
||||
#include <Grid/Hadrons/Modules/MContraction/WeakHamiltonianEye.hpp>
|
||||
#include <Grid/Hadrons/Modules/MContraction/WeakHamiltonianNonEye.hpp>
|
||||
#include <Grid/Hadrons/Modules/MContraction/DiscLoop.hpp>
|
||||
#include <Grid/Hadrons/Modules/MContraction/WeakNeutral4ptDisc.hpp>
|
||||
#include <Grid/Hadrons/Modules/MContraction/Gamma3pt.hpp>
|
||||
#include <Grid/Hadrons/Modules/MContraction/WardIdentity.hpp>
|
||||
#include <Grid/Hadrons/Modules/MContraction/WeakHamiltonianEye.hpp>
|
||||
#include <Grid/Hadrons/Modules/MFermion/GaugeProp.hpp>
|
||||
#include <Grid/Hadrons/Modules/MGauge/Load.hpp>
|
||||
#include <Grid/Hadrons/Modules/MGauge/Random.hpp>
|
||||
#include <Grid/Hadrons/Modules/MGauge/StochEm.hpp>
|
||||
#include <Grid/Hadrons/Modules/MGauge/Unit.hpp>
|
||||
#include <Grid/Hadrons/Modules/MLoop/NoiseLoop.hpp>
|
||||
// #include <Grid/Hadrons/Modules/MScalar/ChargedProp.hpp>
|
||||
// #include <Grid/Hadrons/Modules/MScalar/FreeProp.hpp>
|
||||
// #include <Grid/Hadrons/Modules/MScalar/Scalar.hpp>
|
||||
#include <Grid/Hadrons/Modules/MSink/Point.hpp>
|
||||
#include <Grid/Hadrons/Modules/MSink/Smear.hpp>
|
||||
#include <Grid/Hadrons/Modules/MSolver/RBPrecCG.hpp>
|
||||
#include <Grid/Hadrons/Modules/MSource/Point.hpp>
|
||||
#include <Grid/Hadrons/Modules/MSource/SeqConserved.hpp>
|
||||
#include <Grid/Hadrons/Modules/MSource/SeqGamma.hpp>
|
||||
#include <Grid/Hadrons/Modules/MSource/Point.hpp>
|
||||
#include <Grid/Hadrons/Modules/MSource/Wall.hpp>
|
||||
#include <Grid/Hadrons/Modules/MSource/Z2.hpp>
|
||||
#include <Grid/Hadrons/Modules/MUtilities/TestSeqConserved.hpp>
|
||||
#include <Grid/Hadrons/Modules/MSource/SeqConserved.hpp>
|
||||
#include <Grid/Hadrons/Modules/MSink/Smear.hpp>
|
||||
#include <Grid/Hadrons/Modules/MSink/Point.hpp>
|
||||
#include <Grid/Hadrons/Modules/MSolver/RBPrecCG.hpp>
|
||||
#include <Grid/Hadrons/Modules/MGauge/Load.hpp>
|
||||
#include <Grid/Hadrons/Modules/MGauge/Unit.hpp>
|
||||
#include <Grid/Hadrons/Modules/MGauge/Random.hpp>
|
||||
#include <Grid/Hadrons/Modules/MGauge/StochEm.hpp>
|
||||
#include <Grid/Hadrons/Modules/MUtilities/TestSeqGamma.hpp>
|
||||
#include <Grid/Hadrons/Modules/MUtilities/TestSeqConserved.hpp>
|
||||
#include <Grid/Hadrons/Modules/MLoop/NoiseLoop.hpp>
|
||||
#include <Grid/Hadrons/Modules/MScalar/FreeProp.hpp>
|
||||
#include <Grid/Hadrons/Modules/MScalar/Scalar.hpp>
|
||||
#include <Grid/Hadrons/Modules/MScalar/ChargedProp.hpp>
|
||||
#include <Grid/Hadrons/Modules/MAction/DWF.hpp>
|
||||
#include <Grid/Hadrons/Modules/MAction/Wilson.hpp>
|
||||
|
@ -37,90 +37,44 @@ void TChargedProp::setup(void)
|
||||
{
|
||||
phaseName_.push_back("_shiftphase_" + std::to_string(mu));
|
||||
}
|
||||
GFSrcName_ = "_" + getName() + "_DinvSrc";
|
||||
if (!env().hasRegisteredObject(freeMomPropName_))
|
||||
GFSrcName_ = getName() + "_DinvSrc";
|
||||
fftName_ = getName() + "_fft";
|
||||
|
||||
freeMomPropDone_ = env().hasCreatedObject(freeMomPropName_);
|
||||
GFSrcDone_ = env().hasCreatedObject(GFSrcName_);
|
||||
phasesDone_ = env().hasCreatedObject(phaseName_[0]);
|
||||
envCacheLat(ScalarField, freeMomPropName_);
|
||||
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
||||
{
|
||||
env().registerLattice<ScalarField>(freeMomPropName_);
|
||||
envCacheLat(ScalarField, phaseName_[mu]);
|
||||
}
|
||||
if (!env().hasRegisteredObject(phaseName_[0]))
|
||||
{
|
||||
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
||||
{
|
||||
env().registerLattice<ScalarField>(phaseName_[mu]);
|
||||
}
|
||||
}
|
||||
if (!env().hasRegisteredObject(GFSrcName_))
|
||||
{
|
||||
env().registerLattice<ScalarField>(GFSrcName_);
|
||||
}
|
||||
env().registerLattice<ScalarField>(getName());
|
||||
envCacheLat(ScalarField, GFSrcName_);
|
||||
envCreateLat(ScalarField, getName());
|
||||
envTmpLat(ScalarField, "buf");
|
||||
envTmpLat(ScalarField, "result");
|
||||
envTmpLat(ScalarField, "Amu");
|
||||
envCache(FFT, fftName_, 1, env().getGrid());
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
void TChargedProp::execute(void)
|
||||
{
|
||||
// CACHING ANALYTIC EXPRESSIONS
|
||||
ScalarField &source = *env().getObject<ScalarField>(par().source);
|
||||
Complex ci(0.0,1.0);
|
||||
FFT fft(env().getGrid());
|
||||
|
||||
// cache free scalar propagator
|
||||
if (!env().hasCreatedObject(freeMomPropName_))
|
||||
{
|
||||
LOG(Message) << "Caching momentum space free scalar propagator"
|
||||
<< " (mass= " << par().mass << ")..." << std::endl;
|
||||
freeMomProp_ = env().createLattice<ScalarField>(freeMomPropName_);
|
||||
SIMPL::MomentumSpacePropagator(*freeMomProp_, par().mass);
|
||||
}
|
||||
else
|
||||
{
|
||||
freeMomProp_ = env().getObject<ScalarField>(freeMomPropName_);
|
||||
}
|
||||
// cache G*F*src
|
||||
if (!env().hasCreatedObject(GFSrcName_))
|
||||
|
||||
{
|
||||
GFSrc_ = env().createLattice<ScalarField>(GFSrcName_);
|
||||
fft.FFT_all_dim(*GFSrc_, source, FFT::forward);
|
||||
*GFSrc_ = (*freeMomProp_)*(*GFSrc_);
|
||||
}
|
||||
else
|
||||
{
|
||||
GFSrc_ = env().getObject<ScalarField>(GFSrcName_);
|
||||
}
|
||||
// cache phases
|
||||
if (!env().hasCreatedObject(phaseName_[0]))
|
||||
{
|
||||
std::vector<int> &l = env().getGrid()->_fdimensions;
|
||||
|
||||
LOG(Message) << "Caching shift phases..." << std::endl;
|
||||
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
||||
{
|
||||
Real twoPiL = M_PI*2./l[mu];
|
||||
|
||||
phase_.push_back(env().createLattice<ScalarField>(phaseName_[mu]));
|
||||
LatticeCoordinate(*(phase_[mu]), mu);
|
||||
*(phase_[mu]) = exp(ci*twoPiL*(*(phase_[mu])));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
||||
{
|
||||
phase_.push_back(env().getObject<ScalarField>(phaseName_[mu]));
|
||||
}
|
||||
}
|
||||
makeCaches();
|
||||
|
||||
// PROPAGATOR CALCULATION
|
||||
LOG(Message) << "Computing charged scalar propagator"
|
||||
<< " (mass= " << par().mass
|
||||
<< ", charge= " << par().charge << ")..." << std::endl;
|
||||
|
||||
ScalarField &prop = *env().createLattice<ScalarField>(getName());
|
||||
ScalarField buf(env().getGrid());
|
||||
ScalarField &GFSrc = *GFSrc_, &G = *freeMomProp_;
|
||||
double q = par().charge;
|
||||
|
||||
auto &prop = envGet(ScalarField, getName());
|
||||
auto &GFSrc = envGet(ScalarField, GFSrcName_);
|
||||
auto &G = envGet(ScalarField, freeMomPropName_);
|
||||
auto &fft = envGet(FFT, fftName_);
|
||||
double q = par().charge;
|
||||
envGetTmp(ScalarField, result);
|
||||
envGetTmp(ScalarField, buf);
|
||||
|
||||
// G*F*Src
|
||||
prop = GFSrc;
|
||||
|
||||
@ -146,7 +100,7 @@ void TChargedProp::execute(void)
|
||||
if (!par().output.empty())
|
||||
{
|
||||
std::string filename = par().output + "." +
|
||||
std::to_string(env().getTrajectory());
|
||||
std::to_string(vm().getTrajectory());
|
||||
|
||||
LOG(Message) << "Saving zero-momentum projection to '"
|
||||
<< filename << "'..." << std::endl;
|
||||
@ -166,15 +120,55 @@ void TChargedProp::execute(void)
|
||||
}
|
||||
}
|
||||
|
||||
void TChargedProp::makeCaches(void)
|
||||
{
|
||||
auto &freeMomProp = envGet(ScalarField, freeMomPropName_);
|
||||
auto &GFSrc = envGet(ScalarField, GFSrcName_);
|
||||
auto &fft = envGet(FFT, fftName_);
|
||||
|
||||
if (!freeMomPropDone_)
|
||||
{
|
||||
LOG(Message) << "Caching momentum space free scalar propagator"
|
||||
<< " (mass= " << par().mass << ")..." << std::endl;
|
||||
SIMPL::MomentumSpacePropagator(freeMomProp, par().mass);
|
||||
}
|
||||
if (!GFSrcDone_)
|
||||
{
|
||||
FFT fft(env().getGrid());
|
||||
auto &source = envGet(ScalarField, par().source);
|
||||
|
||||
LOG(Message) << "Caching G*F*src..." << std::endl;
|
||||
fft.FFT_all_dim(GFSrc, source, FFT::forward);
|
||||
GFSrc = freeMomProp*GFSrc;
|
||||
}
|
||||
if (!phasesDone_)
|
||||
{
|
||||
std::vector<int> &l = env().getGrid()->_fdimensions;
|
||||
Complex ci(0.0,1.0);
|
||||
|
||||
LOG(Message) << "Caching shift phases..." << std::endl;
|
||||
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
||||
{
|
||||
Real twoPiL = M_PI*2./l[mu];
|
||||
auto &phmu = envGet(ScalarField, phaseName_[mu]);
|
||||
|
||||
LatticeCoordinate(phmu, mu);
|
||||
phmu = exp(ci*twoPiL*phmu);
|
||||
phase_.push_back(&phmu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TChargedProp::momD1(ScalarField &s, FFT &fft)
|
||||
{
|
||||
EmField &A = *env().getObject<EmField>(par().emField);
|
||||
ScalarField buf(env().getGrid()), result(env().getGrid()),
|
||||
Amu(env().getGrid());
|
||||
auto &A = envGet(EmField, par().emField);
|
||||
Complex ci(0.0,1.0);
|
||||
|
||||
result = zero;
|
||||
envGetTmp(ScalarField, buf);
|
||||
envGetTmp(ScalarField, result);
|
||||
envGetTmp(ScalarField, Amu);
|
||||
|
||||
result = zero;
|
||||
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
||||
{
|
||||
Amu = peekLorentz(A, mu);
|
||||
@ -198,12 +192,13 @@ void TChargedProp::momD1(ScalarField &s, FFT &fft)
|
||||
|
||||
void TChargedProp::momD2(ScalarField &s, FFT &fft)
|
||||
{
|
||||
EmField &A = *env().getObject<EmField>(par().emField);
|
||||
ScalarField buf(env().getGrid()), result(env().getGrid()),
|
||||
Amu(env().getGrid());
|
||||
auto &A = envGet(EmField, par().emField);
|
||||
|
||||
envGetTmp(ScalarField, buf);
|
||||
envGetTmp(ScalarField, result);
|
||||
envGetTmp(ScalarField, Amu);
|
||||
|
||||
result = zero;
|
||||
|
||||
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
||||
{
|
||||
Amu = peekLorentz(A, mu);
|
||||
|
@ -43,14 +43,14 @@ protected:
|
||||
// execution
|
||||
virtual void execute(void);
|
||||
private:
|
||||
void makeCaches(void);
|
||||
void momD1(ScalarField &s, FFT &fft);
|
||||
void momD2(ScalarField &s, FFT &fft);
|
||||
private:
|
||||
std::string freeMomPropName_, GFSrcName_;
|
||||
bool freeMomPropDone_, GFSrcDone_, phasesDone_;
|
||||
std::string freeMomPropName_, GFSrcName_, fftName_;
|
||||
std::vector<std::string> phaseName_;
|
||||
ScalarField *freeMomProp_, *GFSrc_;
|
||||
std::vector<ScalarField *> phase_;
|
||||
EmField *A;
|
||||
};
|
||||
|
||||
MODULE_REGISTER_NS(ChargedProp, TChargedProp, MScalar);
|
||||
|
@ -33,38 +33,31 @@ void TFreeProp::setup(void)
|
||||
{
|
||||
freeMomPropName_ = FREEMOMPROP(par().mass);
|
||||
|
||||
if (!env().hasRegisteredObject(freeMomPropName_))
|
||||
{
|
||||
env().registerLattice<ScalarField>(freeMomPropName_);
|
||||
}
|
||||
env().registerLattice<ScalarField>(getName());
|
||||
freePropDone_ = env().hasCreatedObject(freeMomPropName_);
|
||||
envCacheLat(ScalarField, freeMomPropName_);
|
||||
envCreateLat(ScalarField, getName());
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
void TFreeProp::execute(void)
|
||||
{
|
||||
ScalarField &prop = *env().createLattice<ScalarField>(getName());
|
||||
ScalarField &source = *env().getObject<ScalarField>(par().source);
|
||||
ScalarField *freeMomProp;
|
||||
auto &freeMomProp = envGet(ScalarField, freeMomPropName_);
|
||||
auto &prop = envGet(ScalarField, getName());
|
||||
auto &source = envGet(ScalarField, par().source);
|
||||
|
||||
if (!env().hasCreatedObject(freeMomPropName_))
|
||||
if (!freePropDone_)
|
||||
{
|
||||
LOG(Message) << "Caching momentum space free scalar propagator"
|
||||
<< " (mass= " << par().mass << ")..." << std::endl;
|
||||
freeMomProp = env().createLattice<ScalarField>(freeMomPropName_);
|
||||
SIMPL::MomentumSpacePropagator(*freeMomProp, par().mass);
|
||||
}
|
||||
else
|
||||
{
|
||||
freeMomProp = env().getObject<ScalarField>(freeMomPropName_);
|
||||
SIMPL::MomentumSpacePropagator(freeMomProp, par().mass);
|
||||
}
|
||||
LOG(Message) << "Computing free scalar propagator..." << std::endl;
|
||||
SIMPL::FreePropagator(source, prop, *freeMomProp);
|
||||
SIMPL::FreePropagator(source, prop, freeMomProp);
|
||||
|
||||
if (!par().output.empty())
|
||||
{
|
||||
TextWriter writer(par().output + "." +
|
||||
std::to_string(env().getTrajectory()));
|
||||
std::to_string(vm().getTrajectory()));
|
||||
std::vector<TComplex> buf;
|
||||
std::vector<Complex> result;
|
||||
|
||||
|
@ -40,6 +40,7 @@ protected:
|
||||
virtual void execute(void);
|
||||
private:
|
||||
std::string freeMomPropName_;
|
||||
bool freePropDone_;
|
||||
};
|
||||
|
||||
MODULE_REGISTER_NS(FreeProp, TFreeProp, MScalar);
|
||||
|
@ -7,6 +7,36 @@ echo 'modules_hpp =\' >> modules.inc
|
||||
find Modules -name '*.hpp' -type f -print | sed 's/^/ /;$q;s/$/ \\/' >> modules.inc
|
||||
echo '' >> modules.inc
|
||||
rm -f Modules.hpp
|
||||
echo "/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules.hpp
|
||||
|
||||
Copyright (C) 2015
|
||||
Copyright (C) 2016
|
||||
Copyright (C) 2017
|
||||
|
||||
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 */
|
||||
" > Modules.hpp
|
||||
for f in `find Modules -name '*.hpp'`; do
|
||||
echo "#include <Grid/Hadrons/${f}>" >> Modules.hpp
|
||||
done
|
||||
|
@ -1,38 +1,43 @@
|
||||
modules_cc =\
|
||||
Modules/MGauge/Unit.cc \
|
||||
Modules/MContraction/WeakHamiltonianEye.cc \
|
||||
Modules/MContraction/WeakHamiltonianNonEye.cc \
|
||||
Modules/MContraction/WeakNeutral4ptDisc.cc \
|
||||
Modules/MContraction/WeakHamiltonianNonEye.cc \
|
||||
Modules/MGauge/Load.cc \
|
||||
Modules/MGauge/Unit.cc \
|
||||
Modules/MGauge/StochEm.cc \
|
||||
Modules/MGauge/Random.cc \
|
||||
Modules/MGauge/StochEm.cc
|
||||
Modules/MScalar/FreeProp.cc \
|
||||
Modules/MScalar/ChargedProp.cc
|
||||
|
||||
modules_hpp =\
|
||||
Modules/MAction/DWF.hpp \
|
||||
Modules/MAction/Wilson.hpp \
|
||||
Modules/MSink/Point.hpp \
|
||||
Modules/MSource/Point.hpp \
|
||||
Modules/MGauge/Load.hpp \
|
||||
Modules/MGauge/Random.hpp \
|
||||
Modules/MGauge/StochEm.hpp \
|
||||
Modules/MGauge/Unit.hpp \
|
||||
Modules/MSolver/RBPrecCG.hpp \
|
||||
Modules/MFermion/GaugeProp.hpp \
|
||||
Modules/MContraction/Baryon.hpp \
|
||||
Modules/MContraction/DiscLoop.hpp \
|
||||
Modules/MContraction/Gamma3pt.hpp \
|
||||
Modules/MContraction/Meson.hpp \
|
||||
Modules/MContraction/WardIdentity.hpp \
|
||||
Modules/MContraction/WeakHamiltonian.hpp \
|
||||
Modules/MContraction/WeakHamiltonianEye.hpp \
|
||||
Modules/MContraction/WeakHamiltonianNonEye.hpp \
|
||||
Modules/MContraction/DiscLoop.hpp \
|
||||
Modules/MContraction/WeakNeutral4ptDisc.hpp \
|
||||
Modules/MLoop/NoiseLoop.hpp \
|
||||
Modules/MSink/Smear.hpp \
|
||||
Modules/MSolver/RBPrecCG.hpp \
|
||||
Modules/MSource/SeqConserved.hpp \
|
||||
Modules/MContraction/Gamma3pt.hpp \
|
||||
Modules/MContraction/WardIdentity.hpp \
|
||||
Modules/MContraction/WeakHamiltonianEye.hpp \
|
||||
Modules/MFermion/GaugeProp.hpp \
|
||||
Modules/MSource/SeqGamma.hpp \
|
||||
Modules/MSource/Point.hpp \
|
||||
Modules/MSource/Wall.hpp \
|
||||
Modules/MSource/Z2.hpp \
|
||||
Modules/MSource/SeqConserved.hpp \
|
||||
Modules/MSink/Smear.hpp \
|
||||
Modules/MSink/Point.hpp \
|
||||
Modules/MSolver/RBPrecCG.hpp \
|
||||
Modules/MGauge/Load.hpp \
|
||||
Modules/MGauge/Unit.hpp \
|
||||
Modules/MGauge/Random.hpp \
|
||||
Modules/MGauge/StochEm.hpp \
|
||||
Modules/MUtilities/TestSeqGamma.hpp \
|
||||
Modules/MUtilities/TestSeqConserved.hpp \
|
||||
Modules/MUtilities/TestSeqGamma.hpp
|
||||
Modules/MLoop/NoiseLoop.hpp \
|
||||
Modules/MScalar/FreeProp.hpp \
|
||||
Modules/MScalar/Scalar.hpp \
|
||||
Modules/MScalar/ChargedProp.hpp \
|
||||
Modules/MAction/DWF.hpp \
|
||||
Modules/MAction/Wilson.hpp
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user