mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-12 20:27:06 +01:00
Added representations definitions for the HMC
This commit is contained in:
61
lib/qcd/representations/adjoint.h
Normal file
61
lib/qcd/representations/adjoint.h
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Policy classes for the HMC
|
||||
* Author: Guido Cossu
|
||||
*/
|
||||
|
||||
#ifndef ADJOINT_H
|
||||
#define ADJOINT_H
|
||||
|
||||
|
||||
namespace Grid {
|
||||
namespace QCD {
|
||||
|
||||
/*
|
||||
* This is an helper class for the HMC
|
||||
* Should contain only the data for the adjoint representation
|
||||
* and the facility to convert from the fundamental -> adjoint
|
||||
*/
|
||||
|
||||
template <int ncolour>
|
||||
class AdjointRep {
|
||||
public:
|
||||
typename SU_Adjoint<ncolour>::LatticeAdjMatrix U;
|
||||
const int Dimension = ncolour * ncolour - 1;
|
||||
|
||||
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]
|
||||
// e^a = t^a/sqrt(T_F)
|
||||
// where t^a is the generator in the fundamental
|
||||
// T_F is 1/2 for the fundamental representation
|
||||
conformable(U, Uin);
|
||||
U = zero;
|
||||
LatticeGaugeField tmp(Uin._grid);
|
||||
|
||||
Vector<typename SU<ncolour>::Matrix > ta(ncolour * ncolour - 1);
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
typedef AdjointRep<Nc> AdjointRepresentation;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
46
lib/qcd/representations/hmc_types.h
Normal file
46
lib/qcd/representations/hmc_types.h
Normal file
@ -0,0 +1,46 @@
|
||||
#ifndef HMC_TYPES_H
|
||||
#define HMC_TYPES_H
|
||||
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
#include <qcd/representations/adjoint.h>
|
||||
|
||||
namespace Grid {
|
||||
namespace QCD {
|
||||
|
||||
// Utility to add support for representations other than the fundamental
|
||||
|
||||
template<class... Reptypes>
|
||||
class Representations{
|
||||
public:
|
||||
typedef std::tuple<Reptypes...> Representation_type;
|
||||
Representation_type rep;
|
||||
|
||||
// Multiple types constructor
|
||||
explicit Representations(GridBase *grid):rep(Reptypes(grid)...){};
|
||||
|
||||
int size(){
|
||||
return std::tuple_size< Representation_type >::value;
|
||||
}
|
||||
|
||||
// update the fields
|
||||
template <std::size_t I = 0>
|
||||
inline typename std::enable_if< I == sizeof...(Reptypes), void >::type update(LatticeGaugeField& U) {}
|
||||
|
||||
template <std::size_t I = 0>
|
||||
inline typename std::enable_if <
|
||||
I<sizeof...(Reptypes), void >::type update(LatticeGaugeField& U) {
|
||||
std::get<I>(rep).update_representation(U);
|
||||
update<I + 1>(U);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user