mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-11-04 05:54:32 +00:00 
			
		
		
		
	More on smearing routines, writing APEsmear (dev)
This commit is contained in:
		
							
								
								
									
										150
									
								
								lib/qcd/smearing/APEsmearing.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										150
									
								
								lib/qcd/smearing/APEsmearing.h
									
									
									
									
									
										Normal 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  
 | 
				
			||||||
							
								
								
									
										17
									
								
								lib/qcd/smearing/BaseSmearing.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								lib/qcd/smearing/BaseSmearing.h
									
									
									
									
									
										Normal 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
 | 
				
			||||||
@@ -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
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										32
									
								
								lib/qcd/smearing/StoutSmearing.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								lib/qcd/smearing/StoutSmearing.h
									
									
									
									
									
										Normal 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  
 | 
				
			||||||
@@ -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
 | 
				
			||||||
  //////////////////////////////////////////////////////
 | 
					  //////////////////////////////////////////////////////
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user