mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-10 07:55:35 +00:00
Debugged smearing and adding HMC functions for hirep
This commit is contained in:
parent
a9ae30f868
commit
9dc345e8e8
@ -496,11 +496,12 @@ namespace QCD {
|
|||||||
|
|
||||||
#include <qcd/action/Actions.h>
|
#include <qcd/action/Actions.h>
|
||||||
|
|
||||||
|
#include <qcd/smearing/Smearing.h>
|
||||||
|
|
||||||
|
#include <qcd/representations/hmc_types.h>
|
||||||
|
|
||||||
#include <qcd/hmc/integrators/Integrator.h>
|
#include <qcd/hmc/integrators/Integrator.h>
|
||||||
#include <qcd/hmc/integrators/Integrator_algorithm.h>
|
#include <qcd/hmc/integrators/Integrator_algorithm.h>
|
||||||
#include <qcd/hmc/HMC.h>
|
#include <qcd/hmc/HMC.h>
|
||||||
|
|
||||||
#include <qcd/smearing/Smearing.h>
|
|
||||||
|
|
||||||
#include <qcd/representations/hmc_types.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -67,12 +67,12 @@ public:
|
|||||||
|
|
||||||
typedef Action<GaugeField>* ActPtr; // now force the same colours as the rest of the code
|
typedef Action<GaugeField>* ActPtr; // now force the same colours as the rest of the code
|
||||||
|
|
||||||
int multiplier;
|
unsigned int multiplier;
|
||||||
|
|
||||||
std::vector<ActPtr> actions;
|
std::vector<ActPtr> actions;
|
||||||
|
|
||||||
ActionLevel(int mul = 1) : multiplier(mul) {
|
ActionLevel(unsigned int mul = 1) : actions(0), multiplier(mul) {
|
||||||
assert (mul > 0);
|
assert (mul >= 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
void push_back(ActPtr ptr){
|
void push_back(ActPtr ptr){
|
||||||
@ -83,5 +83,6 @@ public:
|
|||||||
template<class GaugeField> using ActionSet = std::vector<ActionLevel< GaugeField > >;
|
template<class GaugeField> using ActionSet = std::vector<ActionLevel< GaugeField > >;
|
||||||
|
|
||||||
|
|
||||||
}}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -64,7 +64,7 @@ struct IntegratorParameters {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*! @brief Class for Molecular Dynamics management */
|
/*! @brief Class for Molecular Dynamics management */
|
||||||
template <class GaugeField, class SmearingPolicy>
|
template <class GaugeField, class SmearingPolicy ,class RepresentationPolicy >
|
||||||
class Integrator {
|
class Integrator {
|
||||||
protected:
|
protected:
|
||||||
typedef IntegratorParameters ParameterType;
|
typedef IntegratorParameters ParameterType;
|
||||||
@ -81,6 +81,8 @@ class Integrator {
|
|||||||
|
|
||||||
SmearingPolicy& Smearer;
|
SmearingPolicy& Smearer;
|
||||||
|
|
||||||
|
RepresentationPolicy Representations;
|
||||||
|
|
||||||
// Should match any legal (SU(n)) gauge field
|
// Should match any legal (SU(n)) gauge field
|
||||||
// Need to use this template to match Ncol to pass to SU<N> class
|
// Need to use this template to match Ncol to pass to SU<N> class
|
||||||
template <int Ncol, class vec>
|
template <int Ncol, class vec>
|
||||||
@ -108,8 +110,28 @@ class Integrator {
|
|||||||
<< " dt " << ep << " : t_P " << t_P[level] << std::endl;
|
<< " dt " << ep << " : t_P " << t_P[level] << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// to be used by the actionlevel class to iterate
|
||||||
|
// over the representations
|
||||||
|
template <class Level>
|
||||||
|
void update_P_core(Level repr_level, GaugeField& Mom, GaugeField& U,
|
||||||
|
double ep) {
|
||||||
|
typedef typename Level::LatticeField FieldType;
|
||||||
|
FieldType Ur = repr_level->getRepresentation();// update U is better
|
||||||
|
for (int a = 0; a < repr_level.size(); ++a) {
|
||||||
|
FieldType forceR(U._grid);
|
||||||
|
// Implement smearing only for the fundamental representation now
|
||||||
|
repr_level.at(a)->deriv(Ur, forceR);
|
||||||
|
GaugeField force = repr_level.at(a)->RtoFundamentalProject(forceR);
|
||||||
|
std::cout << GridLogIntegrator
|
||||||
|
<< "Hirep Force average: " << norm2(force) / (U._grid->gSites())
|
||||||
|
<< std::endl;
|
||||||
|
Mom -= force * ep;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Add the specialized class for the fundamental case
|
||||||
|
|
||||||
void update_P(GaugeField& Mom, GaugeField& U, int level, double ep) {
|
void update_P(GaugeField& Mom, GaugeField& U, int level, double ep) {
|
||||||
// input U actually not used...
|
// input U actually not used in the fundamental case
|
||||||
for (int a = 0; a < as[level].actions.size(); ++a) {
|
for (int a = 0; a < as[level].actions.size(); ++a) {
|
||||||
GaugeField force(U._grid);
|
GaugeField force(U._grid);
|
||||||
GaugeField& Us = Smearer.get_U(as[level].actions.at(a)->is_smeared);
|
GaugeField& Us = Smearer.get_U(as[level].actions.at(a)->is_smeared);
|
||||||
@ -125,6 +147,8 @@ class Integrator {
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
Mom -= force * ep;
|
Mom -= force * ep;
|
||||||
}
|
}
|
||||||
|
// Add here the other representations
|
||||||
|
// as[level].apply(update_P_hireps, Args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_U(GaugeField& U, double ep) {
|
void update_U(GaugeField& U, double ep) {
|
||||||
@ -147,6 +171,8 @@ class Integrator {
|
|||||||
}
|
}
|
||||||
// Update the smeared fields, can be implemented as observer
|
// Update the smeared fields, can be implemented as observer
|
||||||
Smearer.set_GaugeField(U);
|
Smearer.set_GaugeField(U);
|
||||||
|
// Update the higher representations fields
|
||||||
|
//Representations.update(U);// void functions if fundamental representation
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void step(GaugeField& U, int level, int first, int last) = 0;
|
virtual void step(GaugeField& U, int level, int first, int last) = 0;
|
||||||
@ -154,7 +180,7 @@ class Integrator {
|
|||||||
public:
|
public:
|
||||||
Integrator(GridBase* grid, IntegratorParameters Par,
|
Integrator(GridBase* grid, IntegratorParameters Par,
|
||||||
ActionSet<GaugeField>& Aset, SmearingPolicy& Sm)
|
ActionSet<GaugeField>& Aset, SmearingPolicy& Sm)
|
||||||
: Params(Par), as(Aset), P(grid), levels(Aset.size()), Smearer(Sm) {
|
: Params(Par), as(Aset), P(grid), levels(Aset.size()), Smearer(Sm), Representations(grid) {
|
||||||
t_P.resize(levels, 0.0);
|
t_P.resize(levels, 0.0);
|
||||||
t_U = 0.0;
|
t_U = 0.0;
|
||||||
// initialization of smearer delegated outside of Integrator
|
// initialization of smearer delegated outside of Integrator
|
||||||
@ -166,8 +192,16 @@ class Integrator {
|
|||||||
void refresh(GaugeField& U, GridParallelRNG& pRNG) {
|
void refresh(GaugeField& U, GridParallelRNG& pRNG) {
|
||||||
std::cout << GridLogIntegrator << "Integrator refresh\n";
|
std::cout << GridLogIntegrator << "Integrator refresh\n";
|
||||||
generate_momenta(P, pRNG);
|
generate_momenta(P, pRNG);
|
||||||
|
|
||||||
|
// Update the smeared fields, can be implemented as observer
|
||||||
|
// necessary to keep the fields updated even after a reject
|
||||||
|
// of the Metropolis
|
||||||
|
Smearer.set_GaugeField(U);
|
||||||
|
// Set the (eventual) representations gauge fields
|
||||||
|
// Representations.update(U);
|
||||||
|
|
||||||
// The Smearer is attached to a pointer of the gauge field
|
// The Smearer is attached to a pointer of the gauge field
|
||||||
// automatically gets the updated field
|
// automatically gets the correct field
|
||||||
// whether or not has been accepted in the previous sweep
|
// whether or not has been accepted in the previous sweep
|
||||||
for (int level = 0; level < as.size(); ++level) {
|
for (int level = 0; level < as.size(); ++level) {
|
||||||
for (int actionID = 0; actionID < as[level].actions.size(); ++actionID) {
|
for (int actionID = 0; actionID < as[level].actions.size(); ++actionID) {
|
||||||
@ -178,6 +212,9 @@ class Integrator {
|
|||||||
as[level].actions.at(actionID)->refresh(Us, pRNG);
|
as[level].actions.at(actionID)->refresh(Us, pRNG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate action
|
// Calculate action
|
||||||
@ -220,6 +257,7 @@ class Integrator {
|
|||||||
t_P[level] = 0;
|
t_P[level] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (int step = 0; step < Params.MDsteps; ++step) { // MD step
|
for (int step = 0; step < Params.MDsteps; ++step) { // MD step
|
||||||
int first_step = (step == 0);
|
int first_step = (step == 0);
|
||||||
int last_step = (step == Params.MDsteps - 1);
|
int last_step = (step == Params.MDsteps - 1);
|
||||||
|
@ -91,17 +91,19 @@ namespace Grid{
|
|||||||
* P 1/2 P 1/2
|
* P 1/2 P 1/2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template<class GaugeField, class SmearingPolicy> class LeapFrog :
|
template<class GaugeField,
|
||||||
public Integrator<GaugeField, SmearingPolicy> {
|
class SmearingPolicy,
|
||||||
|
class RepresentationPolicy = Representations< FundamentalRepresentation > > class LeapFrog :
|
||||||
|
public Integrator<GaugeField, SmearingPolicy, RepresentationPolicy> {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef LeapFrog<GaugeField, SmearingPolicy> Algorithm;
|
typedef LeapFrog<GaugeField, SmearingPolicy, RepresentationPolicy> Algorithm;
|
||||||
|
|
||||||
LeapFrog(GridBase* grid,
|
LeapFrog(GridBase* grid,
|
||||||
IntegratorParameters Par,
|
IntegratorParameters Par,
|
||||||
ActionSet<GaugeField> & Aset,
|
ActionSet<GaugeField> & Aset,
|
||||||
SmearingPolicy & Sm):
|
SmearingPolicy & Sm):
|
||||||
Integrator<GaugeField, SmearingPolicy>(grid,Par,Aset,Sm) {};
|
Integrator<GaugeField, SmearingPolicy, RepresentationPolicy>(grid,Par,Aset,Sm) {};
|
||||||
|
|
||||||
|
|
||||||
void step (GaugeField& U, int level,int _first, int _last){
|
void step (GaugeField& U, int level,int _first, int _last){
|
||||||
@ -138,8 +140,10 @@ namespace Grid{
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class GaugeField, class SmearingPolicy> class MinimumNorm2 :
|
template<class GaugeField,
|
||||||
public Integrator<GaugeField, SmearingPolicy> {
|
class SmearingPolicy,
|
||||||
|
class RepresentationPolicy = Representations < FundamentalRepresentation > > class MinimumNorm2 :
|
||||||
|
public Integrator<GaugeField, SmearingPolicy, RepresentationPolicy> {
|
||||||
private:
|
private:
|
||||||
const RealD lambda = 0.1931833275037836;
|
const RealD lambda = 0.1931833275037836;
|
||||||
|
|
||||||
@ -149,7 +153,7 @@ namespace Grid{
|
|||||||
IntegratorParameters Par,
|
IntegratorParameters Par,
|
||||||
ActionSet<GaugeField> & Aset,
|
ActionSet<GaugeField> & Aset,
|
||||||
SmearingPolicy& Sm):
|
SmearingPolicy& Sm):
|
||||||
Integrator<GaugeField, SmearingPolicy>(grid,Par,Aset,Sm) {};
|
Integrator<GaugeField, SmearingPolicy, RepresentationPolicy>(grid,Par,Aset,Sm) {};
|
||||||
|
|
||||||
void step (GaugeField& U, int level, int _first,int _last){
|
void step (GaugeField& U, int level, int _first,int _last){
|
||||||
|
|
||||||
@ -197,8 +201,10 @@ namespace Grid{
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template<class GaugeField, class SmearingPolicy> class ForceGradient :
|
template<class GaugeField,
|
||||||
public Integrator<GaugeField, SmearingPolicy> {
|
class SmearingPolicy,
|
||||||
|
class RepresentationPolicy = Representations< FundamentalRepresentation > > class ForceGradient :
|
||||||
|
public Integrator<GaugeField, SmearingPolicy, RepresentationPolicy> {
|
||||||
private:
|
private:
|
||||||
const RealD lambda = 1.0/6.0;;
|
const RealD lambda = 1.0/6.0;;
|
||||||
const RealD chi = 1.0/72.0;
|
const RealD chi = 1.0/72.0;
|
||||||
@ -211,7 +217,7 @@ namespace Grid{
|
|||||||
IntegratorParameters Par,
|
IntegratorParameters Par,
|
||||||
ActionSet<GaugeField> & Aset,
|
ActionSet<GaugeField> & Aset,
|
||||||
SmearingPolicy &Sm):
|
SmearingPolicy &Sm):
|
||||||
Integrator<GaugeField, SmearingPolicy>(grid,Par,Aset, Sm) {};
|
Integrator<GaugeField, SmearingPolicy, RepresentationPolicy>(grid,Par,Aset, Sm) {};
|
||||||
|
|
||||||
|
|
||||||
void FG_update_P(GaugeField&U, int level,double fg_dt,double ep){
|
void FG_update_P(GaugeField&U, int level,double fg_dt,double ep){
|
||||||
|
@ -19,11 +19,16 @@ namespace QCD {
|
|||||||
template <int ncolour>
|
template <int ncolour>
|
||||||
class AdjointRep {
|
class AdjointRep {
|
||||||
public:
|
public:
|
||||||
typename SU_Adjoint<ncolour>::LatticeAdjMatrix U;
|
// typdef to be used by the Representations class in HMC to get the
|
||||||
|
// types for the higher representation fields
|
||||||
|
typedef typename SU_Adjoint<ncolour>::LatticeAdjMatrix LatticeField;
|
||||||
const int Dimension = ncolour * ncolour - 1;
|
const int Dimension = ncolour * ncolour - 1;
|
||||||
|
|
||||||
|
LatticeField U;
|
||||||
|
|
||||||
|
|
||||||
explicit AdjointRep(GridBase* grid) : U(grid) {}
|
explicit AdjointRep(GridBase* grid) : U(grid) {}
|
||||||
void update_representation(const LatticeGaugeField& Uin) {
|
LatticeField update_representation(const LatticeGaugeField& Uin) {
|
||||||
// Uin is in the fundamental representation
|
// Uin is in the fundamental representation
|
||||||
// get the U in AdjointRep
|
// get the U in AdjointRep
|
||||||
// (U_adj)_B = tr[e^a U e^b U^dag]
|
// (U_adj)_B = tr[e^a U e^b U^dag]
|
||||||
@ -36,7 +41,8 @@ class AdjointRep {
|
|||||||
|
|
||||||
Vector<typename SU<ncolour>::Matrix> ta(ncolour * ncolour - 1);
|
Vector<typename SU<ncolour>::Matrix> ta(ncolour * ncolour - 1);
|
||||||
|
|
||||||
// FIXME probably not very efficient to get all the generators everytime
|
// FIXME probably not very efficient to get all the generators
|
||||||
|
// everytime
|
||||||
for (int a = 0; a < Dimension; a++) SU<ncolour>::generator(a, ta[a]);
|
for (int a = 0; a < Dimension; a++) SU<ncolour>::generator(a, ta[a]);
|
||||||
|
|
||||||
for (int a = 0; a < Dimension; a++) {
|
for (int a = 0; a < Dimension; a++) {
|
||||||
|
39
lib/qcd/representations/fundamental.h
Normal file
39
lib/qcd/representations/fundamental.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Policy classes for the HMC
|
||||||
|
* Author: Guido Cossu
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FUNDAMENTAL_H
|
||||||
|
#define FUNDAMENTAL_H
|
||||||
|
|
||||||
|
|
||||||
|
namespace Grid {
|
||||||
|
namespace QCD {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is an helper class for the HMC
|
||||||
|
* Empty since HMC updates already the fundamental representation
|
||||||
|
*/
|
||||||
|
|
||||||
|
template <int ncolour>
|
||||||
|
class FundamentalRep {
|
||||||
|
public:
|
||||||
|
const int Dimension = ncolour;
|
||||||
|
|
||||||
|
// typdef to be used by the Representations class in HMC to get the
|
||||||
|
// types for the higher representation fields
|
||||||
|
typedef typename SU<ncolour>::LatticeMatrix LatticeField;
|
||||||
|
|
||||||
|
explicit FundamentalRep(GridBase* grid) {} //do nothing
|
||||||
|
void update_representation(const LatticeGaugeField& Uin) {} // do nothing
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef FundamentalRep<Nc> FundamentalRepresentation;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@ -4,16 +4,27 @@
|
|||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <qcd/representations/adjoint.h>
|
#include <qcd/representations/adjoint.h>
|
||||||
|
#include <qcd/representations/fundamental.h>
|
||||||
|
|
||||||
namespace Grid {
|
namespace Grid {
|
||||||
namespace QCD {
|
namespace QCD {
|
||||||
|
|
||||||
// Utility to add support for representations other than the fundamental
|
|
||||||
|
|
||||||
|
// Supported types
|
||||||
|
//enum {Fundamental, Adjoint} repr_type;
|
||||||
|
|
||||||
|
// Utility to add support to the HMC for representations other than the fundamental
|
||||||
template<class... Reptypes>
|
template<class... Reptypes>
|
||||||
class Representations{
|
class Representations{
|
||||||
public:
|
public:
|
||||||
typedef std::tuple<Reptypes...> Representation_type;
|
typedef std::tuple<Reptypes...> Representation_type;
|
||||||
|
|
||||||
|
// To access the Reptypes (FundamentalRepresentation, AdjointRepresentation)
|
||||||
|
template <std::size_t N>
|
||||||
|
using repr_type = typename std::tuple_element<N, Representation_type >::type;
|
||||||
|
// in order to get the typename of the field use
|
||||||
|
// type repr_type::LatticeField
|
||||||
|
|
||||||
Representation_type rep;
|
Representation_type rep;
|
||||||
|
|
||||||
// Multiple types constructor
|
// Multiple types constructor
|
||||||
@ -35,6 +46,10 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef Representations<FundamentalRepresentation> JustTheFundamental;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -728,6 +728,10 @@ typedef SU<2> SU2;
|
|||||||
typedef SU<3> SU3;
|
typedef SU<3> SU3;
|
||||||
typedef SU<4> SU4;
|
typedef SU<4> SU4;
|
||||||
typedef SU<5> SU5;
|
typedef SU<5> SU5;
|
||||||
|
|
||||||
|
|
||||||
|
typedef SU<Nc> FundamentalMatrices;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -137,12 +137,14 @@ class SU_Adjoint : public SU<ncolour> {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Some useful type names
|
||||||
|
|
||||||
typedef SU_Adjoint<2> SU2Adjoint;
|
typedef SU_Adjoint<2> SU2Adjoint;
|
||||||
typedef SU_Adjoint<3> SU3Adjoint;
|
typedef SU_Adjoint<3> SU3Adjoint;
|
||||||
typedef SU_Adjoint<4> SU4Adjoint;
|
typedef SU_Adjoint<4> SU4Adjoint;
|
||||||
typedef SU_Adjoint<5> SU5Adjoint;
|
typedef SU_Adjoint<5> SU5Adjoint;
|
||||||
|
|
||||||
|
typedef SU_Adjoint<Nc> AdjointMatrices;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ public:
|
|||||||
TwoFlavourEvenOddPseudoFermionAction<ImplPolicy> Nf2(FermOp,CG,CG);
|
TwoFlavourEvenOddPseudoFermionAction<ImplPolicy> Nf2(FermOp,CG,CG);
|
||||||
|
|
||||||
//Set smearing (true/false), default: false
|
//Set smearing (true/false), default: false
|
||||||
Nf2.is_smeared=false;
|
Nf2.is_smeared=true;
|
||||||
|
|
||||||
//Collect actions
|
//Collect actions
|
||||||
ActionLevel<LatticeGaugeField> Level1(1);
|
ActionLevel<LatticeGaugeField> Level1(1);
|
||||||
|
@ -43,8 +43,8 @@ class HmcRunner : public NerscHmcRunner {
|
|||||||
void BuildTheAction(int argc, char **argv)
|
void BuildTheAction(int argc, char **argv)
|
||||||
|
|
||||||
{
|
{
|
||||||
typedef WilsonImplR ImplPolicy; // gauge field implemetation
|
typedef WilsonImplR ImplPolicy; // gauge field implemetation for the pseudofermions
|
||||||
typedef WilsonFermionR FermionAction; // type of lattice fermions
|
typedef WilsonFermionR FermionAction; // type of lattice fermions (Wilson, DW, ...)
|
||||||
typedef typename FermionAction::FermionField FermionField;
|
typedef typename FermionAction::FermionField FermionField;
|
||||||
|
|
||||||
UGrid = SpaceTimeGrid::makeFourDimGrid(
|
UGrid = SpaceTimeGrid::makeFourDimGrid(
|
||||||
|
@ -112,7 +112,7 @@ int main(int argc, char** argv) {
|
|||||||
AdjointRep<3> AdjRep(grid);
|
AdjointRep<3> AdjRep(grid);
|
||||||
|
|
||||||
// AdjointRepresentation has the predefined number of colours Nc
|
// AdjointRepresentation has the predefined number of colours Nc
|
||||||
Representations<AdjointRepresentation> RepresentationTypes(grid);
|
Representations<FundamentalRepresentation, AdjointRepresentation> RepresentationTypes(grid);
|
||||||
|
|
||||||
Grid_finalize();
|
Grid_finalize();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user