2017-07-31 12:26:34 +01:00
|
|
|
/*************************************************************************************
|
|
|
|
|
|
|
|
Grid physics library, www.github.com/paboyle/Grid
|
|
|
|
|
|
|
|
Source file: extras/Hadrons/Modules/MFermion/GaugeProp.hpp
|
|
|
|
|
2017-12-26 13:16:47 +00:00
|
|
|
Copyright (C) 2015-2018
|
2017-07-31 12:26:34 +01:00
|
|
|
|
|
|
|
Author: Antonin Portelli <antonin.portelli@me.com>
|
2018-02-26 19:24:19 +00:00
|
|
|
Author: Guido Cossu <guido.cossu@ed.ac.uk>
|
2017-12-26 13:16:47 +00:00
|
|
|
Author: Lanny91 <andrew.lawson@gmail.com>
|
2018-02-26 19:24:19 +00:00
|
|
|
Author: pretidav <david.preti@csic.es>
|
2017-07-31 12:26:34 +01: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 */
|
|
|
|
|
2017-06-08 02:10:48 +01:00
|
|
|
#ifndef Hadrons_MFermion_GaugeProp_hpp_
|
|
|
|
#define Hadrons_MFermion_GaugeProp_hpp_
|
2015-12-23 14:21:35 +00:00
|
|
|
|
2016-12-05 07:47:29 +00:00
|
|
|
#include <Grid/Hadrons/Global.hpp>
|
|
|
|
#include <Grid/Hadrons/Module.hpp>
|
|
|
|
#include <Grid/Hadrons/ModuleFactory.hpp>
|
|
|
|
|
|
|
|
BEGIN_HADRONS_NAMESPACE
|
|
|
|
|
2017-03-10 14:59:11 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* 5D -> 4D and 4D -> 5D conversions. *
|
|
|
|
******************************************************************************/
|
|
|
|
template<class vobj> // Note that 5D object is modified.
|
|
|
|
inline void make_4D(Lattice<vobj> &in_5d, Lattice<vobj> &out_4d, int Ls)
|
|
|
|
{
|
|
|
|
axpby_ssp_pminus(in_5d, 0., in_5d, 1., in_5d, 0, 0);
|
|
|
|
axpby_ssp_pplus(in_5d, 1., in_5d, 1., in_5d, 0, Ls-1);
|
|
|
|
ExtractSlice(out_4d, in_5d, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class vobj>
|
2017-04-26 12:39:07 +01:00
|
|
|
inline void make_5D(Lattice<vobj> &in_4d, Lattice<vobj> &out_5d, int Ls)
|
2017-03-10 14:59:11 +00:00
|
|
|
{
|
|
|
|
out_5d = zero;
|
|
|
|
InsertSlice(in_4d, out_5d, 0, 0);
|
|
|
|
InsertSlice(in_4d, out_5d, Ls-1, 0);
|
|
|
|
axpby_ssp_pplus(out_5d, 0., out_5d, 1., out_5d, 0, 0);
|
|
|
|
axpby_ssp_pminus(out_5d, 0., out_5d, 1., out_5d, Ls-1, Ls-1);
|
|
|
|
}
|
|
|
|
|
2016-12-05 07:47:29 +00:00
|
|
|
/******************************************************************************
|
2017-06-08 02:10:48 +01:00
|
|
|
* GaugeProp *
|
2016-12-05 07:47:29 +00:00
|
|
|
******************************************************************************/
|
2017-06-08 02:10:48 +01:00
|
|
|
BEGIN_MODULE_NAMESPACE(MFermion)
|
|
|
|
|
|
|
|
class GaugePropPar: Serializable
|
2016-12-05 07:47:29 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-06-08 02:10:48 +01:00
|
|
|
GRID_SERIALIZABLE_CLASS_MEMBERS(GaugePropPar,
|
2016-12-05 07:47:29 +00:00
|
|
|
std::string, source,
|
|
|
|
std::string, solver);
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename FImpl>
|
2017-06-08 02:10:48 +01:00
|
|
|
class TGaugeProp: public Module<GaugePropPar>
|
2016-12-05 07:47:29 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-06-06 17:45:30 +01:00
|
|
|
FGS_TYPE_ALIASES(FImpl,);
|
2016-12-05 07:47:29 +00:00
|
|
|
public:
|
|
|
|
// constructor
|
2017-06-08 02:10:48 +01:00
|
|
|
TGaugeProp(const std::string name);
|
2016-12-05 07:47:29 +00:00
|
|
|
// destructor
|
2018-04-24 17:20:25 +01:00
|
|
|
virtual ~TGaugeProp(void) {};
|
2017-06-08 02:10:48 +01:00
|
|
|
// dependency relation
|
2016-12-05 07:47:29 +00:00
|
|
|
virtual std::vector<std::string> getInput(void);
|
|
|
|
virtual std::vector<std::string> getOutput(void);
|
2017-12-03 18:46:18 +00:00
|
|
|
protected:
|
2016-12-05 07:47:29 +00:00
|
|
|
// setup
|
|
|
|
virtual void setup(void);
|
|
|
|
// execution
|
|
|
|
virtual void execute(void);
|
|
|
|
private:
|
|
|
|
unsigned int Ls_;
|
|
|
|
SolverFn *solver_{nullptr};
|
|
|
|
};
|
2015-12-23 14:21:35 +00:00
|
|
|
|
2018-04-23 17:35:01 +01:00
|
|
|
MODULE_REGISTER_TMP(GaugeProp, TGaugeProp<FIMPL>, MFermion);
|
2015-12-23 14:21:35 +00:00
|
|
|
/******************************************************************************
|
2017-06-08 02:10:48 +01:00
|
|
|
* TGaugeProp implementation *
|
2015-12-23 14:21:35 +00:00
|
|
|
******************************************************************************/
|
|
|
|
// constructor /////////////////////////////////////////////////////////////////
|
2016-12-05 07:47:29 +00:00
|
|
|
template <typename FImpl>
|
2017-06-08 02:10:48 +01:00
|
|
|
TGaugeProp<FImpl>::TGaugeProp(const std::string name)
|
|
|
|
: Module<GaugePropPar>(name)
|
2015-12-23 14:21:35 +00:00
|
|
|
{}
|
|
|
|
|
2016-05-04 00:30:29 +01:00
|
|
|
// dependencies/products ///////////////////////////////////////////////////////
|
2016-12-05 07:47:29 +00:00
|
|
|
template <typename FImpl>
|
2017-06-08 02:10:48 +01:00
|
|
|
std::vector<std::string> TGaugeProp<FImpl>::getInput(void)
|
2015-12-23 14:21:35 +00:00
|
|
|
{
|
2016-05-12 11:59:28 +01:00
|
|
|
std::vector<std::string> in = {par().source, par().solver};
|
2016-04-30 08:17:04 +01:00
|
|
|
|
|
|
|
return in;
|
2015-12-23 14:21:35 +00:00
|
|
|
}
|
|
|
|
|
2016-12-05 07:47:29 +00:00
|
|
|
template <typename FImpl>
|
2017-06-08 02:10:48 +01:00
|
|
|
std::vector<std::string> TGaugeProp<FImpl>::getOutput(void)
|
2015-12-23 14:21:35 +00:00
|
|
|
{
|
2015-12-23 14:30:33 +00:00
|
|
|
std::vector<std::string> out = {getName(), getName() + "_5d"};
|
2015-12-23 14:21:35 +00:00
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2016-04-30 08:17:04 +01:00
|
|
|
// setup ///////////////////////////////////////////////////////////////////////
|
2016-12-05 07:47:29 +00:00
|
|
|
template <typename FImpl>
|
2017-06-08 02:10:48 +01:00
|
|
|
void TGaugeProp<FImpl>::setup(void)
|
2016-04-30 08:17:04 +01:00
|
|
|
{
|
2016-06-06 17:45:37 +01:00
|
|
|
Ls_ = env().getObjectLs(par().solver);
|
2017-12-01 19:38:23 +00:00
|
|
|
envCreateLat(PropagatorField, getName());
|
|
|
|
envTmpLat(FermionField, "source", Ls_);
|
|
|
|
envTmpLat(FermionField, "sol", Ls_);
|
|
|
|
envTmpLat(FermionField, "tmp");
|
2016-04-30 08:17:04 +01:00
|
|
|
if (Ls_ > 1)
|
2016-01-14 04:23:51 +00:00
|
|
|
{
|
2017-12-01 19:38:23 +00:00
|
|
|
envCreateLat(PropagatorField, getName() + "_5d", Ls_);
|
2016-01-14 04:23:51 +00:00
|
|
|
}
|
2015-12-23 14:21:35 +00:00
|
|
|
}
|
|
|
|
|
2016-05-04 00:30:29 +01:00
|
|
|
// execution ///////////////////////////////////////////////////////////////////
|
2016-12-05 07:47:29 +00:00
|
|
|
template <typename FImpl>
|
2017-06-08 02:10:48 +01:00
|
|
|
void TGaugeProp<FImpl>::execute(void)
|
2015-12-23 14:21:35 +00:00
|
|
|
{
|
2016-05-04 20:17:27 +01:00
|
|
|
LOG(Message) << "Computing quark propagator '" << getName() << "'"
|
2017-12-01 19:38:23 +00:00
|
|
|
<< std::endl;
|
2016-12-05 07:47:29 +00:00
|
|
|
|
2017-12-13 19:41:41 +00:00
|
|
|
std::string propName = (Ls_ == 1) ? getName() : (getName() + "_5d");
|
|
|
|
auto &prop = envGet(PropagatorField, propName);
|
|
|
|
auto &fullSrc = envGet(PropagatorField, par().source);
|
|
|
|
auto &solver = envGet(SolverFn, par().solver);
|
2016-12-05 07:47:29 +00:00
|
|
|
|
2017-12-13 19:41:41 +00:00
|
|
|
envGetTmp(FermionField, source);
|
|
|
|
envGetTmp(FermionField, sol);
|
|
|
|
envGetTmp(FermionField, tmp);
|
2016-05-12 11:59:28 +01:00
|
|
|
LOG(Message) << "Inverting using solver '" << par().solver
|
2017-12-01 19:38:23 +00:00
|
|
|
<< "' on source '" << par().source << "'" << std::endl;
|
2016-05-12 11:59:28 +01:00
|
|
|
for (unsigned int s = 0; s < Ns; ++s)
|
2017-12-22 18:02:07 +00:00
|
|
|
for (unsigned int c = 0; c < FImpl::Dimension; ++c)
|
2016-04-30 08:17:04 +01:00
|
|
|
{
|
2016-06-06 17:45:37 +01:00
|
|
|
LOG(Message) << "Inversion for spin= " << s << ", color= " << c
|
2017-12-13 19:41:41 +00:00
|
|
|
<< std::endl;
|
2016-05-12 11:59:28 +01:00
|
|
|
// source conversion for 4D sources
|
|
|
|
if (!env().isObject5d(par().source))
|
2016-04-30 08:17:04 +01:00
|
|
|
{
|
2016-05-12 11:59:28 +01:00
|
|
|
if (Ls_ == 1)
|
|
|
|
{
|
2017-12-22 18:02:07 +00:00
|
|
|
PropToFerm<FImpl>(source, fullSrc, s, c);
|
2016-05-12 11:59:28 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-22 18:02:07 +00:00
|
|
|
PropToFerm<FImpl>(tmp, fullSrc, s, c);
|
2017-03-10 14:59:11 +00:00
|
|
|
make_5D(tmp, source, Ls_);
|
2016-05-12 11:59:28 +01:00
|
|
|
}
|
2016-04-30 08:17:04 +01:00
|
|
|
}
|
2016-05-12 11:59:28 +01:00
|
|
|
// source conversion for 5D sources
|
2016-04-30 08:17:04 +01:00
|
|
|
else
|
|
|
|
{
|
2016-05-12 11:59:28 +01:00
|
|
|
if (Ls_ != env().getObjectLs(par().source))
|
|
|
|
{
|
2018-04-25 16:49:14 +01:00
|
|
|
HADRONS_ERROR(Size, "Ls mismatch between quark action and source");
|
2016-05-12 11:59:28 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-22 18:02:07 +00:00
|
|
|
PropToFerm<FImpl>(source, fullSrc, s, c);
|
2016-05-12 11:59:28 +01:00
|
|
|
}
|
2016-04-30 08:17:04 +01:00
|
|
|
}
|
|
|
|
sol = zero;
|
2016-06-06 17:45:37 +01:00
|
|
|
solver(sol, source);
|
2017-12-22 18:02:07 +00:00
|
|
|
FermToProp<FImpl>(prop, sol, s, c);
|
2016-05-12 18:34:42 +01:00
|
|
|
// create 4D propagators from 5D one if necessary
|
|
|
|
if (Ls_ > 1)
|
|
|
|
{
|
2017-12-01 19:38:23 +00:00
|
|
|
PropagatorField &p4d = envGet(PropagatorField, getName());
|
2017-03-10 14:59:11 +00:00
|
|
|
make_4D(sol, tmp, Ls_);
|
2017-12-22 18:02:07 +00:00
|
|
|
FermToProp<FImpl>(p4d, tmp, s, c);
|
2016-05-12 18:34:42 +01:00
|
|
|
}
|
2016-04-30 08:17:04 +01:00
|
|
|
}
|
2015-12-23 14:21:35 +00:00
|
|
|
}
|
2016-12-05 07:47:29 +00:00
|
|
|
|
2017-06-08 02:10:48 +01:00
|
|
|
END_MODULE_NAMESPACE
|
|
|
|
|
2016-12-05 07:47:29 +00:00
|
|
|
END_HADRONS_NAMESPACE
|
|
|
|
|
2017-06-08 02:10:48 +01:00
|
|
|
#endif // Hadrons_MFermion_GaugeProp_hpp_
|