2016-12-15 18:26:39 +00:00
|
|
|
/*************************************************************************************
|
|
|
|
|
2016-02-25 12:07:21 +00:00
|
|
|
Grid physics library, www.github.com/paboyle/Grid
|
|
|
|
|
2016-12-15 18:26:39 +00:00
|
|
|
Source file: extras/Hadrons/Modules/Quark.hpp
|
2016-02-25 12:07:21 +00:00
|
|
|
|
|
|
|
Copyright (C) 2015
|
2016-12-15 18:26:39 +00:00
|
|
|
Copyright (C) 2016
|
2016-02-25 12:07:21 +00:00
|
|
|
|
|
|
|
Author: Antonin Portelli <antonin.portelli@me.com>
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
2016-12-15 18:26:39 +00:00
|
|
|
See the full license in the file "LICENSE" in the top level distribution directory
|
|
|
|
*************************************************************************************/
|
2016-12-15 18:21:52 +00:00
|
|
|
/* END LEGAL */
|
2015-12-23 14:21:35 +00:00
|
|
|
|
2016-12-05 07:47:29 +00:00
|
|
|
#ifndef Hadrons_Quark_hpp_
|
|
|
|
#define Hadrons_Quark_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
|
|
|
/******************************************************************************
|
|
|
|
* TQuark *
|
|
|
|
******************************************************************************/
|
|
|
|
class QuarkPar: Serializable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GRID_SERIALIZABLE_CLASS_MEMBERS(QuarkPar,
|
|
|
|
std::string, source,
|
|
|
|
std::string, solver);
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename FImpl>
|
|
|
|
class TQuark: public Module<QuarkPar>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TYPE_ALIASES(FImpl,);
|
|
|
|
public:
|
|
|
|
// constructor
|
|
|
|
TQuark(const std::string name);
|
|
|
|
// destructor
|
|
|
|
virtual ~TQuark(void) = default;
|
|
|
|
// dependencies/products
|
|
|
|
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_;
|
|
|
|
SolverFn *solver_{nullptr};
|
|
|
|
};
|
2015-12-23 14:21:35 +00:00
|
|
|
|
2016-12-14 17:59:45 +00:00
|
|
|
MODULE_REGISTER(Quark, TQuark<FIMPL>);
|
|
|
|
|
2015-12-23 14:21:35 +00:00
|
|
|
/******************************************************************************
|
2016-12-05 07:47:29 +00:00
|
|
|
* TQuark implementation *
|
2015-12-23 14:21:35 +00:00
|
|
|
******************************************************************************/
|
|
|
|
// constructor /////////////////////////////////////////////////////////////////
|
2016-12-05 07:47:29 +00:00
|
|
|
template <typename FImpl>
|
|
|
|
TQuark<FImpl>::TQuark(const std::string name)
|
2015-12-23 14:21:35 +00:00
|
|
|
: Module(name)
|
|
|
|
{}
|
|
|
|
|
2016-05-04 00:30:29 +01:00
|
|
|
// dependencies/products ///////////////////////////////////////////////////////
|
2016-12-05 07:47:29 +00:00
|
|
|
template <typename FImpl>
|
|
|
|
std::vector<std::string> TQuark<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>
|
|
|
|
std::vector<std::string> TQuark<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>
|
|
|
|
void TQuark<FImpl>::setup(void)
|
2016-04-30 08:17:04 +01:00
|
|
|
{
|
2016-06-06 17:45:37 +01:00
|
|
|
Ls_ = env().getObjectLs(par().solver);
|
2016-12-05 07:47:29 +00:00
|
|
|
env().template registerLattice<PropagatorField>(getName());
|
2016-04-30 08:17:04 +01:00
|
|
|
if (Ls_ > 1)
|
2016-01-14 04:23:51 +00:00
|
|
|
{
|
2016-12-05 07:47:29 +00:00
|
|
|
env().template registerLattice<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>
|
|
|
|
void TQuark<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() << "'"
|
2015-12-23 14:30:33 +00:00
|
|
|
<< std::endl;
|
2016-12-05 07:47:29 +00:00
|
|
|
|
|
|
|
FermionField source(env().getGrid(Ls_)), sol(env().getGrid(Ls_)),
|
|
|
|
tmp(env().getGrid());
|
|
|
|
std::string propName = (Ls_ == 1) ? getName() : (getName() + "_5d");
|
|
|
|
PropagatorField &prop = *env().template createLattice<PropagatorField>(propName);
|
|
|
|
PropagatorField &fullSrc = *env().template getObject<PropagatorField>(par().source);
|
|
|
|
SolverFn &solver = *env().template getObject<SolverFn>(par().solver);
|
2016-05-12 18:34:42 +01:00
|
|
|
if (Ls_ > 1)
|
|
|
|
{
|
2016-12-05 07:47:29 +00:00
|
|
|
env().template createLattice<PropagatorField>(getName());
|
2016-05-12 18:34:42 +01:00
|
|
|
}
|
2016-12-05 07:47:29 +00:00
|
|
|
|
2016-05-12 11:59:28 +01:00
|
|
|
LOG(Message) << "Inverting using solver '" << par().solver
|
|
|
|
<< "' on source '" << par().source << "'" << std::endl;
|
|
|
|
for (unsigned int s = 0; s < Ns; ++s)
|
|
|
|
for (unsigned int c = 0; c < Nc; ++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
|
2016-12-05 07:47:29 +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)
|
|
|
|
{
|
|
|
|
PropToFerm(source, fullSrc, s, c);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PropToFerm(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))
|
|
|
|
{
|
|
|
|
HADRON_ERROR("Ls mismatch between quark action and source");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PropToFerm(source, fullSrc, s, c);
|
|
|
|
}
|
2016-04-30 08:17:04 +01:00
|
|
|
}
|
|
|
|
sol = zero;
|
2016-06-06 17:45:37 +01:00
|
|
|
solver(sol, source);
|
2016-05-07 21:19:38 +01:00
|
|
|
FermToProp(prop, sol, s, c);
|
2016-05-12 18:34:42 +01:00
|
|
|
// create 4D propagators from 5D one if necessary
|
|
|
|
if (Ls_ > 1)
|
|
|
|
{
|
2016-12-05 07:47:29 +00:00
|
|
|
PropagatorField &p4d =
|
|
|
|
*env().template getObject<PropagatorField>(getName());
|
2017-03-10 14:59:11 +00:00
|
|
|
make_4D(sol, tmp, Ls_);
|
2016-05-12 18:34:42 +01:00
|
|
|
FermToProp(p4d, tmp, s, c);
|
|
|
|
}
|
2016-04-30 08:17:04 +01:00
|
|
|
}
|
2015-12-23 14:21:35 +00:00
|
|
|
}
|
2016-12-05 07:47:29 +00:00
|
|
|
|
|
|
|
END_HADRONS_NAMESPACE
|
|
|
|
|
|
|
|
#endif // Hadrons_Quark_hpp_
|