1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-10 07:55:35 +00:00

Merge pull request #25 from LupoA/sp2n/unify_representations

Sp2n/unify representations [close #3]
This commit is contained in:
Alessandro Lupo 2023-05-21 14:55:27 +01:00 committed by GitHub
commit 3c1e5e9517
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 21 additions and 163 deletions

View File

@ -4,8 +4,6 @@
#include <Grid/qcd/representations/adjoint.h>
#include <Grid/qcd/representations/two_index.h>
#include <Grid/qcd/representations/fundamental.h>
#include <Grid/qcd/representations/spfundamental.h>
#include <Grid/qcd/representations/sp_two_index.h>
#include <Grid/qcd/representations/hmc_types.h>
#endif

View File

@ -13,7 +13,7 @@ NAMESPACE_BEGIN(Grid);
* Empty since HMC updates already the fundamental representation
*/
template <int ncolour>
template <int ncolour, class group_name>
class FundamentalRep {
public:
static const int Dimension = ncolour;
@ -21,7 +21,7 @@ public:
// typdef to be used by the Representations class in HMC to get the
// types for the higher representation fields
typedef typename SU<ncolour>::LatticeMatrix LatticeMatrix;
typedef typename GaugeGroup<ncolour,group_name>::LatticeMatrix LatticeMatrix;
typedef LatticeGaugeField LatticeField;
explicit FundamentalRep(GridBase* grid) {} //do nothing
@ -45,7 +45,8 @@ public:
typedef FundamentalRep<Nc> FundamentalRepresentation;
typedef FundamentalRep<Nc,GroupName::SU> FundamentalRepresentation;
typedef FundamentalRep<Nc,GroupName::Sp> SpFundamentalRepresentation;
NAMESPACE_END(Grid);

View File

@ -4,8 +4,6 @@
#include <Grid/qcd/representations/adjoint.h>
#include <Grid/qcd/representations/two_index.h>
#include <Grid/qcd/representations/fundamental.h>
#include <Grid/qcd/representations/spfundamental.h>
#include <Grid/qcd/representations/sp_two_index.h>
#include <Grid/qcd/action/scalar/ScalarImpl.h>
#include <tuple>

View File

@ -1,100 +0,0 @@
/*
* Policy classes for the HMC
* Authors: Guido Cossu, David Preti
*/
#ifndef SP2N2INDEX_H_H
#define SP2N2INDEX_H_H
NAMESPACE_BEGIN(Grid);
/*
* This is an helper class for the HMC
* Should contain only the data for the two index representations
* and the facility to convert from the fundamental -> two index
* The templated parameter TwoIndexSymmetry choses between the
* symmetric and antisymmetric representations
*
* There is an
* enum TwoIndexSymmetry { Symmetric = 1, AntiSymmetric = -1 };
* in the SUnTwoIndex.h file
*/
template <int ncolour, TwoIndexSymmetry S>
class SpTwoIndexRep {
public:
// typdef to be used by the Representations class in HMC to get the
// types for the higher representation fields
typedef typename Sp_TwoIndex<ncolour, S>::LatticeTwoIndexMatrix LatticeMatrix;
typedef typename Sp_TwoIndex<ncolour, S>::LatticeTwoIndexField LatticeField;
static const int Dimension = (ncolour * (ncolour + S) / 2) + S;
static const bool isFundamental = false;
//static const int nsp = Nc / 2;
LatticeField U;
explicit SpTwoIndexRep(GridBase *grid) : U(grid) {}
void update_representation(const LatticeGaugeField &Uin) {
std::cout << GridLogDebug << "Updating TwoIndex representation\n";
// Uin is in the fundamental representation
// get the U in TwoIndexRep
// (U)_{(ij)(lk)} = tr [ adj(e^(ij)) U e^(lk) transpose(U) ]
conformable(U, Uin);
U = Zero();
LatticeColourMatrix tmp(Uin.Grid());
Vector<typename Sp<ncolour>::Matrix> eij(Dimension);
for (int a = 0; a < Dimension; a++)
Sp_TwoIndex<ncolour, S>::base(a, eij[a]);
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 = transpose(Uin_mu) * adj(eij[a]) * Uin_mu;
for (int b = 0; b < Dimension; b++)
pokeColour(U_mu, trace(tmp * eij[b]), a, b);
}
pokeLorentz(U, U_mu, mu);
}
}
LatticeGaugeField RtoFundamentalProject(const LatticeField &in,
Real scale = 1.0) const {
LatticeGaugeField out(in.Grid());
out = Zero();
for (int mu = 0; mu < Nd; mu++) {
LatticeColourMatrix out_mu(in.Grid()); // fundamental representation
LatticeMatrix in_mu = peekLorentz(in, mu);
out_mu = Zero();
typename Sp<ncolour>::LatticeAlgebraVector h(in.Grid());
projectOnAlgebra(h, in_mu, double(Nc + 2 * S)); // factor T(r)/T(fund)
FundamentalLieAlgebraMatrix(h, out_mu); // apply scale only once
pokeLorentz(out, out_mu, mu); // should be 2 for sp4 as. ok
}
return out;
}
private:
void projectOnAlgebra(typename Sp<ncolour>::LatticeAlgebraVector &h_out,
const LatticeMatrix &in, Real scale = 1.0) const {
Sp_TwoIndex<ncolour, S>::projectOnAlgebra(h_out, in, scale);
}
void FundamentalLieAlgebraMatrix(
typename Sp<ncolour>::LatticeAlgebraVector &h,
typename Sp<ncolour>::LatticeMatrix &out, Real scale = 1.0) const {
Sp<ncolour>::FundamentalLieAlgebraMatrix(h, out, scale);
}
};
typedef SpTwoIndexRep<Nc, Symmetric> SpTwoIndexSymmetricRepresentation;
typedef SpTwoIndexRep<Nc, AntiSymmetric> SpTwoIndexAntiSymmetricRepresentation;
NAMESPACE_END(Grid);
#endif

