1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-09-21 01:25:48 +01:00
Grid/lib/qcd/action/scalar/ScalarImpl.h

107 lines
2.7 KiB
C
Raw Normal View History

2017-01-26 15:24:49 +00:00
#ifndef SCALAR_IMPL
#define SCALAR_IMPL
namespace Grid {
//namespace QCD {
template <class S>
class ScalarImplTypes {
public:
2017-01-26 15:24:49 +00:00
typedef S Simd;
2017-01-26 15:24:49 +00:00
template <typename vtype>
using iImplField = iScalar<iScalar<iScalar<vtype> > >;
2017-01-26 15:24:49 +00:00
typedef iImplField<Simd> SiteField;
2017-01-26 15:24:49 +00:00
typedef Lattice<SiteField> Field;
static inline void generate_momenta(Field& P, GridParallelRNG& pRNG) {
2017-01-26 15:24:49 +00:00
gaussian(pRNG, P);
}
2017-01-26 15:24:49 +00:00
static inline Field projectForce(Field& P){return P;}
static inline void update_field(Field& P, Field& U, double ep) {
2017-01-26 15:24:49 +00:00
U += P*ep;
}
static inline RealD FieldSquareNorm(Field& U) {
2017-01-26 15:24:49 +00:00
return (- sum(trace(U*U))/2.0);
}
2017-01-26 15:24:49 +00:00
static inline void HotConfiguration(GridParallelRNG &pRNG, Field &U) {
gaussian(pRNG, U);
}
2017-01-26 15:24:49 +00:00
static inline void TepidConfiguration(GridParallelRNG &pRNG, Field &U) {
gaussian(pRNG, U);
}
2017-01-26 15:24:49 +00:00
static inline void ColdConfiguration(GridParallelRNG &pRNG, Field &U) {
U = 1.0;
}
2017-01-26 15:24:49 +00:00
};
2017-02-09 15:18:38 +00:00
template <class S, unsigned int N>
class ScalarAdjMatrixImplTypes {
2017-02-09 15:18:38 +00:00
public:
typedef S Simd;
template <typename vtype>
using iImplField = iScalar<iScalar<iMatrix<vtype, N> > >;
2017-02-09 15:18:38 +00:00
typedef iImplField<Simd> SiteField;
2017-02-09 15:18:38 +00:00
typedef Lattice<SiteField> Field;
static inline void generate_momenta(Field& P, GridParallelRNG& pRNG) {
QCD::SU<N>::GaussianFundamentalLieAlgebraMatrix(pRNG, P);
2017-02-09 15:18:38 +00:00
}
static inline Field projectForce(Field& P) {return P;}
static inline void update_field(Field& P, Field& U, double ep) {
2017-02-09 15:18:38 +00:00
U += P*ep;
}
static inline RealD FieldSquareNorm(Field& U) {
return (TensorRemove(sum(trace(U*U))).real());
2017-02-09 15:18:38 +00:00
}
2017-02-09 15:18:38 +00:00
static inline void HotConfiguration(GridParallelRNG &pRNG, Field &U) {
QCD::SU<N>::LieRandomize(pRNG, U);
2017-02-09 15:18:38 +00:00
}
2017-02-09 15:18:38 +00:00
static inline void TepidConfiguration(GridParallelRNG &pRNG, Field &U) {
QCD::SU<N>::LieRandomize(pRNG, U, 0.01);
2017-02-09 15:18:38 +00:00
}
2017-02-09 15:18:38 +00:00
static inline void ColdConfiguration(GridParallelRNG &pRNG, Field &U) {
U = zero;
2017-02-09 15:18:38 +00:00
}
2017-02-09 15:18:38 +00:00
};
2017-01-26 15:24:49 +00:00
typedef ScalarImplTypes<vReal> ScalarImplR;
typedef ScalarImplTypes<vRealF> ScalarImplF;
typedef ScalarImplTypes<vRealD> ScalarImplD;
// Hardcoding here the size of the matrices
typedef ScalarAdjMatrixImplTypes<vComplex, QCD::Nc> ScalarAdjImplR;
typedef ScalarAdjMatrixImplTypes<vComplexF, QCD::Nc> ScalarAdjImplF;
typedef ScalarAdjMatrixImplTypes<vComplexD, QCD::Nc> ScalarAdjImplD;
template <int Colours > using ScalarNxNAdjImplR = ScalarAdjMatrixImplTypes<vComplex, Colours >;
template <int Colours > using ScalarNxNAdjImplF = ScalarAdjMatrixImplTypes<vComplexF, Colours >;
template <int Colours > using ScalarNxNAdjImplD = ScalarAdjMatrixImplTypes<vComplexD, Colours >;
//}
}
2017-01-26 15:24:49 +00:00
#endif