2016-02-25 12:07:21 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
Grid physics library, www.github.com/paboyle/Grid
|
|
|
|
|
2016-12-05 07:47:29 +00:00
|
|
|
Source file: programs/Hadrons/TQuark.hpp
|
2016-02-25 12:07:21 +00:00
|
|
|
|
|
|
|
Copyright (C) 2015
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
See the full license in the file "LICENSE" in the top level distribution
|
|
|
|
directory.
|
|
|
|
*******************************************************************************/
|
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
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* 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-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
|
|
|
|
{
|
2016-05-12 18:34:42 +01:00
|
|
|
source = zero;
|
2016-05-12 11:59:28 +01:00
|
|
|
PropToFerm(tmp, fullSrc, s, c);
|
2016-05-12 18:34:42 +01:00
|
|
|
InsertSlice(tmp, source, 0, 0);
|
|
|
|
InsertSlice(tmp, source, Ls_-1, 0);
|
2016-05-12 12:49:49 +01:00
|
|
|
axpby_ssp_pplus(source, 0., source, 1., source, 0, 0);
|
|
|
|
axpby_ssp_pminus(source, 0., source, 1., source, Ls_-1, Ls_-1);
|
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());
|
2016-05-12 18:34:42 +01:00
|
|
|
|
|
|
|
axpby_ssp_pminus(sol, 0., sol, 1., sol, 0, 0);
|
|
|
|
axpby_ssp_pplus(sol, 0., sol, 1., sol, 0, Ls_-1);
|
|
|
|
ExtractSlice(tmp, sol, 0, 0);
|
|
|
|
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
|
|
|
|
|
|
|
typedef TQuark<FIMPL> Quark;
|
|
|
|
|
|
|
|
MODULE_REGISTER(Quark);
|
|
|
|
|
|
|
|
END_HADRONS_NAMESPACE
|
|
|
|
|
|
|
|
#endif // Hadrons_Quark_hpp_
|