View File

@ -1,42 +0,0 @@
#ifndef SPFUNDAMENTAL_H
#define SPFUNDAMENTAL_H
NAMESPACE_BEGIN(Grid);
/*
* This is an helper class for the HMC
* Empty since HMC updates already the fundamental representation
*/
template <int ncolour>
class SpFundamentalRep {
public:
static const int Dimension = ncolour;
//static const int nSp = ncolour/2;
static const bool isFundamental = true;
// typdef to be used by the Representations class in HMC to get the
// types for the higher representation fields
typedef typename Sp<ncolour>::LatticeMatrix LatticeMatrix;
typedef LatticeGaugeField LatticeField;
explicit SpFundamentalRep(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 SpFundamentalRep<Nc> SpFundamentalRepresentation;
NAMESPACE_END(Grid);
#endif

View File

@ -20,14 +20,14 @@ NAMESPACE_BEGIN(Grid);
* in the SUnTwoIndex.h file
*/
template <int ncolour, TwoIndexSymmetry S>
template <int ncolour, TwoIndexSymmetry S, class group_name>
class TwoIndexRep {
public:
// typdef to be used by the Representations class in HMC to get the
// types for the higher representation fields
typedef typename SU_TwoIndex<ncolour, S>::LatticeTwoIndexMatrix LatticeMatrix;
typedef typename SU_TwoIndex<ncolour, S>::LatticeTwoIndexField LatticeField;
static const int Dimension = ncolour * (ncolour + S) / 2;
typedef typename GaugeGroupTwoIndex<ncolour, S, group_name>::LatticeTwoIndexMatrix LatticeMatrix;
typedef typename GaugeGroupTwoIndex<ncolour, S, group_name>::LatticeTwoIndexField LatticeField;
static const int Dimension = GaugeGroupTwoIndex<ncolour,S,group_name>::Dimension;
static const bool isFundamental = false;
LatticeField U;
@ -43,10 +43,10 @@ public:
U = Zero();
LatticeColourMatrix tmp(Uin.Grid());
Vector<typename SU<ncolour>::Matrix> eij(Dimension);
Vector<typename GaugeGroup<ncolour,group_name>::Matrix> eij(Dimension);
for (int a = 0; a < Dimension; a++)
SU_TwoIndex<ncolour, S>::base(a, eij[a]);
GaugeGroupTwoIndex<ncolour, S, group_name>::base(a, eij[a]);
for (int mu = 0; mu < Nd; mu++) {
auto Uin_mu = peekLorentz(Uin, mu);
@ -71,7 +71,7 @@ public:
out_mu = Zero();
typename SU<ncolour>::LatticeAlgebraVector h(in.Grid());
typename GaugeGroup<ncolour, group_name>::LatticeAlgebraVector h(in.Grid());
projectOnAlgebra(h, in_mu, double(Nc + 2 * S)); // factor T(r)/T(fund)
FundamentalLieAlgebraMatrix(h, out_mu); // apply scale only once
pokeLorentz(out, out_mu, mu);
@ -80,20 +80,23 @@ public:
}
private:
void projectOnAlgebra(typename SU<ncolour>::LatticeAlgebraVector &h_out,
void projectOnAlgebra(typename GaugeGroup<ncolour, group_name>::LatticeAlgebraVector &h_out,
const LatticeMatrix &in, Real scale = 1.0) const {
SU_TwoIndex<ncolour, S>::projectOnAlgebra(h_out, in, scale);
GaugeGroupTwoIndex<ncolour, S,group_name>::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);
typename GaugeGroup<ncolour, group_name>::LatticeAlgebraVector &h,
typename GaugeGroup<ncolour, group_name>::LatticeMatrix &out, Real scale = 1.0) const {
GaugeGroup<ncolour,group_name>::FundamentalLieAlgebraMatrix(h, out, scale);
}
};
typedef TwoIndexRep<Nc, Symmetric> TwoIndexSymmetricRepresentation;
typedef TwoIndexRep<Nc, AntiSymmetric> TwoIndexAntiSymmetricRepresentation;
typedef TwoIndexRep<Nc, Symmetric, GroupName::SU> TwoIndexSymmetricRepresentation;
typedef TwoIndexRep<Nc, AntiSymmetric, GroupName::SU> TwoIndexAntiSymmetricRepresentation;
typedef TwoIndexRep<Nc, Symmetric, GroupName::Sp> SpTwoIndexSymmetricRepresentation;
typedef TwoIndexRep<Nc, AntiSymmetric, GroupName::Sp> SpTwoIndexAntiSymmetricRepresentation;
NAMESPACE_END(Grid);