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

Checked the hermiticity of the op in derivative, ok

Still CG fails to converge
This commit is contained in:
Guido Cossu 2016-07-31 12:37:33 +01:00
parent 089f0ab582
commit 49b5c49851
6 changed files with 47 additions and 38 deletions

File diff suppressed because one or more lines are too long

View File

@ -134,9 +134,9 @@ class TwoFlavourPseudoFermionAction : public Action<typename Impl::GaugeField> {
MdagMOp.Op(X, Y); MdagMOp.Op(X, Y);
// Check hermiticity // Check hermiticity
/*
std::vector<int> seeds({1,2,3,4}); std::vector<int> seeds({1,2,3,4});
GridParallelRNG RNG(U._grid); RNG.SeedFixedIntegers(seeds); GridParallelRNG RNG(U._grid); RNG.SeedFixedIntegers(seeds);
FermionField RNGphi(FermOp.FermionGrid()); FermionField RNGphi(FermOp.FermionGrid());
FermionField RNGchi(FermOp.FermionGrid()); FermionField RNGchi(FermOp.FermionGrid());
FermionField Achi(FermOp.FermionGrid()); FermionField Achi(FermOp.FermionGrid());
@ -144,8 +144,8 @@ class TwoFlavourPseudoFermionAction : public Action<typename Impl::GaugeField> {
random(RNG, RNGphi); random(RNG, RNGphi);
random(RNG, RNGchi); random(RNG, RNGchi);
MdagMOp.Op(RNGchi, Achi); MdagMOp.HermOp(RNGchi, Achi);
MdagMOp.Op(RNGphi, Aphi); MdagMOp.HermOp(RNGphi, Aphi);
ComplexD pAc = innerProduct(RNGphi, Achi); ComplexD pAc = innerProduct(RNGphi, Achi);
ComplexD cAp = innerProduct(RNGchi, Aphi); ComplexD cAp = innerProduct(RNGchi, Aphi);
//these should be real //these should be real
@ -153,8 +153,9 @@ class TwoFlavourPseudoFermionAction : public Action<typename Impl::GaugeField> {
ComplexD cAc = innerProduct(RNGchi, Achi); ComplexD cAc = innerProduct(RNGchi, Achi);
std::cout<<GridLogMessage<< "pAc "<<pAc<<" cAp "<< cAp<< " diff "<<pAc-adj(cAp)<<std::endl; std::cout<<GridLogMessage<< "pAc "<<pAc<<" cAp "<< cAp<< " diff "<<pAc-adj(cAp)<<std::endl;
// These ones should be real
std::cout << GridLogMessage << "pAp " << pAp << " cAc " << cAc << std::endl; std::cout << GridLogMessage << "pAp " << pAp << " cAc " << cAc << std::endl;
*/
// Our conventions really make this UdSdU; We do not differentiate wrt Udag // Our conventions really make this UdSdU; We do not differentiate wrt Udag
// here. // here.
// So must take dSdU - adj(dSdU) and left multiply by mom to get dS/dt. // So must take dSdU - adj(dSdU) and left multiply by mom to get dS/dt.

View File

@ -109,12 +109,12 @@ class NerscHmcRunnerTemplate {
int Nsmear = 1; // number of smearing levels int Nsmear = 1; // number of smearing levels
Smear_Stout<Gimpl> Stout(rho); Smear_Stout<Gimpl> Stout(rho);
std::cout << GridLogDebug << " Creating the SmearedConfiguration class\n"; std::cout << GridLogDebug << " Creating the SmearedConfiguration class\n";
SmearedConfiguration<Gimpl> SmearingPolicy(UGrid, Nsmear, Stout); //SmearedConfiguration<Gimpl> SmearingPolicy(UGrid, Nsmear, Stout);
std::cout << GridLogDebug << " done\n"; std::cout << GridLogDebug << " done\n";
////////////// //////////////
//NoSmearing<Gimpl> SmearingPolicy; NoSmearing<Gimpl> SmearingPolicy;
typedef MinimumNorm2<GaugeField, SmearedConfiguration<Gimpl>, RepresentationsPolicy > typedef MinimumNorm2<GaugeField, NoSmearing<Gimpl>, RepresentationsPolicy >
IntegratorType; // change here to change the algorithm IntegratorType; // change here to change the algorithm
IntegratorParameters MDpar(20, 1.0); IntegratorParameters MDpar(20, 1.0);
IntegratorType MDynamics(UGrid, MDpar, TheAction, SmearingPolicy); IntegratorType MDynamics(UGrid, MDpar, TheAction, SmearingPolicy);

View File

@ -149,7 +149,7 @@ class Integrator {
} }
// Force from the other representations // Force from the other representations
//as[level].apply(update_P_hireps, Representations, Mom, U, ep); as[level].apply(update_P_hireps, Representations, Mom, U, ep);
} }
void update_U(GaugeField& U, double ep) { void update_U(GaugeField& U, double ep) {
@ -167,13 +167,12 @@ class Integrator {
auto Umu = PeekIndex<LorentzIndex>(U, mu); auto Umu = PeekIndex<LorentzIndex>(U, mu);
auto Pmu = PeekIndex<LorentzIndex>(Mom, mu); auto Pmu = PeekIndex<LorentzIndex>(Mom, mu);
Umu = expMat(Pmu, ep, Params.Nexp) * Umu; Umu = expMat(Pmu, ep, Params.Nexp) * Umu;
ProjectOnGroup(Umu); PokeIndex<LorentzIndex>(U, ProjectOnGroup(Umu), mu);
PokeIndex<LorentzIndex>(U, Umu, mu);
} }
// Update the smeared fields, can be implemented as observer // Update the smeared fields, can be implemented as observer
Smearer.set_GaugeField(U); Smearer.set_GaugeField(U);
// Update the higher representations fields // Update the higher representations fields
//Representations.update(U); // void functions if fundamental representation Representations.update(U); // void functions if fundamental representation
} }
virtual void step(GaugeField& U, int level, int first, int last) = 0; virtual void step(GaugeField& U, int level, int first, int last) = 0;
@ -217,7 +216,7 @@ class Integrator {
// of the Metropolis // of the Metropolis
Smearer.set_GaugeField(U); Smearer.set_GaugeField(U);
// Set the (eventual) representations gauge fields // Set the (eventual) representations gauge fields
//Representations.update(U); Representations.update(U);
// The Smearer is attached to a pointer of the gauge field // The Smearer is attached to a pointer of the gauge field
// automatically gets the correct field // automatically gets the correct field
@ -232,7 +231,7 @@ class Integrator {
} }
// Refresh the higher representation actions // Refresh the higher representation actions
//as[level].apply(refresh_hireps, Representations, pRNG); as[level].apply(refresh_hireps, Representations, pRNG);
} }
} }
@ -281,7 +280,7 @@ class Integrator {
<< actionID << " H = " << Hterm << std::endl; << actionID << " H = " << Hterm << std::endl;
H += Hterm; H += Hterm;
} }
//as[level].apply(S_hireps, Representations, level, H); as[level].apply(S_hireps, Representations, level, H);
} }
return H; return H;

