1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-09 23:45:36 +00:00

prettiest tests

This commit is contained in:
Alessandro Lupo 2023-07-02 13:25:57 +01:00
parent 559257bbe9
commit 34b11864b6
3 changed files with 129 additions and 104 deletions

View File

@ -9,19 +9,19 @@ STAG5_IMPL_LIST=""
WILSON_IMPL_LIST=" \
WilsonImplF \
WilsonImplD \
WilsonImplD2 \
SpWilsonImplF \
SpWilsonImplD \
WilsonImplD2 \
SpWilsonImplF \
SpWilsonImplD \
WilsonAdjImplF \
WilsonAdjImplD \
WilsonTwoIndexSymmetricImplF \
WilsonTwoIndexSymmetricImplD \
WilsonTwoIndexAntiSymmetricImplF \
WilsonTwoIndexAntiSymmetricImplD \
SpWilsonTwoIndexAntiSymmetricImplF \
SpWilsonTwoIndexAntiSymmetricImplD \
SpWilsonTwoIndexSymmetricImplF \
SpWilsonTwoIndexSymmetricImplD \
SpWilsonTwoIndexAntiSymmetricImplF \
SpWilsonTwoIndexAntiSymmetricImplD \
SpWilsonTwoIndexSymmetricImplF \
SpWilsonTwoIndexSymmetricImplD \
GparityWilsonImplF \
GparityWilsonImplD "

View File

@ -300,3 +300,18 @@ static void Omega(LatticeColourMatrixD &in) {
OmegaLatt = OmegaLatt + (identity * Omega);
in = OmegaLatt;
}
template <ONLY_IF_Sp, class vtype, int N>
static void Omega(iScalar<iScalar<iMatrix<vtype, N> > > &in) {
const int nsp=ncolour/2;
iScalar<iScalar<iMatrix<vtype, N> > > Omega;
Omega = Zero();
for (int i = 0; i < nsp; i++) {
Omega()()(i, nsp + i) = 1.;
Omega()()(nsp + i, i) = -1;
}
in = Omega;
}

View File

