1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-14 01:35:36 +00:00

Hadrons: full volume noise source for A2A

This commit is contained in:
Vera Guelpers 2018-10-16 14:56:12 +01:00
parent b3d6805638
commit 109c74bed8
5 changed files with 235 additions and 0 deletions

View File

@ -7,6 +7,7 @@ Source file: Hadrons/DilutedNoise.hpp
Copyright (C) 2015-2018 Copyright (C) 2015-2018
Author: Antonin Portelli <antonin.portelli@me.com> Author: Antonin Portelli <antonin.portelli@me.com>
Author: Vera Guelpers <Vera.Guelpers@ed.ac.uk>
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -55,6 +56,7 @@ public:
GridCartesian *getGrid(void) const; GridCartesian *getGrid(void) const;
// generate noise (pure virtual) // generate noise (pure virtual)
virtual void generateNoise(GridParallelRNG &rng) = 0; virtual void generateNoise(GridParallelRNG &rng) = 0;
virtual void generateNoise(GridParallelRNG &rng, unsigned int n_src) = 0;
private: private:
std::vector<FermionField> noise_; std::vector<FermionField> noise_;
GridCartesian *grid_; GridCartesian *grid_;
@ -72,10 +74,28 @@ public:
virtual ~TimeDilutedSpinColorDiagonalNoise(void) = default; virtual ~TimeDilutedSpinColorDiagonalNoise(void) = default;
// generate noise // generate noise
virtual void generateNoise(GridParallelRNG &rng); virtual void generateNoise(GridParallelRNG &rng);
virtual void generateNoise(GridParallelRNG &rng, unsigned int n_src);
private: private:
unsigned int nt_; unsigned int nt_;
}; };
template <typename FImpl>
class FullVolumeSpinColorDiagonalNoise: public DilutedNoise<FImpl>
{
public:
typedef typename FImpl::FermionField FermionField;
public:
// constructor/destructor
FullVolumeSpinColorDiagonalNoise(GridCartesian *g, unsigned int n_src);
virtual ~FullVolumeSpinColorDiagonalNoise(void) = default;
// generate noise
virtual void generateNoise(GridParallelRNG &rng);
virtual void generateNoise(GridParallelRNG &rng, unsigned int n_src);
public:
unsigned int n_src;
};
/****************************************************************************** /******************************************************************************
* DilutedNoise template implementation * * DilutedNoise template implementation *
******************************************************************************/ ******************************************************************************/
@ -186,6 +206,61 @@ void TimeDilutedSpinColorDiagonalNoise<FImpl>::generateNoise(GridParallelRNG &rn
} }
} }
template <typename FImpl>
void TimeDilutedSpinColorDiagonalNoise<FImpl>::generateNoise(GridParallelRNG &rng, unsigned int n_src)
{
assert(0);
}
/******************************************************************************
* FullVolumeSpinColorDiagonalNoise template implementation *
******************************************************************************/
template <typename FImpl>
FullVolumeSpinColorDiagonalNoise<FImpl>::
FullVolumeSpinColorDiagonalNoise(GridCartesian *g, unsigned int n_src)
: DilutedNoise<FImpl>(g)
{
this->resize(n_src*Ns*FImpl::Dimension);
}
template <typename FImpl>
void FullVolumeSpinColorDiagonalNoise<FImpl>::generateNoise(GridParallelRNG &rng)
{
assert(0);
}
template <typename FImpl>
void FullVolumeSpinColorDiagonalNoise<FImpl>::generateNoise(GridParallelRNG &rng,unsigned int n_src)
{
typedef decltype(peekColour((*this)[0], 0)) SpinField;
auto &noise = *this;
auto g = this->getGrid();
auto nd = g->GlobalDimensions().size();
auto nc = FImpl::Dimension;
Complex shift(1., 1.);
LatticeComplex eta(g);
SpinField etas(g);
unsigned int i = 0;
bernoulli(rng, eta);
eta = (2.*eta - shift)*(1./::sqrt(2.));
for (unsigned int n = 0; n < n_src; ++n)
{
for (unsigned int s = 0; s < Ns; ++s)
{
etas = zero;
pokeSpin(etas, eta, s);
for (unsigned int c = 0; c < nc; ++c)
{
noise[i] = zero;
pokeColour(noise[i], etas, c);
i++;
}
}
}
}
END_HADRONS_NAMESPACE END_HADRONS_NAMESPACE
#endif // Hadrons_DilutedNoise_hpp_ #endif // Hadrons_DilutedNoise_hpp_

