1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-09-20 09:15:38 +01:00

More on smearing routines, writing APEsmear (dev)

This commit is contained in:
neo 2016-02-19 17:15:27 +09:00
parent 771235017d
commit c1b1b89d17
5 changed files with 294 additions and 4 deletions

View File

@ -0,0 +1,150 @@
/*!
@brief Declaration of Smear_APE class for APE smearing
*/
#ifndef APE_SMEAR_
#define APE_SMEAR_
/*! @brief APE type smearing of link variables. */
template <class Gimpl>
class Smear_APE: public Smear<Gimpl>{
private:
const std::vector<double> rho;/*!< Array of weights */
//This member must be private - we do not want to control from outside
std::vector<double> set_rho(const double)const {
std::vector<double> res;
for(int mn=0; mn<Nd*Nd; ++mn) res.push_back(common_rho);
for(int mu=0; mu<Nd; ++mu) res[mu + mu*Nd] = 0.0;
return res;
}
public:
INHERIT_GIMPL_TYPES(Gimpl)
Smear_APE(const std::vector<double>& rho_):rho(rho_){}
Smear_APE(double rho_val):rho(set_rho(rho_val)){}
Smear_APE():rho(set_rho(1.0)){}
~Smear_APE(){}
void smear(GaugeField& u_smr, const GaugeField& U)const{
double d_rho;
GaugeLinkField Cup, tmp_stpl;
WilsonLoops<Gimpl> WL;
u_smr = zero;
for(int mu=0; mu<Nd; ++mu){
Cup = zero;
for(int nu=0; nu<Nd; ++nu){
d_rho = rho[mu + Nd * nu];
WL.Staple(tmp_stpl, U, mu, nu);
Cup += tmp_stpl*d_rho;
}
pokeLorentz(u_smr, Cup, mu);
}
}
void derivative(GaugeField& SigmaTerm,
const GaugeField& iLambda,
const GaugeField& U)const{
/*
WilsonLoops<Gimpl> WL;
GaugeLinkField staple, u_tmp, iLambda_mu, iLambda_nu;
GaugeLinkField U_mu, U_nu;
GaugeLinkField sh_field ;
GaugeLinkField temp_Sigma;
SU<N>::Matrix temp_mat, temp_mat2;
Real rho_munu, rho_numu;
// to be completed
int Nvol = CommonPrms::instance()->Nvol();
for(int mu = 0; mu < Nd; ++mu){
U_mu = PeekIndex<LorentzIndex>( U, mu);
iLambda_mu = PeekIndex<LorentzIndex>(iLambda, mu);
for(int nu = 0; nu < Nd; ++nu){
if(nu==mu) continue;
U_nu = PeekIndex<LorentzIndex>( U, nu);
iLambda_nu = PeekIndex<LorentzIndex>(iLambda, nu);
rho_munu = rho[mu + Nd * nu];
rho_numu = rho[nu + Nd * mu];
WL.StapleUpper(staple, U, mu, nu);
temp_Sigma = adj(staple)*iLambda_nu;
temp_Sigma *= - rho_numu;
//-r_numu*U_nu(x+mu)*Udag_mu(x+nu)*Udag_nu(x)*Lambda_nu(x)
SigmaTerm .................
for (int site = 0; site < Nvol; ++site){
temp_mat = mat_dag(staple,site) * mat(iLambda_nu,site);
temp_mat *= - rho_numu;
AddMat(SigmaTerm, temp_mat, site, mu);
}
sh_field = shiftField(iLambda_nu, mu, Forward());
for (int site = 0; site < Nvol; ++site){
temp_mat = mat(sh_field,site) * mat_dag(staple,site);
temp_mat *= rho_numu;
AddMat(SigmaTerm, temp_mat, site, mu);
}//r_numu*Lambda_nu(mu)*U_nu(x+mu)*Udag_mu(x+nu)*Udag_nu(x)
sh_field = shiftField(iLambda_mu, nu, Forward());
for (int site = 0; site < Nvol; ++site){
temp_mat = mat(U_nu,site) * mat(sh_field,site) * mat_dag(U_nu,site);
temp_mat = mat_dag(staple,site) * temp_mat;
temp_mat *= - rho_munu;
AddMat(SigmaTerm, temp_mat, site, mu);
}//-r_munu*U_nu(x+mu)*Udag_mu(x+nu)*Lambda_mu(x+nu)*Udag_nu(x)
staple = 0.0;
sh_field = shiftField(U_nu, mu, Forward());
for (int site = 0; site < Nvol; ++site){
temp_mat2 = mat_dag(sh_field,site) * mat_dag(U_mu,site);
temp_mat = temp_mat2 * mat(iLambda_mu,site) * mat(U_nu,site);
temp_mat *= - rho_munu;
AddMat(staple, temp_mat, site);
temp_mat = temp_mat2 * mat(iLambda_nu,site) * mat(U_nu,site);
temp_mat *= rho_numu;
AddMat(staple, temp_mat, site);
}
for (int site = 0; site < Nvol; ++site){
temp_mat = mat_dag(U_nu,site) * mat(iLambda_nu,site);
SetMat(u_tmp, temp_mat, site);
}
sh_field = shiftField(u_tmp, mu, Forward());
for (int site = 0; site < Nvol; ++site){
temp_mat = mat(sh_field,site) * mat_dag(U_mu,site) * mat(U_nu,site);
temp_mat *= - rho_numu;
AddMat(staple, temp_mat, site);
}
sh_field = shiftField(staple, nu, Backward());
AddSlice(SigmaTerm, sh_field, mu);
}
}
*/
}
};
#endif

