1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-04-10 06:00:45 +01:00

Cleaned up HMC output. Tested smeared HMCs for single precision (OK)

This commit is contained in:
Guido Cossu 2016-07-05 12:03:54 +01:00
parent fdfbf11c6d
commit 3e80947c2b
6 changed files with 838 additions and 787 deletions

View File

@ -25,7 +25,8 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
with this program; if not, write to the Free Software Foundation, Inc., with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 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 */ /* END LEGAL */
#include <Grid.h> #include <Grid.h>
@ -44,8 +45,7 @@ namespace Grid {
GridLogger GridLogIterative(1, "Iterative", GridLogColours, "BLUE"); GridLogger GridLogIterative(1, "Iterative", GridLogColours, "BLUE");
GridLogger GridLogIntegrator(1, "Integrator", 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); GridLogError.Active(0);
GridLogWarning.Active(0); GridLogWarning.Active(0);
GridLogMessage.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("Message")) GridLogMessage.Active(1);
if (logstreams[i] == std::string("Iterative")) GridLogIterative.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("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("Integrator")) GridLogIntegrator.Active(1);
if (logstreams[i] == std::string("Colours")) GridLogColours.Active(1); if (logstreams[i] == std::string("Colours")) GridLogColours.Active(1);
} }
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Verbose limiter on MPI tasks // Verbose limiter on MPI tasks
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Grid_quiesce_nodes(void) void Grid_quiesce_nodes(void) {
{
int me = 0; int me = 0;
#ifdef GRID_COMMS_MPI #ifdef GRID_COMMS_MPI
MPI_Comm_rank(MPI_COMM_WORLD, &me); 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 #ifdef GRID_COMMS_MPI
std::cout.clear(); std::cout.clear();
#endif #endif
} }
} }

View File

@ -49,7 +49,6 @@ protected:
public: public:
std::map<std::string, std::string> colour; std::map<std::string, std::string> colour;
Colours(bool activate=false){ Colours(bool activate=false){
Active(activate); Active(activate);
}; };

View File

