mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-11-04 05:54:32 +00:00 
			
		
		
		
	HMC for Wilson Gauge action works
Fixed bug in momenta generation
This commit is contained in:
		@@ -27,16 +27,13 @@ namespace Grid{
 | 
			
		||||
	//not optimal implementation FIXME
 | 
			
		||||
	//extend Ta to include Lorentz indexes
 | 
			
		||||
	RealD factor = 0.5*beta/RealD(Nc);
 | 
			
		||||
	std::cout << "Debug force Wilson  "<< factor << "\n";
 | 
			
		||||
	MatrixField dSdU_mu(U._grid);
 | 
			
		||||
	MatrixField Umu(U._grid);
 | 
			
		||||
	for (int mu=0; mu < Nd; mu++){
 | 
			
		||||
	  Umu = PeekIndex<LorentzIndex>(U,mu);
 | 
			
		||||
	  // Staple in direction mu
 | 
			
		||||
	  WilsonLoops<MatrixField,GaugeField>::Staple(dSdU_mu,U,mu);
 | 
			
		||||
	  std::cout << "Staple norm ["<<mu<<"] = "<< norm2(dSdU_mu) <<"\n";
 | 
			
		||||
	  dSdU_mu = Ta(Umu*adj(dSdU_mu))*factor;
 | 
			
		||||
	  std::cout << "Force norm ["<<mu<<"] = "<< norm2(dSdU_mu) << "  : Umu "<< norm2(Umu)<<"\n";
 | 
			
		||||
	  pokeLorentz(dSdU, dSdU_mu, mu);
 | 
			
		||||
	}
 | 
			
		||||
      };
 | 
			
		||||
 
 | 
			
		||||