View File

@ -1,6 +1,6 @@
/* /*
* Policy classes for the HMC * Policy classes for the HMC
* Author: Guido Cossu * Author: Guido Cossu
*/ */
#ifndef ADJOINT_H #ifndef ADJOINT_H
@ -27,8 +27,9 @@ class AdjointRep {
LatticeField U; LatticeField U;
explicit AdjointRep(GridBase *grid) : U(grid) {} explicit AdjointRep(GridBase *grid) : U(grid) {}
void update_representation(const LatticeGaugeField &Uin) { void update_representation(const LatticeGaugeField &Uin) {
std::cout << GridLogDebug << "Updating adjoint representation\n" ; std::cout << GridLogDebug << "Updating adjoint representation\n" ;
// Uin is in the fundamental representation // Uin is in the fundamental representation
// get the U in AdjointRep // get the U in AdjointRep
// (U_adj)_B = tr[e^a U e^b U^dag] // (U_adj)_B = tr[e^a U e^b U^dag]
@ -41,28 +42,36 @@ class AdjointRep {
Vector<typename SU<ncolour>::Matrix> ta(Dimension); Vector<typename SU<ncolour>::Matrix> ta(Dimension);
// Debug lines
//LatticeMatrix uno(Uin._grid);
//uno = 1.0;
////////////////
// FIXME probably not very efficient to get all the generators // FIXME probably not very efficient to get all the generators
// everytime // everytime
for (int a = 0; a < Dimension; a++) SU<ncolour>::generator(a, ta[a]); for (int a = 0; a < Dimension; a++) SU<ncolour>::generator(a, ta[a]);
for (int mu = 0; mu < Nd; mu++) { for (int mu = 0; mu < Nd; mu++) {
auto Uin_mu = peekLorentz(Uin, mu); auto Uin_mu = peekLorentz(Uin, mu);
auto U_mu = peekLorentz(U, mu); auto U_mu = peekLorentz(U, mu);
for (int a = 0; a < Dimension; a++) { for (int a = 0; a < Dimension; a++) {
tmp = 2.0 * adj(Uin_mu) * ta[a] * Uin_mu; tmp = 2.0 * adj(Uin_mu) * ta[a] * Uin_mu;
for (int b = 0; b < Dimension; b++) for (int b = 0; b < Dimension; b++)
pokeColour(U_mu, trace(tmp * ta[b]), a, b); pokeColour(U_mu, trace(tmp * ta[b]), b, a);
} }
// Check matrix U_mu, must be real orthogonal
//reality
LatticeMatrix Ucheck = U_mu - conjugate(U_mu);
std::cout << GridLogMessage << "Reality check: " << norm2(Ucheck) << std::endl;
LatticeMatrix uno(Uin._grid);
uno = 1.0;
Ucheck = U_mu * adj(U_mu) - uno;
std::cout << GridLogMessage << "orthogonality check: " << norm2(Ucheck) << std::endl;
pokeLorentz(U, U_mu, mu); pokeLorentz(U, U_mu, mu);
// Check matrix U_mu, must be real orthogonal
// reality
/*
LatticeMatrix Ucheck = U_mu - conjugate(U_mu);
std::cout << GridLogMessage << "Reality check: " << norm2(Ucheck) <<
std::endl;
Ucheck = U_mu * adj(U_mu) - uno;
std::cout << GridLogMessage << "orthogonality check: " << norm2(Ucheck) <<
std::endl;
*/
} }
} }
@ -81,8 +90,8 @@ class AdjointRep {
projectOnAlgebra(h, in_mu, scale); projectOnAlgebra(h, in_mu, scale);
FundamentalLieAlgebraMatrix(h, out_mu, 1.0); // apply scale only once FundamentalLieAlgebraMatrix(h, out_mu, 1.0); // apply scale only once
pokeLorentz(out, out_mu, mu); pokeLorentz(out, out_mu, mu);
// Returns traceless antihermitian matrix Nc * Nc. // Returns traceless antihermitian matrix Nc * Nc.
// Confirmed // Confirmed
} }
return out; return out;
} }