@ -20,106 +20,117 @@ static void check_dimensions() {
}
template<int this_nc, TwoIndexSymmetry S>
static void S_checks() {
std::cout << S << std::endl;
std::cout << 1 + S * 3 << std::endl;
static void run_symmetry_checks() {
typedef typename Sp_TwoIndex<this_nc, S>::template iGroupMatrix<Complex> Matrix;
const int this_n = this_nc/2;
const int this_irrep_dim = Sp_TwoIndex<this_nc, S>::Dimension;
const int this_algebra_dim = Sp<this_nc>::AlgebraDimension;
Matrix eij_c;
Matrix e_sum;
RealD realS = S;
std::cout << GridLogMessage << "checking base has symmetry " << S << std::endl;
for (int a=0; a < this_irrep_dim; a++)
{
Sp_TwoIndex<this_nc, S>::base(a, eij_c);
e_sum = eij_c - realS * transpose(eij_c);
std::cout << GridLogMessage << "e_ab - (" << S << " * e_ab^T ) = " << norm2(e_sum) << std::endl;
assert(norm2(e_sum) < 1e-8);
}
}
template<int this_nc, TwoIndexSymmetry S>
static void run_traces_checks() {
typedef typename Sp_TwoIndex<this_nc, S>::template iGroupMatrix<Complex> Matrix;
const int this_n = this_nc/2;
const int this_irrep_dim = Sp_TwoIndex<this_nc, S>::Dimension;
const int this_algebra_dim = Sp<this_nc>::AlgebraDimension;
Matrix eij_a;
Matrix eij_b;
Matrix Omega;
Sp<this_nc>::Omega(Omega);
RealD realS = S;
RealD realA;
std::cout << GridLogMessage << "Checking Tr (e^(ab) Omega ) = 0 and Tr (e^(ab) e^(cd) = delta^((ab)(cd)) ) " << std::endl;
for (int a=0; a < Sp_TwoIndex<this_nc, S>::Dimension; a++) {
Sp_TwoIndex<this_nc, S>::base(a, eij_a);
realA = norm2(trace(Omega*eij_a));
std::cout << GridLogMessage << "Checkig Omega-trace for e_{ab=" << a << "} " << std::endl;
//std::cout << GridLogMessage << "Tr ( Omega e_{ab=" << a << "} ) = " << realA << std::endl;
assert(realA < 1e-8);
for (int b=0; b < Sp_TwoIndex<this_nc, S>::Dimension; b++) {
Sp_TwoIndex<this_nc, S>::base(b, eij_b);
auto d_ab = TensorRemove(trace(eij_a * eij_b));
#if verbose
std::cout << GridLogMessage << "Tr( e_{ab=" << a << "} e_{cd=" << b << "} ) = " << d_ab << std::endl;
#endif
std::cout << GridLogMessage << "Checking orthonormality for e_{ab = " << a << "} " << std::endl;
if (a==b) {
assert(real(d_ab) - realS < 1e-8);
assert(imag(d_ab) < 1e-8);
} else {
assert(real(d_ab) < 1e-8);
assert(imag(d_ab) < 1e-8);
}
}
}
}
template<int this_nc, TwoIndexSymmetry S>
static void run_generators_checks() {
const int this_n = this_nc/2;
const int this_irrep_dim = Sp_TwoIndex<this_nc, S>::Dimension;
const int this_algebra_dim = Sp<this_nc>::AlgebraDimension;
typedef typename Sp_TwoIndex<this_nc, S>::template iGroupMatrix<Complex> Matrix;
int sum = 0;
int sum_im = 0;
Vector<Matrix> ta_fund(this_algebra_dim);
Vector<Matrix> eij(this_irrep_dim);
Matrix tmp_l;
Matrix tmp_r;
for (int n = 0; n < this_algebra_dim; n++)
{
Sp<this_nc>::generator(n, ta_fund[n]);
}
for (int a = 0; a < this_irrep_dim; a++)
{
Sp_TwoIndex<this_nc, S>::base(a, eij[a]);
}
for (int gen_id = 0; gen_id < this_algebra_dim; gen_id++)
{
sum = 0;
sum_im = 0;
std::cout << GridLogMessage << "generator number " << gen_id << std::endl;
for (int a = 0; a < this_irrep_dim; a++)
{
tmp_l = adj(eij[a])*ta_fund[gen_id]*eij[a];
tmp_r = adj(eij[a])*eij[a]*transpose(ta_fund[gen_id]);
#if verbose
std::cout << GridLogMessage << " as_indx = " << a << " eDag T_F e = " << std::endl << tmp_l << std::endl;
std::cout << GridLogMessage << " as_indx = " << a << " eDag e T_F^T = " << std::endl << tmp_r << std::endl;
#endif
//std::cout << GridLogMessage << " as_indx = " << a << " Tr(eDag T_F e + eDag e T_F^T) = " << TensorRemove(trace(tmp_l+tmp_r)) << std::endl;
sum += real(TensorRemove(trace(tmp_l+tmp_r)));
sum_im += imag(TensorRemove(trace(tmp_l+tmp_r)));
}
std::cout << GridLogMessage << "re-evaluated trace of the generator " << gen_id << " is " << sum << " " << sum_im << std::endl;
assert ( sum < 1e-8) ;
assert ( sum_im < 1e-8) ;
}
}
template<int this_nc, TwoIndexSymmetry S>
static void run_base_checks() {
std::cout << GridLogMessage << " ****** " << std::endl;
std::cout << GridLogMessage << "Running checks for Nc = " << this_nc << " TwoIndex Symmetry = " << S << std::endl;
const int this_n = this_nc/2;
const int this_irrep_dim = Sp_TwoIndex<this_nc, S>::Dimension;
const int this_algebra_dim = Sp<this_nc>::AlgebraDimension;
typedef typename Sp_TwoIndex<this_nc, S>::template iGroupMatrix<Complex> Matrix;
typedef typename Sp_TwoIndex<this_nc, S>::template iGroupTwoIndexMatrix<Complex> ASMatrix;
RealD realS = S;
Matrix Omega;
Matrix eij_a;
Matrix eij_b;
Matrix eij_c;
Matrix e_sum;
Omega = Zero();
for (int i = 0; i < this_n; i++)
{
Omega()()(i, this_n + i) = 1.;
Omega()()(this_n + i, i) = -1;
}
RealD realA;
std::cout << GridLogMessage << "checking base has symmetry " << S << std::endl;
for (int a=0; a < this_irrep_dim; a++)
{
Sp_TwoIndex<this_nc, S>::base(a, eij_c);
e_sum = eij_c - realS * transpose(eij_c);
std::cout << GridLogMessage << "e_ab - (" << S << " * e_ab^T ) = " << norm2(e_sum) << std::endl;
assert(norm2(e_sum) < 1e-8);
}
std::cout << GridLogMessage << "Checking Tr (e^(ab) Omega ) = 0 and Tr (e^(ab) e^(cd) = delta^((ab)(cd)) ) " << std::endl;
for (int a=0; a < Sp_TwoIndex<this_nc, S>::Dimension; a++) {
Sp_TwoIndex<this_nc, S>::base(a, eij_a);
realA = norm2(trace(Omega*eij_a));
std::cout << GridLogMessage << "Checkig Omega-trace for e_{ab=" << a << "} " << std::endl;
//std::cout << GridLogMessage << "Tr ( Omega e_{ab=" << a << "} ) = " << realA << std::endl;
assert(realA < 1e-8);
for (int b=0; b < Sp_TwoIndex<this_nc, S>::Dimension; b++) {
Sp_TwoIndex<this_nc, S>::base(b, eij_b);
auto d_ab = TensorRemove(trace(eij_a * eij_b));
#if verbose
std::cout << GridLogMessage << "Tr( e_{ab=" << a << "} e_{cd=" << b << "} ) = " << d_ab << std::endl;
#endif
std::cout << GridLogMessage << "Checking orthonormality for e_{ab = " << a << "} " << std::endl;
if (a==b) {
assert(real(d_ab) - realS < 1e-8);
assert(imag(d_ab) < 1e-8);
} else {
assert(real(d_ab) < 1e-8);
assert(imag(d_ab) < 1e-8);
}
}
}
int sum = 0;
int sum_im = 0;
Vector<Matrix> ta_fund(this_algebra_dim);
Vector<Matrix> eij(this_irrep_dim);
Matrix tmp_l;
Matrix tmp_r;
for (int n = 0; n < this_algebra_dim; n++)
{
Sp<this_nc>::generator(n, ta_fund[n]);
}
for (int a = 0; a < this_irrep_dim; a++)
{
Sp_TwoIndex<this_nc, S>::base(a, eij[a]);
}
for (int gen_id = 0; gen_id < this_algebra_dim; gen_id++)
{
sum = 0;
sum_im = 0;
std::cout << GridLogMessage << "generator number " << gen_id << std::endl;
for (int a = 0; a < this_irrep_dim; a++)
{
tmp_l = adj(eij[a])*ta_fund[gen_id]*eij[a];
tmp_r = adj(eij[a])*eij[a]*transpose(ta_fund[gen_id]);
#if verbose
std::cout << GridLogMessage << " as_indx = " << a << " eDag T_F e = " << std::endl << tmp_l << std::endl;
std::cout << GridLogMessage << " as_indx = " << a << " eDag e T_F^T = " << std::endl << tmp_r << std::endl;
#endif
//std::cout << GridLogMessage << " as_indx = " << a << " Tr(eDag T_F e + eDag e T_F^T) = " << TensorRemove(trace(tmp_l+tmp_r)) << std::endl;
sum += real(TensorRemove(trace(tmp_l+tmp_r)));
sum_im += imag(TensorRemove(trace(tmp_l+tmp_r)));
}
std::cout << GridLogMessage << "re-evaluated trace of the generator " << gen_id << " is " << sum << " " << sum_im << std::endl;
assert ( sum < 1e-8) ;
assert ( sum_im < 1e-8) ;
}
std::cout << GridLogMessage << " ****** " << std::endl;
std::cout << GridLogMessage << "Running checks for Nc = " << this_nc << " TwoIndex Symmetry = " << S << std::endl;
run_symmetry_checks<this_nc, S>();
run_traces_checks<this_nc, S>();
run_generators_checks<this_nc, S>();
}
int main(int argc, char** argv) {
@ -136,4 +147,3 @@ int main(int argc, char** argv) {
run_base_checks<8, Symmetric>();
run_base_checks<8, AntiSymmetric>();
}