View File

@ -0,0 +1,17 @@
/*
@brief Declares base smearing class Smear
*/
#ifndef BASE_SMEAR_
#define BASE_SMEAR_
template <class Gimpl>
class Smear{
public:
INHERIT_GIMPL_TYPES(Gimpl)
virtual ~Smear(){}
virtual void smear (GaugeField&,const GaugeField&)const = 0;
virtual void derivative(GaugeField&,
const GaugeField&,const GaugeField&) const = 0;
};
#endif

View File

@ -77,10 +77,14 @@ namespace Grid {
void set_GaugeField(){ fill_smearedSet(); } void set_GaugeField(){ fill_smearedSet(); }
void smeared_force(GaugeField&) const; void smeared_force(GaugeField&) const;
GaugeField& get_current_conf() const; GaugeField* get_SmearedU() const{
GaugeField& select_conf(bool smeared) const { return const_cast<GaugeField*>(&(SmearedSet[smearingLevels-1]));
}
GaugeField* get_U(bool smeared=false) const {
// get the config, thin links by default
if (smeared){ if (smeared){
if (smearingLevels) return get_current_conf(); if (smearingLevels) return get_SmearedU();
else return ThinLinks; else return ThinLinks;
} }
else return ThinLinks; else return ThinLinks;
@ -93,4 +97,8 @@ namespace Grid {
} }
#endif #endif

View File

@ -0,0 +1,32 @@
/*
@file stoutSmear.hpp
@brief Declares Stout smearing class
*/
#ifndef STOUT_SMEAR_
#define STOUT_SMEAR_
/*! @brief Stout smearing of link variable. */
template <class Gimpl>
class Smear_Stout: public Smear<Gimpl> {
private:
const std::valarray<double> d_rho;
const Smear* SmearBase;
double func_xi0(double w) const;
public:
INHERIT_GIMPL_TYPES(Gimpl)
Smear_Stout(Smear* base):SmearBase(base){}
/*! Default constructor */
Smear_Stout():SmearBase(new Smear_APE()){}
~Smear_Stout(){}
void smear(GaugeField&,const GaugeField&) const;
void BaseSmear(GaugeField&, const GaugeField&) const;
void derivative(GaugeField&, const GaugeField&, const GaugeField&) const;
void exponentiate_iQ(GaugeField&, const GaugeField&) const;
};
#endif

View File

@ -171,6 +171,89 @@ public:
} }
} }
//////////////////////////////////////////////////
// the sum over all staples on each site in direction mu,nu
//////////////////////////////////////////////////
static void Staple(GaugeMat &staple,const GaugeLorentz &Umu,int mu, in nu){
GridBase *grid = Umu._grid;
std::vector<GaugeMat> U(4,grid);
for(int d=0;d<Nd;d++){
U[d] = PeekIndex<LorentzIndex>(Umu,d);
}
staple = zero;
GaugeMat tmp(grid);
if(nu != mu) {
// mu
// ^
// |__> nu
// __
// |
// __|
//
staple+=Gimpl::ShiftStaple(
Gimpl::CovShiftForward (U[nu],nu,
Gimpl::CovShiftBackward(U[mu],mu,
Gimpl::CovShiftIdentityBackward(U[nu],nu))),mu);
// __
// |
// |__
//
//
staple+=Gimpl::ShiftStaple(
Gimpl::CovShiftBackward(U[nu],nu,
Gimpl::CovShiftBackward(U[mu],mu,U[nu])),mu);
}
}
//////////////////////////////////////////////////
// the sum over all staples on each site in direction mu,nu, upper part
//////////////////////////////////////////////////
static void StapleUpper(GaugeMat &staple,const GaugeLorentz &Umu,int mu, in nu){
GridBase *grid = Umu._grid;
std::vector<GaugeMat> U(4,grid);
for(int d=0;d<Nd;d++){
U[d] = PeekIndex<LorentzIndex>(Umu,d);
}
staple = zero;
GaugeMat tmp(grid);
if(nu != mu) {
// mu
// ^
// |__> nu
// __
// |
// __|
//
staple+=Gimpl::ShiftStaple(
Gimpl::CovShiftForward (U[nu],nu,
Gimpl::CovShiftBackward(U[mu],mu,
Gimpl::CovShiftIdentityBackward(U[nu],nu))),mu);
}
}
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
// Similar to above for rectangle is required // Similar to above for rectangle is required
////////////////////////////////////////////////////// //////////////////////////////////////////////////////