View File

@ -32,6 +32,7 @@
#include <Hadrons/Modules/MGauge/FundtoHirep.hpp> #include <Hadrons/Modules/MGauge/FundtoHirep.hpp>
#include <Hadrons/Modules/MGauge/StochEm.hpp> #include <Hadrons/Modules/MGauge/StochEm.hpp>
#include <Hadrons/Modules/MNoise/TimeDilutedSpinColorDiagonal.hpp> #include <Hadrons/Modules/MNoise/TimeDilutedSpinColorDiagonal.hpp>
#include <Hadrons/Modules/MNoise/FullVolumeSpinColorDiagonal.hpp>
#include <Hadrons/Modules/MUtilities/PrecisionCast.hpp> #include <Hadrons/Modules/MUtilities/PrecisionCast.hpp>
#include <Hadrons/Modules/MUtilities/RandomVectors.hpp> #include <Hadrons/Modules/MUtilities/RandomVectors.hpp>
#include <Hadrons/Modules/MUtilities/TestSeqGamma.hpp> #include <Hadrons/Modules/MUtilities/TestSeqGamma.hpp>

View File

@ -0,0 +1,36 @@
/*************************************************************************************
Grid physics library, www.github.com/paboyle/Grid
Source file: Hadrons/Modules/MNoise/FullVolumeSpinColorDiagonal.cc
Copyright (C) 2015-2018
Author: Antonin Portelli <antonin.portelli@me.com>
Author: Vera Guelpers <Vera.Guelpers@ed.ac.uk>
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 */
#include <Hadrons/Modules/MNoise/FullVolumeSpinColorDiagonal.hpp>
using namespace Grid;
using namespace Hadrons;
using namespace MNoise;
template class Grid::Hadrons::MNoise::TFullVolumeSpinColorDiagonal<FIMPL>;
template class Grid::Hadrons::MNoise::TFullVolumeSpinColorDiagonal<ZFIMPL>;

View File