@ -22,7 +22,8 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
with this program; if not, write to the Free Software Foundation, Inc., with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 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 */ /* END LEGAL */
#ifndef GRID_QCD_GAUGE_IMPL_H #ifndef GRID_QCD_GAUGE_IMPL_H
@ -32,7 +33,6 @@ namespace Grid {
namespace QCD { namespace QCD {
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Implementation dependent gauge types // Implementation dependent gauge types
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@ -47,117 +47,119 @@ template<class Gimpl> class WilsonLoops;
typedef typename GImpl::SiteGaugeLink SiteGaugeLink; typedef typename GImpl::SiteGaugeLink SiteGaugeLink;
// //
template<class S,int Nrepresentation=Nc> template <class S, int Nrepresentation = Nc> class GaugeImplTypes {
class GaugeImplTypes {
public: public:
typedef S Simd; typedef S Simd;
template<typename vtype> using iImplGaugeLink = iScalar<iScalar<iMatrix<vtype, Nrepresentation> > >; template <typename vtype>
template<typename vtype> using iImplGaugeField = iVector<iScalar<iMatrix<vtype, Nrepresentation> >, Nd >; using iImplGaugeLink = iScalar<iScalar<iMatrix<vtype, Nrepresentation>>>;
template <typename vtype>
using iImplGaugeField = iVector<iScalar<iMatrix<vtype, Nrepresentation>>, Nd>;
typedef iImplGaugeLink<Simd> SiteGaugeLink; typedef iImplGaugeLink<Simd> SiteGaugeLink;
typedef iImplGaugeField<Simd> SiteGaugeField; 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; typedef Lattice<SiteGaugeField> GaugeField;
// Move this elsewhere? // 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 PARALLEL_FOR_LOOP
for (auto ss = 0; ss < U._grid->oSites(); ss++) { 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 // Composition with smeared link, bc's etc.. probably need multiple inheritance
// Variable precision "S" and variable Nc // Variable precision "S" and variable Nc
template<class GimplTypes> template <class GimplTypes> class PeriodicGaugeImpl : public GimplTypes {
class PeriodicGaugeImpl : public GimplTypes {
public: public:
INHERIT_GIMPL_TYPES(GimplTypes); 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 template <class covariant>
Lattice<covariant> CovShiftForward (const GaugeLinkField &Link, int mu, const Lattice<covariant> &field) { static inline Lattice<covariant>
CovShiftForward(const GaugeLinkField &Link, int mu,
const Lattice<covariant> &field) {
return PeriodicBC::CovShiftForward(Link, mu, field); return PeriodicBC::CovShiftForward(Link, mu, field);
} }
template<class covariant> static inline template <class covariant>
Lattice<covariant> CovShiftBackward(const GaugeLinkField &Link, int mu,const Lattice<covariant> &field) { static inline Lattice<covariant>
CovShiftBackward(const GaugeLinkField &Link, int mu,
const Lattice<covariant> &field) {
return PeriodicBC::CovShiftBackward(Link, mu, field); return PeriodicBC::CovShiftBackward(Link, mu, field);
} }
static inline static inline GaugeLinkField
GaugeLinkField CovShiftIdentityBackward(const GaugeLinkField &Link, int mu) { CovShiftIdentityBackward(const GaugeLinkField &Link, int mu) {
return Cshift(adj(Link), mu, -1); return Cshift(adj(Link), mu, -1);
} }
static inline static inline GaugeLinkField
GaugeLinkField CovShiftIdentityForward(const GaugeLinkField &Link, int mu) { CovShiftIdentityForward(const GaugeLinkField &Link, int mu) {
return Link; return Link;
} }
static inline static inline GaugeLinkField ShiftStaple(const GaugeLinkField &Link, int mu) {
GaugeLinkField ShiftStaple(const GaugeLinkField &Link, int mu) {
return Cshift(Link, mu, 1); return Cshift(Link, mu, 1);
} }
static inline bool isPeriodicGaugeField(void) { static inline bool isPeriodicGaugeField(void) { return true; }
return true;
}
}; };
// Composition with smeared link, bc's etc.. probably need multiple inheritance // Composition with smeared link, bc's etc.. probably need multiple inheritance
// Variable precision "S" and variable Nc // Variable precision "S" and variable Nc
template<class GimplTypes> template <class GimplTypes> class ConjugateGaugeImpl : public GimplTypes {
class ConjugateGaugeImpl : public GimplTypes {
public: public:
INHERIT_GIMPL_TYPES(GimplTypes); 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 template <class covariant>
Lattice<covariant> CovShiftForward (const GaugeLinkField &Link, int mu, const Lattice<covariant> &field) { static Lattice<covariant> CovShiftForward(const GaugeLinkField &Link, int mu,
const Lattice<covariant> &field) {
return ConjugateBC::CovShiftForward(Link, mu, field); return ConjugateBC::CovShiftForward(Link, mu, field);
} }
template<class covariant> static template <class covariant>
Lattice<covariant> CovShiftBackward(const GaugeLinkField &Link, int mu,const Lattice<covariant> &field) { static Lattice<covariant> CovShiftBackward(const GaugeLinkField &Link, int mu,
const Lattice<covariant> &field) {
return ConjugateBC::CovShiftBackward(Link, mu, field); return ConjugateBC::CovShiftBackward(Link, mu, field);
} }
static inline static inline GaugeLinkField
GaugeLinkField CovShiftIdentityBackward(const GaugeLinkField &Link, int mu) { CovShiftIdentityBackward(const GaugeLinkField &Link, int mu) {
GridBase *grid = Link._grid; GridBase *grid = Link._grid;
int Lmu = grid->GlobalDimensions()[mu] - 1; 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); GaugeLinkField tmp(grid);
tmp = adj(Link); tmp = adj(Link);
tmp = where(coor == Lmu, conjugate(tmp), tmp); tmp = where(coor == Lmu, conjugate(tmp), tmp);
return Cshift(tmp, mu, -1); // moves towards positive mu return Cshift(tmp, mu, -1); // moves towards positive mu
} }
static inline static inline GaugeLinkField
GaugeLinkField CovShiftIdentityForward(const GaugeLinkField &Link, int mu) { CovShiftIdentityForward(const GaugeLinkField &Link, int mu) {
return Link; return Link;
} }
static inline static inline GaugeLinkField ShiftStaple(const GaugeLinkField &Link, int mu) {
GaugeLinkField ShiftStaple(const GaugeLinkField &Link, int mu) {
GridBase *grid = Link._grid; GridBase *grid = Link._grid;
int Lmu = grid->GlobalDimensions()[mu] - 1; 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); GaugeLinkField tmp(grid);
tmp = Cshift(Link, mu, 1); tmp = Cshift(Link, mu, 1);
@ -165,10 +167,7 @@ template<class Gimpl> class WilsonLoops;
return tmp; return tmp;
} }
static inline bool isPeriodicGaugeField(void) { static inline bool isPeriodicGaugeField(void) { return false; }
return false;
}
}; };
typedef GaugeImplTypes<vComplex, Nc> GimplTypesR; typedef GaugeImplTypes<vComplex, Nc> GimplTypesR;
@ -179,10 +178,10 @@ template<class Gimpl> class WilsonLoops;
typedef PeriodicGaugeImpl<GimplTypesF> PeriodicGimplF; // Float typedef PeriodicGaugeImpl<GimplTypesF> PeriodicGimplF; // Float
typedef PeriodicGaugeImpl<GimplTypesD> PeriodicGimplD; // Double 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<GimplTypesF> ConjugateGimplF; // Float
typedef ConjugateGaugeImpl<GimplTypesD> ConjugateGimplD; // Double typedef ConjugateGaugeImpl<GimplTypesD> ConjugateGimplD; // Double
} }
} }

