mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-13 20:57:06 +01:00
Merge branch 'feature/hadrons' of github.com:paboyle/Grid into feature/hadrons
This commit is contained in:
@ -57,9 +57,11 @@ std::vector<std::string> TStochEm::getOutput(void)
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
void TStochEm::setup(void)
|
||||
{
|
||||
create_weight = false;
|
||||
if (!env().hasCreatedObject("_" + getName() + "_weight"))
|
||||
{
|
||||
envCacheLat(EmComp, "_" + getName() + "_weight");
|
||||
create_weight = true;
|
||||
}
|
||||
envCreateLat(EmField, getName());
|
||||
}
|
||||
@ -67,13 +69,13 @@ void TStochEm::setup(void)
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
void TStochEm::execute(void)
|
||||
{
|
||||
LOG(Message) << "Generating stochatic EM potential..." << std::endl;
|
||||
LOG(Message) << "Generating stochastic EM potential..." << std::endl;
|
||||
|
||||
PhotonR photon(par().gauge, par().zmScheme);
|
||||
auto &a = envGet(EmField, getName());
|
||||
auto &w = envGet(EmComp, "_" + getName() + "_weight");
|
||||
|
||||
if (!env().hasCreatedObject("_" + getName() + "_weight"))
|
||||
if (create_weight)
|
||||
{
|
||||
LOG(Message) << "Caching stochatic EM potential weight (gauge: "
|
||||
<< par().gauge << ", zero-mode scheme: "
|
||||
|
@ -60,6 +60,8 @@ public:
|
||||
// dependency relation
|
||||
virtual std::vector<std::string> getInput(void);
|
||||
virtual std::vector<std::string> getOutput(void);
|
||||
private:
|
||||
bool create_weight;
|
||||
protected:
|
||||
// setup
|
||||
virtual void setup(void);
|
||||
|
@ -7,7 +7,8 @@ Source file: extras/Hadrons/Modules/MSource/SeqConserved.hpp
|
||||
Copyright (C) 2015-2018
|
||||
|
||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
||||
Author: Lanny91 <andrew.lawson@gmail.com>
|
||||
Author: Andrew Lawson <andrew.lawson1991@gmail.com>
|
||||
Author: Vera Guelpers <v.m.guelpers@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
|
||||
@ -38,9 +39,11 @@ BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/*
|
||||
|
||||
Sequential source
|
||||
Sequential source with insertion of conserved current.
|
||||
Additionally optional insertion of a photon field A_\mu(x).
|
||||
-----------------------------
|
||||
* src_x = q_x * theta(x_3 - tA) * theta(tB - x_3) * J_mu * exp(i x.mom)
|
||||
* src_x = sum_{mu=mu_min}^{mu_max}
|
||||
q_x * theta(x_3 - tA) * theta(tB - x_3) * J_mu * exp(i x.mom) (* A_\mu(x))
|
||||
|
||||
* options:
|
||||
- q: input propagator (string)
|
||||
@ -48,8 +51,10 @@ BEGIN_HADRONS_NAMESPACE
|
||||
- tA: begin timeslice (integer)
|
||||
- tB: end timesilce (integer)
|
||||
- curr_type: type of conserved current to insert (Current)
|
||||
- mu: Lorentz index of current to insert (integer)
|
||||
- mu_min: begin Lorentz Index (integer)
|
||||
- mu_max: end Lorentz Index (integer)
|
||||
- mom: momentum insertion, space-separated float sequence (e.g ".1 .2 1. 0.")
|
||||
- photon: optional photon field (string)
|
||||
|
||||
*/
|
||||
|
||||
@ -67,8 +72,10 @@ public:
|
||||
unsigned int, tA,
|
||||
unsigned int, tB,
|
||||
Current, curr_type,
|
||||
unsigned int, mu,
|
||||
std::string, mom);
|
||||
unsigned int, mu_min,
|
||||
unsigned int, mu_max,
|
||||
std::string, mom,
|
||||
std::string, photon);
|
||||
};
|
||||
|
||||
template <typename FImpl>
|
||||
@ -76,6 +83,8 @@ class TSeqConserved: public Module<SeqConservedPar>
|
||||
{
|
||||
public:
|
||||
FERM_TYPE_ALIASES(FImpl,);
|
||||
public:
|
||||
typedef PhotonR::GaugeField EmField;
|
||||
public:
|
||||
// constructor
|
||||
TSeqConserved(const std::string name);
|
||||
@ -89,10 +98,14 @@ protected:
|
||||
virtual void setup(void);
|
||||
// execution
|
||||
virtual void execute(void);
|
||||
private:
|
||||
bool SeqhasPhase_{false};
|
||||
std::string SeqmomphName_;
|
||||
};
|
||||
|
||||
MODULE_REGISTER_NS(SeqConserved, TSeqConserved<FIMPL>, MSource);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* TSeqConserved implementation *
|
||||
******************************************************************************/
|
||||
@ -100,6 +113,7 @@ MODULE_REGISTER_NS(SeqConserved, TSeqConserved<FIMPL>, MSource);
|
||||
template <typename FImpl>
|
||||
TSeqConserved<FImpl>::TSeqConserved(const std::string name)
|
||||
: Module<SeqConservedPar>(name)
|
||||
, SeqmomphName_ (name + "_Seqmomph")
|
||||
{}
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
@ -107,7 +121,8 @@ template <typename FImpl>
|
||||
std::vector<std::string> TSeqConserved<FImpl>::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in = {par().q, par().action};
|
||||
|
||||
if (!par().photon.empty()) in.push_back(par().photon);
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
@ -116,7 +131,7 @@ std::vector<std::string> TSeqConserved<FImpl>::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out = {getName()};
|
||||
|
||||
return out;
|
||||
return out;
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
@ -125,6 +140,10 @@ void TSeqConserved<FImpl>::setup(void)
|
||||
{
|
||||
auto Ls_ = env().getObjectLs(par().action);
|
||||
envCreateLat(PropagatorField, getName(), Ls_);
|
||||
envTmpLat(PropagatorField, "src_tmp");
|
||||
envCacheLat(LatticeComplex, SeqmomphName_);
|
||||
envTmpLat(LatticeComplex, "coor");
|
||||
envTmpLat(LatticeComplex, "latt_compl");
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
@ -134,27 +153,79 @@ void TSeqConserved<FImpl>::execute(void)
|
||||
if (par().tA == par().tB)
|
||||
{
|
||||
LOG(Message) << "Generating sequential source with conserved "
|
||||
<< par().curr_type << " current insertion (mu = "
|
||||
<< par().mu << ") at " << "t = " << par().tA << std::endl;
|
||||
<< par().curr_type << " current at "
|
||||
<< "t = " << par().tA << " summed over the indices "
|
||||
<< par().mu_min << " <= mu <= " << par().mu_max
|
||||
<< std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(Message) << "Generating sequential source with conserved "
|
||||
<< par().curr_type << " current insertion (mu = "
|
||||
<< par().mu << ") for " << par().tA << " <= t <= "
|
||||
<< par().tB << std::endl;
|
||||
<< par().curr_type << " current for "
|
||||
<< par().tA << " <= t <= "
|
||||
<< par().tB << " summed over the indices "
|
||||
<< par().mu_min << " <= mu <= " << par().mu_max
|
||||
<< std::endl;
|
||||
}
|
||||
auto &src = envGet(PropagatorField, getName());
|
||||
envGetTmp(PropagatorField, src_tmp);
|
||||
src_tmp = src;
|
||||
auto &q = envGet(PropagatorField, par().q);
|
||||
auto &mat = envGet(FMat, par().action);
|
||||
envGetTmp(LatticeComplex, latt_compl);
|
||||
|
||||
std::vector<Real> mom = strToVec<Real>(par().mom);
|
||||
mat.SeqConservedCurrent(q, src, par().curr_type, par().mu,
|
||||
mom, par().tA, par().tB);
|
||||
src = zero;
|
||||
|
||||
//exp(ipx)
|
||||
auto &mom_phase = envGet(LatticeComplex, SeqmomphName_);
|
||||
if (!SeqhasPhase_)
|
||||
{
|
||||
std::vector<Real> mom = strToVec<Real>(par().mom);
|
||||
mom_phase = zero;
|
||||
Complex i(0.0,1.0);
|
||||
envGetTmp(LatticeComplex, coor);
|
||||
for(unsigned int mu = 0; mu < env().getNd(); mu++)
|
||||
{
|
||||
LatticeCoordinate(coor, mu);
|
||||
mom_phase = mom_phase + (mom[mu]/env().getGrid()->_fdimensions[mu])*coor;
|
||||
}
|
||||
mom_phase = exp((Real)(2*M_PI)*i*mom_phase);
|
||||
SeqhasPhase_ = true;
|
||||
}
|
||||
LOG(Message) << "Inserting momentum " << strToVec<Real>(par().mom) << std::endl;
|
||||
|
||||
|
||||
|
||||
if (!par().photon.empty())
|
||||
{
|
||||
LOG(Message) << "Inserting the stochastic photon field " << par().photon << std::endl;
|
||||
}
|
||||
|
||||
for(unsigned int mu=par().mu_min;mu<=par().mu_max;mu++)
|
||||
{
|
||||
if (!par().photon.empty())
|
||||
{
|
||||
//Get the stochastic photon field, if required
|
||||
auto &stoch_photon = envGet(EmField, par().photon);
|
||||
latt_compl = PeekIndex<LorentzIndex>(stoch_photon, mu) * mom_phase;
|
||||
}
|
||||
else
|
||||
{
|
||||
latt_compl = mom_phase;
|
||||
}
|
||||
|
||||
mat.SeqConservedCurrent(q, src_tmp, par().curr_type, mu,
|
||||
par().tA, par().tB, latt_compl);
|
||||
src += src_tmp;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_SeqConserved_hpp_
|
||||
#endif // Hadrons_MSource_SeqConserved_hpp_
|
||||
|
Reference in New Issue
Block a user