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

adjustments in SUn and Sp2n impl

This commit is contained in:
Alessandro Lupo 2023-06-23 15:34:08 +01:00
parent 2822487450
commit f27d2083cd
3 changed files with 74 additions and 208 deletions

View File

@ -10,6 +10,7 @@
// doesn't get found by the scripts/filelist during bootstrapping.
private:
template <ONLY_IF_SU>
static int su2subgroups(GroupName::SU) { return (ncolour * (ncolour - 1)) / 2; }
////////////////////////////////////////////////////////////////////////
// There are N^2-1 generators for SU(N).
@ -59,7 +60,7 @@ static int su2subgroups(GroupName::SU) { return (ncolour * (ncolour - 1)) / 2; }
// ( -2)
//
////////////////////////////////////////////////////////////////////////
template <class cplx>
template <class cplx, ONLY_IF_SU>
static void generator(int lieIndex, iGroupMatrix<cplx> &ta, GroupName::SU) {
// map lie index to which type of generator
int diagIndex;

View File

@ -10,6 +10,7 @@
// doesn't get found by the scripts/filelist during bootstrapping.
private:
template <ONLY_IF_Sp>
static int su2subgroups(GroupName::Sp) { return (ncolour/2 * (ncolour/2 - 1)) / 2; }
// Sp(2N) has N(2N+1) = 2N^2+N generators
@ -280,82 +281,6 @@ static void taProj(const LatticeMatrixType &in, LatticeMatrixType &out, GroupNam
}
public:
template <ONLY_IF_Sp>
static void OmegaInvariance(ColourMatrix &in) {
ColourMatrix Omega;
Omega = Zero();
const int nsp=ncolour/2;
for (int i = 0; i < nsp; i++) {
Omega()()(i, nsp + i) = 1.;
Omega()()(nsp + i, i) = -1;
}
auto diff = Omega - (in * Omega * transpose(in));
auto sdiff = norm2(diff);
if (norm2(sdiff) < 1e-8) {
std::cout << GridLogMessage
<< "Symplectic condition satisfied: Omega invariant" << std::endl;
} else {
std::cout << GridLogMessage
<< "WARNING!!!!!! Matrix Omega NOT left invariant by "
<< norm2(sdiff) << std::endl;
}
}
template <typename GaugeField, ONLY_IF_Sp>
static void OmegaInvariance(GaugeField &in) {
typedef typename GaugeField::vector_type vector_type;
typedef iGroupMatrix<vector_type> vMatrixType;
typedef Lattice<vMatrixType> LatticeMatrixType;
LatticeMatrixType U(in.Grid());
LatticeMatrixType OmegaLatt(in.Grid());
LatticeMatrixType identity(in.Grid());
RealD vol = in.Grid()->gSites();
ColourMatrix Omega;
OmegaLatt = Zero();
Omega = Zero();
identity = 1.;
U = PeekIndex<LorentzIndex>(in, 1);
OmegaInvariance(U);
}
template <ONLY_IF_Sp>
static void OmegaInvariance(LatticeColourMatrixD &in) {
const int nsp=ncolour/2;
LatticeColourMatrixD OmegaLatt(in.Grid());
LatticeColourMatrixD identity(in.Grid());
RealD vol = in.Grid()->gSites();
ColourMatrix Omega;
OmegaLatt = Zero();
Omega = Zero();
identity = 1.;
for (int i = 0; i < nsp; i++) {
Omega()()(i, nsp + i) = 1.;
Omega()()(nsp + i, i) = -1;
}
std::cout << GridLogMessage << "Omega = " << Omega()() << std::endl;
OmegaLatt = OmegaLatt + (identity * Omega);
auto diff = OmegaLatt - (in * OmegaLatt * transpose(in));
auto sdiff = sum(diff);
// assert( norm2(sdiff) < 1e-8 );
if (norm2(sdiff) < 1e-8) {
std::cout << GridLogMessage
<< "Symplectic condition satisfied: Omega invariant" << std::endl;
} else {
std::cout << GridLogMessage
<< "WARNING!!!!!! Matrix Omega NOT left invariant by "
<< norm2(sdiff) << std::endl;
}
}
template <ONLY_IF_Sp>
static void Omega(LatticeColourMatrixD &in) {

View File

@ -2,6 +2,73 @@
using namespace Grid;
template <typename T>
bool has_correct_group_block_structure(const T& U) {
std::cout << GridLogMessage << "Checking the structure is " << std::endl;
std::cout << GridLogMessage << "U = ( W X ) " << std::endl;
std::cout << GridLogMessage << " ( -X^* W^* ) " << std::endl;
std::cout << GridLogMessage << std::endl;
const int nsp = Nc / 2;
Complex i(0., 1.);
for (int c1 = 0; c1 < nsp; c1++) // check on W
{
for (int c2 = 0; c2 < nsp; c2++) {
auto W = PeekIndex<ColourIndex>(U, c1, c2);
auto Wstar = PeekIndex<ColourIndex>(U, c1 + nsp, c2 + nsp);
auto Ww = conjugate(Wstar);
auto amizero = sum(W - Ww);
auto amizeroo = TensorRemove(amizero);
assert(amizeroo.real() < 10e-6);
amizeroo *= i;
assert(amizeroo.real() < 10e-6);
}
}
for (int c1 = 0; c1 < nsp; c1++) {
for (int c2 = 0; c2 < nsp; c2++) {
auto X = PeekIndex<ColourIndex>(U, c1, c2 + nsp);
auto minusXstar = PeekIndex<ColourIndex>(U, c1 + nsp, c2);
auto minusXx = conjugate(minusXstar);
auto amizero = sum(X + minusXx);
auto amizeroo = TensorRemove(amizero);
assert(amizeroo.real() < 10e-6);
amizeroo *= i;
assert(amizeroo.real() < 10e-6);
}
}
return true;
};
template <typename T>
bool is_element_of_sp2n_group(const T& U) {
LatticeColourMatrixD aux(U.Grid());
LatticeColourMatrixD identity(U.Grid());
identity = 1.0;
LatticeColourMatrixD Omega(U.Grid());
Sp<Nc>::Omega(Omega);
std::cout << GridLogMessage << "Check matrix is non-zero " << std::endl;
assert(norm2(U) > 1e-8);
std::cout << GridLogMessage << "Unitary check" << std::endl;
aux = U * adj(U) - identity;
std::cout << GridLogMessage << "U adjU - 1 = " << norm2(aux) << std::endl;
assert(norm2(aux) < 1e-8);
aux = Omega - (U * Omega * transpose(U));
std::cout << GridLogMessage << "Omega - U Omega transpose(U) = " << norm2(aux)
<< std::endl;
assert(norm2(aux) < 1e-8);
std::cout << GridLogMessage
<< "|Det| = " << norm2(Determinant(U)) / U.Grid()->gSites()
<< std::endl;
assert(norm2(Determinant(U)) / U.Grid()->gSites() - 1 < 1e-8);
return has_correct_group_block_structure(U);
}
int main (int argc, char **argv)
{
Grid_init(&argc,&argv);
@ -15,153 +82,26 @@ int main (int argc, char **argv)
LatticeGaugeField Umu(&Grid);
LatticeColourMatrixD U(&Grid);
LatticeColourMatrixD aux(&Grid);
LatticeGaugeField identity(&Grid);
LatticeColourMatrixD Cidentity(&Grid);
double vol = Umu.Grid()->gSites();
const int nsp = Nc/2;
identity = 1.;
Cidentity = 1.;
std::vector<int> pseeds({1,2,3,4,5});
std::vector<int> sseeds({6,7,8,9,10});
GridParallelRNG pRNG(&Grid); pRNG.SeedFixedIntegers(pseeds);
GridSerialRNG sRNG; sRNG.SeedFixedIntegers(sseeds);
std::cout << GridLogMessage << std::endl;
std::cout << GridLogMessage << "-------" << std::endl;
std::cout << GridLogMessage << "Checking Cold Configuration " << std::endl;
std::cout << GridLogMessage << std::endl;
Sp<Nc>::ColdConfiguration(pRNG,Umu);
Sp<Nc>::OmegaInvariance(Umu);
std::cout << GridLogMessage << std::endl;
Umu = Umu - identity;
U = PeekIndex<LorentzIndex>(Umu,1);
assert(is_element_of_sp2n_group(U));
std::cout << GridLogMessage << "U - 1 = " << norm2(sum(U)) << std::endl;
assert ( norm2(sum(U)) < 1e-6);
std::cout << GridLogMessage << std::endl;
std::cout << GridLogMessage << "-------" << std::endl;
std::cout << GridLogMessage << "Checking Hot Configuration" << std::endl;
std::cout << GridLogMessage << std::endl;
Sp<Nc>::HotConfiguration(pRNG,Umu);
Sp<Nc>::OmegaInvariance(Umu);
std::cout << GridLogMessage << std::endl;
U = PeekIndex<LorentzIndex>(Umu,1);
std::cout << GridLogMessage << "Checking unitarity " << std::endl;
aux = U*adj(U) - Cidentity;
assert( norm2(aux) < 1e-6 );
std::cout << GridLogMessage << "ok" << std::endl;
std::cout << GridLogMessage << std::endl;
std::cout << GridLogMessage << "Checking determinant " << std::endl;
std::cout << GridLogMessage << "Det = " << norm2( Determinant(U) )/vol << std::endl;
std::cout << GridLogMessage << std::endl;
std::cout << GridLogMessage << "-------" << std::endl;
assert(is_element_of_sp2n_group(U));
std::cout << GridLogMessage << "Checking Tepid Configuration" << std::endl;
std::cout << GridLogMessage << std::endl;
Sp<Nc>::TepidConfiguration(pRNG,Umu);
Sp<Nc>::OmegaInvariance(Umu);
std::cout << GridLogMessage << std::endl;
U = PeekIndex<LorentzIndex>(Umu,1);
std::cout << GridLogMessage << "Checking unitarity " << std::endl;
aux = U*adj(U) - Cidentity;
assert( norm2(aux) < 1e-6 );
std::cout << GridLogMessage << "ok" << std::endl;
std::cout << GridLogMessage << std::endl;
std::cout << GridLogMessage << "Checking determinant " << std::endl;
std::cout << GridLogMessage << "Det = " << norm2( Determinant(U) )/vol << std::endl;
std::cout << GridLogMessage << std::endl;
std::cout << GridLogMessage << "Checking the structure is " << std::endl;
std::cout << GridLogMessage << "U = ( W X ) " << std::endl;
std::cout << GridLogMessage << " ( -X^* W^* ) " << std::endl;
std::cout << GridLogMessage << std::endl;
Complex i(0., 1.);
Sp<Nc>::HotConfiguration(pRNG,Umu);
U = PeekIndex<LorentzIndex>(Umu,0);
for (int c1 = 0; c1 < nsp; c1++) //check on W
{
for (int c2 = 0; c2 < nsp; c2++)
{
auto W = PeekIndex<ColourIndex>(U,c1,c2);
auto Wstar = PeekIndex<ColourIndex>(U,c1+nsp,c2+nsp);
auto Ww = conjugate( Wstar );
auto amizero = sum(W - Ww);
auto amizeroo = TensorRemove(amizero);
//std::cout << GridLogMessage << "diff(real,im) = " << amizeroo << std::endl;
assert( amizeroo.real() < 10e-6 );
amizeroo *= i;
assert( amizeroo.real() < 10e-6 );
//std::cout << GridLogMessage << "ok " << std::endl;
}
}
for (int c1 = 0; c1 < nsp ; c1++)
{
for (int c2 = 0; c2 < nsp; c2++)
{
auto X = PeekIndex<ColourIndex>(U,c1,c2+nsp);
auto minusXstar = PeekIndex<ColourIndex>(U,c1+nsp,c2);
auto minusXx = conjugate(minusXstar);
auto amizero = sum (X + minusXx);
auto amizeroo = TensorRemove(amizero);
//std::cout << GridLogMessage << "diff(real,im) = " << amizeroo << std::endl;
assert( amizeroo.real() < 10e-6 );
amizeroo *= i;
assert( amizeroo.real() < 10e-6 );
//std::cout << GridLogMessage << "ok " << std::endl;
}
}
std::cout << GridLogMessage << "Hot start ok " << std::endl;
Sp<Nc>::HotConfiguration(pRNG,Umu);
U = PeekIndex<LorentzIndex>(Umu,0);
for (int c1 = 0; c1 < nsp; c1++) //check on W
{
for (int c2 = 0; c2 < nsp; c2++)
{
auto W = PeekIndex<ColourIndex>(U,c1,c2);
auto Wstar = PeekIndex<ColourIndex>(U,c1+nsp,c2+nsp);
auto Ww = conjugate( Wstar );
auto amizero = sum(W - Ww);
auto amizeroo = TensorRemove(amizero);
//std::cout << GridLogMessage << "diff(real,im) = " << amizeroo << std::endl;
assert( amizeroo.real() < 10e-6 );
amizeroo *= i;
assert( amizeroo.real() < 10e-6 );
//std::cout << GridLogMessage << "ok " << std::endl;
}
}
for (int c1 = 0; c1 < nsp ; c1++)
{
for (int c2 = 0; c2 < nsp; c2++)
{
auto X = PeekIndex<ColourIndex>(U,c1,c2+nsp);
auto minusXstar = PeekIndex<ColourIndex>(U,c1+nsp,c2);
auto minusXx = conjugate(minusXstar);
auto amizero = sum (X + minusXx);
auto amizeroo = TensorRemove(amizero);
//std::cout << GridLogMessage << "diff(real,im) = " << amizeroo << std::endl;
assert( amizeroo.real() < 10e-6 );
amizeroo *= i;
assert( amizeroo.real() < 10e-6 );
//std::cout << GridLogMessage << "ok " << std::endl;
}
}
std::cout << GridLogMessage << "Tepid start ok " << std::endl;
std::cout << GridLogMessage << std::endl;
assert(is_element_of_sp2n_group(U));
Grid_finalize();