mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-17 15:27:06 +01:00
Hadrons: modules moved in their own directory & utility script to add new modules
This commit is contained in:
83
programs/Hadrons/modules/AWilson.cc
Normal file
83
programs/Hadrons/modules/AWilson.cc
Normal file
@ -0,0 +1,83 @@
|
||||
/*******************************************************************************
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: programs/Hadrons/AWilson.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 <Hadrons/Modules/AWilson.hpp>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace Hadrons;
|
||||
|
||||
/******************************************************************************
|
||||
* AWilson implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
AWilson::AWilson(const std::string name)
|
||||
: Module(name)
|
||||
{}
|
||||
|
||||
// parse parameters ////////////////////////////////////////////////////////////
|
||||
void AWilson::parseParameters(XmlReader &reader, const std::string name)
|
||||
{
|
||||
read(reader, name, par_);
|
||||
}
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
std::vector<std::string> AWilson::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in = {par_.gauge};
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
std::vector<std::string> AWilson::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out = {getName()};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
void AWilson::setup(void)
|
||||
{
|
||||
unsigned int size;
|
||||
|
||||
size = 3*env().lattice4dSize<WilsonFermionR::DoubledGaugeField>();
|
||||
env().registerObject(getName(), size);
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
void AWilson::execute()
|
||||
{
|
||||
auto &U = *env().get<LatticeGaugeField>(par_.gauge);
|
||||
auto &grid = *env().getGrid();
|
||||
auto &gridRb = *env().getRbGrid();
|
||||
auto fMatPt = new WilsonFermionR(U, grid, gridRb, par_.mass);
|
||||
unsigned int size;
|
||||
|
||||
LOG(Message) << "Setting up Wilson fermion matrix with m= " << par_.mass
|
||||
<< " using gauge field '" << par_.gauge << "'" << std::endl;
|
||||
env().addFermionMatrix(getName(), fMatPt);
|
||||
}
|
71
programs/Hadrons/modules/AWilson.hpp
Normal file
71
programs/Hadrons/modules/AWilson.hpp
Normal file
@ -0,0 +1,71 @@
|
||||
/*******************************************************************************
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: programs/Hadrons/AWilson.hpp
|
||||
|
||||
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.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef Hadrons_AWilson_hpp_
|
||||
#define Hadrons_AWilson_hpp_
|
||||
|
||||
#include <Hadrons/Global.hpp>
|
||||
#include <Hadrons/Module.hpp>
|
||||
#include <Hadrons/ModuleFactory.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* Wilson quark action *
|
||||
******************************************************************************/
|
||||
class AWilson: public Module
|
||||
{
|
||||
public:
|
||||
class Par: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(Par, std::string, gauge,
|
||||
double , mass);
|
||||
};
|
||||
public:
|
||||
// constructor
|
||||
AWilson(const std::string name);
|
||||
// destructor
|
||||
virtual ~AWilson(void) = default;
|
||||
// parse parameters
|
||||
virtual void parseParameters(XmlReader &reader, const std::string name);
|
||||
// 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:
|
||||
Par par_;
|
||||
};
|
||||
|
||||
MODULE_REGISTER(AWilson);
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_AWilson_hpp_
|
100
programs/Hadrons/modules/CMeson.cc
Normal file
100
programs/Hadrons/modules/CMeson.cc
Normal file
@ -0,0 +1,100 @@
|
||||
/*******************************************************************************
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: programs/Hadrons/CMeson.cc
|
||||
|
||||
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.
|
||||
*******************************************************************************/
|
||||
|
||||
#include <Hadrons/Modules/CMeson.hpp>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace QCD;
|
||||
using namespace Hadrons;
|
||||
|
||||
/******************************************************************************
|
||||
* CMeson implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
CMeson::CMeson(const std::string name)
|
||||
: Module(name)
|
||||
{}
|
||||
|
||||
// parse parameters ////////////////////////////////////////////////////////////
|
||||
void CMeson::parseParameters(XmlReader &reader, const std::string name)
|
||||
{
|
||||
read(reader, name, par_);
|
||||
}
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
std::vector<std::string> CMeson::getInput(void)
|
||||
{
|
||||
std::vector<std::string> input = {par_.q1, par_.q2};
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
std::vector<std::string> CMeson::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> output = {getName()};
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
void CMeson::execute(void)
|
||||
{
|
||||
LOG(Message) << "Computing meson contraction '" << getName() << "' using"
|
||||
<< " quarks '" << par_.q1 << "' and '" << par_.q2 << "'"
|
||||
<< std::endl;
|
||||
|
||||
XmlWriter writer(par_.output);
|
||||
LatticePropagator &q1 = *env().get<LatticePropagator>(par_.q1);
|
||||
LatticePropagator &q2 = *env().get<LatticePropagator>(par_.q2);
|
||||
LatticeComplex c(env().getGrid());
|
||||
SpinMatrix g[Ns*Ns], g5;
|
||||
std::vector<TComplex> buf;
|
||||
Result result;
|
||||
unsigned int nt = env().getGrid()->GlobalDimensions()[Tp];
|
||||
|
||||
g5 = makeGammaProd(Ns*Ns - 1);
|
||||
result.corr.resize(Ns*Ns);
|
||||
for (unsigned int i = 0; i < Ns*Ns; ++i)
|
||||
{
|
||||
g[i] = makeGammaProd(i);
|
||||
}
|
||||
for (unsigned int iSink = 0; iSink < Ns*Ns; ++iSink)
|
||||
{
|
||||
result.corr[iSink].resize(Ns*Ns);
|
||||
for (unsigned int iSrc = 0; iSrc < Ns*Ns; ++iSrc)
|
||||
{
|
||||
c = trace(g[iSink]*q1*g[iSrc]*g5*adj(q2)*g5);
|
||||
sliceSum(c, buf, Tp);
|
||||
result.corr[iSink][iSrc].resize(buf.size());
|
||||
for (unsigned int t = 0; t < buf.size(); ++t)
|
||||
{
|
||||
result.corr[iSink][iSrc][t] = TensorRemove(buf[t]);
|
||||
}
|
||||
}
|
||||
}
|
||||
write(writer, "meson", result);
|
||||
}
|
77
programs/Hadrons/modules/CMeson.hpp
Normal file
77
programs/Hadrons/modules/CMeson.hpp
Normal file
@ -0,0 +1,77 @@
|
||||
/*******************************************************************************
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: programs/Hadrons/CMeson.hpp
|
||||
|
||||
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.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef Hadrons_CMeson_hpp_
|
||||
#define Hadrons_CMeson_hpp_
|
||||
|
||||
#include <Hadrons/Global.hpp>
|
||||
#include <Hadrons/Module.hpp>
|
||||
#include <Hadrons/ModuleFactory.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* CMeson *
|
||||
******************************************************************************/
|
||||
class CMeson: public Module
|
||||
{
|
||||
public:
|
||||
class Par: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(Par,
|
||||
std::string, q1,
|
||||
std::string, q2,
|
||||
std::string, output);
|
||||
};
|
||||
class Result: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(Result,
|
||||
std::vector<std::vector<std::vector<Complex>>>, corr);
|
||||
};
|
||||
public:
|
||||
// constructor
|
||||
CMeson(const std::string name);
|
||||
// destructor
|
||||
virtual ~CMeson(void) = default;
|
||||
// parse parameters
|
||||
virtual void parseParameters(XmlReader &reader, const std::string name);
|
||||
// dependencies/products
|
||||
virtual std::vector<std::string> getInput(void);
|
||||
virtual std::vector<std::string> getOutput(void);
|
||||
// execution
|
||||
virtual void execute(void);
|
||||
private:
|
||||
Par par_;
|
||||
};
|
||||
|
||||
MODULE_REGISTER(CMeson);
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_CMeson_hpp_
|
81
programs/Hadrons/modules/GLoad.cc
Normal file
81
programs/Hadrons/modules/GLoad.cc
Normal file
@ -0,0 +1,81 @@
|
||||
/*******************************************************************************
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: programs/Hadrons/GLoad.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 <Hadrons/Modules/GLoad.hpp>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace Hadrons;
|
||||
|
||||
/******************************************************************************
|
||||
* GLoad implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
GLoad::GLoad(const std::string name)
|
||||
: Module(name)
|
||||
{}
|
||||
|
||||
// parse parameters ////////////////////////////////////////////////////////////
|
||||
void GLoad::parseParameters(XmlReader &reader, const std::string name)
|
||||
{
|
||||
read(reader, name, par_);
|
||||
}
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
std::vector<std::string> GLoad::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
std::vector<std::string> GLoad::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out = {getName()};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
void GLoad::setup(void)
|
||||
{
|
||||
env().registerLattice<LatticeGaugeField>(getName());
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
void GLoad::execute(void)
|
||||
{
|
||||
NerscField header;
|
||||
std::string fileName = par_.file + "."
|
||||
+ std::to_string(env().getTrajectory());
|
||||
|
||||
LOG(Message) << "Loading NERSC configuration from file '" << fileName
|
||||
<< "'" << std::endl;
|
||||
LatticeGaugeField &U = *env().create<LatticeGaugeField>(getName());
|
||||
NerscIO::readConfiguration(U, header, fileName);
|
||||
LOG(Message) << "NERSC header:" << std::endl;
|
||||
dump_nersc_header(header, LOG(Message));
|
||||
}
|
70
programs/Hadrons/modules/GLoad.hpp
Normal file
70
programs/Hadrons/modules/GLoad.hpp
Normal file
@ -0,0 +1,70 @@
|
||||
/*******************************************************************************
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: programs/Hadrons/GLoad.hpp
|
||||
|
||||
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.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef Hadrons_GLoad_hpp_
|
||||
#define Hadrons_GLoad_hpp_
|
||||
|
||||
#include <Hadrons/Global.hpp>
|
||||
#include <Hadrons/Module.hpp>
|
||||
#include <Hadrons/ModuleFactory.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* Load a NERSC configuration *
|
||||
******************************************************************************/
|
||||
class GLoad: public Module
|
||||
{
|
||||
public:
|
||||
class Par: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(Par, std::string, file);
|
||||
};
|
||||
public:
|
||||
// constructor
|
||||
GLoad(const std::string name);
|
||||
// destructor
|
||||
virtual ~GLoad(void) = default;
|
||||
// parse parameters
|
||||
virtual void parseParameters(XmlReader &reader, const std::string name);
|
||||
// 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:
|
||||
Par par_;
|
||||
};
|
||||
|
||||
MODULE_REGISTER(GLoad);
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_GLoad_hpp_
|
66
programs/Hadrons/modules/GRandom.cc
Normal file
66
programs/Hadrons/modules/GRandom.cc
Normal file
@ -0,0 +1,66 @@
|
||||
/*******************************************************************************
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: programs/Hadrons/GRandom.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 <Hadrons/Modules/GRandom.hpp>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace Hadrons;
|
||||
|
||||
/******************************************************************************
|
||||
* GRandom implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
GRandom::GRandom(const std::string name)
|
||||
: Module(name)
|
||||
{}
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
std::vector<std::string> GRandom::getInput(void)
|
||||
{
|
||||
return std::vector<std::string>();
|
||||
}
|
||||
|
||||
std::vector<std::string> GRandom::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out = {getName()};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
void GRandom::setup(void)
|
||||
{
|
||||
env().registerLattice<LatticeGaugeField>(getName());
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
void GRandom::execute(void)
|
||||
{
|
||||
LOG(Message) << "Generating random gauge configuration" << std::endl;
|
||||
LatticeGaugeField &U = *env().create<LatticeGaugeField>(getName());
|
||||
SU3::HotConfiguration(*env().get4dRng(), U);
|
||||
}
|
60
programs/Hadrons/modules/GRandom.hpp
Normal file
60
programs/Hadrons/modules/GRandom.hpp
Normal file
@ -0,0 +1,60 @@
|
||||
/*******************************************************************************
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: programs/Hadrons/GRandom.hpp
|
||||
|
||||
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.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef Hadrons_GRandom_hpp_
|
||||
#define Hadrons_GRandom_hpp_
|
||||
|
||||
#include <Hadrons/Global.hpp>
|
||||
#include <Hadrons/Module.hpp>
|
||||
#include <Hadrons/ModuleFactory.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* Random gauge *
|
||||
******************************************************************************/
|
||||
class GRandom: public Module
|
||||
{
|
||||
public:
|
||||
// constructor
|
||||
GRandom(const std::string name);
|
||||
// destructor
|
||||
virtual ~GRandom(void) = default;
|
||||
// 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);
|
||||
};
|
||||
|
||||
MODULE_REGISTER(GRandom);
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_GRandom_hpp_
|
66
programs/Hadrons/modules/GUnit.cc
Normal file
66
programs/Hadrons/modules/GUnit.cc
Normal file
@ -0,0 +1,66 @@
|
||||
/*******************************************************************************
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: programs/Hadrons/GUnit.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 <Hadrons/Modules/GUnit.hpp>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace Hadrons;
|
||||
|
||||
/******************************************************************************
|
||||
* GUnit implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
GUnit::GUnit(const std::string name)
|
||||
: Module(name)
|
||||
{}
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
std::vector<std::string> GUnit::getInput(void)
|
||||
{
|
||||
return std::vector<std::string>();
|
||||
}
|
||||
|
||||
std::vector<std::string> GUnit::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out = {getName()};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
void GUnit::setup(void)
|
||||
{
|
||||
env().registerLattice<LatticeGaugeField>(getName());
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
void GUnit::execute(void)
|
||||
{
|
||||
LOG(Message) << "Creating unit gauge configuration" << std::endl;
|
||||
LatticeGaugeField &U = *env().create<LatticeGaugeField>(getName());
|
||||
SU3::ColdConfiguration(*env().get4dRng(), U);
|
||||
}
|
60
programs/Hadrons/modules/GUnit.hpp
Normal file
60
programs/Hadrons/modules/GUnit.hpp
Normal file
@ -0,0 +1,60 @@
|
||||
/*******************************************************************************
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: programs/Hadrons/GUnit.hpp
|
||||
|
||||
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.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef Hadrons_GUnit_hpp_
|
||||
#define Hadrons_GUnit_hpp_
|
||||
|
||||
#include <Hadrons/Global.hpp>
|
||||
#include <Hadrons/Module.hpp>
|
||||
#include <Hadrons/ModuleFactory.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* Unit gauge *
|
||||
******************************************************************************/
|
||||
class GUnit: public Module
|
||||
{
|
||||
public:
|
||||
// constructor
|
||||
GUnit(const std::string name);
|
||||
// destructor
|
||||
virtual ~GUnit(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);
|
||||
};
|
||||
|
||||
MODULE_REGISTER(GUnit);
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_GUnit_hpp_
|
127
programs/Hadrons/modules/MQuark.cc
Normal file
127
programs/Hadrons/modules/MQuark.cc
Normal file
@ -0,0 +1,127 @@
|
||||
/*******************************************************************************
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: programs/Hadrons/MQuark.cc
|
||||
|
||||
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.
|
||||
*******************************************************************************/
|
||||
|
||||
#include <Hadrons/Modules/MQuark.hpp>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace QCD;
|
||||
using namespace Hadrons;
|
||||
|
||||
/******************************************************************************
|
||||
* MQuark implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
MQuark::MQuark(const std::string name)
|
||||
: Module(name)
|
||||
{}
|
||||
|
||||
// parse parameters ////////////////////////////////////////////////////////////
|
||||
void MQuark::parseParameters(XmlReader &reader, const std::string name)
|
||||
{
|
||||
read(reader, name, par_);
|
||||
}
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
std::vector<std::string> MQuark::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in = {par_.source, par_.solver};
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
std::vector<std::string> MQuark::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out = {getName(), getName() + "_5d"};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
void MQuark::setup(void)
|
||||
{
|
||||
Ls_ = env().getObjectLs(env().getSolverAction(par_.solver));
|
||||
env().registerLattice<LatticePropagator>(getName());
|
||||
if (Ls_ > 1)
|
||||
{
|
||||
env().registerLattice<LatticePropagator>(getName() + "_5d", Ls_);
|
||||
}
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
void MQuark::execute(void)
|
||||
{
|
||||
LatticePropagator *fullSource;
|
||||
LatticeFermion source(env().getGrid(Ls_)), sol(env().getGrid(Ls_));
|
||||
std::string propName = (Ls_ == 1) ? getName() : (getName() + "_5d");
|
||||
|
||||
LOG(Message) << "Computing quark propagator '" << getName() << "'"
|
||||
<< std::endl;
|
||||
LatticePropagator &prop = *env().create<LatticePropagator>(propName);
|
||||
// source conversion for 4D sources
|
||||
if (!env().isObject5d(par_.source))
|
||||
{
|
||||
if (Ls_ == 1)
|
||||
{
|
||||
fullSource = env().get<LatticePropagator>(par_.source);
|
||||
}
|
||||
else
|
||||
{
|
||||
HADRON_ERROR("MQuark not implemented with 5D actions");
|
||||
}
|
||||
}
|
||||
// source conversion for 5D sources
|
||||
else
|
||||
{
|
||||
if (Ls_ == 1)
|
||||
{
|
||||
HADRON_ERROR("MQuark not implemented with 5D actions");
|
||||
}
|
||||
else if (Ls_ != env().getObjectLs(par_.source))
|
||||
{
|
||||
HADRON_ERROR("Ls mismatch between quark action and source");
|
||||
}
|
||||
else
|
||||
{
|
||||
fullSource = env().get<LatticePropagator>(par_.source);
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
PropToFerm(source, *fullSource, s, c);
|
||||
sol = zero;
|
||||
env().callSolver(par_.solver, sol, source);
|
||||
FermToProp(prop, sol, s, c);
|
||||
}
|
||||
// create 4D propagators from 5D one if necessary
|
||||
if (Ls_ > 1)
|
||||
{
|
||||
HADRON_ERROR("MQuark not implemented with 5D actions");
|
||||
}
|
||||
}
|
73
programs/Hadrons/modules/MQuark.hpp
Normal file
73
programs/Hadrons/modules/MQuark.hpp
Normal file
@ -0,0 +1,73 @@
|
||||
/*******************************************************************************
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: programs/Hadrons/MQuark.hpp
|
||||
|
||||
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.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef Hadrons_MQuark_hpp_
|
||||
#define Hadrons_MQuark_hpp_
|
||||
|
||||
#include <Hadrons/Global.hpp>
|
||||
#include <Hadrons/Module.hpp>
|
||||
#include <Hadrons/ModuleFactory.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* MQuark *
|
||||
******************************************************************************/
|
||||
class MQuark: public Module
|
||||
{
|
||||
public:
|
||||
class Par: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(Par, std::string, source,
|
||||
std::string, solver);
|
||||
};
|
||||
public:
|
||||
// constructor
|
||||
MQuark(const std::string name);
|
||||
// destructor
|
||||
virtual ~MQuark(void) = default;
|
||||
// parse parameters
|
||||
virtual void parseParameters(XmlReader &reader, const std::string name);
|
||||
// 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:
|
||||
Par par_;
|
||||
unsigned int Ls_;
|
||||
Environment::Solver *solver_{nullptr};
|
||||
};
|
||||
|
||||
MODULE_REGISTER(MQuark);
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_MQuark_hpp_
|
88
programs/Hadrons/modules/SolRBPrecCG.cc
Normal file
88
programs/Hadrons/modules/SolRBPrecCG.cc
Normal file
@ -0,0 +1,88 @@
|
||||
/*******************************************************************************
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: programs/Hadrons/SolRBPrecCG.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 <Hadrons/Modules/SolRBPrecCG.hpp>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace QCD;
|
||||
using namespace Hadrons;
|
||||
|
||||
/******************************************************************************
|
||||
* SolRBPrecCG implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
SolRBPrecCG::SolRBPrecCG(const std::string name)
|
||||
: Module(name)
|
||||
{}
|
||||
|
||||
// parse parameters ////////////////////////////////////////////////////////////
|
||||
void SolRBPrecCG::parseParameters(XmlReader &reader, const std::string name)
|
||||
{
|
||||
read(reader, name, par_);
|
||||
}
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
std::vector<std::string> SolRBPrecCG::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in = {par_.action};
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
std::vector<std::string> SolRBPrecCG::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out = {getName()};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
void SolRBPrecCG::setup(void)
|
||||
{
|
||||
env().registerObject(getName(), 0);
|
||||
env().addOwnership(getName(), par_.action);
|
||||
env().setSolverAction(getName(), par_.action);
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
void SolRBPrecCG::execute(void)
|
||||
{
|
||||
auto &mat = *(env().getFermionMatrix(par_.action));
|
||||
auto solver = [&mat, this](LatticeFermion &sol,
|
||||
const LatticeFermion &source)
|
||||
{
|
||||
ConjugateGradient<LatticeFermion> cg(par_.residual, 10000);
|
||||
SchurRedBlackDiagMooeeSolve<LatticeFermion> schurSolver(cg);
|
||||
|
||||
schurSolver(mat, source, sol);
|
||||
};
|
||||
|
||||
LOG(Message) << "setting up Schur red-black preconditioned CG for"
|
||||
<< " action '" << par_.action << "' with residual "
|
||||
<< par_.residual << std::endl;
|
||||
env().addSolver(getName(), solver);
|
||||
}
|
71
programs/Hadrons/modules/SolRBPrecCG.hpp
Normal file
71
programs/Hadrons/modules/SolRBPrecCG.hpp
Normal file
@ -0,0 +1,71 @@
|
||||
/*******************************************************************************
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: programs/Hadrons/SolRBPrecCG.hpp
|
||||
|
||||
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.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef Hadrons_SolRBPrecCG_hpp_
|
||||
#define Hadrons_SolRBPrecCG_hpp_
|
||||
|
||||
#include <Hadrons/Global.hpp>
|
||||
#include <Hadrons/Module.hpp>
|
||||
#include <Hadrons/ModuleFactory.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* Schur red-black preconditioned CG *
|
||||
******************************************************************************/
|
||||
class SolRBPrecCG: public Module
|
||||
{
|
||||
public:
|
||||
class Par: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(Par, std::string, action,
|
||||
double , residual);
|
||||
};
|
||||
public:
|
||||
// constructor
|
||||
SolRBPrecCG(const std::string name);
|
||||
// destructor
|
||||
virtual ~SolRBPrecCG(void) = default;
|
||||
// parse parameters
|
||||
virtual void parseParameters(XmlReader &reader, const std::string name);
|
||||
// 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:
|
||||
Par par_;
|
||||
};
|
||||
|
||||
MODULE_REGISTER(SolRBPrecCG);
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_SolRBPrecCG_hpp_
|
80
programs/Hadrons/modules/SrcPoint.cc
Normal file
80
programs/Hadrons/modules/SrcPoint.cc
Normal file
@ -0,0 +1,80 @@
|
||||
/*******************************************************************************
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: programs/Hadrons/SrcPoint.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 <Hadrons/Modules/SrcPoint.hpp>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace Hadrons;
|
||||
|
||||
/******************************************************************************
|
||||
* SrcPoint implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
SrcPoint::SrcPoint(const std::string name)
|
||||
: Module(name)
|
||||
{}
|
||||
|
||||
// parse parameters ////////////////////////////////////////////////////////////
|
||||
void SrcPoint::parseParameters(XmlReader &reader, const std::string name)
|
||||
{
|
||||
read(reader, name, par_);
|
||||
}
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
std::vector<std::string> SrcPoint::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
std::vector<std::string> SrcPoint::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out = {getName()};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
void SrcPoint::setup(void)
|
||||
{
|
||||
env().registerLattice<LatticePropagator>(getName());
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
void SrcPoint::execute(void)
|
||||
{
|
||||
std::vector<int> position = strToVec<int>(par_.position);
|
||||
SpinColourMatrix id;
|
||||
|
||||
LOG(Message) << "Creating point source at position [" << par_.position
|
||||
<< "]" << std::endl;
|
||||
LatticePropagator &src = *env().create<LatticePropagator>(getName());
|
||||
id = 1.;
|
||||
src = zero;
|
||||
pokeSite(id, src, position);
|
||||
}
|
81
programs/Hadrons/modules/SrcPoint.hpp
Normal file
81
programs/Hadrons/modules/SrcPoint.hpp
Normal file
@ -0,0 +1,81 @@
|
||||
/*******************************************************************************
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: programs/Hadrons/SrcPoint.hpp
|
||||
|
||||
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.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef Hadrons_SrcPoint_hpp_
|
||||
#define Hadrons_SrcPoint_hpp_
|
||||
|
||||
#include <Hadrons/Global.hpp>
|
||||
#include <Hadrons/Module.hpp>
|
||||
#include <Hadrons/ModuleFactory.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/*
|
||||
|
||||
Point source
|
||||
------------
|
||||
* src_x = delta_x,o
|
||||
|
||||
* options: o
|
||||
- position: space-separated integer sequence (e.g. "0 1 1 0")
|
||||
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* SrcPoint *
|
||||
******************************************************************************/
|
||||
class SrcPoint: public Module
|
||||
{
|
||||
public:
|
||||
class Par: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(Par, std::string, position);
|
||||
};
|
||||
public:
|
||||
// constructor
|
||||
SrcPoint(const std::string name);
|
||||
// destructor
|
||||
virtual ~SrcPoint(void) = default;
|
||||
// parse parameters
|
||||
virtual void parseParameters(XmlReader &reader, const std::string name);
|
||||
// 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:
|
||||
Par par_;
|
||||
};
|
||||
|
||||
MODULE_REGISTER(SrcPoint);
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_SrcPoint_hpp_
|
93
programs/Hadrons/modules/SrcZ2.cc
Normal file
93
programs/Hadrons/modules/SrcZ2.cc
Normal file
@ -0,0 +1,93 @@
|
||||
/*******************************************************************************
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: programs/Hadrons/SrcZ2.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 <Hadrons/Modules/SrcZ2.hpp>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace Hadrons;
|
||||
|
||||
/******************************************************************************
|
||||
* SrcZ2 implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
SrcZ2::SrcZ2(const std::string name)
|
||||
: Module(name)
|
||||
{}
|
||||
|
||||
// parse parameters ////////////////////////////////////////////////////////////
|
||||
void SrcZ2::parseParameters(XmlReader &reader, const std::string name)
|
||||
{
|
||||
read(reader, name, par_);
|
||||
}
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
std::vector<std::string> SrcZ2::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
std::vector<std::string> SrcZ2::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out = {getName()};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
void SrcZ2::setup(void)
|
||||
{
|
||||
env().registerLattice<LatticePropagator>(getName());
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
void SrcZ2::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;
|
||||
}
|
||||
LatticePropagator &src = *env().create<LatticePropagator>(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;
|
||||
}
|
83
programs/Hadrons/modules/SrcZ2.hpp
Normal file
83
programs/Hadrons/modules/SrcZ2.hpp
Normal file
@ -0,0 +1,83 @@
|
||||
/*******************************************************************************
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: programs/Hadrons/SrcZ2.hpp
|
||||
|
||||
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.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef Hadrons_SrcZ2_hpp_
|
||||
#define Hadrons_SrcZ2_hpp_
|
||||
|
||||
#include <Hadrons/Global.hpp>
|
||||
#include <Hadrons/Module.hpp>
|
||||
#include <Hadrons/ModuleFactory.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/*
|
||||
|
||||
Z_2 stochastic source
|
||||
-----------------------------
|
||||
* src_x = eta_x * theta(x_3 - ta) * theta(tb - x_3)
|
||||
|
||||
* options:
|
||||
- tA: begin timeslice (integer)
|
||||
- tB: end timesilce (integer)
|
||||
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* SrcZ2 *
|
||||
******************************************************************************/
|
||||
class SrcZ2: public Module
|
||||
{
|
||||
public:
|
||||
class Par: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(Par, unsigned int, tA,
|
||||
unsigned int, tB);
|
||||
};
|
||||
public:
|
||||
// constructor
|
||||
SrcZ2(const std::string name);
|
||||
// destructor
|
||||
virtual ~SrcZ2(void) = default;
|
||||
// parse parameters
|
||||
virtual void parseParameters(XmlReader &reader, const std::string name);
|
||||
// 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:
|
||||
Par par_;
|
||||
};
|
||||
|
||||
MODULE_REGISTER(SrcZ2);
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_SrcZ2_hpp_
|
Reference in New Issue
Block a user