View File

@ -39,8 +39,8 @@ namespace Grid {
namespace QCD { namespace QCD {
// Here change the allowed (higher) representations // Here change the allowed (higher) representations
//typedef Representations< FundamentalRepresentation, AdjointRepresentation > TheRepresentations; typedef Representations< FundamentalRepresentation, AdjointRepresentation > TheRepresentations;
typedef Representations< FundamentalRepresentation > TheRepresentations; //typedef Representations< FundamentalRepresentation > TheRepresentations;
class HmcRunner : public NerscHmcRunnerHirep< TheRepresentations > { class HmcRunner : public NerscHmcRunnerHirep< TheRepresentations > {
@ -48,8 +48,8 @@ class HmcRunner : public NerscHmcRunnerHirep< TheRepresentations > {
void BuildTheAction(int argc, char **argv) void BuildTheAction(int argc, char **argv)
{ {
typedef WilsonImplR ImplPolicy; // gauge field implemetation for the pseudofermions typedef WilsonAdjImplR ImplPolicy; // gauge field implemetation for the pseudofermions
typedef WilsonFermionR FermionAction; // type of lattice fermions (Wilson, DW, ...) typedef WilsonAdjFermionR FermionAction; // type of lattice fermions (Wilson, DW, ...)
typedef typename FermionAction::FermionField FermionField; typedef typename FermionAction::FermionField FermionField;
UGrid = SpaceTimeGrid::makeFourDimGrid( UGrid = SpaceTimeGrid::makeFourDimGrid(
@ -61,8 +61,8 @@ class HmcRunner : public NerscHmcRunnerHirep< TheRepresentations > {
FrbGrid = UrbGrid; FrbGrid = UrbGrid;
// temporarily need a gauge field // temporarily need a gauge field
LatticeGaugeField U(UGrid); //LatticeGaugeField U(UGrid);
//AdjointRepresentation::LatticeField U(UGrid); AdjointRepresentation::LatticeField U(UGrid);
// Gauge action // Gauge action
WilsonGaugeActionR Waction(5.6); WilsonGaugeActionR Waction(5.6);