View File

@ -25,7 +25,8 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
with this program; if not, write to the Free Software Foundation, Inc., with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 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 */ /* END LEGAL */
//-------------------------------------------------------------------- //--------------------------------------------------------------------
@ -41,13 +42,10 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
#include <string> #include <string>
namespace Grid { namespace Grid {
namespace QCD { namespace QCD {
struct HMCparameters { struct HMCparameters {
Integer StartTrajectory; Integer StartTrajectory;
Integer Trajectories; /* @brief Number of sweeps in this run */ Integer Trajectories; /* @brief Number of sweeps in this run */
bool MetropolisTest; bool MetropolisTest;
@ -61,27 +59,40 @@ namespace Grid{
Trajectories = 200; 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> template <class GaugeField>
class HmcObservable { class HmcObservable {
public: 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> template <class Gimpl>
class PlaquetteLogger : public HmcObservable<typename Gimpl::GaugeField> { class PlaquetteLogger : public HmcObservable<typename Gimpl::GaugeField> {
private: private:
std::string Stem; std::string Stem;
public: public:
INHERIT_GIMPL_TYPES(Gimpl); INHERIT_GIMPL_TYPES(Gimpl);
PlaquetteLogger(std::string cf) { PlaquetteLogger(std::string cf) { Stem = 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); std::ofstream of(file);
RealD peri_plaq = WilsonLoops<PeriodicGimplR>::avgPlaquette(U); RealD peri_plaq = WilsonLoops<PeriodicGimplR>::avgPlaquette(U);
@ -90,17 +101,27 @@ namespace Grid{
RealD impl_plaq = WilsonLoops<Gimpl>::avgPlaquette(U); RealD impl_plaq = WilsonLoops<Gimpl>::avgPlaquette(U);
RealD impl_rect = WilsonLoops<Gimpl>::avgRectangle(U); RealD impl_rect = WilsonLoops<Gimpl>::avgRectangle(U);
of << traj<<" "<< impl_plaq << " " << impl_rect << " "<< peri_plaq<<" "<<peri_rect<<std::endl; of << traj << " " << impl_plaq << " " << impl_rect << " " << peri_plaq
std::cout<< GridLogMessage<< "traj"<<" "<< "plaq " << " " << " rect " << " "<< "peri_plaq" <<" "<<"peri_rect"<<std::endl; << " " << peri_rect << std::endl;
std::cout<< GridLogMessage<< 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> template <class GaugeField, class IntegratorType>
class HybridMonteCarlo { class HybridMonteCarlo {
private: private:
const HMCparameters Params; const HMCparameters Params;
GridSerialRNG &sRNG; // Fixme: need a RNG management strategy. GridSerialRNG &sRNG; // Fixme: need a RNG management strategy.
@ -114,60 +135,64 @@ namespace Grid{
// Metropolis step // Metropolis step
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
bool metropolis_test(const RealD DeltaH) { bool metropolis_test(const RealD DeltaH) {
RealD rn_test; RealD rn_test;
RealD prob = std::exp(-DeltaH); RealD prob = std::exp(-DeltaH);
random(sRNG, rn_test); random(sRNG, rn_test);
std::cout<<GridLogMessage<< "--------------------------------------------\n"; std::cout << GridLogMessage
std::cout<<GridLogMessage<< "dH = "<<DeltaH << " Random = "<< rn_test <<"\n"; << "--------------------------------------------------\n";
std::cout<<GridLogMessage<< "Acc. Probability = " << ((prob<1.0)? prob: 1.0)<< " "; 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 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; return true;
} else { // rejected } else { // rejected
std::cout<<GridLogMessage <<"-- REJECTED\n"; std::cout << GridLogMessage << "Metropolis_test -- REJECTED\n";
std::cout << GridLogMessage
<< "--------------------------------------------------\n";
return false; return false;
} }
} }
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
// Evolution // Evolution
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
RealD evolve_step(GaugeField &U) { RealD evolve_step(GaugeField &U) {
TheIntegrator.refresh(U, pRNG); // set U and initialize P and phi's TheIntegrator.refresh(U, pRNG); // set U and initialize P and phi's
RealD H0 = TheIntegrator.S(U); // initial state action 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); TheIntegrator.integrate(U);
RealD H1 = TheIntegrator.S(U); // updated state action 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); return (H1 - H0);
} }
public: public:
///////////////////////////////////////// /////////////////////////////////////////
// Constructor // Constructor
///////////////////////////////////////// /////////////////////////////////////////
HybridMonteCarlo(HMCparameters Pms, IntegratorType &_Int, GridSerialRNG &_sRNG, GridParallelRNG &_pRNG, GaugeField &_U) : HybridMonteCarlo(HMCparameters Pams, IntegratorType &_Int,
Params(Pms), GridSerialRNG &_sRNG, GridParallelRNG &_pRNG, GaugeField &_U)
TheIntegrator(_Int), : Params(Pams), TheIntegrator(_Int), sRNG(_sRNG), pRNG(_pRNG), Ucur(_U) {}
sRNG(_sRNG),
pRNG(_pRNG),
Ucur(_U)
{
}
~HybridMonteCarlo(){}; ~HybridMonteCarlo(){};
void AddObservable(HmcObservable<GaugeField> *obs) { void AddObservable(HmcObservable<GaugeField> *obs) {
@ -175,21 +200,22 @@ namespace Grid{
} }
void evolve(void) { void evolve(void) {
Real DeltaH; Real DeltaH;
GaugeField Ucopy(Ucur._grid); GaugeField Ucopy(Ucur._grid);
// Actual updates (evolve a copy Ucopy then copy back eventually) Params.print();
for(int traj=Params.StartTrajectory; traj < Params.Trajectories+Params.StartTrajectory; ++traj){
// 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"; std::cout << GridLogMessage << "-- # Trajectory = " << traj << "\n";
Ucopy = Ucur; Ucopy = Ucur;
DeltaH = evolve_step(Ucopy); DeltaH = evolve_step(Ucopy);
bool accept = true; bool accept = true;
if ( traj > Params.NoMetropolisUntil) { if (traj >= Params.NoMetropolisUntil) {
accept = metropolis_test(DeltaH); accept = metropolis_test(DeltaH);
} }
@ -200,7 +226,6 @@ namespace Grid{
for (int obs = 0; obs < Observables.size(); obs++) { for (int obs = 0; obs < Observables.size(); obs++) {
Observables[obs]->TrajectoryComplete(traj + 1, Ucur, sRNG, pRNG); Observables[obs]->TrajectoryComplete(traj + 1, Ucur, sRNG, pRNG);
} }
} }
} }
}; };
@ -208,5 +233,4 @@ namespace Grid{
} // QCD } // QCD
} // Grid } // Grid
#endif #endif

View File

@ -81,6 +81,14 @@ public:
NumTraj = ivec[0]; 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; GridSerialRNG sRNG;
GridParallelRNG pRNG(UGrid); GridParallelRNG pRNG(UGrid);
@ -112,31 +120,28 @@ public:
HMCparameters HMCpar; HMCparameters HMCpar;
HMCpar.StartTrajectory = StartTraj; HMCpar.StartTrajectory = StartTraj;
HMCpar.Trajectories = NumTraj; HMCpar.Trajectories = NumTraj;
HMCpar.NoMetropolisUntil = NumThermalizations;
if ( StartType == HotStart ) { if ( StartType == HotStart ) {
// Hot start // Hot start
HMCpar.NoMetropolisUntil =10;
HMCpar.MetropolisTest = true; HMCpar.MetropolisTest = true;
sRNG.SeedFixedIntegers(SerSeed); sRNG.SeedFixedIntegers(SerSeed);
pRNG.SeedFixedIntegers(ParSeed); pRNG.SeedFixedIntegers(ParSeed);
SU3::HotConfiguration(pRNG, U); SU3::HotConfiguration(pRNG, U);
} else if ( StartType == ColdStart ) { } else if ( StartType == ColdStart ) {
// Cold start // Cold start
HMCpar.NoMetropolisUntil =10;
HMCpar.MetropolisTest = true; HMCpar.MetropolisTest = true;
sRNG.SeedFixedIntegers(SerSeed); sRNG.SeedFixedIntegers(SerSeed);
pRNG.SeedFixedIntegers(ParSeed); pRNG.SeedFixedIntegers(ParSeed);
SU3::ColdConfiguration(pRNG, U); SU3::ColdConfiguration(pRNG, U);
} else if ( StartType == TepidStart ) { } else if ( StartType == TepidStart ) {
// Tepid start // Tepid start
HMCpar.NoMetropolisUntil =10;
HMCpar.MetropolisTest = true; HMCpar.MetropolisTest = true;
sRNG.SeedFixedIntegers(SerSeed); sRNG.SeedFixedIntegers(SerSeed);
pRNG.SeedFixedIntegers(ParSeed); pRNG.SeedFixedIntegers(ParSeed);
SU3::TepidConfiguration(pRNG, U); SU3::TepidConfiguration(pRNG, U);
} else if ( StartType == CheckpointStart ) { } else if ( StartType == CheckpointStart ) {
HMCpar.NoMetropolisUntil =10;
HMCpar.MetropolisTest = true; HMCpar.MetropolisTest = true;
// CheckpointRestart // CheckpointRestart
Checkpoint.CheckpointRestore(StartTraj, U, sRNG, pRNG); Checkpoint.CheckpointRestore(StartTraj, U, sRNG, pRNG);

View File

@ -25,7 +25,8 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
with this program; if not, write to the Free Software Foundation, Inc., with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 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 */ /* END LEGAL */
#ifndef QCD_UTILS_WILSON_LOOPS_H #ifndef QCD_UTILS_WILSON_LOOPS_H
@ -34,10 +35,8 @@ namespace Grid {
namespace QCD { namespace QCD {
// Common wilson loop observables // Common wilson loop observables
template<class Gimpl> template <class Gimpl> class WilsonLoops : public Gimpl {
class WilsonLoops : public Gimpl {
public: public:
INHERIT_GIMPL_TYPES(Gimpl); INHERIT_GIMPL_TYPES(Gimpl);
typedef typename Gimpl::GaugeLinkField GaugeMat; typedef typename Gimpl::GaugeLinkField GaugeMat;
@ -46,21 +45,25 @@ namespace Grid {
////////////////////////////////////////////////// //////////////////////////////////////////////////
// directed plaquette oriented in mu,nu plane // directed plaquette oriented in mu,nu plane
////////////////////////////////////////////////// //////////////////////////////////////////////////
static void dirPlaquette(GaugeMat &plaq,const std::vector<GaugeMat> &U, const int mu, const int nu) 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, // Annoyingly, must use either scope resolution to find dependent base
// or this-> ; there is no "this" in a static method. This forces explicit Gimpl scope // class,
// resolution throughout the usage in this file, and rather defeats the purpose of deriving // 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. // from Gimpl.
plaq = Gimpl::CovShiftBackward(U[mu],mu, plaq = Gimpl::CovShiftBackward(
Gimpl::CovShiftBackward(U[nu],nu, U[mu], mu, Gimpl::CovShiftBackward(
Gimpl::CovShiftForward (U[mu],mu,U[nu]))); U[nu], nu, Gimpl::CovShiftForward(U[mu], mu, U[nu])));
} }
////////////////////////////////////////////////// //////////////////////////////////////////////////
// trace of directed plaquette oriented in mu,nu plane // 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); GaugeMat sp(U[0]._grid);
dirPlaquette(sp, U, mu, nu); dirPlaquette(sp, U, mu, nu);
plaq = trace(sp); plaq = trace(sp);
@ -68,8 +71,8 @@ namespace Grid {
////////////////////////////////////////////////// //////////////////////////////////////////////////
// sum over all planes of plaquette // 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); LatticeComplex sitePlaq(U[0]._grid);
Plaq = zero; Plaq = zero;
for (int mu = 1; mu < Nd; mu++) { for (int mu = 1; mu < Nd; mu++) {
@ -113,7 +116,8 @@ namespace Grid {
static RealD linkTrace(const GaugeLorentz &Umu) { static RealD linkTrace(const GaugeLorentz &Umu) {
std::vector<GaugeMat> U(4, Umu._grid); 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++) { for (int mu = 0; mu < Nd; mu++) {
U[mu] = PeekIndex<LorentzIndex>(Umu, mu); U[mu] = PeekIndex<LorentzIndex>(Umu, mu);
Tr = Tr + trace(U[mu]); Tr = Tr + trace(U[mu]);
@ -130,7 +134,8 @@ namespace Grid {
////////////////////////////////////////////////// //////////////////////////////////////////////////
// the sum over all staples on each site in direction mu,nu // 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; GridBase *grid = Umu._grid;
@ -140,7 +145,6 @@ namespace Grid {
} }
staple = zero; staple = zero;
if (nu != mu) { if (nu != mu) {
// mu // mu
@ -153,9 +157,11 @@ namespace Grid {
// //
staple += Gimpl::ShiftStaple( staple += Gimpl::ShiftStaple(
Gimpl::CovShiftForward (U[nu],nu, Gimpl::CovShiftForward(
Gimpl::CovShiftBackward(U[mu],mu, U[nu], nu,
Gimpl::CovShiftIdentityBackward(U[nu],nu))),mu); Gimpl::CovShiftBackward(
U[mu], mu, Gimpl::CovShiftIdentityBackward(U[nu], nu))),
mu);
// __ // __
// | // |
@ -164,8 +170,8 @@ namespace Grid {
// //
staple += Gimpl::ShiftStaple( staple += Gimpl::ShiftStaple(
Gimpl::CovShiftBackward(U[nu], nu, 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; staple = zero;
GaugeMat tmp(grid); GaugeMat tmp(grid);
for (int nu = 0; nu < Nd; nu++) { for (int nu = 0; nu < Nd; nu++) {
if (nu != mu) { if (nu != mu) {
@ -198,9 +203,11 @@ namespace Grid {
// //
staple += Gimpl::ShiftStaple( staple += Gimpl::ShiftStaple(
Gimpl::CovShiftForward (U[nu],nu, Gimpl::CovShiftForward(
Gimpl::CovShiftBackward(U[mu],mu, U[nu], nu,
Gimpl::CovShiftIdentityBackward(U[nu],nu))),mu); Gimpl::CovShiftBackward(
U[mu], mu, Gimpl::CovShiftIdentityBackward(U[nu], nu))),
mu);
// __ // __
// | // |
@ -209,16 +216,17 @@ namespace Grid {
// //
staple += Gimpl::ShiftStaple( staple += Gimpl::ShiftStaple(
Gimpl::CovShiftBackward(U[nu], nu, 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 // 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; staple = zero;
@ -240,36 +248,38 @@ namespace Grid {
// //
staple += Gimpl::ShiftStaple( staple += Gimpl::ShiftStaple(
Gimpl::CovShiftForward (U[nu],nu, Gimpl::CovShiftForward(
Gimpl::CovShiftBackward(U[mu],mu, U[nu], nu,
Gimpl::CovShiftIdentityBackward(U[nu],nu))),mu); Gimpl::CovShiftBackward(
U[mu], mu, Gimpl::CovShiftIdentityBackward(U[nu], nu))),
mu);
} }
} }
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
// Similar to above for rectangle is required // Similar to above for rectangle is required
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
static void dirRectangle(GaugeMat &rect,const std::vector<GaugeMat> &U, const int mu, const int nu) 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]))* // ->->| rect = Gimpl::CovShiftForward(
adj(Gimpl::CovShiftForward(U[nu],nu,Gimpl::CovShiftForward(U[mu],mu,U[mu]))) ; 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 + rect = rect +
Gimpl::CovShiftForward(U[mu],mu,Gimpl::CovShiftForward(U[nu],nu,U[nu]))* // ->|| Gimpl::CovShiftForward(
adj(Gimpl::CovShiftForward(U[nu],nu,Gimpl::CovShiftForward(U[nu],nu,U[mu]))) ; 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); GaugeMat sp(U[0]._grid);
dirRectangle(sp, U, mu, nu); dirRectangle(sp, U, mu, nu);
rect = trace(sp); 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); LatticeComplex siteRect(U[0]._grid);
Rect = zero; Rect = zero;
for (int mu = 1; mu < Nd; mu++) { 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). // 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; Stap = zero;
@ -344,14 +357,12 @@ namespace Grid {
Staple2x1 = Gimpl::CovShiftForward(U[nu], nu, tmp); Staple2x1 = Gimpl::CovShiftForward(U[nu], nu, tmp);
// Down staple // Down staple
// |___ ___| // |___ ___|
// //
tmp = adj(U2[mu]) * U[nu]; tmp = adj(U2[mu]) * U[nu];
Staple2x1 += Gimpl::CovShiftBackward(U[nu], nu, Cshift(tmp, mu, -2)); Staple2x1 += Gimpl::CovShiftBackward(U[nu], nu, Cshift(tmp, mu, -2));
// ___ ___ // ___ ___
// | ___| // | ___|
// |___ ___| // |___ ___|
@ -366,7 +377,8 @@ namespace Grid {
// tmp= Staple2x1* Cshift(U[mu],mu,-2); // tmp= Staple2x1* Cshift(U[mu],mu,-2);
// Stap+= Cshift(tmp,mu,1) ; // 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 = adj(U2[nu]) * tmp;
tmp = Cshift(tmp, nu, -2); tmp = Cshift(tmp, nu, -2);
Stap += Cshift(tmp, mu, 1); 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); RectStapleUnoptimised(Stap, Umu, mu);
} }
static void RectStaple(const GaugeLorentz &Umu, GaugeMat &Stap, static void RectStaple(const GaugeLorentz &Umu, GaugeMat &Stap,
std::vector<GaugeMat> &U2, std::vector<GaugeMat> &U2, std::vector<GaugeMat> &U,
std::vector<GaugeMat> &U, int mu) int mu) {
{
if (Gimpl::isPeriodicGaugeField()) { if (Gimpl::isPeriodicGaugeField()) {
RectStapleOptimised(Stap, U2, U, mu); RectStapleOptimised(Stap, U2, U, mu);
} else { } 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; GridBase *grid = Umu._grid;
std::vector<GaugeMat> U(Nd, grid); std::vector<GaugeMat> U(Nd, grid);
@ -423,38 +433,52 @@ namespace Grid {
// | __ | // | __ |
// //
Stap += Gimpl::ShiftStaple( Stap += Gimpl::ShiftStaple(
Gimpl::CovShiftForward (U[mu],mu, Gimpl::CovShiftForward(
Gimpl::CovShiftForward (U[nu],nu, U[mu], mu,
Gimpl::CovShiftBackward(U[mu],mu, Gimpl::CovShiftForward(
Gimpl::CovShiftBackward(U[mu],mu, U[nu], nu,
Gimpl::CovShiftIdentityBackward(U[nu],nu))))) , mu); Gimpl::CovShiftBackward(
U[mu], mu,
Gimpl::CovShiftBackward(
U[mu], mu,
Gimpl::CovShiftIdentityBackward(U[nu], nu))))),
mu);
// __ // __
// |__ __ | // |__ __ |
Stap += Gimpl::ShiftStaple( Stap += Gimpl::ShiftStaple(
Gimpl::CovShiftForward (U[mu],mu, Gimpl::CovShiftForward(
Gimpl::CovShiftBackward(U[nu],nu, U[mu], mu,
Gimpl::CovShiftBackward(U[mu],mu, Gimpl::CovShiftBackward(
Gimpl::CovShiftBackward(U[mu],mu, U[nu])))) , mu); U[nu], nu,
Gimpl::CovShiftBackward(
U[mu], mu, Gimpl::CovShiftBackward(U[mu], mu, U[nu])))),
mu);
// __ // __
// |__ __ | // |__ __ |
Stap += Gimpl::ShiftStaple( Stap += Gimpl::ShiftStaple(
Gimpl::CovShiftBackward(U[nu],nu, Gimpl::CovShiftBackward(
Gimpl::CovShiftBackward(U[mu],mu, U[nu], nu,
Gimpl::CovShiftBackward(U[mu],mu, Gimpl::CovShiftBackward(
Gimpl::CovShiftForward(U[nu],nu,U[mu])))) , mu); U[mu], mu,
Gimpl::CovShiftBackward(
U[mu], mu, Gimpl::CovShiftForward(U[nu], nu, U[mu])))),
mu);
// __ ___ // __ ___
// |__ | // |__ |
Stap += Gimpl::ShiftStaple( Stap += Gimpl::ShiftStaple(
Gimpl::CovShiftForward (U[nu],nu, Gimpl::CovShiftForward(
Gimpl::CovShiftBackward(U[mu],mu, U[nu], nu,
Gimpl::CovShiftBackward(U[mu],mu, Gimpl::CovShiftBackward(
Gimpl::CovShiftBackward(U[nu],nu,U[mu])))) , mu); 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( Stap += Gimpl::ShiftStaple(
Gimpl::CovShiftForward(U[nu],nu, Gimpl::CovShiftForward(
Gimpl::CovShiftForward(U[nu],nu, U[nu], nu,
Gimpl::CovShiftBackward(U[mu],mu, Gimpl::CovShiftForward(
Gimpl::CovShiftBackward(U[nu],nu, U[nu], nu,
Gimpl::CovShiftIdentityBackward(U[nu],nu))))) , mu); 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( Stap += Gimpl::ShiftStaple(
Gimpl::CovShiftBackward(U[nu],nu, Gimpl::CovShiftBackward(
Gimpl::CovShiftBackward(U[nu],nu, U[nu], nu,
Gimpl::CovShiftBackward(U[mu],mu, Gimpl::CovShiftBackward(
Gimpl::CovShiftForward (U[nu],nu,U[nu])))) , mu); U[nu], nu,
}} Gimpl::CovShiftBackward(
U[mu], mu, Gimpl::CovShiftForward(U[nu], nu, U[nu])))),
mu);
}
}
} }
}; };
typedef WilsonLoops<PeriodicGimplR> ColourWilsonLoops; typedef WilsonLoops<PeriodicGimplR> ColourWilsonLoops;
typedef WilsonLoops<PeriodicGimplR> U1WilsonLoops; typedef WilsonLoops<PeriodicGimplR> U1WilsonLoops;
typedef WilsonLoops<PeriodicGimplR> SU2WilsonLoops; typedef WilsonLoops<PeriodicGimplR> SU2WilsonLoops;
typedef WilsonLoops<PeriodicGimplR> SU3WilsonLoops; typedef WilsonLoops<PeriodicGimplR> SU3WilsonLoops;
}
}} }
#endif #endif