1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-04-04 19:25:56 +01:00

Debugging smeared HMC

This commit is contained in:
neo 2016-04-13 17:00:14 +09:00
parent a87b744621
commit 339be37dba
8 changed files with 63 additions and 35 deletions

View File

@ -100,7 +100,7 @@ namespace Grid{
PhiOdd =PhiOdd*scale; PhiOdd =PhiOdd*scale;
PhiEven=PhiEven*scale; PhiEven=PhiEven*scale;
}; };
////////////////////////////////////////////////////// //////////////////////////////////////////////////////

View File

@ -94,7 +94,7 @@ public:
// Smearing policy // Smearing policy
std::cout << GridLogMessage << " Creating the Stout class\n"; std::cout << GridLogMessage << " Creating the Stout class\n";
double rho = 0.1; // smearing parameter double rho = 0.1; // smearing parameter
int Nsmear = 3; // number of smearing levels int Nsmear = 1; // number of smearing levels
Smear_Stout<Gimpl> Stout(rho); Smear_Stout<Gimpl> Stout(rho);
std::cout << GridLogMessage << " Creating the SmearedConfiguration class\n"; std::cout << GridLogMessage << " Creating the SmearedConfiguration class\n";
SmearedConfiguration<Gimpl> SmearingPolicy(UGrid, Nsmear, Stout); SmearedConfiguration<Gimpl> SmearingPolicy(UGrid, Nsmear, Stout);
@ -144,7 +144,7 @@ public:
// Attach the gauge field to the smearing Policy and create the fill the smeared set // Attach the gauge field to the smearing Policy and create the fill the smeared set
// notice that the unit configuration is singular in this procedure // notice that the unit configuration is singular in this procedure
std::cout << GridLogMessage << " Filling the smeared set\n"; std::cout << GridLogMessage << "Filling the smeared set\n";
SmearingPolicy.set_GaugeField(U); SmearingPolicy.set_GaugeField(U);
HybridMonteCarlo<GaugeField,IntegratorType> HMC(HMCpar, MDynamics,sRNG,pRNG,U); HybridMonteCarlo<GaugeField,IntegratorType> HMC(HMCpar, MDynamics,sRNG,pRNG,U);

View File

