2018-08-07 18:40:48 +01:00
|
|
|
/*************************************************************************************
|
|
|
|
|
|
|
|
Grid physics library, www.github.com/paboyle/Grid
|
|
|
|
|
2018-09-01 21:30:30 +01:00
|
|
|
Source file: Hadrons/Modules/MScalarSUN/StochFreeField.hpp
|
2018-08-07 18:40:48 +01:00
|
|
|
|
2019-02-05 18:55:24 +00:00
|
|
|
Copyright (C) 2015-2019
|
2018-08-07 18:40:48 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
*************************************************************************************/
|
|
|
|
/* END LEGAL */
|
2018-05-10 22:29:48 +01:00
|
|
|
#ifndef Hadrons_MScalarSUN_StochFreeField_hpp_
|
|
|
|
#define Hadrons_MScalarSUN_StochFreeField_hpp_
|
|
|
|
|
2018-08-28 15:00:40 +01:00
|
|
|
#include <Hadrons/Global.hpp>
|
|
|
|
#include <Hadrons/Module.hpp>
|
|
|
|
#include <Hadrons/ModuleFactory.hpp>
|
2018-05-10 22:29:48 +01:00
|
|
|
|
|
|
|
BEGIN_HADRONS_NAMESPACE
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* stochastic free SU(N) scalar field *
|
|
|
|
******************************************************************************/
|
|
|
|
BEGIN_MODULE_NAMESPACE(MScalarSUN)
|
|
|
|
|
|
|
|
class StochFreeFieldPar: Serializable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GRID_SERIALIZABLE_CLASS_MEMBERS(StochFreeFieldPar,
|
|
|
|
double, m2,
|
2018-09-01 17:36:35 +01:00
|
|
|
double, g,
|
|
|
|
double, smearing);
|
2018-05-10 22:29:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename SImpl>
|
|
|
|
class TStochFreeField: public Module<StochFreeFieldPar>
|
|
|
|
{
|
|
|
|
public:
|
2018-05-18 20:49:55 +01:00
|
|
|
typedef typename SImpl::Field Field;
|
|
|
|
typedef typename SImpl::ComplexField ComplexField;
|
|
|
|
typedef typename SImpl::Group Group;
|
|
|
|
typedef typename SImpl::SiteField::scalar_object Site;
|
2018-05-10 22:29:48 +01:00
|
|
|
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");
|
2018-09-01 17:36:35 +01:00
|
|
|
envTmpLat(ComplexField, "smear");
|
2018-05-10 22:29:48 +01:00
|
|
|
create_weight = true;
|
|
|
|
}
|
|
|
|
envTmpLat(Field, "phift");
|
2018-05-18 20:49:55 +01:00
|
|
|
envTmpLat(ComplexField, "ca");
|
2018-05-10 22:29:48 +01:00
|
|
|
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");
|
2018-08-10 18:27:00 +01:00
|
|
|
auto &rng = rng4d();
|
2018-05-10 22:29:48 +01:00
|
|
|
double trphi2;
|
2018-09-29 17:55:19 +01:00
|
|
|
FFT fft(envGetGrid(Field));
|
2018-05-10 22:29:48 +01:00
|
|
|
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;
|
|
|
|
|
2018-09-01 17:36:35 +01:00
|
|
|
envGetTmp(ComplexField, smear);
|
|
|
|
SImpl::MomentaSquare(smear);
|
|
|
|
smear = exp(-par().smearing*smear);
|
2018-05-10 22:29:48 +01:00
|
|
|
SImpl::MomentumSpacePropagator(w, sqrt(par().m2));
|
2018-09-01 17:36:35 +01:00
|
|
|
w *= par().g/N*smear;
|
2018-05-14 18:58:39 +01:00
|
|
|
w = sqrt(vol)*sqrt(w);
|
2018-05-10 22:29:48 +01:00
|
|
|
}
|
|
|
|
LOG(Message) << "Generating random momentum-space field" << std::endl;
|
|
|
|
envGetTmp(Field, phift);
|
2018-05-18 20:49:55 +01:00
|
|
|
envGetTmp(ComplexField, ca);
|
|
|
|
phift = zero;
|
|
|
|
for (int a = 0; a < Nadj; ++a)
|
|
|
|
{
|
|
|
|
Site ta;
|
|
|
|
|
|
|
|
gaussian(rng, ca);
|
|
|
|
Group::generator(a, ta);
|
|
|
|
phift += ca*ta;
|
|
|
|
}
|
2018-05-10 22:29:48 +01:00
|
|
|
phift *= w;
|
|
|
|
LOG(Message) << "Field Fourier transform" << std::endl;
|
|
|
|
fft.FFT_all_dim(phi, phift, FFT::backward);
|
2018-05-18 20:49:55 +01:00
|
|
|
phi = 0.5*(phi - adj(phi));
|
2018-05-10 22:29:48 +01:00
|
|
|
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_
|