@ -0,0 +1,121 @@
/*************************************************************************************
Grid physics library, www.github.com/paboyle/Grid
Source file: Hadrons/Modules/MNoise/FullVolumeSpinColorDiagonal.hpp
Copyright (C) 2015-2018
Author: Antonin Portelli <antonin.portelli@me.com>
Author: Vera Guelpers <Vera.Guelpers@ed.ac.uk>
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 */
#ifndef Hadrons_MNoise_FullVolumeSpinColorDiagonal_hpp_
#define Hadrons_MNoise_FullVolumeSpinColorDiagonal_hpp_
#include <Hadrons/Global.hpp>
#include <Hadrons/Module.hpp>
#include <Hadrons/ModuleFactory.hpp>
#include <Hadrons/DilutedNoise.hpp>
BEGIN_HADRONS_NAMESPACE
/******************************************************************************
* Generate full volume spin-color diagonal noise *
******************************************************************************/
BEGIN_MODULE_NAMESPACE(MNoise)
class FullVolumeSpinColorDiagonalPar: Serializable
{
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(FullVolumeSpinColorDiagonalPar,
unsigned int, nsrc);
};
template <typename FImpl>
class TFullVolumeSpinColorDiagonal: public Module<FullVolumeSpinColorDiagonalPar>
{
public:
FERM_TYPE_ALIASES(FImpl,);
public:
// constructor
TFullVolumeSpinColorDiagonal(const std::string name);
// destructor
virtual ~TFullVolumeSpinColorDiagonal(void) {};
// 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_TMP(FullVolumeSpinColorDiagonal, TFullVolumeSpinColorDiagonal<FIMPL>, MNoise);
MODULE_REGISTER_TMP(ZFullVolumeSpinColorDiagonal, TFullVolumeSpinColorDiagonal<ZFIMPL>, MNoise);
/******************************************************************************
* TFullVolumeSpinColorDiagonal implementation *
******************************************************************************/
// constructor /////////////////////////////////////////////////////////////////
template <typename FImpl>
TFullVolumeSpinColorDiagonal<FImpl>::TFullVolumeSpinColorDiagonal(const std::string name)
: Module<FullVolumeSpinColorDiagonalPar>(name)
{}
// dependencies/products ///////////////////////////////////////////////////////
template <typename FImpl>
std::vector<std::string> TFullVolumeSpinColorDiagonal<FImpl>::getInput(void)
{
std::vector<std::string> in;
return in;
}
template <typename FImpl>
std::vector<std::string> TFullVolumeSpinColorDiagonal<FImpl>::getOutput(void)
{
std::vector<std::string> out = {getName()};
return out;
}
// setup ///////////////////////////////////////////////////////////////////////
template <typename FImpl>
void TFullVolumeSpinColorDiagonal<FImpl>::setup(void)
{
envCreateDerived(DilutedNoise<FImpl>,
FullVolumeSpinColorDiagonalNoise<FImpl>,
getName(), 1, envGetGrid(FermionField), par().nsrc);
}
// execution ///////////////////////////////////////////////////////////////////
template <typename FImpl>
void TFullVolumeSpinColorDiagonal<FImpl>::execute(void)
{
auto &noise = envGet(DilutedNoise<FImpl>, getName());
LOG(Message) << "Generating full volume, spin-color diagonal noise" << std::endl;
noise.generateNoise(rng4d(),par().nsrc);
}
END_MODULE_NAMESPACE
END_HADRONS_NAMESPACE
#endif // Hadrons_MNoise_FullVolumeSpinColorDiagonal_hpp_

View File

@ -31,6 +31,7 @@ modules_cc =\
Modules/MGauge/FundtoHirep.cc \ Modules/MGauge/FundtoHirep.cc \
Modules/MGauge/GaugeFix.cc \ Modules/MGauge/GaugeFix.cc \
Modules/MNoise/TimeDilutedSpinColorDiagonal.cc \ Modules/MNoise/TimeDilutedSpinColorDiagonal.cc \
Modules/MNoise/FullVolumeSpinColorDiagonal.cc \
Modules/MUtilities/RandomVectors.cc \ Modules/MUtilities/RandomVectors.cc \
Modules/MUtilities/TestSeqGamma.cc \ Modules/MUtilities/TestSeqGamma.cc \
Modules/MUtilities/PrecisionCast.cc \ Modules/MUtilities/PrecisionCast.cc \
@ -101,6 +102,7 @@ modules_hpp =\
Modules/MGauge/FundtoHirep.hpp \ Modules/MGauge/FundtoHirep.hpp \
Modules/MGauge/StochEm.hpp \ Modules/MGauge/StochEm.hpp \
Modules/MNoise/TimeDilutedSpinColorDiagonal.hpp \ Modules/MNoise/TimeDilutedSpinColorDiagonal.hpp \
Modules/MNoise/FullVolumeSpinColorDiagonal.hpp \
Modules/MUtilities/PrecisionCast.hpp \ Modules/MUtilities/PrecisionCast.hpp \
Modules/MUtilities/RandomVectors.hpp \ Modules/MUtilities/RandomVectors.hpp \
Modules/MUtilities/TestSeqGamma.hpp \ Modules/MUtilities/TestSeqGamma.hpp \