@ -115,10 +115,12 @@ namespace Grid{
void update_P(GaugeField &Mom,GaugeField&U, int level,double ep){ void update_P(GaugeField &Mom,GaugeField&U, int level,double ep){
for(int a=0; a<as[level].actions.size(); ++a){ for(int a=0; a<as[level].actions.size(); ++a){
GaugeField force(U._grid); GaugeField force(U._grid);
as[level].actions.at(a)->deriv(U,force); // deriv should not include Ta GaugeField& Us = Smearer.get_U(as[level].actions.at(a)->is_smeared);
as[level].actions.at(a)->deriv(Us,force); // deriv should not include Ta
std::cout<<GridLogIntegrator<< "Smearing (on/off): "<<as[level].actions.at(a)->is_smeared <<std::endl; std::cout<<GridLogIntegrator<< "Smearing (on/off): "<<as[level].actions.at(a)->is_smeared <<std::endl;
if (as[level].actions.at(a)->is_smeared) Smearer.smeared_force(force); if (as[level].actions.at(a)->is_smeared) Smearer.smeared_force(force);
force = Ta(force); force = Ta(force);
std::cout<<GridLogIntegrator<< "Force average: "<< norm2(force)/(U._grid->gSites()) <<std::endl;
Mom = Mom - force*ep; Mom = Mom - force*ep;
} }
} }

View File

@ -35,6 +35,7 @@ namespace Grid {
Smear_APE():rho(set_rho(1.0)){} Smear_APE():rho(set_rho(1.0)){}
~Smear_APE(){} ~Smear_APE(){}
///////////////////////////////////////////////////////////////////////////////
void smear(GaugeField& u_smr, const GaugeField& U)const{ void smear(GaugeField& u_smr, const GaugeField& U)const{
GridBase *grid = U._grid; GridBase *grid = U._grid;
double d_rho; double d_rho;
@ -45,16 +46,19 @@ namespace Grid {
for(int mu=0; mu<Nd; ++mu){ for(int mu=0; mu<Nd; ++mu){
Cup = zero; Cup = zero;
for(int nu=0; nu<Nd; ++nu){ for(int nu=0; nu<Nd; ++nu){
d_rho = rho[mu + Nd * nu]; if (nu != mu) {
// get the staple in direction mu, nu d_rho = rho[mu + Nd * nu];
WL.Staple(tmp_stpl, U, mu, nu); //nb staple conventions of IroIro and Grid differ by a dag // get the staple in direction mu, nu
Cup += tmp_stpl*d_rho; WL.Staple(tmp_stpl, U, mu, nu); //nb staple conventions of IroIro and Grid differ by a dagger
Cup += tmp_stpl*d_rho;
}
} }
// save the Cup link-field on the u_smr gauge-field // save the Cup link-field on the u_smr gauge-field
pokeLorentz(u_smr, adj(Cup), mu); // u_smr[mu] = Cup^dag pokeLorentz(u_smr, adj(Cup), mu); // u_smr[mu] = Cup^dag
} }
} }
////////////////////////////////////////////////////////////////////////////////
void derivative(GaugeField& SigmaTerm, void derivative(GaugeField& SigmaTerm,
const GaugeField& iLambda, const GaugeField& iLambda,
const GaugeField& U)const{ const GaugeField& U)const{

View File

@ -48,6 +48,10 @@ namespace Grid {
for(int smearLvl = 0; smearLvl < smearingLevels; ++smearLvl){ for(int smearLvl = 0; smearLvl < smearingLevels; ++smearLvl){
StoutSmearing.smear(SmearedSet[smearLvl],previous_u); StoutSmearing.smear(SmearedSet[smearLvl],previous_u);
previous_u = SmearedSet[smearLvl]; previous_u = SmearedSet[smearLvl];
RealD impl_plaq = WilsonLoops<Gimpl>::avgPlaquette(previous_u);
std::cout<< GridLogDebug << "[SmearedConfiguration] Plaq: " << impl_plaq<< std::endl;
} }
} }
@ -73,14 +77,14 @@ namespace Grid {
pokeLorentz(SigmaK, SigmaKPrime_mu*e_iQ + adj(Cmu)*iLambda_mu, mu); pokeLorentz(SigmaK, SigmaKPrime_mu*e_iQ + adj(Cmu)*iLambda_mu, mu);
pokeLorentz(iLambda, iLambda_mu, mu); pokeLorentz(iLambda, iLambda_mu, mu);
} }
StoutSmearing.derivative(SigmaK, iLambda, GaugeK); StoutSmearing.derivative(SigmaK, iLambda, GaugeK);// derivative of SmearBase
return SigmaK; return SigmaK;
} }
/*! @brief Returns smeared configuration at level 'Level' */ /*! @brief Returns smeared configuration at level 'Level' */
const GaugeField& get_smeared_conf(int Level) const{ const GaugeField& get_smeared_conf(int Level) const{
return SmearedSet[Level]; return SmearedSet[Level];
} }
//====================================================================
void set_iLambda(GaugeLinkField& iLambda, void set_iLambda(GaugeLinkField& iLambda,
GaugeLinkField& e_iQ, GaugeLinkField& e_iQ,
const GaugeLinkField& iQ, const GaugeLinkField& iQ,
@ -117,8 +121,8 @@ namespace Grid {
w2 = w * w; w2 = w * w;
cosw = cos(w); cosw = cos(w);
emiu = toComplex(cos(u)) - timesI(toComplex(u)); emiu = toComplex(cos(u)) - timesI(toComplex(sin(u)));
e2iu = toComplex(cos(2.0*u)) + timesI(toComplex(2.0*u)); e2iu = toComplex(cos(2.0*u)) + timesI(toComplex(sin(2.0*u)));
r01 = (toComplex(2.0*u) + timesI(toComplex(2.0*(u2-w2)))) * e2iu r01 = (toComplex(2.0*u) + timesI(toComplex(2.0*(u2-w2)))) * e2iu
+ emiu * (toComplex(16.0*u*cosw + 2.0*u*(3.0*u2+w2)*xi0) + + emiu * (toComplex(16.0*u*cosw + 2.0*u*(3.0*u2+w2)*xi0) +
@ -174,7 +178,7 @@ namespace Grid {
} }
//====================================================================
public: public:
GaugeField* ThinLinks; /*!< @brief Pointer to the thin GaugeField* ThinLinks; /*!< @brief Pointer to the thin
links configuration */ links configuration */
@ -201,12 +205,14 @@ namespace Grid {
// attach the smeared routines to the thin links U and fill the smeared set // 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(GaugeField& U){ fill_smearedSet(U);}
//====================================================================
void smeared_force(GaugeField& SigmaTilde) const{ void smeared_force(GaugeField& SigmaTilde) const{
if (smearingLevels > 0){ if (smearingLevels > 0){
GaugeField force = SigmaTilde;//actually = U*SigmaTilde, check this for Grid GaugeField force = SigmaTilde;//actually = U*SigmaTilde
GaugeLinkField tmp_mu(SigmaTilde._grid); GaugeLinkField tmp_mu(SigmaTilde._grid);
for (int mu = 0; mu < Nd; mu++){ for (int mu = 0; mu < Nd; mu++){
// to get SigmaTilde
tmp_mu = adj(peekLorentz(SmearedSet[smearingLevels-1], mu)) * peekLorentz(force,mu); tmp_mu = adj(peekLorentz(SmearedSet[smearingLevels-1], mu)) * peekLorentz(force,mu);
pokeLorentz(force, tmp_mu, mu); pokeLorentz(force, tmp_mu, mu);
} }
@ -221,7 +227,8 @@ namespace Grid {
} }
}// if smearingLevels = 0 do nothing }// if smearingLevels = 0 do nothing
} }
//====================================================================
GaugeField& get_SmearedU(){ GaugeField& get_SmearedU(){
return SmearedSet[smearingLevels-1]; return SmearedSet[smearingLevels-1];
@ -230,10 +237,22 @@ namespace Grid {
GaugeField& get_U(bool smeared=false) { GaugeField& get_U(bool smeared=false) {
// get the config, thin links by default // get the config, thin links by default
if (smeared){ if (smeared){
if (smearingLevels) return get_SmearedU(); if (smearingLevels){
else return *ThinLinks; RealD impl_plaq = WilsonLoops<Gimpl>::avgPlaquette(SmearedSet[smearingLevels-1]);
std::cout<< GridLogDebug << "getting U Plaq: " << impl_plaq<< std::endl;
return get_SmearedU();
}
else {
RealD impl_plaq = WilsonLoops<Gimpl>::avgPlaquette(*ThinLinks);
std::cout<< GridLogDebug << "getting Thin Plaq: " << impl_plaq<< std::endl;
return *ThinLinks;
}
} }
else return *ThinLinks; else{
RealD impl_plaq = WilsonLoops<Gimpl>::avgPlaquette(*ThinLinks);
std::cout<< GridLogDebug << "getting Thin Plaq: " << impl_plaq<< std::endl;
return *ThinLinks;}
} }
}; };

View File

@ -33,7 +33,7 @@ namespace Grid {
void smear(GaugeField& u_smr,const GaugeField& U) const{ void smear(GaugeField& u_smr,const GaugeField& U) const{
GaugeField C(U._grid); GaugeField C(U._grid);
GaugeLinkField tmp(U._grid), q_mu(U._grid), Umu(U._grid); GaugeLinkField tmp(U._grid), iq_mu(U._grid), Umu(U._grid);
std::cout<< GridLogDebug << "Stout smearing started\n"; std::cout<< GridLogDebug << "Stout smearing started\n";
@ -42,8 +42,8 @@ namespace Grid {
for (int mu = 0; mu<Nd; mu++){ for (int mu = 0; mu<Nd; mu++){
tmp = peekLorentz(C,mu); tmp = peekLorentz(C,mu);
Umu = peekLorentz(U,mu); Umu = peekLorentz(U,mu);
q_mu = Ta(tmp * adj(Umu)); // q_mu = Ta(Omega_mu) iq_mu = Ta(tmp * adj(Umu)); // iq_mu = Ta(Omega_mu) to match the signs with the paper
exponentiate_iQ(tmp, q_mu); exponentiate_iQ(tmp, iq_mu);
pokeLorentz(u_smr, tmp*Umu, mu);// u_smr = exp(iQ_mu)*U_mu pokeLorentz(u_smr, tmp*Umu, mu);// u_smr = exp(iQ_mu)*U_mu
} }
@ -68,6 +68,10 @@ namespace Grid {
// only one Lorentz direction at a time // only one Lorentz direction at a time
// notice that it actually computes
// exp ( input matrix )
// the i sign is coming from outside
// input matrix is anti-hermitian NOT hermitian
GridBase *grid = iQ._grid; GridBase *grid = iQ._grid;
GaugeLinkField unity(grid); GaugeLinkField unity(grid);
@ -94,6 +98,7 @@ namespace Grid {
GridBase *grid = u._grid; GridBase *grid = u._grid;
LatticeReal c0(grid), c1(grid), tmp(grid), c0max(grid), theta(grid); LatticeReal c0(grid), c1(grid), tmp(grid), c0max(grid), theta(grid);
// sign in c0 from the conventions on the Ta
c0 = - toReal(imag(trace(iQ3))) * one_over_three; c0 = - toReal(imag(trace(iQ3))) * one_over_three;
c1 = - toReal(real(trace(iQ2))) * one_over_two; c1 = - toReal(real(trace(iQ2))) * one_over_two;
tmp = c1 * one_over_three; tmp = c1 * one_over_three;
@ -101,7 +106,7 @@ namespace Grid {
theta = acos(c0/c0max); theta = acos(c0/c0max);
u = sqrt(tmp) * cos( theta * one_over_three); u = sqrt(tmp) * cos( theta * one_over_three);
w = sqrt(c1) * sin ( theta * one_over_three); w = sqrt(c1) * sin( theta * one_over_three);
} }
void set_fj(LatticeComplex& f0, LatticeComplex& f1, LatticeComplex& f2, void set_fj(LatticeComplex& f0, LatticeComplex& f1, LatticeComplex& f2,

View File

@ -197,7 +197,7 @@ namespace Grid {
Gimpl::CovShiftForward (U[nu],nu, Gimpl::CovShiftForward (U[nu],nu,
Gimpl::CovShiftBackward(U[mu],mu, Gimpl::CovShiftBackward(U[mu],mu,
Gimpl::CovShiftIdentityBackward(U[nu],nu))),mu); Gimpl::CovShiftIdentityBackward(U[nu],nu))),mu);
// __ // __
// | // |
// |__ // |__
@ -216,27 +216,25 @@ namespace Grid {
////////////////////////////////////////////////// //////////////////////////////////////////////////
static void StapleUpper(GaugeMat &staple,const GaugeLorentz &Umu,int mu, int nu){ static void StapleUpper(GaugeMat &staple,const GaugeLorentz &Umu,int mu, int 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; staple = zero;
if(nu != mu) { if(nu != mu) {
GridBase *grid = Umu._grid;
std::vector<GaugeMat> U(4,grid);
for(int d=0;d<Nd;d++){
U[d] = PeekIndex<LorentzIndex>(Umu,d);
}
// mu // mu
// ^ // ^
// |__> nu // |__> nu
// __ // __
// | // |
// __| // __|
// //
staple+=Gimpl::ShiftStaple( staple+=Gimpl::ShiftStaple(
Gimpl::CovShiftForward (U[nu],nu, Gimpl::CovShiftForward (U[nu],nu,
Gimpl::CovShiftBackward(U[mu],mu, Gimpl::CovShiftBackward(U[mu],mu,

View File

@ -66,7 +66,7 @@ public:
TwoFlavourEvenOddPseudoFermionAction<ImplPolicy> Nf2(FermOp,CG,CG); TwoFlavourEvenOddPseudoFermionAction<ImplPolicy> Nf2(FermOp,CG,CG);
Nf2.is_smeared=false; Nf2.is_smeared=true;
//Collect actions //Collect actions
ActionLevel<LatticeGaugeField> Level1(1); ActionLevel<LatticeGaugeField> Level1(1);