diff --git a/Grid/qcd/action/fermion/instantiation/generate_instantiations.sh b/Grid/qcd/action/fermion/instantiation/generate_instantiations.sh index 7e33f634..728dc5e7 100755 --- a/Grid/qcd/action/fermion/instantiation/generate_instantiations.sh +++ b/Grid/qcd/action/fermion/instantiation/generate_instantiations.sh @@ -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 " diff --git a/Grid/qcd/utils/Sp2n.impl b/Grid/qcd/utils/Sp2n.impl index 3db63ed1..4c660d3a 100644 --- a/Grid/qcd/utils/Sp2n.impl +++ b/Grid/qcd/utils/Sp2n.impl @@ -300,3 +300,18 @@ static void Omega(LatticeColourMatrixD &in) { OmegaLatt = OmegaLatt + (identity * Omega); in = OmegaLatt; } + +template +static void Omega(iScalar > > &in) { + const int nsp=ncolour/2; + + iScalar > > Omega; + Omega = Zero(); + + for (int i = 0; i < nsp; i++) { + Omega()()(i, nsp + i) = 1.; + Omega()()(nsp + i, i) = -1; + } + + in = Omega; +} diff --git a/tests/sp2n/Test_2as_base.cc b/tests/sp2n/Test_2as_base.cc index 0dda2a76..72b2e17a 100644 --- a/tests/sp2n/Test_2as_base.cc +++ b/tests/sp2n/Test_2as_base.cc @@ -20,106 +20,117 @@ static void check_dimensions() { } template -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::template iGroupMatrix Matrix; + const int this_n = this_nc/2; + const int this_irrep_dim = Sp_TwoIndex::Dimension; + const int this_algebra_dim = Sp::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::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 +static void run_traces_checks() { + typedef typename Sp_TwoIndex::template iGroupMatrix Matrix; + const int this_n = this_nc/2; + const int this_irrep_dim = Sp_TwoIndex::Dimension; + const int this_algebra_dim = Sp::AlgebraDimension; + Matrix eij_a; + Matrix eij_b; + Matrix Omega; + Sp::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::Dimension; a++) { + Sp_TwoIndex::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::Dimension; b++) { + Sp_TwoIndex::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 +static void run_generators_checks() { + const int this_n = this_nc/2; + const int this_irrep_dim = Sp_TwoIndex::Dimension; + const int this_algebra_dim = Sp::AlgebraDimension; + typedef typename Sp_TwoIndex::template iGroupMatrix Matrix; + int sum = 0; + int sum_im = 0; + Vector ta_fund(this_algebra_dim); + Vector eij(this_irrep_dim); + Matrix tmp_l; + Matrix tmp_r; + for (int n = 0; n < this_algebra_dim; n++) + { + Sp::generator(n, ta_fund[n]); + } + for (int a = 0; a < this_irrep_dim; a++) + { + Sp_TwoIndex::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 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::Dimension; - const int this_algebra_dim = Sp::AlgebraDimension; - typedef typename Sp_TwoIndex::template iGroupMatrix Matrix; - typedef typename Sp_TwoIndex::template iGroupTwoIndexMatrix 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::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::Dimension; a++) { - Sp_TwoIndex::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::Dimension; b++) { - Sp_TwoIndex::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 ta_fund(this_algebra_dim); - Vector eij(this_irrep_dim); - Matrix tmp_l; - Matrix tmp_r; - for (int n = 0; n < this_algebra_dim; n++) - { - Sp::generator(n, ta_fund[n]); - } - for (int a = 0; a < this_irrep_dim; a++) - { - Sp_TwoIndex::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(); + run_traces_checks(); + run_generators_checks(); } 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>(); } -