2018-10-15 15:49:42 +01:00
|
|
|
#ifndef Hadrons_Momentum_hpp_
|
|
|
|
#define Hadrons_Momentum_hpp_
|
2018-10-12 10:59:33 +01:00
|
|
|
|
|
|
|
#include <Hadrons/Global.hpp>
|
|
|
|
#include <Hadrons/Module.hpp>
|
|
|
|
#include <Hadrons/ModuleFactory.hpp>
|
|
|
|
|
|
|
|
BEGIN_HADRONS_NAMESPACE
|
|
|
|
|
|
|
|
/*
|
|
|
|
Plane Wave source
|
|
|
|
-----------------
|
|
|
|
src_x = e^i2pi/L * p *position
|
|
|
|
*/
|
|
|
|
|
|
|
|
/******************************************************************************
|
2018-10-15 15:49:42 +01:00
|
|
|
* Plane Wave source *
|
|
|
|
******************************************************************************/
|
|
|
|
BEGIN_MODULE_NAMESPACE(MSource)
|
2018-10-12 10:59:33 +01:00
|
|
|
|
2018-10-15 15:49:42 +01:00
|
|
|
class MomentumPar: Serializable
|
|
|
|
{
|
|
|
|
public:
|
2018-10-12 10:59:33 +01:00
|
|
|
//What is meant by serializable in this context
|
2018-10-15 15:49:42 +01:00
|
|
|
GRID_SERIALIZABLE_CLASS_MEMBERS(MomentumPar,
|
2018-10-12 10:59:33 +01:00
|
|
|
std::string, mom);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <typename FImpl>
|
2018-10-15 15:49:42 +01:00
|
|
|
class TMomentum: public Module<MomentumPar>
|
2018-10-12 10:59:33 +01:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
FERM_TYPE_ALIASES(FImpl,);
|
|
|
|
public:
|
|
|
|
// constructor
|
2018-10-15 15:49:42 +01:00
|
|
|
TMomentum(const std::string name);
|
2018-10-12 10:59:33 +01:00
|
|
|
// destructor
|
2018-10-15 15:49:42 +01:00
|
|
|
virtual ~TMomentum(void) {};
|
2018-10-12 10:59:33 +01:00
|
|
|
// 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);
|
|
|
|
};
|
|
|
|
|
2018-10-15 15:49:42 +01:00
|
|
|
MODULE_REGISTER_TMP(Momentum, TMomentum<FIMPL>, MSource);
|
|
|
|
//MODULE_REGISTER_NS(Momentum, TMomentum, MSource);
|
2018-10-12 10:59:33 +01:00
|
|
|
|
|
|
|
/******************************************************************************
|
2018-10-15 15:49:42 +01:00
|
|
|
* TMomentum template implementation *
|
2018-10-12 10:59:33 +01:00
|
|
|
******************************************************************************/
|
|
|
|
// constructor /////////////////////////////////////////////////////////////////
|
|
|
|
template <typename FImpl>
|
2018-10-15 15:49:42 +01:00
|
|
|
TMomentum<FImpl>::TMomentum(const std::string name)
|
|
|
|
: Module<MomentumPar>(name)
|
2018-10-12 10:59:33 +01:00
|
|
|
{}
|
|
|
|
|
|
|
|
// dependencies/products ///////////////////////////////////////////////////////
|
|
|
|
template <typename FImpl>
|
2018-10-15 15:49:42 +01:00
|
|
|
std::vector<std::string> TMomentum<FImpl>::getInput(void)
|
2018-10-12 10:59:33 +01:00
|
|
|
{
|
|
|
|
std::vector<std::string> in;
|
|
|
|
return in;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename FImpl>
|
2018-10-15 15:49:42 +01:00
|
|
|
std::vector<std::string> TMomentum<FImpl>::getOutput(void)
|
2018-10-12 10:59:33 +01:00
|
|
|
{
|
|
|
|
std::vector<std::string> out = {getName()};
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// setup ///////////////////////////////////////////////////////////////////////
|
|
|
|
template <typename FImpl>
|
2018-10-15 15:49:42 +01:00
|
|
|
void TMomentum<FImpl>::setup(void)
|
2018-10-12 10:59:33 +01:00
|
|
|
{
|
|
|
|
envCreateLat(PropagatorField, getName());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//execution//////////////////////////////////////////////////////////////////
|
|
|
|
template <typename FImpl>
|
2018-10-15 15:49:42 +01:00
|
|
|
void TMomentum<FImpl>::execute(void)
|
2018-10-12 10:59:33 +01:00
|
|
|
{
|
|
|
|
LOG(Message) << "Generating planewave momentum source with momentum " << par().mom << std::endl;
|
|
|
|
//what does this env do?
|
|
|
|
PropagatorField &src = envGet(PropagatorField, getName());
|
|
|
|
Lattice<iScalar<vInteger>> t(env().getGrid());
|
|
|
|
LatticeComplex C(env().getGrid()), coor(env().getGrid());
|
|
|
|
std::vector<Real> p;
|
|
|
|
std::vector<Real> latt_size(GridDefaultLatt().begin(), GridDefaultLatt().end());
|
|
|
|
Complex i(0.0,1.0);
|
|
|
|
|
|
|
|
LOG(Message) << " " << std::endl;
|
|
|
|
//get the momentum from parameters
|
|
|
|
p = strToVec<Real>(par().mom);
|
|
|
|
C = zero;
|
|
|
|
LOG(Message) << "momentum converted from string - " << std::to_string(p[0]) <<std::to_string(p[1]) <<std::to_string(p[2]) << std::to_string(p[3]) << std::endl;
|
|
|
|
for(int mu=0;mu<4;mu++){
|
|
|
|
Real TwoPiL = M_PI * 2.0/ latt_size[mu];
|
|
|
|
LatticeCoordinate(coor,mu);
|
|
|
|
C = C +(TwoPiL * p[mu]) * coor;
|
|
|
|
}
|
|
|
|
C = exp(C*i);
|
|
|
|
LOG(Message) << "exponential of pdotx taken " << std::endl;
|
|
|
|
src = src + C;
|
|
|
|
LOG(Message) << "source created" << std::endl;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
END_MODULE_NAMESPACE
|
|
|
|
|
|
|
|
END_HADRONS_NAMESPACE
|
|
|
|
|
2018-10-15 15:49:42 +01:00
|
|
|
#endif // Hadrons_Momentum_hpp_
|