1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-06-13 20:57:06 +01:00

Added all elements for Hirep HMC

TODO: Test and debug
This commit is contained in:
Guido Cossu
2016-07-18 12:05:23 +01:00
parent 7edf4c6c04
commit 9c77bb69a5
9 changed files with 148 additions and 79 deletions

View File

@ -1,12 +1,11 @@
/*
* Policy classes for the HMC
* Author: Guido Cossu
*/
*/
#ifndef ADJOINT_H
#define ADJOINT_H
namespace Grid {
namespace QCD {
@ -19,17 +18,16 @@ namespace QCD {
template <int ncolour>
class AdjointRep {
public:
// typdef to be used by the Representations class in HMC to get the
// types for the higher representation fields
// 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 LatticeMatrix;
typedef typename SU_Adjoint<ncolour>::LatticeAdjField LatticeField;
const int Dimension = ncolour * ncolour - 1;
static const int Dimension = ncolour * ncolour - 1;
LatticeField U;
explicit AdjointRep(GridBase* grid) : U(grid) {}
void update_representation(const LatticeGaugeField& Uin) {
explicit AdjointRep(GridBase *grid) : U(grid) {}
void update_representation(const LatticeGaugeField &Uin) {
// Uin is in the fundamental representation
// get the U in AdjointRep
// (U_adj)_B = tr[e^a U e^b U^dag]
@ -38,31 +36,59 @@ class AdjointRep {
// T_F is 1/2 for the fundamental representation
conformable(U, Uin);
U = zero;
LatticeGaugeField tmp(Uin._grid);
LatticeColourMatrix tmp(Uin._grid);
Vector<typename SU<ncolour>::Matrix> ta(ncolour * ncolour - 1);
Vector<typename SU<ncolour>::Matrix> ta(Dimension);
// 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++) {
tmp = 2.0 * adj(Uin) * ta[a] * Uin;
for (int b = 0; b < (ncolour * ncolour - 1); b++) {
auto Tr = TensorRemove(trace(tmp * ta[b]));
pokeColour(U, Tr, a, b);
for (int mu = 0; mu < Nd; mu++) {
auto Uin_mu = peekLorentz(Uin, mu);
auto U_mu = peekLorentz(U, mu);
for (int a = 0; a < Dimension; a++) {
tmp = 2.0 * adj(Uin_mu) * ta[a] * Uin_mu;
for (int b = 0; b < (ncolour * ncolour - 1); b++)
pokeColour(U_mu, trace(tmp * ta[b]), a, b);
}
}
pokeLorentz(U, U_mu, mu);
}
}
LatticeGaugeField RtoFundamentalProject(const LatticeField &in,
Real scale = 1.0) const {
LatticeGaugeField out(in._grid);
for (int mu = 0; mu < Nd; mu++) {
LatticeColourMatrix out_mu(in._grid); // fundamental representation
LatticeMatrix in_mu = peekLorentz(in, mu);
out_mu = zero;
typename SU<ncolour>::LatticeAlgebraVector h(in._grid);
projectOnAlgebra(h, in_mu, scale);
FundamentalLieAlgebraMatrix(h, out_mu, 1.0); // apply scale only once
pokeLorentz(out, out_mu, mu);
}
return out;
}
private:
void projectOnAlgebra(typename SU<ncolour>::LatticeAlgebraVector &h_out,
const LatticeMatrix &in, Real scale = 1.0) const {
SU_Adjoint<ncolour>::projectOnAlgebra(h_out, in, scale);
}
void FundamentalLieAlgebraMatrix(
typename SU<ncolour>::LatticeAlgebraVector &h,
typename SU<ncolour>::LatticeMatrix &out, Real scale = 1.0) const {
SU<ncolour>::FundamentalLieAlgebraMatrix(h, out, scale);
}
};
typedef AdjointRep<Nc> AdjointRepresentation;
typedef AdjointRep<Nc> AdjointRepresentation;
}
}
#endif

View File

@ -18,7 +18,7 @@ namespace QCD {
template <int ncolour>
class FundamentalRep {
public:
const int Dimension = ncolour;
static const int Dimension = ncolour;
// typdef to be used by the Representations class in HMC to get the
// types for the higher representation fields
@ -27,6 +27,11 @@ class FundamentalRep {
explicit FundamentalRep(GridBase* grid) {} //do nothing
void update_representation(const LatticeGaugeField& Uin) {} // do nothing
LatticeField RtoFundamentalProject(const LatticeField& in, Real scale = 1.0) const{
return (scale * in);
}
};
typedef FundamentalRep<Nc> FundamentalRepresentation;

View File

@ -28,7 +28,7 @@ class Representations {
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
// type repr_type<I>::LatticeField
Representation_type rep;