1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-06-14 13:57:07 +01:00

Hadrons: templatisation of the fermion implementation

This commit is contained in:
2016-12-05 16:47:29 +09:00
parent 7ae734103e
commit d1f7c6b94e
18 changed files with 483 additions and 638 deletions

View File

@ -1,75 +0,0 @@
/*******************************************************************************
Grid physics library, www.github.com/paboyle/Grid
Source file: programs/Hadrons/Point.cc
Copyright (C) 2016
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.
*******************************************************************************/
#include <Grid/Hadrons/Modules/MSource/Point.hpp>
using namespace Grid;
using namespace Hadrons;
using namespace MSource;
/******************************************************************************
* Point implementation *
******************************************************************************/
// constructor /////////////////////////////////////////////////////////////////
Point::Point(const std::string name)
: Module<PointPar>(name)
{}
// dependencies/products ///////////////////////////////////////////////////////
std::vector<std::string> Point::getInput(void)
{
std::vector<std::string> in;
return in;
}
std::vector<std::string> Point::getOutput(void)
{
std::vector<std::string> out = {getName()};
return out;
}
// setup ///////////////////////////////////////////////////////////////////////
void Point::setup(void)
{
env().registerLattice<PropagatorField>(getName());
}
// execution ///////////////////////////////////////////////////////////////////
void Point::execute(void)
{
std::vector<int> position = strToVec<int>(par().position);
SpinColourMatrix id;
LOG(Message) << "Creating point source at position [" << par().position
<< "]" << std::endl;
PropagatorField &src = *env().createLattice<PropagatorField>(getName());
id = 1.;
src = zero;
pokeSite(id, src, position);
}

View File

@ -1,7 +1,7 @@
/*******************************************************************************
Grid physics library, www.github.com/paboyle/Grid
Source file: programs/Hadrons/Point.hpp
Source file: programs/Hadrons/TPoint.hpp
Copyright (C) 2016
@ -46,7 +46,7 @@ BEGIN_HADRONS_NAMESPACE
*/
/******************************************************************************
* Point *
* TPoint *
******************************************************************************/
BEGIN_MODULE_NAMESPACE(MSource)
@ -57,13 +57,16 @@ public:
std::string, position);
};
class Point: public Module<PointPar>
template <typename FImpl>
class TPoint: public Module<PointPar>
{
public:
TYPE_ALIASES(FImpl,);
public:
// constructor
Point(const std::string name);
TPoint(const std::string name);
// destructor
virtual ~Point(void) = default;
virtual ~TPoint(void) = default;
// dependency relation
virtual std::vector<std::string> getInput(void);
virtual std::vector<std::string> getOutput(void);
@ -73,6 +76,56 @@ public:
virtual void execute(void);
};
/******************************************************************************
* TPoint template implementation *
******************************************************************************/
// constructor /////////////////////////////////////////////////////////////////
template <typename FImpl>
TPoint<FImpl>::TPoint(const std::string name)
: Module<PointPar>(name)
{}
// dependencies/products ///////////////////////////////////////////////////////
template <typename FImpl>
std::vector<std::string> TPoint<FImpl>::getInput(void)
{
std::vector<std::string> in;
return in;
}
template <typename FImpl>
std::vector<std::string> TPoint<FImpl>::getOutput(void)
{
std::vector<std::string> out = {getName()};
return out;
}
// setup ///////////////////////////////////////////////////////////////////////
template <typename FImpl>
void TPoint<FImpl>::setup(void)
{
env().template registerLattice<PropagatorField>(getName());
}
// execution ///////////////////////////////////////////////////////////////////
template <typename FImpl>
void TPoint<FImpl>::execute(void)
{
std::vector<int> position = strToVec<int>(par().position);
typename SitePropagator::scalar_object id;
LOG(Message) << "Creating point source at position [" << par().position
<< "]" << std::endl;
PropagatorField &src = *env().template createLattice<PropagatorField>(getName());
id = 1.;
src = zero;
pokeSite(id, src, position);
}
typedef TPoint<FIMPL> Point;
END_MODULE_NAMESPACE
MODULE_REGISTER_NS(Point, MSource);

View File