@@ -7,9 +7,9 @@ namespace Grid{
 | 
			
		||||
	// FIXME fill this constructor  now just default values
 | 
			
		||||
	  
 | 
			
		||||
	////////////////////////////// Default values
 | 
			
		||||
	Nsweeps             = 10;
 | 
			
		||||
	TotalSweeps         = 10;
 | 
			
		||||
	ThermalizationSteps = 1;
 | 
			
		||||
	Nsweeps             = 100;
 | 
			
		||||
	TotalSweeps         = 20;
 | 
			
		||||
	ThermalizationSteps = 20;
 | 
			
		||||
	StartingConfig      = 0;
 | 
			
		||||
	SaveInterval        = 1;
 | 
			
		||||
	Filename_prefix     = "Conf_";
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,7 @@
 | 
			
		||||
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <memory>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
 | 
			
		||||
namespace Grid{
 | 
			
		||||
  namespace QCD{
 | 
			
		||||
@@ -55,12 +56,12 @@ namespace Grid{
 | 
			
		||||
 | 
			
		||||
	MD.init(U,pRNG);     // set U and initialize P and phi's 
 | 
			
		||||
	RealD H0 = MD.S(U);     // current state            
 | 
			
		||||
	std::cout<<"Total H_before = "<< H0 << "\n";
 | 
			
		||||
	std::cout<<"Total H before = "<< H0 << "\n";
 | 
			
		||||
      
 | 
			
		||||
	MD.integrate(U,0);
 | 
			
		||||
      
 | 
			
		||||
	RealD H1 = MD.S(U);     // updated state            
 | 
			
		||||
	std::cout<<"Total H_after = "<< H1 << "\n";
 | 
			
		||||
	std::cout<<"Total H after = "<< H1 << "\n";
 | 
			
		||||
      
 | 
			
		||||
	return (H1-H0);
 | 
			
		||||
      }
 | 
			
		||||
@@ -84,19 +85,14 @@ namespace Grid{
 | 
			
		||||
 | 
			
		||||
      void evolve(LatticeLorentzColourMatrix& Uin){
 | 
			
		||||
	Real DeltaH;
 | 
			
		||||
	Real timer;
 | 
			
		||||
      
 | 
			
		||||
	// Thermalizations
 | 
			
		||||
	for(int iter=1; iter <= Params.ThermalizationSteps; ++iter){
 | 
			
		||||
	  std::cout << "-- # Thermalization step = "<< iter <<  "\n";
 | 
			
		||||
	
 | 
			
		||||
	  DeltaH = evolve_step(Uin);
 | 
			
		||||
	
 | 
			
		||||
	  std::cout<< "[Timing] Trajectory time (s) : "<< timer/1000.0 << "\n";
 | 
			
		||||
	  std::cout<< " dH = "<< DeltaH << "\n";
 | 
			
		||||
	
 | 
			
		||||
	  // Update matrix
 | 
			
		||||
	  //Uin = MD->get_U();  //accept every time
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Actual updates (evolve a copy Ucopy then copy back eventually)
 | 
			
		||||
@@ -109,13 +105,9 @@ namespace Grid{
 | 
			
		||||
	  DeltaH = evolve_step(Ucopy);
 | 
			
		||||
		
 | 
			
		||||
	  if(metropolis_test(DeltaH)) Uin = Ucopy;
 | 
			
		||||
	  // need sync?	
 | 
			
		||||
	  //need sync?
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
      
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    };
 | 
			
		||||
    
 | 
			
		||||
  }// QCD
 | 
			
		||||
 
 | 
			
		||||
@@ -15,10 +15,12 @@ namespace Grid{
 | 
			
		||||
 | 
			
		||||
    void MDutils::generate_momenta_su3(LatticeLorentzColourMatrix& P,GridParallelRNG& pRNG){
 | 
			
		||||
      LatticeColourMatrix Pmu(P._grid);
 | 
			
		||||
      Pmu = zero;
 | 
			
		||||
      for(int mu=0;mu<Nd;mu++){
 | 
			
		||||
	SU3::GaussianLieAlgebraMatrix(pRNG, Pmu);
 | 
			
		||||
	pokeLorentz(P, Pmu, mu);
 | 
			
		||||
      }
 | 
			
		||||
      
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -71,14 +71,13 @@ namespace Grid{
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
      void update_U(LatticeLorentzColourMatrix&U, double ep){
 | 
			
		||||
	//rewrite exponential to deal with the lorentz index?
 | 
			
		||||
	//rewrite exponential to deal automatically  with the lorentz index?
 | 
			
		||||
	LatticeColourMatrix Umu(U._grid);
 | 
			
		||||
	LatticeColourMatrix Pmu(U._grid);
 | 
			
		||||
	for (int mu = 0; mu < Nd; mu++){
 | 
			
		||||
	  Umu=peekLorentz(U, mu);
 | 
			
		||||
	  Pmu=peekLorentz(*P, mu);
 | 
			
		||||
	  std::cout << "U norm ["<<mu<<"] = "<< norm2(Umu) << "  : Pmu "<< norm2(Pmu)<<"\n";
 | 
			
		||||
	  Umu = expMat(Pmu, Complex(ep, 0.0))*Umu;
 | 
			
		||||
	  Umu = expMat(Pmu, ep)*Umu;
 | 
			
		||||
	  pokeLorentz(U, Umu, mu);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -105,14 +104,10 @@ namespace Grid{
 | 
			
		||||
		GridParallelRNG& pRNG){
 | 
			
		||||
	std::cout<< "Integrator init\n";
 | 
			
		||||
	if (!P){
 | 
			
		||||
	  std::unique_ptr<LatticeLorentzColourMatrix> Pnew(new LatticeLorentzColourMatrix(U._grid));
 | 
			
		||||
	  std::unique_ptr<LatticeLorentzColourMatrix> Pnew(new LatticeLorentzColourMatrix(U._grid));	  
 | 
			
		||||
	  P = std::move(Pnew);
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	MDutils::generate_momenta(*P,pRNG);
 | 
			
		||||
	
 | 
			
		||||
       
 | 
			
		||||
	
 | 
			
		||||
	for(int level=0; level< as.size(); ++level){
 | 
			
		||||
	  for(int actionID=0; actionID<as.at(level).size(); ++actionID){
 | 
			
		||||
	    as[level].at(actionID)->init(U, pRNG);
 | 
			
		||||
@@ -128,7 +123,7 @@ namespace Grid{
 | 
			
		||||
	// Momenta
 | 
			
		||||
	for (int mu=0; mu <Nd; mu++){
 | 
			
		||||
	  LatticeColourMatrix Pmu = peekLorentz(*P, mu);
 | 
			
		||||
	  Hloc -= trace(Pmu*adj(Pmu));
 | 
			
		||||
	  Hloc -= trace(Pmu*Pmu);
 | 
			
		||||
	}
 | 
			
		||||
	Complex Hsum = sum(Hloc);
 | 
			
		||||
	
 | 
			
		||||
 
 | 
			
		||||
@@ -545,21 +545,21 @@ Note that in step D setting B ~ X - A and using B in place of A in step E will g
 | 
			
		||||
 | 
			
		||||
  static void GaussianLieAlgebraMatrix(GridParallelRNG     &pRNG,LatticeMatrix &out,double scale=1.0){
 | 
			
		||||
    GridBase *grid = out._grid;
 | 
			
		||||
    LatticeComplex ca (grid);
 | 
			
		||||
    LatticeMatrix  lie(grid);
 | 
			
		||||
    LatticeReal ca (grid);
 | 
			
		||||
    LatticeMatrix  la (grid);
 | 
			
		||||
    Complex ci(0.0,scale);
 | 
			
		||||
    Matrix ta;
 | 
			
		||||
 | 
			
		||||
    out=zero;
 | 
			
		||||
    for(int a=0;a<generators();a++){
 | 
			
		||||
 | 
			
		||||
      gaussian(pRNG,ca); 
 | 
			
		||||
      generator(a,ta);
 | 
			
		||||
 | 
			
		||||
      la=ci*ca*ta;
 | 
			
		||||
      out = lie+la; // e^{i la ta}
 | 
			
		||||
      
 | 
			
		||||
      la=toComplex(ca)*ci*ta;
 | 
			
		||||
   
 | 
			
		||||
      out += la; 
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user