1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-06-15 14:27:06 +01:00

Debugging the Smearing routines

This commit is contained in:
2016-04-05 16:19:30 +09:00
parent 2d8bb356e3
commit 4b1cf580e0
10 changed files with 118 additions and 67 deletions

View File

@ -35,21 +35,22 @@ namespace Grid {
Smear_APE():rho(set_rho(1.0)){}
~Smear_APE(){}
void smear(GaugeField& u_smr, const GaugeField& U)const{
GridBase *grid = U._grid;
double d_rho;
GaugeLinkField Cup(grid), tmp_stpl(grid);
WilsonLoops<Gimpl> WL;
u_smr = zero; // probably unecessary
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];
// get the staple in direction mu, nu
WL.Staple(tmp_stpl, U, mu, nu); //nb staple conventions of IroIro and Grid differ by a dag
Cup += tmp_stpl*d_rho;
}
// save the Cup link-field on the u_smr gauge-field
pokeLorentz(u_smr, adj(Cup), mu); // u_smr[mu] = Cup^dag
}
}
@ -66,8 +67,10 @@ namespace Grid {
int vol = U._grid->gSites();
WilsonLoops<Gimpl> WL;
GaugeLinkField staple(grid), u_tmp(grid), iLambda_mu(grid), iLambda_nu(grid);
GaugeLinkField U_mu(grid), U_nu(grid), sh_field(grid), temp_Sigma(grid);
GaugeLinkField staple(grid), u_tmp(grid);
GaugeLinkField iLambda_mu(grid), iLambda_nu(grid);
GaugeLinkField U_mu(grid), U_nu(grid);
GaugeLinkField sh_field(grid), temp_Sigma(grid);
Real rho_munu, rho_numu;
for(int mu = 0; mu < Nd; ++mu){

View File

@ -7,7 +7,7 @@
template <class Gimpl>
class Smear{
public:
INHERIT_GIMPL_TYPES(Gimpl)
INHERIT_GIMPL_TYPES(Gimpl) // inherits the types for the gauge fields
virtual ~Smear(){}
virtual void smear (GaugeField&,const GaugeField&)const = 0;

View File

@ -22,7 +22,7 @@ namespace Grid {
It stores a list of smeared configurations.
*/
template <class Gimpl>
class SmearedConfiguration {
class SmearedConfiguration {
public:
INHERIT_GIMPL_TYPES(Gimpl) ;
@ -33,17 +33,23 @@ namespace Grid {
// Member functions
//====================================================================
void fill_smearedSet(){
GaugeField previous_u;
void fill_smearedSet(GaugeField& U){
ThinLinks = &U; //attach the smearing routine to the field U
//check that the pointer is not null
if (ThinLinks==NULL)
std::cout << GridLogError << "[SmearedConfiguration] Error in ThinLinks pointer\n";
std::cout<< GridLogDebug << "[SmearedConfiguration] Filling SmearedSet\n";
previous_u = *ThinLinks;
for(int smearLvl = 0; smearLvl < smearingLevels; ++smearLvl){
StoutSmearing.smear(SmearedSet[smearLvl],previous_u);
previous_u = SmearedSet[smearLvl];
if (smearingLevels > 0){
GaugeField previous_u(U._grid);
std::cout<< GridLogDebug << "[SmearedConfiguration] Filling SmearedSet\n";
previous_u = *ThinLinks;
for(int smearLvl = 0; smearLvl < smearingLevels; ++smearLvl){
StoutSmearing.smear(SmearedSet[smearLvl],previous_u);
previous_u = SmearedSet[smearLvl];
}
}
}
//====================================================================
GaugeField AnalyticSmearedForce(const GaugeField& SigmaKPrime,
@ -86,9 +92,9 @@ namespace Grid {
LatticeReal u(grid), w(grid);
LatticeComplex f0(grid), f1(grid), f2(grid);
LatticeReal xi0(grid), xi1(grid), fden(grid), tmp(grid);
LatticeReal xi0(grid), xi1(grid), tmp(grid);
LatticeReal u2(grid), w2(grid), cosw(grid);
LatticeComplex emiu(grid), e2iu(grid), qt(grid);
LatticeComplex emiu(grid), e2iu(grid), qt(grid), fden(grid);
LatticeComplex r01(grid), r11(grid), r21(grid), r02(grid), r12(grid);
LatticeComplex r22(grid), tr1(grid), tr2(grid);
LatticeComplex b10(grid), b11(grid), b12(grid), b20(grid), b21(grid), b22(grid);
@ -173,66 +179,70 @@ namespace Grid {
links configuration */
/*! @brief Standard constructor */
SmearedConfiguration(GridCartesian * UGrid,
unsigned int Nsmear,
Smear_Stout<Gimpl>& Stout):
smearingLevels(Nsmear),
SmearedConfiguration(GridCartesian * UGrid,
unsigned int Nsmear,
Smear_Stout<Gimpl>& Stout):
smearingLevels(Nsmear),
StoutSmearing(Stout),
ThinLinks(new GaugeField(UGrid)){
ThinLinks(NULL){
for (unsigned int i=0; i< smearingLevels; ++i)
SmearedSet.push_back(*(new GaugeField(UGrid)));
}
/*! For just thin links */
SmearedConfiguration(GridCartesian * UGrid):
smearingLevels(0),
SmearedConfiguration():
smearingLevels(0),
StoutSmearing(),
SmearedSet(0),
ThinLinks(new GaugeField(UGrid)){}
SmearedSet(),
ThinLinks(NULL){}
// attach the smeared routines to the thin links U and fill the smeared set
void set_GaugeField(GaugeField& U){ fill_smearedSet(U);}
void set_GaugeField(){ fill_smearedSet(); }
void smeared_force(GaugeField& SigmaTilde) const{
GaugeField force = SigmaTilde;//actually = U*SigmaTilde, check this for Grid
GaugeLinkField tmp_mu(SigmaTilde._grid);
for (int mu = 0; mu < Nd; mu++){
tmp_mu = adj(peekLorentz(SmearedSet[smearingLevels-1], mu)) * peekLorentz(force,mu);
pokeLorentz(force, tmp_mu, mu);
pokeLorentz(force, tmp_mu, mu);
}
for(int ismr = smearingLevels - 1; ismr > 0; --ismr)
force = AnalyticSmearedForce(force,get_smeared_conf(ismr-1));
force = AnalyticSmearedForce(force,*ThinLinks);
for (int mu = 0; mu < Nd; mu++){
tmp_mu = peekLorentz(*ThinLinks, mu) * peekLorentz(force, mu);
pokeLorentz(SigmaTilde, tmp_mu, mu);
}
}
GaugeField* get_SmearedU() const{
return const_cast<GaugeField*>(&(SmearedSet[smearingLevels-1]));
GaugeField& get_SmearedU(){
return SmearedSet[smearingLevels-1];
}
GaugeField* get_U(bool smeared=false) const {
GaugeField& get_U(bool smeared=false) {
// get the config, thin links by default
if (smeared){
if (smearingLevels) return get_SmearedU();
else return ThinLinks;
else return *ThinLinks;
}
else return ThinLinks;
else return *ThinLinks;
}
};
}
}
#endif

View File

@ -20,10 +20,14 @@ namespace Grid {
public:
INHERIT_GIMPL_TYPES(Gimpl)
Smear_Stout(Smear < Gimpl >* base):SmearBase(base){}
Smear_Stout(Smear < Gimpl >* base):SmearBase(base){
static_assert(Nc==3, "Stout smearing currently implemented only for Nc==3");
}
/*! Default constructor */
Smear_Stout():SmearBase(new Smear_APE < Gimpl > ()){}
Smear_Stout():SmearBase(new Smear_APE < Gimpl > ()){
static_assert(Nc==3, "Stout smearing currently implemented only for Nc==3");
}
~Smear_Stout(){}