mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-25 13:15:55 +01:00
Merge pull request #120 from paboyle/feature/scalar-hmc-update
Scalar HMC update. I agree with the changes.
This commit is contained in:
commit
dafb351d38
@ -93,6 +93,8 @@ class ScalarImplTypes {
|
|||||||
class ScalarAdjMatrixImplTypes {
|
class ScalarAdjMatrixImplTypes {
|
||||||
public:
|
public:
|
||||||
typedef S Simd;
|
typedef S Simd;
|
||||||
|
typedef QCD::SU<N> Group;
|
||||||
|
|
||||||
template <typename vtype>
|
template <typename vtype>
|
||||||
using iImplField = iScalar<iScalar<iMatrix<vtype, N>>>;
|
using iImplField = iScalar<iScalar<iMatrix<vtype, N>>>;
|
||||||
template <typename vtype>
|
template <typename vtype>
|
||||||
@ -108,7 +110,7 @@ class ScalarImplTypes {
|
|||||||
typedef Field PropagatorField;
|
typedef Field PropagatorField;
|
||||||
|
|
||||||
static inline void generate_momenta(Field& P, GridParallelRNG& pRNG) {
|
static inline void generate_momenta(Field& P, GridParallelRNG& pRNG) {
|
||||||
QCD::SU<N>::GaussianFundamentalLieAlgebraMatrix(pRNG, P);
|
Group::GaussianFundamentalLieAlgebraMatrix(pRNG, P);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline Field projectForce(Field& P) {return P;}
|
static inline Field projectForce(Field& P) {return P;}
|
||||||
@ -122,11 +124,11 @@ class ScalarImplTypes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline void HotConfiguration(GridParallelRNG &pRNG, Field &U) {
|
static inline void HotConfiguration(GridParallelRNG &pRNG, Field &U) {
|
||||||
QCD::SU<N>::LieRandomize(pRNG, U);
|
Group::LieRandomize(pRNG, U);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void TepidConfiguration(GridParallelRNG &pRNG, Field &U) {
|
static inline void TepidConfiguration(GridParallelRNG &pRNG, Field &U) {
|
||||||
QCD::SU<N>::LieRandomize(pRNG, U, 0.01);
|
Group::LieRandomize(pRNG, U, 0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void ColdConfiguration(GridParallelRNG &pRNG, Field &U) {
|
static inline void ColdConfiguration(GridParallelRNG &pRNG, Field &U) {
|
||||||
|
@ -81,7 +81,7 @@ namespace Grid {
|
|||||||
phiStencil.HaloExchange(p, compressor);
|
phiStencil.HaloExchange(p, compressor);
|
||||||
Field action(p._grid), pshift(p._grid), phisquared(p._grid);
|
Field action(p._grid), pshift(p._grid), phisquared(p._grid);
|
||||||
phisquared = p*p;
|
phisquared = p*p;
|
||||||
action = (2.0*Ndim + mass_square)*phisquared + lambda*phisquared*phisquared;
|
action = (2.0*Ndim + mass_square)*phisquared + lambda/24.*phisquared*phisquared;
|
||||||
for (int mu = 0; mu < Ndim; mu++) {
|
for (int mu = 0; mu < Ndim; mu++) {
|
||||||
// pshift = Cshift(p, mu, +1); // not efficient, implement with stencils
|
// pshift = Cshift(p, mu, +1); // not efficient, implement with stencils
|
||||||
parallel_for (int i = 0; i < p._grid->oSites(); i++) {
|
parallel_for (int i = 0; i < p._grid->oSites(); i++) {
|
||||||
@ -98,7 +98,7 @@ namespace Grid {
|
|||||||
permute(temp2, *temp, permute_type);
|
permute(temp2, *temp, permute_type);
|
||||||
action._odata[i] -= temp2*(*t_p) + (*t_p)*temp2;
|
action._odata[i] -= temp2*(*t_p) + (*t_p)*temp2;
|
||||||
} else {
|
} else {
|
||||||
action._odata[i] -= *temp*(*t_p) + (*t_p)*(*temp);
|
action._odata[i] -= (*temp)*(*t_p) + (*t_p)*(*temp);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
action._odata[i] -= phiStencil.CommBuf()[SE->_offset]*(*t_p) + (*t_p)*phiStencil.CommBuf()[SE->_offset];
|
action._odata[i] -= phiStencil.CommBuf()[SE->_offset]*(*t_p) + (*t_p)*phiStencil.CommBuf()[SE->_offset];
|
||||||
@ -113,7 +113,7 @@ namespace Grid {
|
|||||||
|
|
||||||
virtual void deriv(const Field &p, Field &force) {
|
virtual void deriv(const Field &p, Field &force) {
|
||||||
assert(p._grid->Nd() == Ndim);
|
assert(p._grid->Nd() == Ndim);
|
||||||
force = (2.0*Ndim + mass_square)*p + 2.0*lambda*p*p*p;
|
force = (2.0*Ndim + mass_square)*p + lambda/12.*p*p*p;
|
||||||
// move this outside
|
// move this outside
|
||||||
static Stencil phiStencil(p._grid, npoint, 0, directions, displacements);
|
static Stencil phiStencil(p._grid, npoint, 0, directions, displacements);
|
||||||
phiStencil.HaloExchange(p, compressor);
|
phiStencil.HaloExchange(p, compressor);
|
||||||
|
@ -76,7 +76,7 @@ struct HMCparameters: Serializable {
|
|||||||
|
|
||||||
template < class ReaderClass >
|
template < class ReaderClass >
|
||||||
void initialize(Reader<ReaderClass> &TheReader){
|
void initialize(Reader<ReaderClass> &TheReader){
|
||||||
std::cout << "Reading HMC\n";
|
std::cout << GridLogMessage << "Reading HMC\n";
|
||||||
read(TheReader, "HMC", *this);
|
read(TheReader, "HMC", *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,6 +253,7 @@ class HMCResourceManager {
|
|||||||
template<class T, class... Types>
|
template<class T, class... Types>
|
||||||
void AddObservable(Types&&... Args){
|
void AddObservable(Types&&... Args){
|
||||||
ObservablesList.push_back(std::unique_ptr<T>(new T(std::forward<Types>(Args)...)));
|
ObservablesList.push_back(std::unique_ptr<T>(new T(std::forward<Types>(Args)...)));
|
||||||
|
ObservablesList.back()->print_parameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<HmcObservable<typename ImplementationPolicy::Field>* > GetObservables(){
|
std::vector<HmcObservable<typename ImplementationPolicy::Field>* > GetObservables(){
|
||||||
|
@ -716,8 +716,7 @@ template<typename GaugeField,typename GaugeMat>
|
|||||||
|
|
||||||
for (int a = 0; a < AdjointDimension; a++) {
|
for (int a = 0; a < AdjointDimension; a++) {
|
||||||
generator(a, Ta);
|
generator(a, Ta);
|
||||||
auto tmp = - 2.0 * (trace(timesI(Ta) * in)) * scale;// 2.0 for the normalization of the trace in the fundamental rep
|
pokeColour(h_out, - 2.0 * (trace(timesI(Ta) * in)) * scale, a);
|
||||||
pokeColour(h_out, tmp, a);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ using namespace Grid;
|
|||||||
using namespace Grid::QCD;
|
using namespace Grid::QCD;
|
||||||
|
|
||||||
template <class Impl>
|
template <class Impl>
|
||||||
class MagLogger : public HmcObservable<typename Impl::Field> {
|
class MagMeas : public HmcObservable<typename Impl::Field> {
|
||||||
public:
|
public:
|
||||||
typedef typename Impl::Field Field;
|
typedef typename Impl::Field Field;
|
||||||
typedef typename Impl::Simd::scalar_type Trace;
|
typedef typename Impl::Simd::scalar_type Trace;
|
||||||
@ -72,13 +72,13 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <class Impl>
|
template <class Impl>
|
||||||
class MagMod: public ObservableModule<MagLogger<Impl>, NoParameters>{
|
class MagMod: public ObservableModule<MagMeas<Impl>, NoParameters>{
|
||||||
typedef ObservableModule<MagLogger<Impl>, NoParameters> ObsBase;
|
typedef ObservableModule<MagMeas<Impl>, NoParameters> ObsBase;
|
||||||
using ObsBase::ObsBase; // for constructors
|
using ObsBase::ObsBase; // for constructors
|
||||||
|
|
||||||
// acquire resource
|
// acquire resource
|
||||||
virtual void initialize(){
|
virtual void initialize(){
|
||||||
this->ObservablePtr.reset(new MagLogger<Impl>());
|
this->ObservablePtr.reset(new MagMeas<Impl>());
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
MagMod(): ObsBase(NoParameters()){}
|
MagMod(): ObsBase(NoParameters()){}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user