Added support for the Two index Symmetric and Antisymmetric representations

Tested for HMC convergence: OK
Added also a test file showing an example for mixed representations
This commit is contained in:
Guido Cossu committed 2016-09-22 14:17:37 +01:00
1 parent fda408ee6f
commit b6597b74e7
13 files changed
+850 -174

No files matched your search

+1 -1
View File
@@ -1,3 +1,3 @@
HFILES=./tensors/Tensor_extract_merge.h ./tensors/Tensor_exp.h ./tensors/Tensor_index.h ./tensors/Tensor_arith_add.h ./tensors/Tensor_determinant.h ./tensors/Tensor_outer.h ./tensors/Tensor_trace.h ./tensors/Tensor_arith_mac.h ./tensors/Tensor_logical.h ./tensors/Tensor_reality.h ./tensors/Tensor_arith_sub.h ./tensors/Tensor_Ta.h ./tensors/Tensor_class.h ./tensors/Tensor_inner.h ./tensors/Tensor_arith_mul.h ./tensors/Tensor_transpose.h ./tensors/Tensor_arith.h ./tensors/Tensor_unary.h ./tensors/Tensor_arith_scalar.h ./tensors/Tensor_traits.h ./stencil/Lebesgue.h ./PerfCount.h ./FFT.h ./Communicator.h ./simd/Grid_vector_types.h ./simd/Grid_qpx.h ./simd/Grid_imci.h ./simd/Grid_avx.h ./simd/Intel512single.h ./simd/Grid_vector_unops.h ./simd/Grid_neon.h ./simd/Intel512common.h ./simd/Intel512wilson.h ./simd/Intel512imci.h ./simd/Intel512double.h ./simd/Grid_generic.h ./simd/Grid_avx512.h ./simd/Grid_sse4.h ./simd/Intel512avx.h ./Threads.h ./Timer.h ./algorithms/approx/bigfloat_double.h ./algorithms/approx/bigfloat.h ./algorithms/approx/Chebyshev.h ./algorithms/approx/Remez.h ./algorithms/approx/Zolotarev.h ./algorithms/approx/MultiShiftFunction.h ./algorithms/SparseMatrix.h ./algorithms/LinearOperator.h ./algorithms/Preconditioner.h ./algorithms/CoarsenedMatrix.h ./algorithms/iterative/AdefGeneric.h ./algorithms/iterative/ImplicitlyRestartedLanczos.h ./algorithms/iterative/ConjugateGradientMultiShift.h ./algorithms/iterative/DenseMatrix.h ./algorithms/iterative/ConjugateResidual.h ./algorithms/iterative/EigenSort.h ./algorithms/iterative/MatrixUtils.h ./algorithms/iterative/ConjugateGradientMixedPrec.h ./algorithms/iterative/PrecGeneralisedConjugateResidual.h ./algorithms/iterative/NormalEquations.h ./algorithms/iterative/Francis.h ./algorithms/iterative/SchurRedBlack.h ./algorithms/iterative/ConjugateGradient.h ./algorithms/iterative/Householder.h ./algorithms/iterative/PrecConjugateResidual.h ./algorithms/iterative/Matrix.h ./Algorithms.h ./fftw/fftw3.h ./lattice/Lattice_base.h ./lattice/Lattice_overload.h ./lattice/Lattice_ET.h ./lattice/Lattice_comparison_utils.h ./lattice/Lattice_trace.h ./lattice/Lattice_coordinate.h ./lattice/Lattice_arith.h ./lattice/Lattice_peekpoke.h ./lattice/Lattice_local.h ./lattice/Lattice_rng.h ./lattice/Lattice_comparison.h ./lattice/Lattice_reality.h ./lattice/Lattice_transpose.h ./lattice/Lattice_transfer.h ./lattice/Lattice_conformable.h ./lattice/Lattice_unary.h ./lattice/Lattice_where.h ./lattice/Lattice_reduction.h ./Cartesian.h ./Simd.h ./Init.h ./serialisation/TextIO.h ./serialisation/Serialisation.h ./serialisation/MacroMagic.h ./serialisation/BaseIO.h ./serialisation/XmlIO.h ./serialisation/BinaryIO.h ./communicator/Communicator_base.h ./Log.h ./Lattice.h ./cshift/Cshift_mpi.h ./cshift/Cshift_none.h ./cshift/Cshift_common.h ./Lexicographic.h ./Tensors.h ./Cshift.h ./parallelIO/NerscIO.h ./parallelIO/BinaryIO.h ./qcd/smearing/BaseSmearing.h ./qcd/smearing/GaugeConfiguration.h ./qcd/smearing/StoutSmearing.h ./qcd/smearing/APEsmearing.h ./qcd/smearing/Smearing.h ./qcd/hmc/HmcRunner.h ./qcd/hmc/NerscCheckpointer.h ./qcd/hmc/integrators/Integrator.h ./qcd/hmc/integrators/Integrator_algorithm.h ./qcd/hmc/HMC.h ./qcd/action/fermion/OverlapWilsonCayleyZolotarevFermion.h ./qcd/action/fermion/OverlapWilsonContfracZolotarevFermion.h ./qcd/action/fermion/WilsonFermion5D.h ./qcd/action/fermion/MobiusFermion.h ./qcd/action/fermion/MobiusZolotarevFermion.h ./qcd/action/fermion/OverlapWilsonPartialFractionZolotarevFermion.h ./qcd/action/fermion/DomainWallFermion.h ./qcd/action/fermion/ZMobiusFermion.h ./qcd/action/fermion/WilsonFermion.h ./qcd/action/fermion/OverlapWilsonCayleyTanhFermion.h ./qcd/action/fermion/FermionOperatorImpl.h ./qcd/action/fermion/g5HermitianLinop.h ./qcd/action/fermion/ContinuedFractionFermion5D.h ./qcd/action/fermion/WilsonTMFermion.h ./qcd/action/fermion/FermionOperator.h ./qcd/action/fermion/OverlapWilsonContfracTanhFermion.h ./qcd/action/fermion/PartialFractionFermion5D.h ./qcd/action/fermion/CayleyFermion5D.h ./qcd/action/fermion/OverlapWilsonPartialFractionTanhFermion.h ./qcd/action/fermion/ScaledShamirFermion.h ./qcd/action/fermion/ShamirZolotarevFermion.h ./qcd/action/fermion/WilsonKernels.h ./qcd/action/fermion/WilsonCompressor.h ./qcd/action/fermion/WilsonKernelsAsmBody.h ./qcd/action/ActionParams.h ./qcd/action/Actions.h ./qcd/action/pseudofermion/OneFlavourRationalRatio.h ./qcd/action/pseudofermion/OneFlavourEvenOddRational.h ./qcd/action/pseudofermion/TwoFlavourEvenOdd.h ./qcd/action/pseudofermion/OneFlavourEvenOddRationalRatio.h ./qcd/action/pseudofermion/TwoFlavourRatio.h ./qcd/action/pseudofermion/EvenOddSchurDifferentiable.h ./qcd/action/pseudofermion/TwoFlavour.h ./qcd/action/pseudofermion/TwoFlavourEvenOddRatio.h ./qcd/action/pseudofermion/OneFlavourRational.h ./qcd/action/gauge/WilsonGaugeAction.h ./qcd/action/gauge/PlaqPlusRectangleAction.h ./qcd/action/gauge/GaugeImpl.h ./qcd/action/ActionBase.h ./qcd/QCD.h ./qcd/spin/TwoSpinor.h ./qcd/spLine truncated
HFILES=./tensors/Tensor_extract_merge.h ./tensors/Tensor_exp.h ./tensors/Tensor_index.h ./tensors/Tensor_arith_add.h ./tensors/Tensor_determinant.h ./tensors/Tensor_outer.h ./tensors/Tensor_trace.h ./tensors/Tensor_arith_mac.h ./tensors/Tensor_logical.h ./tensors/Tensor_reality.h ./tensors/Tensor_arith_sub.h ./tensors/Tensor_Ta.h ./tensors/Tensor_class.h ./tensors/Tensor_inner.h ./tensors/Tensor_arith_mul.h ./tensors/Tensor_transpose.h ./tensors/Tensor_arith.h ./tensors/Tensor_unary.h ./tensors/Tensor_arith_scalar.h ./tensors/Tensor_traits.h ./stencil/Lebesgue.h ./PerfCount.h ./FFT.h ./Communicator.h ./simd/Grid_vector_types.h ./simd/Grid_qpx.h ./simd/Grid_imci.h ./simd/Grid_avx.h ./simd/Intel512single.h ./simd/Grid_vector_unops.h ./simd/Grid_neon.h ./simd/Intel512common.h ./simd/Intel512wilson.h ./simd/Intel512imci.h ./simd/Intel512double.h ./simd/Grid_generic.h ./simd/Grid_avx512.h ./simd/Grid_sse4.h ./simd/Intel512avx.h ./Threads.h ./Timer.h ./algorithms/approx/bigfloat_double.h ./algorithms/approx/bigfloat.h ./algorithms/approx/Chebyshev.h ./algorithms/approx/Remez.h ./algorithms/approx/Zolotarev.h ./algorithms/approx/MultiShiftFunction.h ./algorithms/SparseMatrix.h ./algorithms/LinearOperator.h ./algorithms/Preconditioner.h ./algorithms/CoarsenedMatrix.h ./algorithms/iterative/AdefGeneric.h ./algorithms/iterative/ImplicitlyRestartedLanczos.h ./algorithms/iterative/ConjugateGradientMultiShift.h ./algorithms/iterative/DenseMatrix.h ./algorithms/iterative/ConjugateResidual.h ./algorithms/iterative/EigenSort.h ./algorithms/iterative/MatrixUtils.h ./algorithms/iterative/ConjugateGradientMixedPrec.h ./algorithms/iterative/PrecGeneralisedConjugateResidual.h ./algorithms/iterative/NormalEquations.h ./algorithms/iterative/Francis.h ./algorithms/iterative/SchurRedBlack.h ./algorithms/iterative/ConjugateGradient.h ./algorithms/iterative/Householder.h ./algorithms/iterative/PrecConjugateResidual.h ./algorithms/iterative/Matrix.h ./Algorithms.h ./fftw/fftw3.h ./lattice/Lattice_base.h ./lattice/Lattice_overload.h ./lattice/Lattice_ET.h ./lattice/Lattice_comparison_utils.h ./lattice/Lattice_trace.h ./lattice/Lattice_coordinate.h ./lattice/Lattice_arith.h ./lattice/Lattice_peekpoke.h ./lattice/Lattice_local.h ./lattice/Lattice_rng.h ./lattice/Lattice_comparison.h ./lattice/Lattice_reality.h ./lattice/Lattice_transpose.h ./lattice/Lattice_transfer.h ./lattice/Lattice_conformable.h ./lattice/Lattice_unary.h ./lattice/Lattice_where.h ./lattice/Lattice_reduction.h ./Cartesian.h ./Simd.h ./Init.h ./serialisation/TextIO.h ./serialisation/Serialisation.h ./serialisation/MacroMagic.h ./serialisation/BaseIO.h ./serialisation/XmlIO.h ./serialisation/BinaryIO.h ./communicator/Communicator_base.h ./Log.h ./Lattice.h ./cshift/Cshift_mpi.h ./cshift/Cshift_none.h ./cshift/Cshift_common.h ./Lexicographic.h ./Tensors.h ./Cshift.h ./parallelIO/NerscIO.h ./parallelIO/BinaryIO.h ./qcd/smearing/BaseSmearing.h ./qcd/smearing/GaugeConfiguration.h ./qcd/smearing/StoutSmearing.h ./qcd/smearing/APEsmearing.h ./qcd/smearing/Smearing.h ./qcd/hmc/HmcRunner.h ./qcd/hmc/NerscCheckpointer.h ./qcd/hmc/integrators/Integrator.h ./qcd/hmc/integrators/Integrator_algorithm.h ./qcd/hmc/HMC.h ./qcd/action/fermion/OverlapWilsonCayleyZolotarevFermion.h ./qcd/action/fermion/OverlapWilsonContfracZolotarevFermion.h ./qcd/action/fermion/WilsonFermion5D.h ./qcd/action/fermion/MobiusFermion.h ./qcd/action/fermion/MobiusZolotarevFermion.h ./qcd/action/fermion/OverlapWilsonPartialFractionZolotarevFermion.h ./qcd/action/fermion/DomainWallFermion.h ./qcd/action/fermion/ZMobiusFermion.h ./qcd/action/fermion/WilsonFermion.h ./qcd/action/fermion/OverlapWilsonCayleyTanhFermion.h ./qcd/action/fermion/FermionOperatorImpl.h ./qcd/action/fermion/g5HermitianLinop.h ./qcd/action/fermion/ContinuedFractionFermion5D.h ./qcd/action/fermion/WilsonTMFermion.h ./qcd/action/fermion/FermionOperator.h ./qcd/action/fermion/OverlapWilsonContfracTanhFermion.h ./qcd/action/fermion/PartialFractionFermion5D.h ./qcd/action/fermion/CayleyFermion5D.h ./qcd/action/fermion/OverlapWilsonPartialFractionTanhFermion.h ./qcd/action/fermion/ScaledShamirFermion.h ./qcd/action/fermion/ShamirZolotarevFermion.h ./qcd/action/fermion/WilsonKernels.h ./qcd/action/fermion/WilsonCompressor.h ./qcd/action/fermion/WilsonKernelsAsmBody.h ./qcd/action/ActionParams.h ./qcd/action/Actions.h ./qcd/action/pseudofermion/OneFlavourRationalRatio.h ./qcd/action/pseudofermion/OneFlavourEvenOddRational.h ./qcd/action/pseudofermion/TwoFlavourEvenOdd.h ./qcd/action/pseudofermion/OneFlavourEvenOddRationalRatio.h ./qcd/action/pseudofermion/TwoFlavourRatio.h ./qcd/action/pseudofermion/EvenOddSchurDifferentiable.h ./qcd/action/pseudofermion/TwoFlavour.h ./qcd/action/pseudofermion/TwoFlavourEvenOddRatio.h ./qcd/action/pseudofermion/OneFlavourRational.h ./qcd/action/gauge/WilsonGaugeAction.h ./qcd/action/gauge/PlaqPlusRectangleAction.h ./qcd/action/gauge/GaugeImpl.h ./qcd/action/ActionBase.h ./qcd/QCD.h ./qcd/spin/TwoSpinor.h ./qcd/spLine truncated
CCFILES=./stencil/Stencil_common.cc ./stencil/Lebesgue.cc ./algorithms/approx/MultiShiftFunction.cc ./algorithms/approx/Remez.cc ./algorithms/approx/Zolotarev.cc ./PerfCount.cc ./serialisation/BinaryIO.cc ./serialisation/XmlIO.cc ./serialisation/TextIO.cc ./qcd/hmc/HMC.cc ./qcd/action/fermion/CayleyFermion5D.cc ./qcd/action/fermion/ContinuedFractionFermion5D.cc ./qcd/action/fermion/CayleyFermion5Ddense.cc ./qcd/action/fermion/WilsonKernelsHand.cc ./qcd/action/fermion/WilsonTMFermion.cc ./qcd/action/fermion/WilsonFermion.cc ./qcd/action/fermion/CayleyFermion5Dcache.cc ./qcd/action/fermion/WilsonKernelsAsm.cc ./qcd/action/fermion/CayleyFermion5Dssp.cc ./qcd/action/fermion/WilsonKernels.cc ./qcd/action/fermion/WilsonFermion5D.cc ./qcd/action/fermion/PartialFractionFermion5D.cc ./qcd/action/fermion/CayleyFermion5Dvec.cc ./qcd/spin/Dirac.cc ./qcd/utils/SpaceTimeGrid.cc ./Init.cc ./pugixml/pugixml.cc ./Log.cc
+5 -4
View File
@@ -45,7 +45,7 @@ namespace QCD {
static const int Zm = 6;
static const int Tm = 7;
static const int Nc=3;
static const int Nc=2;
static const int Ns=4;
static const int Nd=4;
static const int Nhs=2; // half spinor
@@ -499,12 +499,13 @@ namespace QCD {
#include <Grid/qcd/spin/TwoSpinor.h>
#include <Grid/qcd/utils/LinalgUtils.h>
#include <Grid/qcd/utils/CovariantCshift.h>
// Include representations
#include <Grid/qcd/utils/SUn.h>
#include <Grid/qcd/utils/SUnAdjoint.h>
#include <Grid/qcd/utils/SUnTwoIndex.h>
#include <Grid/qcd/representations/hmc_types.h>
#include <Grid/qcd/action/Actions.h>
#include <Grid/qcd/smearing/Smearing.h>
+8
View File
@@ -120,6 +120,10 @@ typedef SymanzikGaugeAction<ConjugateGimplD> ConjugateSymanzikGaugeAction
template class A<WilsonAdjImplF>; \
template class A<WilsonAdjImplD>;
#define TwoIndexFermOpTemplateInstantiate(A) \
template class A<WilsonTwoIndexSymmetricImplF>; \
template class A<WilsonTwoIndexSymmetricImplD>;
#define FermOp5dVecTemplateInstantiate(A) \
template class A<DomainWallVec5dImplF>; \
template class A<DomainWallVec5dImplD>; \
@@ -180,6 +184,10 @@ typedef WilsonFermion<WilsonAdjImplR> WilsonAdjFermionR;
typedef WilsonFermion<WilsonAdjImplF> WilsonAdjFermionF;
typedef WilsonFermion<WilsonAdjImplD> WilsonAdjFermionD;
typedef WilsonFermion<WilsonTwoIndexSymmetricImplR> WilsonTwoIndexSymmetricFermionR;
typedef WilsonFermion<WilsonTwoIndexSymmetricImplF> WilsonTwoIndexSymmetricFermionF;
typedef WilsonFermion<WilsonTwoIndexSymmetricImplD> WilsonTwoIndexSymmetricFermionD;
typedef WilsonTMFermion<WilsonImplR> WilsonTMFermionR;
typedef WilsonTMFermion<WilsonImplF> WilsonTMFermionF;
typedef WilsonTMFermion<WilsonImplD> WilsonTMFermionD;
+5 -1
View File
@@ -522,7 +522,11 @@ namespace Grid {
typedef WilsonImpl<vComplex, AdjointRepresentation > WilsonAdjImplR; // Real.. whichever prec
typedef WilsonImpl<vComplexF, AdjointRepresentation > WilsonAdjImplF; // Float
typedef WilsonImpl<vComplexD, AdjointRepresentation > WilsonAdjImplD; // Double
typedef WilsonImpl<vComplex, TwoIndexSymmetricRepresentation > WilsonTwoIndexSymmetricImplR; // Real.. whichever prec
typedef WilsonImpl<vComplexF, TwoIndexSymmetricRepresentation > WilsonTwoIndexSymmetricImplF; // Float
typedef WilsonImpl<vComplexD, TwoIndexSymmetricRepresentation > WilsonTwoIndexSymmetricImplD; // Double
typedef DomainWallVec5dImpl<vComplex ,Nc> DomainWallVec5dImplR; // Real.. whichever prec
typedef DomainWallVec5dImpl<vComplexF,Nc> DomainWallVec5dImplF; // Float
typedef DomainWallVec5dImpl<vComplexD,Nc> DomainWallVec5dImplD; // Double
+1
View File
@@ -309,6 +309,7 @@ void WilsonFermion<Impl>::DhopInternal(StencilImpl &st, LebesgueOrder &lo,
FermOpTemplateInstantiate(WilsonFermion);
AdjointFermOpTemplateInstantiate(WilsonFermion);
TwoIndexFermOpTemplateInstantiate(WilsonFermion);
GparityFermOpTemplateInstantiate(WilsonFermion);
}
}
+1
View File
@@ -526,6 +526,7 @@ void WilsonKernels<Impl>::DiracOptDhopDir(
FermOpTemplateInstantiate(WilsonKernels);
AdjointFermOpTemplateInstantiate(WilsonKernels);
TwoIndexFermOpTemplateInstantiate(WilsonKernels);
}}
+1
View File
@@ -2,6 +2,7 @@
#define HMC_TYPES_H
#include <Grid/qcd/representations/adjoint.h>
#include <Grid/qcd/representations/two_index.h>
#include <Grid/qcd/representations/fundamental.h>
#include <tuple>
#include <utility>
@@ -1,53 +1,62 @@
/*
* Policy classes for the HMC
* Author: Guido Cossu
* Authors: Guido Cossu, David Preti
*/
#ifndef ADJOINT_H
#define ADJOINT_H
#ifndef SUN2INDEX_H_H
#define SUN2INDEX_H_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
*/
* 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 TwoIndexSymmetricRep {
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;
typedef typename SU_TwoIndex<ncolour, S>::LatticeTwoIndexMatrix LatticeMatrix;
typedef typename SU_TwoIndex<ncolour, S>::LatticeTwoIndexField LatticeField;
static const int Dimension = ncolour * (ncolour + S) / 2;
LatticeField U;
explicit TwoIndexSymmetricRep(GridBase *grid) : U(grid) {}
explicit TwoIndexRep(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 AdjointRep
// (U)(ij)_(lk) =
// e^a =
// 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 SU<ncolour>::Matrix> ta(Dimension);
Vector<typename SU<ncolour>::Matrix> eij(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++)
SU_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);
}
}
@@ -63,8 +72,8 @@ class TwoIndexSymmetricRep {
out_mu = zero;
typename SU<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
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);
}
return out;
@@ -73,7 +82,7 @@ class TwoIndexSymmetricRep {
private:
void projectOnAlgebra(typename SU<ncolour>::LatticeAlgebraVector &h_out,
const LatticeMatrix &in, Real scale = 1.0) const {
SU_TwoIndex<ncolour,S>::projectOnAlgebra(h_out, in, scale);
SU_TwoIndex<ncolour, S>::projectOnAlgebra(h_out, in, scale);
}
void FundamentalLieAlgebraMatrix(
@@ -83,9 +92,8 @@ class TwoIndexSymmetricRep {
}
};
typedef TwoIndexRep< Nc, Symmetric > TwoIndexSymmetricRepresentation;
typedef TwoIndexRep< Nc, AntiSymmetric > TwoIndexAntiSymmetricRepresentation;
typedef TwoIndexRep<Nc, Symmetric> TwoIndexSymmetricRepresentation;
typedef TwoIndexRep<Nc, AntiSymmetric> TwoIndexAntiSymmetricRepresentation;
}
}
#endif
+242 -130
View File
@@ -1,11 +1,8 @@
#ifndef QCD_UTIL_SUNADJOINT_H
#define QCD_UTIL_SUNADJOINT_H
////////////////////////////////////////////////////////////////////////
//
// * Two index representation generators
//
// * Normalisation for the fundamental generators:
// * Normalisation for the fundamental generators:
// trace ta tb = 1/2 delta_ab = T_F delta_ab
// T_F = 1/2 for SU(N) groups
//
@@ -17,147 +14,262 @@
//
// Then the generators are written as
//
// (iT^(ij))_lk = i
// (iT_a)^(ij)(lk) = i * ( tr[e^(ij)^dag e^(lk) T^trasp_a] +
// tr[e^(lk)e^(ij)^dag T_a] ) //
//
//
////////////////////////////////////////////////////////////////////////
// Authors: David Preti, Guido Cossu
#ifndef QCD_UTIL_SUN2INDEX_H
#define QCD_UTIL_SUN2INDEX_H
namespace Grid {
namespace QCD {
namespace QCD {
enum TwoIndexSymmetry {Symmetric = 1, AntiSymmetric = -1};
template <int ncolour, TwoIndexSymmetry S>
class SU_TwoIndex : public SU<ncolour> {
public:
static const int Dimension = ncolour * (ncolour + S) / 2;
template <typename vtype>
using iSUnTwoIndexMatrix =
iScalar<iScalar<iMatrix<vtype, Dimension > > >;
typedef iSUnTwoIndexMatrix<Complex> TIMatrix;
typedef iSUnTwoIndexMatrix<ComplexF> TIMatrixF;
typedef iSUnTwoIndexMatrix<ComplexD> TIMatrixD;
typedef iSUnTwoIndexMatrix<vComplex> vTIMatrix;
typedef iSUnTwoIndexMatrix<vComplexF> vTIMatrixF;
typedef iSUnTwoIndexMatrix<vComplexD> vTIMatrixD;
typedef Lattice<vAMatrix> LatticeTwoIndexMatrix;
typedef Lattice<vAMatrixF> LatticeTwoIndexMatrixF;
typedef Lattice<vAMatrixD> LatticeTwoIndexMatrixD;
typedef Lattice<iVector<iScalar<iMatrix<vComplex, Dimension> >, Nd> >
enum TwoIndexSymmetry { Symmetric = 1, AntiSymmetric = -1 };
inline Real delta(int a, int b) { return (a == b) ? 1.0 : 0.0; }
template <int ncolour, TwoIndexSymmetry S>
class SU_TwoIndex : public SU<ncolour> {
public:
static const int Dimension = ncolour * (ncolour + S) / 2;
static const int NumGenerators = SU<ncolour>::AdjointDimension;
template <typename vtype>
using iSUnTwoIndexMatrix = iScalar<iScalar<iMatrix<vtype, Dimension> > >;
typedef iSUnTwoIndexMatrix<Complex> TIMatrix;
typedef iSUnTwoIndexMatrix<ComplexF> TIMatrixF;
typedef iSUnTwoIndexMatrix<ComplexD> TIMatrixD;
typedef iSUnTwoIndexMatrix<vComplex> vTIMatrix;
typedef iSUnTwoIndexMatrix<vComplexF> vTIMatrixF;
typedef iSUnTwoIndexMatrix<vComplexD> vTIMatrixD;
typedef Lattice<vTIMatrix> LatticeTwoIndexMatrix;
typedef Lattice<vTIMatrixF> LatticeTwoIndexMatrixF;
typedef Lattice<vTIMatrixD> LatticeTwoIndexMatrixD;
typedef Lattice<iVector<iScalar<iMatrix<vComplex, Dimension> >, Nd> >
LatticeTwoIndexField;
typedef Lattice<iVector<iScalar<iMatrix<vComplexF, Dimension> >, Nd> >
typedef Lattice<iVector<iScalar<iMatrix<vComplexF, Dimension> >, Nd> >
LatticeTwoIndexFieldF;
typedef Lattice<iVector<iScalar<iMatrix<vComplexD, Dimension> >, Nd> >
typedef Lattice<iVector<iScalar<iMatrix<vComplexD, Dimension> >, Nd> >
LatticeTwoIndexFieldD;
template <typename vtype>
using iSUnMatrix = iScalar<iScalar<iMatrix<vtype, ncolour> > >;
template <class cplx>
static void generator(int Index, iSUnTwoIndexMatrix<cplx> &iTwoIdxTa) {
// returns i(T)^(ij) necessary for the projectors
// see definitions above
iTwoIdxTa = zero;
Vector<typename SU<ncolour>::template iSUnMatrix<cplx> > tij(Dimension);
typename SU<ncolour>::template iSUnMatrix<cplx> tmp;
typedef iSUnMatrix<Complex> Matrix;
typedef iSUnMatrix<ComplexF> MatrixF;
typedef iSUnMatrix<ComplexD> MatrixD;
template <class cplx>
static void base(int Index, iSUnMatrix<cplx> &eij) {
// returns (e)^(ij)_{kl} necessary for change of base U_F -> U_R
assert(Index < NumGenerators);
eij = zero;
for (int a = 0; a < Dimension; a++) {
}
// for the linearisation of the 2 indexes
static int a[ncolour * (ncolour - 1) / 2][2]; // store the a <-> i,j
static bool filled = false;
if (!filled) {
int counter = 0;
for (int i = 1; i < ncolour; i++) {
for (int j = 0; j < i; j++) {
a[counter++][0] = i;
a[counter++][1] = j;
}
}
filled = true;
}
static void printGenerators(void) {
for (int gen = 0; gen < Dimension; gen++) {
AMatrix ta;
generator(gen, ta);
std::cout << GridLogMessage << "Nc = " << ncolour << " t_" << gen
<< std::endl;
std::cout << GridLogMessage << ta << std::endl;
}
}
static void testGenerators(void) {
TIMatrix TwoIndexTa;
}
static void TwoIndexLieAlgebraMatrix(const typename SU<ncolour>::LatticeAlgebraVector &h,
LatticeTwoIndexMatrix &out, Real scale = 1.0) {
conformable(h, out);
GridBase *grid = out._grid;
LatticeAdjMatrix la(grid);
TIMatrix iTa;
out = zero;
for (int a = 0; a < Dimension; a++) {
generator(a, iTa);
la = peekColour(h, a) * iTa;
out += la;
}
out *= scale;
}
// Projects the algebra components a lattice matrix (of dimension ncol*ncol -1 )
static void projectOnAlgebra(typename SU<ncolour>::LatticeAlgebraVector &h_out, const LatticeTwoIndexMatrix &in, Real scale = 1.0) {
conformable(h_out, in);
h_out = zero;
TIMatrix iTa;
Real coefficient = - 2.0/(ncolour + 2*S) * scale;// 2/(Nc +/- 2) for the normalization of the trace in the two index rep
for (int a = 0; a < Dimension; a++) {
generator(a, iTa);
auto tmp = real(trace(iTa * in)) * coefficient;
pokeColour(h_out, tmp, a);
}
}
// a projector that keeps the generators stored to avoid the overhead of recomputing them
static void projector(typename SU<ncolour>::LatticeAlgebraVector &h_out, const LatticeTwoIndexMatrix &in, Real scale = 1.0) {
conformable(h_out, in);
static std::vector<TIMatrix> iTa(Dimension); // to store the generators
h_out = zero;
static bool precalculated = false;
if (!precalculated){
precalculated = true;
for (int a = 0; a < Dimension; a++) generator(a, iTa[a]);
}
Real coefficient = - 2.0/(ncolour + 2*S) * scale; // 2/(Nc +/- 2) for the normalization of the trace in the two index rep
for (int a = 0; a < Dimension; a++) {
auto tmp = real(trace(iTa[a] * in)) * coefficient;
pokeColour(h_out, tmp, a);
}
}
};
// Some useful type names
typedef SU_TwoIndex<2, Symmetric> SU2TwoIndexSymm;
typedef SU_TwoIndex<3, Symmetric> SU3TwoIndexSymm;
typedef SU_TwoIndex<4, Symmetric> SU4TwoIndexSymm;
typedef SU_TwoIndex<5, Symmetric> SU5TwoIndexSymm;
typedef SU_TwoIndex<Nc, Symmetric> TwoIndexSymmMatrices;
typedef SU_TwoIndex<2, AntiSymmetric> SU2TwoIndexAntiSymm;
typedef SU_TwoIndex<3, AntiSymmetric> SU3TwoIndexAntiSymm;
typedef SU_TwoIndex<4, AntiSymmetric> SU4TwoIndexAntiSymm;
typedef SU_TwoIndex<5, AntiSymmetric> SU5TwoIndexAntiSymm;
typedef SU_TwoIndex<Nc, AntiSymmetric> TwoIndexAntiSymmMatrices;
if (Index < ncolour * (ncolour - 1) / 2) {
baseOffDiagonal(a[Index][0], a[Index][1], eij);
} else {
baseDiagonal(Index, eij);
}
}
template <class cplx>
static void baseDiagonal(int Index, iSUnMatrix<cplx> &eij) {
eij = zero;
eij()()(Index - ncolour * (ncolour - 1) / 2,
Index - ncolour * (ncolour - 1) / 2) = 1.0;
}
template <class cplx>
static void baseOffDiagonal(int i, int j, iSUnMatrix<cplx> &eij) {
eij = zero;
for (int k = 0; k < ncolour; k++)
for (int l = 0; l < ncolour; l++)
eij()()(l, k) = delta(i, k) * delta(j, l) +
S * delta(j, k) * delta(i, l);
RealD nrm = 1. / std::sqrt(2.0);
eij = eij * nrm;
}
static void printBase(void) {
for (int gen = 0; gen < Dimension; gen++) {
Matrix tmp;
base(gen, tmp);
std::cout << GridLogMessage << "Nc = " << ncolour << " t_" << gen
<< std::endl;
std::cout << GridLogMessage << tmp << std::endl;
}
}
template <class cplx>
static void generator(int Index, iSUnTwoIndexMatrix<cplx> &i2indTa) {
Vector<typename SU<ncolour>::template iSUnMatrix<cplx> > ta(
ncolour * ncolour - 1);
Vector<typename SU<ncolour>::template iSUnMatrix<cplx> > eij(Dimension);
typename SU<ncolour>::template iSUnMatrix<cplx> tmp;
i2indTa = zero;
for (int a = 0; a < ncolour * ncolour - 1; a++)
SU<ncolour>::generator(a, ta[a]);
for (int a = 0; a < Dimension; a++) base(a, eij[a]);
for (int a = 0; a < Dimension; a++) {
tmp = transpose(ta[Index]) * adj(eij[a]) + adj(eij[a]) * ta[Index];
for (int b = 0; b < Dimension; b++) {
typename SU<ncolour>::template iSUnMatrix<cplx> tmp1 =
tmp * eij[b];
Complex iTr = TensorRemove(timesI(trace(tmp1)));
i2indTa()()(a, b) = iTr;
}
}
}
static void printGenerators(void) {
for (int gen = 0; gen < ncolour * ncolour - 1; gen++) {
TIMatrix i2indTa;
generator(gen, i2indTa);
std::cout << GridLogMessage << "Nc = " << ncolour << " t_" << gen
<< std::endl;
std::cout << GridLogMessage << i2indTa << std::endl;
}
}
static void testGenerators(void) {
TIMatrix i2indTa, i2indTb;
std::cout << GridLogMessage << "2IndexRep - Checking if traceless"
<< std::endl;
for (int a = 0; a < ncolour * ncolour - 1; a++) {
generator(a, i2indTa);
std::cout << GridLogMessage << a << std::endl;
assert(norm2(trace(i2indTa)) < 1.0e-6);
}
std::cout << GridLogMessage << std::endl;
std::cout << GridLogMessage << "2IndexRep - Checking if antihermitean"
<< std::endl;
for (int a = 0; a < ncolour * ncolour - 1; a++) {
generator(a, i2indTa);
std::cout << GridLogMessage << a << std::endl;
assert(norm2(adj(i2indTa) + i2indTa) < 1.0e-6);
}
std::cout << GridLogMessage << std::endl;
std::cout << GridLogMessage
<< "2IndexRep - Checking Tr[Ta*Tb]=delta(a,b)*(N +- 2)/2"
<< std::endl;
for (int a = 0; a < ncolour * ncolour - 1; a++) {
for (int b = 0; b < ncolour * ncolour - 1; b++) {
generator(a, i2indTa);
generator(b, i2indTb);
// generator returns iTa, so we need a minus sign here
Complex Tr = -TensorRemove(trace(i2indTa * i2indTb));
std::cout << GridLogMessage << "a=" << a << "b=" << b << "Tr=" << Tr
<< std::endl;
}
}
std::cout << GridLogMessage << std::endl;
}
static void TwoIndexLieAlgebraMatrix(
const typename SU<ncolour>::LatticeAlgebraVector &h,
LatticeTwoIndexMatrix &out, Real scale = 1.0) {
conformable(h, out);
GridBase *grid = out._grid;
LatticeTwoIndexMatrix la(grid);
TIMatrix i2indTa;
out = zero;
for (int a = 0; a < ncolour * ncolour - 1; a++) {
generator(a, i2indTa);
la = peekColour(h, a) * i2indTa;
out += la;
}
out *= scale;
}
// Projects the algebra components
// of a lattice matrix ( of dimension ncol*ncol -1 )
static void projectOnAlgebra(
typename SU<ncolour>::LatticeAlgebraVector &h_out,
const LatticeTwoIndexMatrix &in, Real scale = 1.0) {
conformable(h_out, in);
h_out = zero;
TIMatrix i2indTa;
Real coefficient = -2.0 / (ncolour + 2 * S) * scale;
// 2/(Nc +/- 2) for the normalization of the trace in the two index rep
for (int a = 0; a < ncolour * ncolour - 1; a++) {
generator(a, i2indTa);
auto tmp = real(trace(i2indTa * in)) * coefficient;
pokeColour(h_out, tmp, a);
}
}
// a projector that keeps the generators stored to avoid the overhead of
// recomputing them
static void projector(typename SU<ncolour>::LatticeAlgebraVector &h_out,
const LatticeTwoIndexMatrix &in, Real scale = 1.0) {
conformable(h_out, in);
// to store the generators
static std::vector<TIMatrix> i2indTa(ncolour * ncolour -1);
h_out = zero;
static bool precalculated = false;
if (!precalculated) {
precalculated = true;
for (int a = 0; a < ncolour * ncolour - 1; a++) generator(a, i2indTa[a]);
}
Real coefficient =
-2.0 / (ncolour + 2 * S) * scale; // 2/(Nc +/- 2) for the normalization
// of the trace in the two index rep
for (int a = 0; a < ncolour * ncolour - 1; a++) {
auto tmp = real(trace(i2indTa[a] * in)) * coefficient;
pokeColour(h_out, tmp, a);
}
}
};
// Some useful type names
typedef SU_TwoIndex<Nc, Symmetric> TwoIndexSymmMatrices;
typedef SU_TwoIndex<Nc, AntiSymmetric> TwoIndexAntiSymmMatrices;
typedef SU_TwoIndex<2, Symmetric> SU2TwoIndexSymm;
typedef SU_TwoIndex<3, Symmetric> SU3TwoIndexSymm;
typedef SU_TwoIndex<4, Symmetric> SU4TwoIndexSymm;
typedef SU_TwoIndex<5, Symmetric> SU5TwoIndexSymm;
typedef SU_TwoIndex<2, AntiSymmetric> SU2TwoIndexAntiSymm;
typedef SU_TwoIndex<3, AntiSymmetric> SU3TwoIndexAntiSymm;
typedef SU_TwoIndex<4, AntiSymmetric> SU4TwoIndexAntiSymm;
typedef SU_TwoIndex<5, AntiSymmetric> SU5TwoIndexAntiSymm;
}
}
#endif