1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-14 09:45:36 +00:00
Grid/Hadrons/Modules/MGauge/StochEm.cc

86 lines
3.0 KiB
C++
Raw Normal View History

2016-12-21 23:29:41 +00:00
/*************************************************************************************
Grid physics library, www.github.com/paboyle/Grid
2018-09-01 21:30:30 +01:00
Source file: Hadrons/Modules/MGauge/StochEm.cc
2016-12-21 23:29:41 +00:00
2017-12-26 13:16:47 +00:00
Copyright (C) 2015-2018
2016-12-21 23:29:41 +00:00
2017-12-26 13:16:47 +00:00
Author: Antonin Portelli <antonin.portelli@me.com>
Author: James Harrison <jch1g10@soton.ac.uk>
2018-04-23 17:36:20 +01:00
Author: Vera Guelpers <vmg1n14@soton.ac.uk>
2016-12-21 23:29:41 +00:00
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/MGauge/StochEm.hpp>
2016-12-21 23:29:41 +00:00
using namespace Grid;
using namespace Hadrons;
using namespace MGauge;
/******************************************************************************
* TStochEm implementation *
******************************************************************************/
// constructor /////////////////////////////////////////////////////////////////
TStochEm::TStochEm(const std::string name)
: Module<StochEmPar>(name)
{}
// dependencies/products ///////////////////////////////////////////////////////
std::vector<std::string> TStochEm::getInput(void)
{
std::vector<std::string> in;
return in;
}
std::vector<std::string> TStochEm::getOutput(void)
{
std::vector<std::string> out = {getName()};
return out;
}
// setup ///////////////////////////////////////////////////////////////////////
void TStochEm::setup(void)
{
weightDone_ = env().hasCreatedObject("_" + getName() + "_weight");
envCacheLat(EmComp, "_" + getName() + "_weight");
envCreateLat(EmField, getName());
2016-12-21 23:29:41 +00:00
}
// execution ///////////////////////////////////////////////////////////////////
void TStochEm::execute(void)
{
LOG(Message) << "Generating stochastic EM potential..." << std::endl;
std::vector<Real> improvements = strToVec<Real>(par().improvement);
PhotonR photon(envGetGrid(EmField), par().gauge, par().zmScheme, improvements);
auto &a = envGet(EmField, getName());
auto &w = envGet(EmComp, "_" + getName() + "_weight");
2016-12-21 23:29:41 +00:00
if (!weightDone_)
2016-12-21 23:29:41 +00:00
{
LOG(Message) << "Caching stochastic EM potential weight (gauge: "
2016-12-21 23:29:41 +00:00
<< par().gauge << ", zero-mode scheme: "
<< par().zmScheme << ")..." << std::endl;
photon.StochasticWeight(w);
2016-12-21 23:29:41 +00:00
}
photon.StochasticField(a, rng4d(), w);
2016-12-21 23:29:41 +00:00
}