@ -1,88 +0,0 @@
/*******************************************************************************
Grid physics library, www.github.com/paboyle/Grid
Source file: programs/Hadrons/Z2.cc
Copyright (C) 2016
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.
*******************************************************************************/
#include <Grid/Hadrons/Modules/MSource/Z2.hpp>
using namespace Grid;
using namespace Hadrons;
using namespace MSource;
/******************************************************************************
* Z2 implementation *
******************************************************************************/
// constructor /////////////////////////////////////////////////////////////////
Z2::Z2(const std::string name)
: Module<Z2Par>(name)
{}
// dependencies/products ///////////////////////////////////////////////////////
std::vector<std::string> Z2::getInput(void)
{
std::vector<std::string> in;
return in;
}
std::vector<std::string> Z2::getOutput(void)
{
std::vector<std::string> out = {getName()};
return out;
}
// setup ///////////////////////////////////////////////////////////////////////
void Z2::setup(void)
{
env().registerLattice<PropagatorField>(getName());
}
// execution ///////////////////////////////////////////////////////////////////
void Z2::execute(void)
{
Lattice<iScalar<vInteger>> t(env().getGrid());
LatticeComplex eta(env().getGrid());
LatticeFermion phi(env().getGrid());
Complex shift(1., 1.);
if (par().tA == par().tB)
{
LOG(Message) << "Generating Z_2 wall source at t= " << par().tA
<< std::endl;
}
else
{
LOG(Message) << "Generating Z_2 band for " << par().tA << " <= t <= "
<< par().tB << std::endl;
}
PropagatorField &src = *env().createLattice<PropagatorField>(getName());
LatticeCoordinate(t, Tp);
bernoulli(*env().get4dRng(), eta);
eta = (2.*eta - shift)*(1./::sqrt(2.));
eta = where((t >= par().tA) and (t <= par().tB), eta, 0.*eta);
src = 1.;
src = src*eta;
}

View File

@ -1,7 +1,7 @@
/*******************************************************************************
Grid physics library, www.github.com/paboyle/Grid
Source file: programs/Hadrons/Z2.hpp
Source file: programs/Hadrons/TZ2.hpp
Copyright (C) 2016
@ -47,7 +47,7 @@ BEGIN_HADRONS_NAMESPACE
*/
/******************************************************************************
* Z2 *
* Z2 stochastic source *
******************************************************************************/
BEGIN_MODULE_NAMESPACE(MSource)
@ -59,13 +59,16 @@ public:
unsigned int, tB);
};
class Z2: public Module<Z2Par>
template <typename FImpl>
class TZ2: public Module<Z2Par>
{
public:
TYPE_ALIASES(FImpl,);
public:
// constructor
Z2(const std::string name);
TZ2(const std::string name);
// destructor
virtual ~Z2(void) = default;
virtual ~TZ2(void) = default;
// dependency relation
virtual std::vector<std::string> getInput(void);
virtual std::vector<std::string> getOutput(void);
@ -75,6 +78,68 @@ public:
virtual void execute(void);
};
/******************************************************************************
* TZ2 template implementation *
******************************************************************************/
// constructor /////////////////////////////////////////////////////////////////
template <typename FImpl>
TZ2<FImpl>::TZ2(const std::string name)
: Module<Z2Par>(name)
{}
// dependencies/products ///////////////////////////////////////////////////////
template <typename FImpl>
std::vector<std::string> TZ2<FImpl>::getInput(void)
{
std::vector<std::string> in;
return in;
}
template <typename FImpl>
std::vector<std::string> TZ2<FImpl>::getOutput(void)
{
std::vector<std::string> out = {getName()};
return out;
}
// setup ///////////////////////////////////////////////////////////////////////
template <typename FImpl>
void TZ2<FImpl>::setup(void)
{
env().template registerLattice<PropagatorField>(getName());
}
// execution ///////////////////////////////////////////////////////////////////
template <typename FImpl>
void TZ2<FImpl>::execute(void)
{
Lattice<iScalar<vInteger>> t(env().getGrid());
LatticeComplex eta(env().getGrid());
Complex shift(1., 1.);
if (par().tA == par().tB)
{
LOG(Message) << "Generating Z_2 wall source at t= " << par().tA
<< std::endl;
}
else
{
LOG(Message) << "Generating Z_2 band for " << par().tA << " <= t <= "
<< par().tB << std::endl;
}
PropagatorField &src = *env().template createLattice<PropagatorField>(getName());
LatticeCoordinate(t, Tp);
bernoulli(*env().get4dRng(), eta);
eta = (2.*eta - shift)*(1./::sqrt(2.));
eta = where((t >= par().tA) and (t <= par().tB), eta, 0.*eta);
src = 1.;
src = src*eta;
}
typedef TZ2<FIMPL> Z2;
END_MODULE_NAMESPACE
MODULE_REGISTER_NS(Z2, MSource);