1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-10 07:55:35 +00:00

Hadrons: scalar SU(N) stochastic free field

This commit is contained in:
Antonin Portelli 2018-05-10 22:29:48 +01:00
parent 8cb205725b
commit 93771f3099
4 changed files with 150 additions and 30 deletions

View File

@ -1,33 +1,3 @@
/*************************************************************************************
Grid physics library, www.github.com/paboyle/Grid
Source file: extras/Hadrons/Modules.hpp
Copyright (C) 2015-2018
Author: Antonin Portelli <antonin.portelli@me.com>
Author: Guido Cossu <guido.cossu@ed.ac.uk>
Author: Lanny91 <andrew.lawson@gmail.com>
Author: pretidav <david.preti@csic.es>
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 <Grid/Hadrons/Modules/MContraction/Baryon.hpp>
#include <Grid/Hadrons/Modules/MContraction/Meson.hpp>
#include <Grid/Hadrons/Modules/MContraction/WeakHamiltonian.hpp>
@ -61,6 +31,7 @@ See the full license in the file "LICENSE" in the top level distribution directo
#include <Grid/Hadrons/Modules/MAction/Wilson.hpp>
#include <Grid/Hadrons/Modules/MAction/WilsonClover.hpp>
#include <Grid/Hadrons/Modules/MAction/ZMobiusDWF.hpp>
#include <Grid/Hadrons/Modules/MScalarSUN/StochFreeField.hpp>
#include <Grid/Hadrons/Modules/MScalarSUN/ShiftProbe.hpp>
#include <Grid/Hadrons/Modules/MScalarSUN/Div.hpp>
#include <Grid/Hadrons/Modules/MScalarSUN/TrMag.hpp>

View File

@ -0,0 +1,11 @@
#include <Grid/Hadrons/Modules/MScalarSUN/StochFreeField.hpp>
using namespace Grid;
using namespace Hadrons;
using namespace MScalarSUN;
template class Grid::Hadrons::MScalarSUN::TStochFreeField<ScalarNxNAdjImplR<2>>;
template class Grid::Hadrons::MScalarSUN::TStochFreeField<ScalarNxNAdjImplR<3>>;
template class Grid::Hadrons::MScalarSUN::TStochFreeField<ScalarNxNAdjImplR<4>>;
template class Grid::Hadrons::MScalarSUN::TStochFreeField<ScalarNxNAdjImplR<5>>;
template class Grid::Hadrons::MScalarSUN::TStochFreeField<ScalarNxNAdjImplR<6>>;

View File

@ -0,0 +1,136 @@
#ifndef Hadrons_MScalarSUN_StochFreeField_hpp_
#define Hadrons_MScalarSUN_StochFreeField_hpp_
#include <Grid/Hadrons/Global.hpp>
#include <Grid/Hadrons/Module.hpp>
#include <Grid/Hadrons/ModuleFactory.hpp>
BEGIN_HADRONS_NAMESPACE
/******************************************************************************
* stochastic free SU(N) scalar field *
******************************************************************************/
BEGIN_MODULE_NAMESPACE(MScalarSUN)
class StochFreeFieldPar: Serializable
{
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(StochFreeFieldPar,
double, m2,
double, g);
};
template <typename SImpl>
class TStochFreeField: public Module<StochFreeFieldPar>
{
public:
typedef typename SImpl::Field Field;
typedef typename SImpl::ComplexField ComplexField;
typedef typename SImpl::Group Group;
typedef typename Group::LatticeAlgebraVector AlgebraField;
public:
// constructor
TStochFreeField(const std::string name);
// destructor
virtual ~TStochFreeField(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);
private:
bool create_weight;
};
MODULE_REGISTER_TMP(StochFreeFieldSU2, TStochFreeField<ScalarNxNAdjImplR<2>>, MScalarSUN);
MODULE_REGISTER_TMP(StochFreeFieldSU3, TStochFreeField<ScalarNxNAdjImplR<3>>, MScalarSUN);
MODULE_REGISTER_TMP(StochFreeFieldSU4, TStochFreeField<ScalarNxNAdjImplR<4>>, MScalarSUN);
MODULE_REGISTER_TMP(StochFreeFieldSU5, TStochFreeField<ScalarNxNAdjImplR<5>>, MScalarSUN);
MODULE_REGISTER_TMP(StochFreeFieldSU6, TStochFreeField<ScalarNxNAdjImplR<6>>, MScalarSUN);
/******************************************************************************
* TStochFreeField implementation *
******************************************************************************/
// constructor /////////////////////////////////////////////////////////////////
template <typename SImpl>
TStochFreeField<SImpl>::TStochFreeField(const std::string name)
: Module<StochFreeFieldPar>(name)
{}
// dependencies/products ///////////////////////////////////////////////////////
template <typename SImpl>
std::vector<std::string> TStochFreeField<SImpl>::getInput(void)
{
std::vector<std::string> in;
return in;
}
template <typename SImpl>
std::vector<std::string> TStochFreeField<SImpl>::getOutput(void)
{
std::vector<std::string> out = {getName()};
return out;
}
// setup ///////////////////////////////////////////////////////////////////////
template <typename SImpl>
void TStochFreeField<SImpl>::setup(void)
{
create_weight = false;
if (!env().hasCreatedObject("_" + getName() + "_weight"))
{
envCacheLat(ComplexField, "_" + getName() + "_weight");
create_weight = true;
}
envTmpLat(Field, "phift");
envCreateLat(Field, getName());
}
// execution ///////////////////////////////////////////////////////////////////
template <typename SImpl>
void TStochFreeField<SImpl>::execute(void)
{
LOG(Message) << "Generating stochastic scalar field" << std::endl;
const unsigned int N = Group::Dimension;
const unsigned int Nadj = Group::AdjointDimension;
auto &phi = envGet(Field, getName());
auto &w = envGet(ComplexField, "_" + getName() + "_weight");
auto &rng = *env().get4dRng();
double trphi2;
FFT fft(env().getGrid());
Integer vol;
vol = 1;
for(int d = 0; d < env().getNd(); d++)
{
vol = vol*env().getDim(d);
}
if (create_weight)
{
LOG(Message) << "Caching momentum-space scalar action" << std::endl;
SImpl::MomentumSpacePropagator(w, sqrt(par().m2));
w *= par().g/N;
w = sqrt(vol*real(w));
}
LOG(Message) << "Generating random momentum-space field" << std::endl;
envGetTmp(Field, phift);
Group::GaussianFundamentalLieAlgebraMatrix(rng, phift);
phift *= w;
LOG(Message) << "Field Fourier transform" << std::endl;
fft.FFT_all_dim(phi, phift, FFT::backward);
phi = (1./sqrt(2.))*(phi - adj(phi));
trphi2 = -TensorRemove(sum(trace(phi*phi))).real()/vol;
LOG(Message) << "tr(phi^2)= " << trphi2 << std::endl;
}
END_MODULE_NAMESPACE
END_HADRONS_NAMESPACE
#endif // Hadrons_MScalarSUN_StochFreeField_hpp_

View File

@ -37,6 +37,7 @@ modules_cc =\
Modules/MScalarSUN/EMT.cc \
Modules/MScalarSUN/ShiftProbe.cc \
Modules/MScalarSUN/TransProj.cc \
Modules/MScalarSUN/StochFreeField.cc \
Modules/MScalarSUN/TwoPoint.cc \
Modules/MScalarSUN/Div.cc \
Modules/MIO/LoadEigenPack.cc \
@ -78,6 +79,7 @@ modules_hpp =\
Modules/MAction/Wilson.hpp \
Modules/MAction/WilsonClover.hpp \
Modules/MAction/ZMobiusDWF.hpp \
Modules/MScalarSUN/StochFreeField.hpp \
Modules/MScalarSUN/ShiftProbe.hpp \
Modules/MScalarSUN/Div.hpp \
Modules/MScalarSUN/TrMag.hpp \