mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-11-04 14:04:32 +00:00 
			
		
		
		
	Cleaned up HMC output. Tested smeared HMCs for single precision (OK)
This commit is contained in:
		
							
								
								
									
										19
									
								
								lib/Log.cc
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								lib/Log.cc
									
									
									
									
									
								
							@@ -25,7 +25,8 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
 | 
			
		||||
with this program; if not, write to the Free Software Foundation, Inc.,
 | 
			
		||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 | 
			
		||||
 | 
			
		||||
    See the full license in the file "LICENSE" in the top level distribution directory
 | 
			
		||||
See the full license in the file "LICENSE" in the top level distribution
 | 
			
		||||
directory
 | 
			
		||||
*************************************************************************************/
 | 
			
		||||
/*  END LEGAL */
 | 
			
		||||
#include <Grid.h>
 | 
			
		||||
@@ -44,8 +45,7 @@ namespace Grid {
 | 
			
		||||
GridLogger GridLogIterative(1, "Iterative", GridLogColours, "BLUE");
 | 
			
		||||
GridLogger GridLogIntegrator(1, "Integrator", GridLogColours, "BLUE");
 | 
			
		||||
 | 
			
		||||
void GridLogConfigure(std::vector<std::string> &logstreams)
 | 
			
		||||
{
 | 
			
		||||
void GridLogConfigure(std::vector<std::string> &logstreams) {
 | 
			
		||||
  GridLogError.Active(0);
 | 
			
		||||
  GridLogWarning.Active(0);
 | 
			
		||||
  GridLogMessage.Active(0);
 | 
			
		||||
@@ -61,18 +61,17 @@ void GridLogConfigure(std::vector<std::string> &logstreams)
 | 
			
		||||
    if (logstreams[i] == std::string("Message")) GridLogMessage.Active(1);
 | 
			
		||||
    if (logstreams[i] == std::string("Iterative")) GridLogIterative.Active(1);
 | 
			
		||||
    if (logstreams[i] == std::string("Debug")) GridLogDebug.Active(1);
 | 
			
		||||
    if ( logstreams[i]== std::string("Performance") ) GridLogPerformance.Active(1);
 | 
			
		||||
    if (logstreams[i] == std::string("Performance"))
 | 
			
		||||
      GridLogPerformance.Active(1);
 | 
			
		||||
    if (logstreams[i] == std::string("Integrator")) GridLogIntegrator.Active(1);
 | 
			
		||||
    if (logstreams[i] == std::string("Colours")) GridLogColours.Active(1);
 | 
			
		||||
     
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////
 | 
			
		||||
// Verbose limiter on MPI tasks
 | 
			
		||||
////////////////////////////////////////////////////////////
 | 
			
		||||
void Grid_quiesce_nodes(void)
 | 
			
		||||
{
 | 
			
		||||
void Grid_quiesce_nodes(void) {
 | 
			
		||||
  int me = 0;
 | 
			
		||||
#ifdef GRID_COMMS_MPI
 | 
			
		||||
  MPI_Comm_rank(MPI_COMM_WORLD, &me);
 | 
			
		||||
@@ -85,13 +84,9 @@ void Grid_quiesce_nodes(void)
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Grid_unquiesce_nodes(void)
 | 
			
		||||
{
 | 
			
		||||
void Grid_unquiesce_nodes(void) {
 | 
			
		||||
#ifdef GRID_COMMS_MPI
 | 
			
		||||
  std::cout.clear();
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -49,7 +49,6 @@ protected:
 | 
			
		||||
public:
 | 
			
		||||
  std::map<std::string, std::string> colour;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  Colours(bool activate=false){
 | 
			
		||||
    Active(activate);
 | 
			
		||||
  };
 | 
			
		||||
 
 | 
			
		||||
@@ -22,7 +22,8 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
 | 
			
		||||
with this program; if not, write to the Free Software Foundation, Inc.,
 | 
			
		||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 | 
			
		||||
 | 
			
		||||
    See the full license in the file "LICENSE" in the top level distribution directory
 | 
			
		||||
See the full license in the file "LICENSE" in the top level distribution
 | 
			
		||||
directory
 | 
			
		||||
*************************************************************************************/
 | 
			
		||||
/*  END LEGAL */
 | 
			
		||||
#ifndef GRID_QCD_GAUGE_IMPL_H
 | 
			
		||||
@@ -32,7 +33,6 @@ namespace Grid {
 | 
			
		||||
 | 
			
		||||
namespace QCD {
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// Implementation dependent gauge types
 | 
			
		||||
////////////////////////////////////////////////////////////////////////
 | 
			
		||||
@@ -47,117 +47,119 @@ template<class Gimpl> class WilsonLoops;
 | 
			
		||||
  typedef typename GImpl::SiteGaugeLink SiteGaugeLink;
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
    template<class S,int Nrepresentation=Nc>
 | 
			
		||||
    class GaugeImplTypes { 
 | 
			
		||||
template <class S, int Nrepresentation = Nc> class GaugeImplTypes {
 | 
			
		||||
public:
 | 
			
		||||
    
 | 
			
		||||
  typedef S Simd;
 | 
			
		||||
 | 
			
		||||
      template<typename vtype> using iImplGaugeLink          = iScalar<iScalar<iMatrix<vtype, Nrepresentation> > >;
 | 
			
		||||
      template<typename vtype> using iImplGaugeField         = iVector<iScalar<iMatrix<vtype, Nrepresentation> >, Nd  >;
 | 
			
		||||
  template <typename vtype>
 | 
			
		||||
  using iImplGaugeLink = iScalar<iScalar<iMatrix<vtype, Nrepresentation>>>;
 | 
			
		||||
  template <typename vtype>
 | 
			
		||||
  using iImplGaugeField = iVector<iScalar<iMatrix<vtype, Nrepresentation>>, Nd>;
 | 
			
		||||
 | 
			
		||||
  typedef iImplGaugeLink<Simd> SiteGaugeLink;
 | 
			
		||||
  typedef iImplGaugeField<Simd> SiteGaugeField;
 | 
			
		||||
 | 
			
		||||
      typedef Lattice<SiteGaugeLink>                GaugeLinkField; // bit ugly naming; polarised gauge field, lorentz... all ugly
 | 
			
		||||
  typedef Lattice<SiteGaugeLink> GaugeLinkField; // bit ugly naming; polarised
 | 
			
		||||
                                                 // gauge field, lorentz... all
 | 
			
		||||
                                                 // ugly
 | 
			
		||||
  typedef Lattice<SiteGaugeField> GaugeField;
 | 
			
		||||
 | 
			
		||||
  // Move this elsewhere?
 | 
			
		||||
    static inline void AddGaugeLink(GaugeField& U, GaugeLinkField& W, int mu){  // U[mu] += W 
 | 
			
		||||
  static inline void AddGaugeLink(GaugeField &U, GaugeLinkField &W,
 | 
			
		||||
                                  int mu) { // U[mu] += W
 | 
			
		||||
    PARALLEL_FOR_LOOP
 | 
			
		||||
    for (auto ss = 0; ss < U._grid->oSites(); ss++) {
 | 
			
		||||
	         U._odata[ss]._internal[mu] = U._odata[ss]._internal[mu] + W._odata[ss]._internal;
 | 
			
		||||
      U._odata[ss]._internal[mu] =
 | 
			
		||||
          U._odata[ss]._internal[mu] + W._odata[ss]._internal;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
    
 | 
			
		||||
      
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// Composition with smeared link, bc's etc.. probably need multiple inheritance
 | 
			
		||||
// Variable precision "S" and variable Nc
 | 
			
		||||
    template<class GimplTypes>
 | 
			
		||||
    class PeriodicGaugeImpl : public GimplTypes  { 
 | 
			
		||||
template <class GimplTypes> class PeriodicGaugeImpl : public GimplTypes {
 | 
			
		||||
public:
 | 
			
		||||
 | 
			
		||||
  INHERIT_GIMPL_TYPES(GimplTypes);
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    // Support needed for the assembly of loops including all boundary condition effects such as conjugate bcs
 | 
			
		||||
  // Support needed for the assembly of loops including all boundary condition
 | 
			
		||||
  // effects such as conjugate bcs
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
      template<class covariant>  static inline
 | 
			
		||||
      Lattice<covariant> CovShiftForward (const GaugeLinkField &Link, int mu, const Lattice<covariant> &field) {
 | 
			
		||||
  template <class covariant>
 | 
			
		||||
  static inline Lattice<covariant>
 | 
			
		||||
  CovShiftForward(const GaugeLinkField &Link, int mu,
 | 
			
		||||
                  const Lattice<covariant> &field) {
 | 
			
		||||
    return PeriodicBC::CovShiftForward(Link, mu, field);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
      template<class covariant> static inline
 | 
			
		||||
      Lattice<covariant> CovShiftBackward(const GaugeLinkField &Link, int mu,const Lattice<covariant> &field) {
 | 
			
		||||
  template <class covariant>
 | 
			
		||||
  static inline Lattice<covariant>
 | 
			
		||||
  CovShiftBackward(const GaugeLinkField &Link, int mu,
 | 
			
		||||
                   const Lattice<covariant> &field) {
 | 
			
		||||
    return PeriodicBC::CovShiftBackward(Link, mu, field);
 | 
			
		||||
  }
 | 
			
		||||
      static inline
 | 
			
		||||
      GaugeLinkField CovShiftIdentityBackward(const GaugeLinkField &Link, int mu) {
 | 
			
		||||
  static inline GaugeLinkField
 | 
			
		||||
  CovShiftIdentityBackward(const GaugeLinkField &Link, int mu) {
 | 
			
		||||
    return Cshift(adj(Link), mu, -1);
 | 
			
		||||
  }
 | 
			
		||||
      static inline
 | 
			
		||||
      GaugeLinkField CovShiftIdentityForward(const GaugeLinkField &Link, int mu) {
 | 
			
		||||
  static inline GaugeLinkField
 | 
			
		||||
  CovShiftIdentityForward(const GaugeLinkField &Link, int mu) {
 | 
			
		||||
    return Link;
 | 
			
		||||
  }
 | 
			
		||||
      static inline
 | 
			
		||||
      GaugeLinkField ShiftStaple(const GaugeLinkField &Link, int mu) {
 | 
			
		||||
  static inline GaugeLinkField ShiftStaple(const GaugeLinkField &Link, int mu) {
 | 
			
		||||
    return Cshift(Link, mu, 1);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
      static inline bool isPeriodicGaugeField(void) {
 | 
			
		||||
	return true;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
  static inline bool isPeriodicGaugeField(void) { return true; }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
// Composition with smeared link, bc's etc.. probably need multiple inheritance
 | 
			
		||||
// Variable precision "S" and variable Nc
 | 
			
		||||
    template<class GimplTypes>
 | 
			
		||||
    class ConjugateGaugeImpl : public GimplTypes { 
 | 
			
		||||
template <class GimplTypes> class ConjugateGaugeImpl : public GimplTypes {
 | 
			
		||||
public:
 | 
			
		||||
 | 
			
		||||
  INHERIT_GIMPL_TYPES(GimplTypes);
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    // Support needed for the assembly of loops including all boundary condition effects such as Gparity.
 | 
			
		||||
  // Support needed for the assembly of loops including all boundary condition
 | 
			
		||||
  // effects such as Gparity.
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    template<class covariant>  static
 | 
			
		||||
    Lattice<covariant> CovShiftForward (const GaugeLinkField &Link, int mu, const Lattice<covariant> &field) {
 | 
			
		||||
  template <class covariant>
 | 
			
		||||
  static Lattice<covariant> CovShiftForward(const GaugeLinkField &Link, int mu,
 | 
			
		||||
                                            const Lattice<covariant> &field) {
 | 
			
		||||
    return ConjugateBC::CovShiftForward(Link, mu, field);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
    template<class covariant> static
 | 
			
		||||
    Lattice<covariant> CovShiftBackward(const GaugeLinkField &Link, int mu,const Lattice<covariant> &field) {
 | 
			
		||||
  template <class covariant>
 | 
			
		||||
  static Lattice<covariant> CovShiftBackward(const GaugeLinkField &Link, int mu,
 | 
			
		||||
                                             const Lattice<covariant> &field) {
 | 
			
		||||
    return ConjugateBC::CovShiftBackward(Link, mu, field);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
    static inline
 | 
			
		||||
    GaugeLinkField CovShiftIdentityBackward(const GaugeLinkField &Link, int mu) {
 | 
			
		||||
  static inline GaugeLinkField
 | 
			
		||||
  CovShiftIdentityBackward(const GaugeLinkField &Link, int mu) {
 | 
			
		||||
    GridBase *grid = Link._grid;
 | 
			
		||||
    int Lmu = grid->GlobalDimensions()[mu] - 1;
 | 
			
		||||
 | 
			
		||||
      Lattice<iScalar<vInteger> > coor(grid);    LatticeCoordinate(coor,mu);
 | 
			
		||||
    Lattice<iScalar<vInteger>> coor(grid);
 | 
			
		||||
    LatticeCoordinate(coor, mu);
 | 
			
		||||
 | 
			
		||||
    GaugeLinkField tmp(grid);
 | 
			
		||||
    tmp = adj(Link);
 | 
			
		||||
    tmp = where(coor == Lmu, conjugate(tmp), tmp);
 | 
			
		||||
    return Cshift(tmp, mu, -1); // moves towards positive mu
 | 
			
		||||
  }
 | 
			
		||||
    static inline
 | 
			
		||||
    GaugeLinkField CovShiftIdentityForward(const GaugeLinkField &Link, int mu) {
 | 
			
		||||
  static inline GaugeLinkField
 | 
			
		||||
  CovShiftIdentityForward(const GaugeLinkField &Link, int mu) {
 | 
			
		||||
    return Link;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
    static inline
 | 
			
		||||
    GaugeLinkField ShiftStaple(const GaugeLinkField &Link, int mu) {
 | 
			
		||||
  static inline GaugeLinkField ShiftStaple(const GaugeLinkField &Link, int mu) {
 | 
			
		||||
    GridBase *grid = Link._grid;
 | 
			
		||||
    int Lmu = grid->GlobalDimensions()[mu] - 1;
 | 
			
		||||
 | 
			
		||||
      Lattice<iScalar<vInteger> > coor(grid);    LatticeCoordinate(coor,mu);
 | 
			
		||||
    Lattice<iScalar<vInteger>> coor(grid);
 | 
			
		||||
    LatticeCoordinate(coor, mu);
 | 
			
		||||
 | 
			
		||||
    GaugeLinkField tmp(grid);
 | 
			
		||||
    tmp = Cshift(Link, mu, 1);
 | 
			
		||||
@@ -165,10 +167,7 @@ template<class Gimpl> class WilsonLoops;
 | 
			
		||||
    return tmp;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
    static inline bool isPeriodicGaugeField(void) {
 | 
			
		||||
      return false;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
  static inline bool isPeriodicGaugeField(void) { return false; }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
typedef GaugeImplTypes<vComplex, Nc> GimplTypesR;
 | 
			
		||||
@@ -179,10 +178,10 @@ template<class Gimpl> class WilsonLoops;
 | 
			
		||||
typedef PeriodicGaugeImpl<GimplTypesF> PeriodicGimplF; // Float
 | 
			
		||||
typedef PeriodicGaugeImpl<GimplTypesD> PeriodicGimplD; // Double
 | 
			
		||||
 | 
			
		||||
    typedef ConjugateGaugeImpl<GimplTypesR> ConjugateGimplR; // Real.. whichever prec
 | 
			
		||||
typedef ConjugateGaugeImpl<GimplTypesR>
 | 
			
		||||
    ConjugateGimplR; // Real.. whichever prec
 | 
			
		||||
typedef ConjugateGaugeImpl<GimplTypesF> ConjugateGimplF; // Float
 | 
			
		||||
typedef ConjugateGaugeImpl<GimplTypesD> ConjugateGimplD; // Double
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -25,7 +25,8 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
 | 
			
		||||
with this program; if not, write to the Free Software Foundation, Inc.,
 | 
			
		||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 | 
			
		||||
 | 
			
		||||
    See the full license in the file "LICENSE" in the top level distribution directory
 | 
			
		||||
See the full license in the file "LICENSE" in the top level distribution
 | 
			
		||||
directory
 | 
			
		||||
*************************************************************************************/
 | 
			
		||||
/*  END LEGAL */
 | 
			
		||||
//--------------------------------------------------------------------
 | 
			
		||||
@@ -41,13 +42,10 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
 | 
			
		||||
 | 
			
		||||
#include <string>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
namespace Grid {
 | 
			
		||||
namespace QCD {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct HMCparameters {
 | 
			
		||||
 | 
			
		||||
  Integer StartTrajectory;
 | 
			
		||||
  Integer Trajectories; /* @brief Number of sweeps in this run */
 | 
			
		||||
  bool MetropolisTest;
 | 
			
		||||
@@ -61,27 +59,40 @@ namespace Grid{
 | 
			
		||||
    Trajectories = 200;
 | 
			
		||||
    /////////////////////////////////
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  void print() const {
 | 
			
		||||
    std::cout << GridLogMessage << "[HMC parameter] Trajectories            : " << Trajectories << "\n";
 | 
			
		||||
    std::cout << GridLogMessage << "[HMC parameter] Start trajectory        : " << StartTrajectory << "\n";
 | 
			
		||||
    std::cout << GridLogMessage << "[HMC parameter] Metropolis test (on/off): " << MetropolisTest << "\n";
 | 
			
		||||
    std::cout << GridLogMessage << "[HMC parameter] Thermalization trajs    : " << NoMetropolisUntil << "\n";
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template <class GaugeField>
 | 
			
		||||
class HmcObservable {
 | 
			
		||||
 public:
 | 
			
		||||
      virtual void TrajectoryComplete (int traj, GaugeField &U, GridSerialRNG &sRNG, GridParallelRNG & pRNG )=0;
 | 
			
		||||
  virtual void TrajectoryComplete(int traj, GaugeField &U, GridSerialRNG &sRNG,
 | 
			
		||||
                                  GridParallelRNG &pRNG) = 0;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template <class Gimpl>
 | 
			
		||||
class PlaquetteLogger : public HmcObservable<typename Gimpl::GaugeField> {
 | 
			
		||||
 private:
 | 
			
		||||
  std::string Stem;
 | 
			
		||||
 | 
			
		||||
 public:
 | 
			
		||||
  INHERIT_GIMPL_TYPES(Gimpl);
 | 
			
		||||
      PlaquetteLogger(std::string cf) {
 | 
			
		||||
        Stem  = cf;
 | 
			
		||||
      };
 | 
			
		||||
  PlaquetteLogger(std::string cf) { Stem = cf; };
 | 
			
		||||
 | 
			
		||||
      void TrajectoryComplete(int traj, GaugeField &U, GridSerialRNG &sRNG, GridParallelRNG & pRNG )
 | 
			
		||||
  void TrajectoryComplete(int traj, GaugeField &U, GridSerialRNG &sRNG,
 | 
			
		||||
                          GridParallelRNG &pRNG) {
 | 
			
		||||
    std::string file;
 | 
			
		||||
    {
 | 
			
		||||
	  std::string file;   { std::ostringstream os; os << Stem     <<"."<< traj; file = os.str(); }
 | 
			
		||||
      std::ostringstream os;
 | 
			
		||||
      os << Stem << "." << traj;
 | 
			
		||||
      file = os.str();
 | 
			
		||||
    }
 | 
			
		||||
    std::ofstream of(file);
 | 
			
		||||
 | 
			
		||||
    RealD peri_plaq = WilsonLoops<PeriodicGimplR>::avgPlaquette(U);
 | 
			
		||||
@@ -90,17 +101,27 @@ namespace Grid{
 | 
			
		||||
    RealD impl_plaq = WilsonLoops<Gimpl>::avgPlaquette(U);
 | 
			
		||||
    RealD impl_rect = WilsonLoops<Gimpl>::avgRectangle(U);
 | 
			
		||||
 | 
			
		||||
	  of << traj<<" "<< impl_plaq << " " << impl_rect << "  "<< peri_plaq<<" "<<peri_rect<<std::endl;
 | 
			
		||||
	  std::cout<< GridLogMessage<< "traj"<<" "<< "plaq " << " " << " rect  " << "  "<< "peri_plaq" <<" "<<"peri_rect"<<std::endl;
 | 
			
		||||
	  std::cout<< GridLogMessage<< traj<<" "<< impl_plaq << " " << impl_rect << "  "<< peri_plaq<<" "<<peri_rect<<std::endl;
 | 
			
		||||
    of << traj << " " << impl_plaq << " " << impl_rect << "  " << peri_plaq
 | 
			
		||||
       << " " << peri_rect << std::endl;
 | 
			
		||||
    std::cout << GridLogMessage << "traj"
 | 
			
		||||
              << " "
 | 
			
		||||
              << "plaq "
 | 
			
		||||
              << " "
 | 
			
		||||
              << " rect  "
 | 
			
		||||
              << "  "
 | 
			
		||||
              << "peri_plaq"
 | 
			
		||||
              << " "
 | 
			
		||||
              << "peri_rect" << std::endl;
 | 
			
		||||
    std::cout << GridLogMessage << traj << " " << impl_plaq << " " << impl_rect
 | 
			
		||||
              << "  " << peri_plaq << " " << peri_rect << std::endl;
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
    //    template <class GaugeField, class Integrator, class Smearer, class Boundary> 
 | 
			
		||||
//    template <class GaugeField, class Integrator, class Smearer, class
 | 
			
		||||
//    Boundary>
 | 
			
		||||
template <class GaugeField, class IntegratorType>
 | 
			
		||||
class HybridMonteCarlo {
 | 
			
		||||
 private:
 | 
			
		||||
 | 
			
		||||
  const HMCparameters Params;
 | 
			
		||||
 | 
			
		||||
  GridSerialRNG &sRNG;    // Fixme: need a RNG management strategy.
 | 
			
		||||
@@ -114,60 +135,64 @@ namespace Grid{
 | 
			
		||||
  // Metropolis step
 | 
			
		||||
  /////////////////////////////////////////////////////////
 | 
			
		||||
  bool metropolis_test(const RealD DeltaH) {
 | 
			
		||||
 | 
			
		||||
    RealD rn_test;
 | 
			
		||||
 | 
			
		||||
    RealD prob = std::exp(-DeltaH);
 | 
			
		||||
 | 
			
		||||
    random(sRNG, rn_test);
 | 
			
		||||
 | 
			
		||||
	std::cout<<GridLogMessage<< "--------------------------------------------\n";
 | 
			
		||||
	std::cout<<GridLogMessage<< "dH = "<<DeltaH << "  Random = "<< rn_test <<"\n";
 | 
			
		||||
	std::cout<<GridLogMessage<< "Acc. Probability = " << ((prob<1.0)? prob: 1.0)<< "   ";
 | 
			
		||||
    std::cout << GridLogMessage
 | 
			
		||||
              << "--------------------------------------------------\n";
 | 
			
		||||
    std::cout << GridLogMessage << "exp(-dH) = " << prob
 | 
			
		||||
              << "  Random = " << rn_test << "\n";
 | 
			
		||||
    std::cout << GridLogMessage
 | 
			
		||||
              << "Acc. Probability = " << ((prob < 1.0) ? prob : 1.0) << "\n";
 | 
			
		||||
 | 
			
		||||
    if ((prob > 1.0) || (rn_test <= prob)) {  // accepted
 | 
			
		||||
	  std::cout<<GridLogMessage <<"-- ACCEPTED\n";
 | 
			
		||||
      std::cout << GridLogMessage << "Metropolis_test -- ACCEPTED\n";
 | 
			
		||||
      std::cout << GridLogMessage
 | 
			
		||||
                << "--------------------------------------------------\n";
 | 
			
		||||
      return true;
 | 
			
		||||
    } else {  // rejected
 | 
			
		||||
	  std::cout<<GridLogMessage <<"-- REJECTED\n";
 | 
			
		||||
      std::cout << GridLogMessage << "Metropolis_test -- REJECTED\n";
 | 
			
		||||
      std::cout << GridLogMessage
 | 
			
		||||
                << "--------------------------------------------------\n";
 | 
			
		||||
      return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /////////////////////////////////////////////////////////
 | 
			
		||||
  // Evolution
 | 
			
		||||
  /////////////////////////////////////////////////////////
 | 
			
		||||
  RealD evolve_step(GaugeField &U) {
 | 
			
		||||
 | 
			
		||||
    TheIntegrator.refresh(U, pRNG);  // set U and initialize P and phi's
 | 
			
		||||
 | 
			
		||||
    RealD H0 = TheIntegrator.S(U);  // initial state action
 | 
			
		||||
 | 
			
		||||
	std::cout<<GridLogMessage<<"Total H before = "<< H0 << "\n";
 | 
			
		||||
    std::streamsize current_precision = std::cout.precision();
 | 
			
		||||
    std::cout.precision(17);
 | 
			
		||||
    std::cout << GridLogMessage << "Total H before trajectory = " << H0 << "\n";
 | 
			
		||||
    std::cout.precision(current_precision);
 | 
			
		||||
 | 
			
		||||
    TheIntegrator.integrate(U);
 | 
			
		||||
 | 
			
		||||
    RealD H1 = TheIntegrator.S(U);  // updated state action
 | 
			
		||||
 | 
			
		||||
	std::cout<<GridLogMessage<<"Total H after = "<< H1 << "\n";
 | 
			
		||||
    std::cout.precision(17);
 | 
			
		||||
    std::cout << GridLogMessage << "Total H after trajectory  = " << H1
 | 
			
		||||
              << "  dH = " << H1 - H0 << "\n";
 | 
			
		||||
    std::cout.precision(current_precision);
 | 
			
		||||
 | 
			
		||||
    return (H1 - H0);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 public:
 | 
			
		||||
 | 
			
		||||
  /////////////////////////////////////////
 | 
			
		||||
  // Constructor
 | 
			
		||||
  /////////////////////////////////////////
 | 
			
		||||
      HybridMonteCarlo(HMCparameters Pms,  IntegratorType &_Int, GridSerialRNG &_sRNG, GridParallelRNG &_pRNG, GaugeField &_U) :
 | 
			
		||||
        Params(Pms), 
 | 
			
		||||
	TheIntegrator(_Int), 
 | 
			
		||||
	sRNG(_sRNG),
 | 
			
		||||
	pRNG(_pRNG),
 | 
			
		||||
	Ucur(_U)
 | 
			
		||||
      {
 | 
			
		||||
      }
 | 
			
		||||
  HybridMonteCarlo(HMCparameters Pams, IntegratorType &_Int,
 | 
			
		||||
                   GridSerialRNG &_sRNG, GridParallelRNG &_pRNG, GaugeField &_U)
 | 
			
		||||
      : Params(Pams), TheIntegrator(_Int), sRNG(_sRNG), pRNG(_pRNG), Ucur(_U) {}
 | 
			
		||||
  ~HybridMonteCarlo(){};
 | 
			
		||||
 | 
			
		||||
  void AddObservable(HmcObservable<GaugeField> *obs) {
 | 
			
		||||
@@ -175,21 +200,22 @@ namespace Grid{
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  void evolve(void) {
 | 
			
		||||
 | 
			
		||||
    Real DeltaH;
 | 
			
		||||
 | 
			
		||||
    GaugeField Ucopy(Ucur._grid);
 | 
			
		||||
 | 
			
		||||
	// Actual updates (evolve a copy Ucopy then copy back eventually)
 | 
			
		||||
	for(int traj=Params.StartTrajectory; traj < Params.Trajectories+Params.StartTrajectory; ++traj){
 | 
			
		||||
    Params.print();
 | 
			
		||||
 | 
			
		||||
    // Actual updates (evolve a copy Ucopy then copy back eventually)
 | 
			
		||||
    for (int traj = Params.StartTrajectory;
 | 
			
		||||
         traj < Params.Trajectories + Params.StartTrajectory; ++traj) {
 | 
			
		||||
      std::cout << GridLogMessage << "-- # Trajectory = " << traj << "\n";
 | 
			
		||||
      Ucopy = Ucur;
 | 
			
		||||
 | 
			
		||||
      DeltaH = evolve_step(Ucopy);
 | 
			
		||||
 | 
			
		||||
      bool accept = true;
 | 
			
		||||
	  if ( traj > Params.NoMetropolisUntil) { 
 | 
			
		||||
      if (traj >= Params.NoMetropolisUntil) {
 | 
			
		||||
        accept = metropolis_test(DeltaH);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
@@ -200,7 +226,6 @@ namespace Grid{
 | 
			
		||||
      for (int obs = 0; obs < Observables.size(); obs++) {
 | 
			
		||||
        Observables[obs]->TrajectoryComplete(traj + 1, Ucur, sRNG, pRNG);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
@@ -208,5 +233,4 @@ namespace Grid{
 | 
			
		||||
}  // QCD
 | 
			
		||||
}  // Grid
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -81,6 +81,14 @@ public:
 | 
			
		||||
      NumTraj = ivec[0];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    int NumThermalizations = 10;
 | 
			
		||||
    if( GridCmdOptionExists(argv,argv+argc,"--Thermalizations") ){
 | 
			
		||||
      arg= GridCmdOptionPayload(argv,argv+argc,"--Thermalizations");
 | 
			
		||||
      std::vector<int> ivec(0);
 | 
			
		||||
      GridCmdOptionIntVector(arg,ivec);
 | 
			
		||||
      NumThermalizations = ivec[0];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    GridSerialRNG    sRNG;
 | 
			
		||||
    GridParallelRNG  pRNG(UGrid);
 | 
			
		||||
@@ -112,31 +120,28 @@ public:
 | 
			
		||||
    HMCparameters HMCpar;
 | 
			
		||||
    HMCpar.StartTrajectory   = StartTraj;
 | 
			
		||||
    HMCpar.Trajectories      = NumTraj;
 | 
			
		||||
    HMCpar.NoMetropolisUntil = NumThermalizations;
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    if ( StartType == HotStart ) {
 | 
			
		||||
      // Hot start
 | 
			
		||||
      HMCpar.NoMetropolisUntil =10;
 | 
			
		||||
      HMCpar.MetropolisTest = true;
 | 
			
		||||
      sRNG.SeedFixedIntegers(SerSeed);
 | 
			
		||||
      pRNG.SeedFixedIntegers(ParSeed);
 | 
			
		||||
      SU3::HotConfiguration(pRNG, U);
 | 
			
		||||
    } else if ( StartType == ColdStart ) { 
 | 
			
		||||
      // Cold start
 | 
			
		||||
      HMCpar.NoMetropolisUntil =10;
 | 
			
		||||
      HMCpar.MetropolisTest = true;
 | 
			
		||||
      sRNG.SeedFixedIntegers(SerSeed);
 | 
			
		||||
      pRNG.SeedFixedIntegers(ParSeed);
 | 
			
		||||
      SU3::ColdConfiguration(pRNG, U);
 | 
			
		||||
    } else if ( StartType == TepidStart ) {       
 | 
			
		||||
      // Tepid start
 | 
			
		||||
      HMCpar.NoMetropolisUntil =10;
 | 
			
		||||
      HMCpar.MetropolisTest = true;
 | 
			
		||||
      sRNG.SeedFixedIntegers(SerSeed);
 | 
			
		||||
      pRNG.SeedFixedIntegers(ParSeed);
 | 
			
		||||
      SU3::TepidConfiguration(pRNG, U);
 | 
			
		||||
    } else if ( StartType == CheckpointStart ) { 
 | 
			
		||||
      HMCpar.NoMetropolisUntil =10;
 | 
			
		||||
      HMCpar.MetropolisTest = true;
 | 
			
		||||
      // CheckpointRestart
 | 
			
		||||
      Checkpoint.CheckpointRestore(StartTraj, U, sRNG, pRNG);
 | 
			
		||||
 
 | 
			
		||||
@@ -25,7 +25,8 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
 | 
			
		||||
    with this program; if not, write to the Free Software Foundation, Inc.,
 | 
			
		||||
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 | 
			
		||||
 | 
			
		||||
    See the full license in the file "LICENSE" in the top level distribution directory
 | 
			
		||||
    See the full license in the file "LICENSE" in the top level distribution
 | 
			
		||||
directory
 | 
			
		||||
*************************************************************************************/
 | 
			
		||||
/*  END LEGAL */
 | 
			
		||||
#ifndef QCD_UTILS_WILSON_LOOPS_H
 | 
			
		||||
@@ -34,10 +35,8 @@ namespace Grid {
 | 
			
		||||
namespace QCD {
 | 
			
		||||
 | 
			
		||||
// Common wilson loop observables
 | 
			
		||||
    template<class Gimpl>
 | 
			
		||||
      class WilsonLoops : public Gimpl {
 | 
			
		||||
template <class Gimpl> class WilsonLoops : public Gimpl {
 | 
			
		||||
public:
 | 
			
		||||
      
 | 
			
		||||
  INHERIT_GIMPL_TYPES(Gimpl);
 | 
			
		||||
 | 
			
		||||
  typedef typename Gimpl::GaugeLinkField GaugeMat;
 | 
			
		||||
@@ -46,21 +45,25 @@ namespace Grid {
 | 
			
		||||
  //////////////////////////////////////////////////
 | 
			
		||||
  // directed plaquette oriented in mu,nu plane
 | 
			
		||||
  //////////////////////////////////////////////////
 | 
			
		||||
      static void dirPlaquette(GaugeMat &plaq,const std::vector<GaugeMat> &U, const int mu, const int nu)
 | 
			
		||||
      {
 | 
			
		||||
	// Annoyingly, must use either scope resolution to find dependent base class, 
 | 
			
		||||
	// or this-> ; there is no "this" in a static method. This forces explicit Gimpl scope
 | 
			
		||||
	// resolution throughout the usage in this file, and rather defeats the purpose of deriving
 | 
			
		||||
  static void dirPlaquette(GaugeMat &plaq, const std::vector<GaugeMat> &U,
 | 
			
		||||
                           const int mu, const int nu) {
 | 
			
		||||
    // Annoyingly, must use either scope resolution to find dependent base
 | 
			
		||||
    // class,
 | 
			
		||||
    // or this-> ; there is no "this" in a static method. This forces explicit
 | 
			
		||||
    // Gimpl scope
 | 
			
		||||
    // resolution throughout the usage in this file, and rather defeats the
 | 
			
		||||
    // purpose of deriving
 | 
			
		||||
    // from Gimpl.
 | 
			
		||||
	plaq = Gimpl::CovShiftBackward(U[mu],mu,
 | 
			
		||||
		   Gimpl::CovShiftBackward(U[nu],nu,
 | 
			
		||||
		   Gimpl::CovShiftForward (U[mu],mu,U[nu])));
 | 
			
		||||
    plaq = Gimpl::CovShiftBackward(
 | 
			
		||||
        U[mu], mu, Gimpl::CovShiftBackward(
 | 
			
		||||
                       U[nu], nu, Gimpl::CovShiftForward(U[mu], mu, U[nu])));
 | 
			
		||||
  }
 | 
			
		||||
  //////////////////////////////////////////////////
 | 
			
		||||
  // trace of directed plaquette oriented in mu,nu plane
 | 
			
		||||
  //////////////////////////////////////////////////
 | 
			
		||||
      static void traceDirPlaquette(LatticeComplex &plaq, const std::vector<GaugeMat> &U, const int mu, const int nu)
 | 
			
		||||
      {
 | 
			
		||||
  static void traceDirPlaquette(LatticeComplex &plaq,
 | 
			
		||||
                                const std::vector<GaugeMat> &U, const int mu,
 | 
			
		||||
                                const int nu) {
 | 
			
		||||
    GaugeMat sp(U[0]._grid);
 | 
			
		||||
    dirPlaquette(sp, U, mu, nu);
 | 
			
		||||
    plaq = trace(sp);
 | 
			
		||||
@@ -68,8 +71,8 @@ namespace Grid {
 | 
			
		||||
  //////////////////////////////////////////////////
 | 
			
		||||
  // sum over all planes of plaquette
 | 
			
		||||
  //////////////////////////////////////////////////
 | 
			
		||||
      static void sitePlaquette(LatticeComplex &Plaq,const std::vector<GaugeMat> &U)
 | 
			
		||||
      {
 | 
			
		||||
  static void sitePlaquette(LatticeComplex &Plaq,
 | 
			
		||||
                            const std::vector<GaugeMat> &U) {
 | 
			
		||||
    LatticeComplex sitePlaq(U[0]._grid);
 | 
			
		||||
    Plaq = zero;
 | 
			
		||||
    for (int mu = 1; mu < Nd; mu++) {
 | 
			
		||||
@@ -113,7 +116,8 @@ namespace Grid {
 | 
			
		||||
  static RealD linkTrace(const GaugeLorentz &Umu) {
 | 
			
		||||
    std::vector<GaugeMat> U(4, Umu._grid);
 | 
			
		||||
 | 
			
		||||
	LatticeComplex Tr(Umu._grid); Tr=zero;
 | 
			
		||||
    LatticeComplex Tr(Umu._grid);
 | 
			
		||||
    Tr = zero;
 | 
			
		||||
    for (int mu = 0; mu < Nd; mu++) {
 | 
			
		||||
      U[mu] = PeekIndex<LorentzIndex>(Umu, mu);
 | 
			
		||||
      Tr = Tr + trace(U[mu]);
 | 
			
		||||
@@ -130,7 +134,8 @@ namespace Grid {
 | 
			
		||||
  //////////////////////////////////////////////////
 | 
			
		||||
  // the sum over all staples on each site in direction mu,nu
 | 
			
		||||
  //////////////////////////////////////////////////
 | 
			
		||||
      static void Staple(GaugeMat &staple,const GaugeLorentz &Umu,int mu, int nu){
 | 
			
		||||
  static void Staple(GaugeMat &staple, const GaugeLorentz &Umu, int mu,
 | 
			
		||||
                     int nu) {
 | 
			
		||||
 | 
			
		||||
    GridBase *grid = Umu._grid;
 | 
			
		||||
 | 
			
		||||
@@ -140,7 +145,6 @@ namespace Grid {
 | 
			
		||||
    }
 | 
			
		||||
    staple = zero;
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
    if (nu != mu) {
 | 
			
		||||
 | 
			
		||||
      // mu
 | 
			
		||||
@@ -153,9 +157,11 @@ namespace Grid {
 | 
			
		||||
      //
 | 
			
		||||
 | 
			
		||||
      staple += Gimpl::ShiftStaple(
 | 
			
		||||
				     Gimpl::CovShiftForward (U[nu],nu, 
 | 
			
		||||
							     Gimpl::CovShiftBackward(U[mu],mu,
 | 
			
		||||
										     Gimpl::CovShiftIdentityBackward(U[nu],nu))),mu);
 | 
			
		||||
          Gimpl::CovShiftForward(
 | 
			
		||||
              U[nu], nu,
 | 
			
		||||
              Gimpl::CovShiftBackward(
 | 
			
		||||
                  U[mu], mu, Gimpl::CovShiftIdentityBackward(U[nu], nu))),
 | 
			
		||||
          mu);
 | 
			
		||||
 | 
			
		||||
      //  __
 | 
			
		||||
      // |
 | 
			
		||||
@@ -164,8 +170,8 @@ namespace Grid {
 | 
			
		||||
      //
 | 
			
		||||
      staple += Gimpl::ShiftStaple(
 | 
			
		||||
          Gimpl::CovShiftBackward(U[nu], nu,
 | 
			
		||||
							     Gimpl::CovShiftBackward(U[mu],mu,U[nu])),mu);
 | 
			
		||||
      
 | 
			
		||||
                                  Gimpl::CovShiftBackward(U[mu], mu, U[nu])),
 | 
			
		||||
          mu);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -183,7 +189,6 @@ namespace Grid {
 | 
			
		||||
    staple = zero;
 | 
			
		||||
    GaugeMat tmp(grid);
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    for (int nu = 0; nu < Nd; nu++) {
 | 
			
		||||
 | 
			
		||||
      if (nu != mu) {
 | 
			
		||||
@@ -198,9 +203,11 @@ namespace Grid {
 | 
			
		||||
        //
 | 
			
		||||
 | 
			
		||||
        staple += Gimpl::ShiftStaple(
 | 
			
		||||
	        Gimpl::CovShiftForward (U[nu],nu, 
 | 
			
		||||
		Gimpl::CovShiftBackward(U[mu],mu,
 | 
			
		||||
		Gimpl::CovShiftIdentityBackward(U[nu],nu))),mu);
 | 
			
		||||
            Gimpl::CovShiftForward(
 | 
			
		||||
                U[nu], nu,
 | 
			
		||||
                Gimpl::CovShiftBackward(
 | 
			
		||||
                    U[mu], mu, Gimpl::CovShiftIdentityBackward(U[nu], nu))),
 | 
			
		||||
            mu);
 | 
			
		||||
 | 
			
		||||
        //  __
 | 
			
		||||
        // |
 | 
			
		||||
@@ -209,16 +216,17 @@ namespace Grid {
 | 
			
		||||
        //
 | 
			
		||||
        staple += Gimpl::ShiftStaple(
 | 
			
		||||
            Gimpl::CovShiftBackward(U[nu], nu,
 | 
			
		||||
		Gimpl::CovShiftBackward(U[mu],mu,U[nu])),mu);
 | 
			
		||||
                                    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, int nu){
 | 
			
		||||
  static void StapleUpper(GaugeMat &staple, const GaugeLorentz &Umu, int mu,
 | 
			
		||||
                          int nu) {
 | 
			
		||||
 | 
			
		||||
    staple = zero;
 | 
			
		||||
 | 
			
		||||
@@ -240,36 +248,38 @@ namespace Grid {
 | 
			
		||||
      //
 | 
			
		||||
 | 
			
		||||
      staple += Gimpl::ShiftStaple(
 | 
			
		||||
				     Gimpl::CovShiftForward (U[nu],nu, 
 | 
			
		||||
							     Gimpl::CovShiftBackward(U[mu],mu,
 | 
			
		||||
										     Gimpl::CovShiftIdentityBackward(U[nu],nu))),mu);
 | 
			
		||||
 | 
			
		||||
          Gimpl::CovShiftForward(
 | 
			
		||||
              U[nu], nu,
 | 
			
		||||
              Gimpl::CovShiftBackward(
 | 
			
		||||
                  U[mu], mu, Gimpl::CovShiftIdentityBackward(U[nu], nu))),
 | 
			
		||||
          mu);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  //////////////////////////////////////////////////////
 | 
			
		||||
  // Similar to above for rectangle is required
 | 
			
		||||
  //////////////////////////////////////////////////////
 | 
			
		||||
  static void dirRectangle(GaugeMat &rect,const std::vector<GaugeMat> &U, const int mu, const int nu)
 | 
			
		||||
  {
 | 
			
		||||
    rect =  Gimpl::CovShiftForward(U[mu],mu,Gimpl::CovShiftForward(U[mu],mu,U[nu]))* // ->->|
 | 
			
		||||
	adj(Gimpl::CovShiftForward(U[nu],nu,Gimpl::CovShiftForward(U[mu],mu,U[mu]))) ;
 | 
			
		||||
  static void dirRectangle(GaugeMat &rect, const std::vector<GaugeMat> &U,
 | 
			
		||||
                           const int mu, const int nu) {
 | 
			
		||||
    rect = Gimpl::CovShiftForward(
 | 
			
		||||
               U[mu], mu, Gimpl::CovShiftForward(U[mu], mu, U[nu])) * // ->->|
 | 
			
		||||
           adj(Gimpl::CovShiftForward(
 | 
			
		||||
               U[nu], nu, Gimpl::CovShiftForward(U[mu], mu, U[mu])));
 | 
			
		||||
    rect = rect +
 | 
			
		||||
          Gimpl::CovShiftForward(U[mu],mu,Gimpl::CovShiftForward(U[nu],nu,U[nu]))* // ->||
 | 
			
		||||
      adj(Gimpl::CovShiftForward(U[nu],nu,Gimpl::CovShiftForward(U[nu],nu,U[mu]))) ;
 | 
			
		||||
           Gimpl::CovShiftForward(
 | 
			
		||||
               U[mu], mu, Gimpl::CovShiftForward(U[nu], nu, U[nu])) * // ->||
 | 
			
		||||
               adj(Gimpl::CovShiftForward(
 | 
			
		||||
                   U[nu], nu, Gimpl::CovShiftForward(U[nu], nu, U[mu])));
 | 
			
		||||
  }
 | 
			
		||||
  static void traceDirRectangle(LatticeComplex &rect, const std::vector<GaugeMat> &U, const int mu, const int nu)
 | 
			
		||||
  {
 | 
			
		||||
  static void traceDirRectangle(LatticeComplex &rect,
 | 
			
		||||
                                const std::vector<GaugeMat> &U, const int mu,
 | 
			
		||||
                                const int nu) {
 | 
			
		||||
    GaugeMat sp(U[0]._grid);
 | 
			
		||||
    dirRectangle(sp, U, mu, nu);
 | 
			
		||||
    rect = trace(sp);
 | 
			
		||||
  }
 | 
			
		||||
  static void siteRectangle(LatticeComplex &Rect,const std::vector<GaugeMat> &U)
 | 
			
		||||
  {
 | 
			
		||||
  static void siteRectangle(LatticeComplex &Rect,
 | 
			
		||||
                            const std::vector<GaugeMat> &U) {
 | 
			
		||||
    LatticeComplex siteRect(U[0]._grid);
 | 
			
		||||
    Rect = zero;
 | 
			
		||||
    for (int mu = 1; mu < Nd; mu++) {
 | 
			
		||||
@@ -320,11 +330,14 @@ namespace Grid {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  // Hop by two optimisation strategy does not work nicely with Gparity. (could do,
 | 
			
		||||
  // Hop by two optimisation strategy does not work nicely with Gparity. (could
 | 
			
		||||
  // do,
 | 
			
		||||
  // but need to track two deep where cross boundary and apply a conjugation).
 | 
			
		||||
  // Must differentiate this in Gimpl, and use Gimpl::isPeriodicGaugeField to do so .
 | 
			
		||||
  // Must differentiate this in Gimpl, and use Gimpl::isPeriodicGaugeField to do
 | 
			
		||||
  // so .
 | 
			
		||||
  ////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
  static void RectStapleOptimised(GaugeMat &Stap,std::vector<GaugeMat> &U2,std::vector<GaugeMat> &U,int mu){
 | 
			
		||||
  static void RectStapleOptimised(GaugeMat &Stap, std::vector<GaugeMat> &U2,
 | 
			
		||||
                                  std::vector<GaugeMat> &U, int mu) {
 | 
			
		||||
 | 
			
		||||
    Stap = zero;
 | 
			
		||||
 | 
			
		||||
@@ -344,14 +357,12 @@ namespace Grid {
 | 
			
		||||
 | 
			
		||||
        Staple2x1 = Gimpl::CovShiftForward(U[nu], nu, tmp);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        // Down staple
 | 
			
		||||
        //             |___ ___|
 | 
			
		||||
        //
 | 
			
		||||
        tmp = adj(U2[mu]) * U[nu];
 | 
			
		||||
        Staple2x1 += Gimpl::CovShiftBackward(U[nu], nu, Cshift(tmp, mu, -2));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //              ___ ___
 | 
			
		||||
        //             |    ___|
 | 
			
		||||
        //             |___ ___|
 | 
			
		||||
@@ -366,7 +377,8 @@ namespace Grid {
 | 
			
		||||
 | 
			
		||||
        //	tmp= Staple2x1* Cshift(U[mu],mu,-2);
 | 
			
		||||
        //	Stap+= Cshift(tmp,mu,1) ;
 | 
			
		||||
	Stap+= Cshift(Staple2x1,mu,1)*Cshift(U[mu],mu,-1); ;
 | 
			
		||||
        Stap += Cshift(Staple2x1, mu, 1) * Cshift(U[mu], mu, -1);
 | 
			
		||||
        ;
 | 
			
		||||
 | 
			
		||||
        //       --
 | 
			
		||||
        //      |  |
 | 
			
		||||
@@ -387,19 +399,16 @@ namespace Grid {
 | 
			
		||||
        tmp = adj(U2[nu]) * tmp;
 | 
			
		||||
        tmp = Cshift(tmp, nu, -2);
 | 
			
		||||
        Stap += Cshift(tmp, mu, 1);
 | 
			
		||||
    }}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  static void RectStaple(GaugeMat &Stap,const GaugeLorentz & Umu,int mu)
 | 
			
		||||
  {
 | 
			
		||||
  static void RectStaple(GaugeMat &Stap, const GaugeLorentz &Umu, int mu) {
 | 
			
		||||
    RectStapleUnoptimised(Stap, Umu, mu);
 | 
			
		||||
  }
 | 
			
		||||
  static void RectStaple(const GaugeLorentz &Umu, GaugeMat &Stap,
 | 
			
		||||
			 std::vector<GaugeMat> &U2,
 | 
			
		||||
			 std::vector<GaugeMat> &U, int mu)
 | 
			
		||||
  {
 | 
			
		||||
                         std::vector<GaugeMat> &U2, std::vector<GaugeMat> &U,
 | 
			
		||||
                         int mu) {
 | 
			
		||||
    if (Gimpl::isPeriodicGaugeField()) {
 | 
			
		||||
      RectStapleOptimised(Stap, U2, U, mu);
 | 
			
		||||
    } else {
 | 
			
		||||
@@ -407,7 +416,8 @@ namespace Grid {
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  static void RectStapleUnoptimised(GaugeMat &Stap,const GaugeLorentz &Umu,int mu){
 | 
			
		||||
  static void RectStapleUnoptimised(GaugeMat &Stap, const GaugeLorentz &Umu,
 | 
			
		||||
                                    int mu) {
 | 
			
		||||
    GridBase *grid = Umu._grid;
 | 
			
		||||
 | 
			
		||||
    std::vector<GaugeMat> U(Nd, grid);
 | 
			
		||||
@@ -423,38 +433,52 @@ namespace Grid {
 | 
			
		||||
        //          |    __ |
 | 
			
		||||
        //
 | 
			
		||||
        Stap += Gimpl::ShiftStaple(
 | 
			
		||||
		  Gimpl::CovShiftForward (U[mu],mu,
 | 
			
		||||
		  Gimpl::CovShiftForward (U[nu],nu,
 | 
			
		||||
		  Gimpl::CovShiftBackward(U[mu],mu,
 | 
			
		||||
                  Gimpl::CovShiftBackward(U[mu],mu,
 | 
			
		||||
		  Gimpl::CovShiftIdentityBackward(U[nu],nu))))) , mu);
 | 
			
		||||
            Gimpl::CovShiftForward(
 | 
			
		||||
                U[mu], mu,
 | 
			
		||||
                Gimpl::CovShiftForward(
 | 
			
		||||
                    U[nu], nu,
 | 
			
		||||
                    Gimpl::CovShiftBackward(
 | 
			
		||||
                        U[mu], mu,
 | 
			
		||||
                        Gimpl::CovShiftBackward(
 | 
			
		||||
                            U[mu], mu,
 | 
			
		||||
                            Gimpl::CovShiftIdentityBackward(U[nu], nu))))),
 | 
			
		||||
            mu);
 | 
			
		||||
 | 
			
		||||
        //              __
 | 
			
		||||
        //          |__ __ |
 | 
			
		||||
 | 
			
		||||
        Stap += Gimpl::ShiftStaple(
 | 
			
		||||
                  Gimpl::CovShiftForward (U[mu],mu,
 | 
			
		||||
		  Gimpl::CovShiftBackward(U[nu],nu,
 | 
			
		||||
		  Gimpl::CovShiftBackward(U[mu],mu,
 | 
			
		||||
                  Gimpl::CovShiftBackward(U[mu],mu, U[nu])))) , mu);
 | 
			
		||||
            Gimpl::CovShiftForward(
 | 
			
		||||
                U[mu], mu,
 | 
			
		||||
                Gimpl::CovShiftBackward(
 | 
			
		||||
                    U[nu], nu,
 | 
			
		||||
                    Gimpl::CovShiftBackward(
 | 
			
		||||
                        U[mu], mu, Gimpl::CovShiftBackward(U[mu], mu, U[nu])))),
 | 
			
		||||
            mu);
 | 
			
		||||
 | 
			
		||||
        //           __
 | 
			
		||||
        //          |__ __ |
 | 
			
		||||
 | 
			
		||||
        Stap += Gimpl::ShiftStaple(
 | 
			
		||||
		  Gimpl::CovShiftBackward(U[nu],nu,
 | 
			
		||||
		  Gimpl::CovShiftBackward(U[mu],mu,
 | 
			
		||||
		  Gimpl::CovShiftBackward(U[mu],mu,
 | 
			
		||||
		  Gimpl::CovShiftForward(U[nu],nu,U[mu])))) , mu);
 | 
			
		||||
            Gimpl::CovShiftBackward(
 | 
			
		||||
                U[nu], nu,
 | 
			
		||||
                Gimpl::CovShiftBackward(
 | 
			
		||||
                    U[mu], mu,
 | 
			
		||||
                    Gimpl::CovShiftBackward(
 | 
			
		||||
                        U[mu], mu, Gimpl::CovShiftForward(U[nu], nu, U[mu])))),
 | 
			
		||||
            mu);
 | 
			
		||||
 | 
			
		||||
        //           __ ___
 | 
			
		||||
        //          |__    |
 | 
			
		||||
 | 
			
		||||
        Stap += Gimpl::ShiftStaple(
 | 
			
		||||
		   Gimpl::CovShiftForward (U[nu],nu,
 | 
			
		||||
	           Gimpl::CovShiftBackward(U[mu],mu,
 | 
			
		||||
                   Gimpl::CovShiftBackward(U[mu],mu,
 | 
			
		||||
                   Gimpl::CovShiftBackward(U[nu],nu,U[mu])))) , mu);
 | 
			
		||||
            Gimpl::CovShiftForward(
 | 
			
		||||
                U[nu], nu,
 | 
			
		||||
                Gimpl::CovShiftBackward(
 | 
			
		||||
                    U[mu], mu,
 | 
			
		||||
                    Gimpl::CovShiftBackward(
 | 
			
		||||
                        U[mu], mu, Gimpl::CovShiftBackward(U[nu], nu, U[mu])))),
 | 
			
		||||
            mu);
 | 
			
		||||
 | 
			
		||||
        //       --
 | 
			
		||||
        //      |  |
 | 
			
		||||
@@ -462,12 +486,16 @@ namespace Grid {
 | 
			
		||||
        //      |  |
 | 
			
		||||
 | 
			
		||||
        Stap += Gimpl::ShiftStaple(
 | 
			
		||||
		   Gimpl::CovShiftForward(U[nu],nu,
 | 
			
		||||
		   Gimpl::CovShiftForward(U[nu],nu,
 | 
			
		||||
                   Gimpl::CovShiftBackward(U[mu],mu,
 | 
			
		||||
                   Gimpl::CovShiftBackward(U[nu],nu,
 | 
			
		||||
		   Gimpl::CovShiftIdentityBackward(U[nu],nu))))) , mu);
 | 
			
		||||
 | 
			
		||||
            Gimpl::CovShiftForward(
 | 
			
		||||
                U[nu], nu,
 | 
			
		||||
                Gimpl::CovShiftForward(
 | 
			
		||||
                    U[nu], nu,
 | 
			
		||||
                    Gimpl::CovShiftBackward(
 | 
			
		||||
                        U[mu], mu,
 | 
			
		||||
                        Gimpl::CovShiftBackward(
 | 
			
		||||
                            U[nu], nu,
 | 
			
		||||
                            Gimpl::CovShiftIdentityBackward(U[nu], nu))))),
 | 
			
		||||
            mu);
 | 
			
		||||
 | 
			
		||||
        //      |  |
 | 
			
		||||
        //
 | 
			
		||||
@@ -475,22 +503,23 @@ namespace Grid {
 | 
			
		||||
        //       --
 | 
			
		||||
 | 
			
		||||
        Stap += Gimpl::ShiftStaple(
 | 
			
		||||
		   Gimpl::CovShiftBackward(U[nu],nu,
 | 
			
		||||
		   Gimpl::CovShiftBackward(U[nu],nu,
 | 
			
		||||
                   Gimpl::CovShiftBackward(U[mu],mu,
 | 
			
		||||
                   Gimpl::CovShiftForward (U[nu],nu,U[nu])))) , mu);
 | 
			
		||||
    }}
 | 
			
		||||
            Gimpl::CovShiftBackward(
 | 
			
		||||
                U[nu], nu,
 | 
			
		||||
                Gimpl::CovShiftBackward(
 | 
			
		||||
                    U[nu], nu,
 | 
			
		||||
                    Gimpl::CovShiftBackward(
 | 
			
		||||
                        U[mu], mu, Gimpl::CovShiftForward(U[nu], nu, U[nu])))),
 | 
			
		||||
            mu);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
typedef WilsonLoops<PeriodicGimplR> ColourWilsonLoops;
 | 
			
		||||
typedef WilsonLoops<PeriodicGimplR> U1WilsonLoops;
 | 
			
		||||
typedef WilsonLoops<PeriodicGimplR> SU2WilsonLoops;
 | 
			
		||||
typedef WilsonLoops<PeriodicGimplR> SU3WilsonLoops;
 | 
			
		||||
 | 
			
		||||
}}
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
		Reference in New Issue
	
	Block a user