2018-11-08 08:58:09 +00:00
|
|
|
/*************************************************************************************
|
|
|
|
|
|
|
|
Grid physics library, www.github.com/paboyle/Grid
|
|
|
|
|
2018-11-22 19:43:49 +00:00
|
|
|
Source file: Hadrons/Modules/MSolver/A2AAslashVectors.hpp
|
2018-11-08 08:58:09 +00:00
|
|
|
|
|
|
|
Copyright (C) 2015-2018
|
|
|
|
|
|
|
|
Author: Vera Guelpers <Vera.Guelpers@ed.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
|
|
|
|
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 */
|
2018-11-22 19:43:49 +00:00
|
|
|
#ifndef Hadrons_MSolver_A2AAslashVectors_hpp_
|
|
|
|
#define Hadrons_MSolver_A2AAslashVectors_hpp_
|
2018-11-08 08:58:09 +00:00
|
|
|
|
|
|
|
#include <Hadrons/Global.hpp>
|
|
|
|
#include <Hadrons/Module.hpp>
|
|
|
|
#include <Hadrons/ModuleFactory.hpp>
|
|
|
|
#include <Hadrons/Solver.hpp>
|
2018-11-22 19:43:49 +00:00
|
|
|
#include <Hadrons/A2AVectors.hpp>
|
2018-11-08 08:58:09 +00:00
|
|
|
|
|
|
|
BEGIN_HADRONS_NAMESPACE
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* Create all-to-all V & W vectors *
|
|
|
|
******************************************************************************/
|
|
|
|
BEGIN_MODULE_NAMESPACE(MSolver)
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Calculate a sequential propagator on an insertion of i*g_mu*A_mu
|
|
|
|
* on an A2A vector
|
|
|
|
*
|
|
|
|
* vv_i(y) = S(y,x) * i * g_mu*A_mu(x) * v_i(x)
|
|
|
|
*
|
|
|
|
* with
|
|
|
|
*
|
2018-11-13 14:54:48 +00:00
|
|
|
* - vector: A2A vector v_i(x)
|
|
|
|
* - emField: A_mu(x): electromagnetic photon field
|
2018-11-08 08:58:09 +00:00
|
|
|
* - solver: the solver for calculating the sequential propagator
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2018-11-22 19:43:49 +00:00
|
|
|
class A2AAslashVectorsPar: Serializable
|
2018-11-08 08:58:09 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-11-22 19:43:49 +00:00
|
|
|
GRID_SERIALIZABLE_CLASS_MEMBERS(A2AAslashVectorsPar,
|
2018-11-13 14:54:48 +00:00
|
|
|
std::string, vector,
|
|
|
|
std::string, emField,
|
2018-11-22 19:43:49 +00:00
|
|
|
std::string, solver,
|
|
|
|
std::string, output,
|
|
|
|
bool, multiFile);
|
2018-11-08 08:58:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename FImpl>
|
2018-11-22 19:43:49 +00:00
|
|
|
class TA2AAslashVectors : public Module<A2AAslashVectorsPar>
|
2018-11-08 08:58:09 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
FERM_TYPE_ALIASES(FImpl,);
|
|
|
|
SOLVER_TYPE_ALIASES(FImpl,);
|
|
|
|
public:
|
2018-11-22 19:43:49 +00:00
|
|
|
typedef PhotonR::GaugeField EmField;
|
2018-11-08 08:58:09 +00:00
|
|
|
public:
|
|
|
|
// constructor
|
2018-11-22 19:43:49 +00:00
|
|
|
TA2AAslashVectors(const std::string name);
|
2018-11-08 08:58:09 +00:00
|
|
|
// destructor
|
2018-11-22 19:43:49 +00:00
|
|
|
virtual ~TA2AAslashVectors(void) {};
|
2018-11-08 08:58:09 +00: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);
|
|
|
|
private:
|
|
|
|
unsigned int Ls_;
|
|
|
|
};
|
|
|
|
|
2018-11-22 19:43:49 +00:00
|
|
|
MODULE_REGISTER_TMP(A2AAslashVectors, TA2AAslashVectors<FIMPL>, MSolver);
|
|
|
|
MODULE_REGISTER_TMP(ZA2AAslashVectors, TA2AAslashVectors<ZFIMPL>, MSolver);
|
2018-11-08 08:58:09 +00:00
|
|
|
|
|
|
|
/******************************************************************************
|
2018-11-22 19:43:49 +00:00
|
|
|
* TA2AAslashVectors implementation *
|
2018-11-08 08:58:09 +00:00
|
|
|
******************************************************************************/
|
|
|
|
// constructor /////////////////////////////////////////////////////////////////
|
|
|
|
template <typename FImpl>
|
2018-11-22 19:43:49 +00:00
|
|
|
TA2AAslashVectors<FImpl>::TA2AAslashVectors(const std::string name)
|
|
|
|
: Module<A2AAslashVectorsPar>(name)
|
2018-11-08 08:58:09 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
// dependencies/products ///////////////////////////////////////////////////////
|
|
|
|
template <typename FImpl>
|
2018-11-22 19:43:49 +00:00
|
|
|
std::vector<std::string> TA2AAslashVectors<FImpl>::getInput(void)
|
2018-11-08 08:58:09 +00:00
|
|
|
{
|
2018-11-13 14:54:48 +00:00
|
|
|
std::vector<std::string> in = {par().vector, par().emField, par().solver};
|
2018-11-08 08:58:09 +00:00
|
|
|
|
|
|
|
return in;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename FImpl>
|
2018-11-22 19:43:49 +00:00
|
|
|
std::vector<std::string> TA2AAslashVectors<FImpl>::getOutput(void)
|
2018-11-08 08:58:09 +00:00
|
|
|
{
|
|
|
|
std::vector<std::string> out = {getName()};
|
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
// setup ///////////////////////////////////////////////////////////////////////
|
|
|
|
template <typename FImpl>
|
2018-11-22 19:43:49 +00:00
|
|
|
void TA2AAslashVectors<FImpl>::setup(void)
|
2018-11-08 08:58:09 +00:00
|
|
|
{
|
|
|
|
Ls_ = env().getObjectLs(par().solver);
|
2018-11-13 14:54:48 +00:00
|
|
|
auto &vvector = envGet(std::vector<FermionField>, par().vector);
|
2018-11-08 08:58:09 +00:00
|
|
|
unsigned int Nmodes = vvector.size();
|
|
|
|
envCreate(std::vector<FermionField>, getName(), 1,
|
|
|
|
Nmodes, envGetGrid(FermionField));
|
|
|
|
|
|
|
|
envTmpLat(FermionField, "v4dtmp");
|
|
|
|
envTmpLat(FermionField, "v5dtmp", Ls_);
|
|
|
|
envTmpLat(FermionField, "v5dtmp_sol", Ls_);
|
|
|
|
}
|
|
|
|
|
|
|
|
// execution ///////////////////////////////////////////////////////////////////
|
|
|
|
template <typename FImpl>
|
2018-11-22 19:43:49 +00:00
|
|
|
void TA2AAslashVectors<FImpl>::execute(void)
|
2018-11-08 08:58:09 +00:00
|
|
|
{
|
|
|
|
auto &solver = envGet(Solver, par().solver);
|
2018-11-13 14:54:48 +00:00
|
|
|
auto &stoch_photon = envGet(EmField, par().emField);
|
|
|
|
auto &vvector = envGet(std::vector<FermionField>, par().vector);
|
2018-11-08 08:58:09 +00:00
|
|
|
auto &Aslashv = envGet(std::vector<FermionField>, getName());
|
|
|
|
unsigned int Nmodes = vvector.size();
|
|
|
|
auto &mat = solver.getFMat();
|
|
|
|
envGetTmp(FermionField, v4dtmp);
|
|
|
|
envGetTmp(FermionField, v5dtmp);
|
|
|
|
envGetTmp(FermionField, v5dtmp_sol);
|
|
|
|
|
|
|
|
Complex ci(0.0,1.0);
|
|
|
|
|
|
|
|
startTimer("Seq Aslash");
|
2018-11-22 19:43:49 +00:00
|
|
|
LOG(Message) << "Calculate Sequential propagator on Aslash * v with the A2A vector "
|
|
|
|
<< par().vector << " and the photon field " << par().emField << std::endl;
|
2018-11-08 08:58:09 +00:00
|
|
|
for(unsigned int i=0; i<Nmodes; i++)
|
|
|
|
{
|
2018-11-22 19:43:49 +00:00
|
|
|
v4dtmp = zero;
|
|
|
|
startTimer("Multiply Aslash");
|
|
|
|
for(unsigned int mu=0;mu<=3;mu++)
|
|
|
|
{
|
|
|
|
Gamma gmu(Gamma::gmu[mu]);
|
|
|
|
v4dtmp += ci * PeekIndex<LorentzIndex>(stoch_photon, mu) * (gmu * vvector[i]);
|
|
|
|
}
|
|
|
|
stopTimer("Multiply Aslash");
|
|
|
|
|
|
|
|
startTimer("Inversion");
|
|
|
|
if (Ls_ == 1)
|
|
|
|
{
|
|
|
|
solver(Aslashv[i], v4dtmp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mat.ImportPhysicalFermionSource(v4dtmp, v5dtmp);
|
|
|
|
solver(v5dtmp_sol, v5dtmp);
|
|
|
|
mat.ExportPhysicalFermionSolution(v5dtmp_sol, v4dtmp);
|
|
|
|
Aslashv[i] = v4dtmp;
|
|
|
|
}
|
|
|
|
stopTimer("Inversion");
|
2018-11-08 08:58:09 +00:00
|
|
|
}
|
|
|
|
stopTimer("Seq Aslash");
|
2018-11-22 19:43:49 +00:00
|
|
|
if (!par().output.empty())
|
|
|
|
{
|
|
|
|
startTimer("I/O");
|
|
|
|
A2AVectorsIo::write(par().output, Aslashv, par().multiFile, vm().getTrajectory());
|
|
|
|
stopTimer("I/O");
|
|
|
|
}
|
2018-11-08 08:58:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
END_MODULE_NAMESPACE
|
|
|
|
|
|
|
|
END_HADRONS_NAMESPACE
|
|
|
|
|
2018-11-22 19:43:49 +00:00
|
|
|
#endif // Hadrons_MSolver_A2AAslashVectors_hpp_
|