From 564738b1ff57810f46e9209840cc5daeb637157b Mon Sep 17 00:00:00 2001 From: James Harrison Date: Tue, 17 Oct 2017 14:03:57 +0100 Subject: [PATCH] Add module for unit EM field --- extras/Hadrons/Modules.hpp | 1 + extras/Hadrons/Modules/MGauge/UnitEm.cc | 68 ++++++++++++++++++++++++ extras/Hadrons/Modules/MGauge/UnitEm.hpp | 67 +++++++++++++++++++++++ extras/Hadrons/modules.inc | 2 + lib/qcd/action/gauge/Photon.h | 18 +++++++ 5 files changed, 156 insertions(+) create mode 100644 extras/Hadrons/Modules/MGauge/UnitEm.cc create mode 100644 extras/Hadrons/Modules/MGauge/UnitEm.hpp diff --git a/extras/Hadrons/Modules.hpp b/extras/Hadrons/Modules.hpp index 4e1e62f7..78bb213d 100644 --- a/extras/Hadrons/Modules.hpp +++ b/extras/Hadrons/Modules.hpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include diff --git a/extras/Hadrons/Modules/MGauge/UnitEm.cc b/extras/Hadrons/Modules/MGauge/UnitEm.cc new file mode 100644 index 00000000..906be4cc --- /dev/null +++ b/extras/Hadrons/Modules/MGauge/UnitEm.cc @@ -0,0 +1,68 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: extras/Hadrons/Modules/MGauge/StochEm.cc + +Copyright (C) 2015 +Copyright (C) 2016 + + +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 + +using namespace Grid; +using namespace Hadrons; +using namespace MGauge; + +/****************************************************************************** +* TStochEm implementation * +******************************************************************************/ +// constructor ///////////////////////////////////////////////////////////////// +TUnitEm::TUnitEm(const std::string name) +: Module(name) +{} + +// dependencies/products /////////////////////////////////////////////////////// +std::vector TUnitEm::getInput(void) +{ + return std::vector(); +} + +std::vector TUnitEm::getOutput(void) +{ + std::vector out = {getName()}; + + return out; +} + +// setup /////////////////////////////////////////////////////////////////////// +void TUnitEm::setup(void) +{ + env().registerLattice(getName()); +} + +// execution /////////////////////////////////////////////////////////////////// +void TUnitEm::execute(void) +{ + PhotonR photon(); + EmField &a = *env().createLattice(getName()); + LOG(Message) << "Generating unit EM potential..." << std::endl; + photon.UnitField(a); +} diff --git a/extras/Hadrons/Modules/MGauge/UnitEm.hpp b/extras/Hadrons/Modules/MGauge/UnitEm.hpp new file mode 100644 index 00000000..ea910929 --- /dev/null +++ b/extras/Hadrons/Modules/MGauge/UnitEm.hpp @@ -0,0 +1,67 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: extras/Hadrons/Modules/MGauge/StochEm.hpp + +Copyright (C) 2015 +Copyright (C) 2016 + + +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_MGauge_UnitEm_hpp_ +#define Hadrons_MGauge_UnitEm_hpp_ + +#include +#include +#include + +BEGIN_HADRONS_NAMESPACE + +/****************************************************************************** + * StochEm * + ******************************************************************************/ +BEGIN_MODULE_NAMESPACE(MGauge) + +class TUnitEm: public Module +{ +public: + typedef PhotonR::GaugeField EmField; + typedef PhotonR::GaugeLinkField EmComp; +public: + // constructor + TUnitEm(const std::string name); + // destructor + virtual ~TUnitEm(void) = default; + // dependency relation + virtual std::vector getInput(void); + virtual std::vector getOutput(void); + // setup + virtual void setup(void); + // execution + virtual void execute(void); +}; + +MODULE_REGISTER_NS(UnitEm, TUnitEm, MGauge); + +END_MODULE_NAMESPACE + +END_HADRONS_NAMESPACE + +#endif // Hadrons_MGauge_UnitEm_hpp_ diff --git a/extras/Hadrons/modules.inc b/extras/Hadrons/modules.inc index 29d63f58..b3c65de0 100644 --- a/extras/Hadrons/modules.inc +++ b/extras/Hadrons/modules.inc @@ -6,6 +6,7 @@ modules_cc =\ Modules/MGauge/Random.cc \ Modules/MGauge/StochEm.cc \ Modules/MGauge/Unit.cc \ + Modules/MGauge/UnitEm.cc \ Modules/MScalar/ChargedProp.cc \ Modules/MScalar/FreeProp.cc \ Modules/MScalar/ScalarVP.cc @@ -26,6 +27,7 @@ modules_hpp =\ Modules/MGauge/Random.hpp \ Modules/MGauge/StochEm.hpp \ Modules/MGauge/Unit.hpp \ + Modules/MGauge/UnitEm.hpp \ Modules/MLoop/NoiseLoop.hpp \ Modules/MScalar/ChargedProp.hpp \ Modules/MScalar/FreeProp.hpp \ diff --git a/lib/qcd/action/gauge/Photon.h b/lib/qcd/action/gauge/Photon.h index 7e21a1de..1429c2ba 100644 --- a/lib/qcd/action/gauge/Photon.h +++ b/lib/qcd/action/gauge/Photon.h @@ -68,6 +68,7 @@ namespace QCD{ void StochasticField(GaugeField &out, GridParallelRNG &rng); void StochasticField(GaugeField &out, GridParallelRNG &rng, const GaugeLinkField &weight); + void UnitField(GaugeField &out); private: void invKHatSquared(GaugeLinkField &out); void zmSub(GaugeLinkField &out); @@ -219,6 +220,23 @@ namespace QCD{ out = real(out); } + + template + void Photon::UnitField(GaugeField &out) + { + auto *grid = dynamic_cast(out._grid); + const unsigned int nd = grid->_ndimension; + GaugeLinkField r(grid); + + r = Complex(1.0,0.0); + + for(int mu = 0; mu < nd; mu++) + { + pokeLorentz(out, r, mu); + } + + out = real(out); + } // template // void Photon::FeynmanGaugeMomentumSpacePropagator_L(GaugeField &out, // const GaugeField &in)