2021-10-12 09:06:15 +01:00
# include <Grid/Grid.h>
using namespace Grid ;
int main ( int argc , char * * argv )
{
2021-10-13 15:07:23 +01:00
Grid_init ( & argc , & argv ) ;
2021-10-12 09:06:15 +01:00
Coordinate latt_size = GridDefaultLatt ( ) ;
Coordinate simd_layout = GridDefaultSimd ( Nd , vComplex : : Nsimd ( ) ) ;
Coordinate mpi_layout = GridDefaultMpi ( ) ;
GridCartesian Grid ( latt_size , simd_layout , mpi_layout ) ;
GridRedBlackCartesian RBGrid ( & Grid ) ;
LatticeGaugeField Umu ( & Grid ) ;
LatticeColourMatrixD U ( & Grid ) ;
2021-10-12 12:12:16 +01:00
LatticeColourMatrixD aux ( & Grid ) ;
LatticeColourMatrixD identity ( & Grid ) ;
2023-04-03 16:31:19 +01:00
// Will test resimplectification-related functionalities (from ProjectOnGaugeGroup, ProjectOnSpGroup, ProjectGn) and projection on the algebra (from ProjectSp2nAlgebra)
// we work with matrices with positive determinant so detU = 1 even if in principle ProjectOnGaugeGroup and ProjectOnSpGroup allow for detU=-1
// so the checks will be the same for the three functions
// NB only ProjectGn is the proper simplectification function
2022-11-30 14:27:19 +00:00
const int nsp = Nc / 2 ;
2021-10-13 15:07:23 +01:00
2021-10-12 12:12:16 +01:00
identity = 1.0 ;
RealD epsilon = 0.01 ;
Complex i ( 0. , 1. ) ;
RealD u = 0. ;
double vol = Umu . Grid ( ) - > gSites ( ) ;
2021-10-12 09:06:15 +01:00
std : : vector < int > pseeds ( { 1 , 2 , 3 , 4 , 5 } ) ;
GridParallelRNG pRNG ( & Grid ) ; pRNG . SeedFixedIntegers ( pseeds ) ;
SU < Nc > : : HotConfiguration ( pRNG , Umu ) ;
2023-04-03 16:31:19 +01:00
U = PeekIndex < LorentzIndex > ( Umu , 0 ) ;
2021-10-12 12:12:16 +01:00
aux = U * adj ( U ) - identity ;
2021-10-13 15:07:23 +01:00
std : : cout < < GridLogMessage < < " Starting with random SUn matrix " < < std : : endl ;
std : : cout < < GridLogMessage < < " Unitary check " < < std : : endl ;
2021-10-12 12:12:16 +01:00
std : : cout < < GridLogMessage < < " U adjU - 1 = " < < norm2 ( aux ) < < std : : endl ;
2021-10-13 15:07:23 +01:00
assert ( norm2 ( aux ) < 1e-8 ) ;
2021-10-12 12:12:16 +01:00
std : : cout < < GridLogMessage < < std : : endl ;
2021-10-13 15:07:23 +01:00
if ( Nc ! = 2 )
{
2021-10-22 10:44:54 +01:00
std : : cout < < GridLogMessage < < " This matrix should not leave Omega invariant, expect a warning " < < std : : endl ;
2021-10-13 15:07:23 +01:00
}
2022-11-23 19:40:28 +00:00
Sp < Nc > : : OmegaInvariance ( U ) ;
2021-10-12 12:12:16 +01:00
std : : cout < < GridLogMessage < < std : : endl ;
2021-10-12 09:06:15 +01:00
2021-10-12 12:12:16 +01:00
U = U + epsilon * identity ;
aux = U * adj ( U ) - identity ;
2021-10-12 09:06:15 +01:00
2021-10-13 15:07:23 +01:00
std : : cout < < GridLogMessage < < " Unitary matrix deformed " < < std : : endl ;
2021-10-12 12:12:16 +01:00
std : : cout < < GridLogMessage < < " now U adjU - 1 = " < < norm2 ( aux ) < < std : : endl ;
2023-04-03 16:31:19 +01:00
// Testing ProjectOnSpGroup
std : : cout < < GridLogMessage < < " Testing ProjectOnSpGroup " < < std : : endl ;
std : : cout < < GridLogMessage < < " Apply ProjectOnSpGroup to deformed matrix " < < std : : endl ;
2023-03-17 11:36:58 +00:00
U = ProjectOnSpGroup ( U ) ;
2023-04-03 16:31:19 +01:00
2021-10-12 12:12:16 +01:00
aux = U * adj ( U ) - identity ;
2023-04-03 16:31:19 +01:00
std : : cout < < GridLogMessage < < " Unitary check after ProjectOnSpGroup " < < std : : endl ;
2021-10-12 12:12:16 +01:00
std : : cout < < GridLogMessage < < " U adjU - 1 = " < < norm2 ( aux ) < < std : : endl ;
2021-10-22 10:44:54 +01:00
assert ( norm2 ( aux ) < 1e-8 ) ;
2021-10-13 15:07:23 +01:00
// actual sp2n check
2023-04-03 16:31:19 +01:00
std : : cout < < GridLogMessage < < " Checking Omega invariance after ProjectOnSpGroup " < < std : : endl ;
Sp < Nc > : : OmegaInvariance ( U ) ; // no assertion here, but the next check will kill us if we are not simplectic
2021-10-13 15:07:23 +01:00
2021-10-12 12:12:16 +01:00
// checks on elements
2021-10-22 10:44:54 +01:00
2023-04-03 16:31:19 +01:00
std : : cout < < GridLogMessage < < " Checking the structure is " < < std : : endl ;
std : : cout < < GridLogMessage < < " U = ( W X ) " < < std : : endl ;
std : : cout < < GridLogMessage < < " ( -X^* W^* ) " < < std : : endl ;
2021-10-22 10:44:54 +01:00
std : : cout < < GridLogMessage < < std : : endl ;
2023-04-03 16:31:19 +01:00
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 ) ;
}
}
std : : cout < < GridLogMessage < < " Testing ProjectOnGaugeGroup " < < std : : endl ;
U = U + 2932.111 * identity ;
std : : cout < < GridLogMessage < < " Apply ProjectOnGaugeGroup to deformed matrix " < < std : : endl ;
Sp < Nc > : : ProjectOnGaugeGroup ( U ) ;
aux = U * adj ( U ) - identity ;
std : : cout < < GridLogMessage < < " U adjU - 1 = " < < norm2 ( aux ) < < std : : endl ;
assert ( norm2 ( aux ) < 1e-8 ) ;
Sp < Nc > : : OmegaInvariance ( 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 ;
2023-03-17 11:36:58 +00:00
std : : cout < < GridLogMessage < < std : : endl ;
2023-04-03 16:31:19 +01:00
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 ) ;
}
}
std : : cout < < GridLogMessage < < " Testing ProjectGn " < < std : : endl ;
U = U + 2932.111 * identity ;
std : : cout < < GridLogMessage < < " Apply ProjectGn to deformed matrix " < < std : : endl ;
Sp < Nc > : : ProjectGn ( U ) ;
aux = U * adj ( U ) - identity ;
std : : cout < < GridLogMessage < < " U adjU - 1 = " < < norm2 ( aux ) < < std : : endl ;
assert ( norm2 ( aux ) < 1e-8 ) ;
std : : cout < < GridLogMessage < < " Det after ProjectGn = " < < norm2 ( Determinant ( U ) ) / vol < < std : : endl ;
assert ( norm2 ( aux ) - 1 < 1e-8 ) ;
Sp < Nc > : : OmegaInvariance ( U ) ;
2021-10-13 15:07:23 +01:00
std : : cout < < GridLogMessage < < " Checking the structure is " < < std : : endl ;
std : : cout < < GridLogMessage < < " U = ( W X ) " < < std : : endl ;
std : : cout < < GridLogMessage < < " ( -X^* W^* ) " < < std : : endl ;
2021-10-12 12:12:16 +01:00
std : : cout < < GridLogMessage < < std : : endl ;
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 ) ;
}
}
2021-10-13 15:07:23 +01:00
2021-10-12 12:12:16 +01:00
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 ) ;
}
}
2023-04-03 16:31:19 +01:00
std : : cout < < GridLogMessage < < " Testing ProjectSp2nAlgebra " < < std : : endl ;
2021-10-12 12:12:16 +01:00
2023-04-03 16:31:19 +01:00
U = PeekIndex < LorentzIndex > ( Umu , 1 ) ;
U = U + 666. * identity ;
aux = U * adj ( U ) - identity ;
std : : cout < < GridLogMessage < < " Matrix deformed " < < std : : endl ;
std : : cout < < GridLogMessage < < " U adjU - 1 = " < < norm2 ( aux ) < < std : : endl ;
std : : cout < < GridLogMessage < < " Apply ProjectSp2nAlgebra to deformed matrix " < < std : : endl ;
U = ProjectSp2nAlgebra ( U ) ;
aux = U * adj ( U ) - identity ;
std : : cout < < GridLogMessage < < " U adjU - 1 = " < < norm2 ( aux ) < < std : : endl ;
assert ( norm2 ( aux ) < 1e-8 ) ;
std : : cout < < GridLogMessage < < " Check that Omega U Omega = conj(U) " < < std : : endl ;
LatticeColourMatrixD Omega ( & Grid ) ;
Sp < Nc > : : Omega ( Omega ) ;
aux = Omega * U * Omega - conjugate ( U ) ;
std : : cout < < GridLogMessage < < " Omega U Omega - conj(U) = " < < norm2 ( aux ) < < std : : endl ;
assert ( norm2 ( aux ) < 1e-8 ) ;
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 ;
for ( int c1 = 0 ; c1 < nsp ; c1 + + ) //check on W
2021-10-12 12:12:16 +01:00
{
2023-04-03 16:31:19 +01:00
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 ) ;
}
}
2021-10-12 12:12:16 +01:00
2023-04-03 16:31:19 +01:00
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 ) ;
}
}
2021-10-12 09:06:15 +01:00
Grid_finalize ( ) ;
}
2023-04-03 16:31:19 +01:00