Skip to content

Commit 97c8dec

Browse files
committed
testing new reconstructSU function and GaugeSUmungers
1 parent 650a76d commit 97c8dec

1 file changed

Lines changed: 101 additions & 14 deletions

File tree

tests/IO/Test_io_mungers.cc

Lines changed: 101 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,28 @@ Author: Gaurav Ray <gaurav.sinharay@swansea.ac.uk>
3232
using namespace std;
3333
using namespace Grid;
3434

35-
// Unit tests to check the various (un)munger classes
35+
// tests to check the various (un)munger classes
3636
// and functions in parallelIO/Metadata.h
37+
void check_reconstruct3();
3738
void check_reconstructSU();
3839
void check_reconstructSp();
3940
void checkBinarySimpleMungers();
4041
void checkGaugeSimpleMungers();
4142
void checkGaugeDoubleStoredMungers();
4243
void checkGauge3x2mungers();
44+
void checkGaugeSUmungers();
4345
void checkGaugeSpmungers();
4446

4547
// check result is still in SU, determinant==1
4648
// need to mock up an SU matrix
47-
void check_reconstructSU() {
49+
void check_reconstruct3() {
4850

4951
ColourMatrixD Ta, Tb, Tc, arg;
5052
SU<Nc>::generator(1, Ta);
5153
SU<Nc>::generator(4, Tb);
5254
SU<Nc>::generator(6, Tc);
5355

54-
const RealD a(0.6), b(0.9), c(0.7);
56+
const RealD a(0.1), b(0.2), c(0.3);
5557

5658
ColourMatrixD SU3_field;
5759
arg = timesI(a*Ta + b*Tb + c*Tc);
@@ -72,20 +74,56 @@ void check_reconstructSU() {
7274

7375
reconstruct3(test);
7476

75-
ColourMatrixD new_cm = Zero();
76-
7777
// check result is unitary and det==1
7878
for(int mu=0;mu<Nd;mu++) {
79-
new_cm = peekIndex<LorentzIndex>(test, mu);
79+
auto new_cm = peekIndex<LorentzIndex>(test, mu);
8080
//std::cout << GridLogMessage << new_cm()()(Nc-1,1) << std::endl;
8181
auto det = Determinant(new_cm);
82-
//std::cout << GridLogMessage << "det: " << det << " norm2: " << norm2(det) << std::endl;
83-
//std::cout << GridLogMessage << "norm2(UU^dag-1.0): " << norm2( new_cm*adj(new_cm)-1.0 ) << std::endl;
84-
assert( abs(norm2(det)-1.0) < 1e-15 );
82+
std::cout << GridLogMessage << "reconstruct3::norm2(UU^dag-1.0): " << norm2( new_cm*adj(new_cm)-1.0 ) << std::endl;
83+
//assert( abs(norm2(det)-1.0) < 1e-15 );
8584
}
8685

8786
}
8887

88+
void check_reconstructSU() {
89+
90+
ColourMatrixD Ta, Tb, Tc, arg, SUN_field;
91+
SU<Nc>::generator(2, Ta);
92+
SU<Nc>::generator(4, Tb);
93+
SU<Nc>::generator(7, Tc);
94+
95+
const RealD a(0.1), b(0.2), c(0.3);
96+
97+
arg = timesI(a*Ta + b*Tb + c*Tc);
98+
SUN_field = Exponentiate(arg, 2.0); // what is RealD alpha??
99+
//std::cout << GridLogMessage << "Original Field\n" << SUN_field << std::endl;
100+
101+
//set last row equal to zero
102+
for(int j=0;j<Nc;j++) {
103+
SUN_field()()(Nc-1,j) = 0.0;
104+
}
105+
106+
//std::cout << GridLogMessage << SUN_field << std::endl;
107+
LorentzColourMatrixD test = Zero();
108+
109+
for(int mu=0; mu<Nd; mu++){
110+
pokeLorentz(test,SUN_field,mu);
111+
}
112+
113+
reconstructSU(test);
114+
115+
// check result is unitary and det==1
116+
for(int mu=0;mu<Nd;mu++) {
117+
auto new_cm = peekIndex<LorentzIndex>(test, mu);
118+
auto det = Determinant(new_cm);
119+
//std::cout << GridLogMessage << "reconstructSU::norm2(det): " << norm2(det) << std::endl;
120+
//std::cout << GridLogMessage << "reconstructSU::norm2(UU^dag-1.0): " << norm2( new_cm*adj(new_cm)-1.0 ) << std::endl;
121+
assert( abs( norm2(det)-1.0 ) < 1e-15 );
122+
assert( norm2( new_cm*adj(new_cm)-1.0 ) < 1e-15 );
123+
}
124+
}
125+
126+
89127
void check_reconstructSp() {
90128

91129
LorentzColourMatrix cm = Zero();
@@ -269,7 +307,53 @@ void checkGauge3x2mungers() {
269307
//std::cout << test_recon << std::endl;
270308

271309
// round-trip test
272-
assert(norm2(test_recon-test)<10e-7);
310+
std::cout << "SU3mungeing: " << norm2(test_recon-test) << std::endl;
311+
//assert(norm2(test_recon-test)<10e-7);
312+
313+
}
314+
315+
void checkGaugeSUmungers() {
316+
ColourMatrixD Ta, Tb, Tc, arg;
317+
SU<Nc>::generator(1, Ta);
318+
SU<Nc>::generator(4, Tb);
319+
SU<Nc>::generator(6, Tc);
320+
321+
const RealD a(0.6), b(0.9), c(0.7);
322+
323+
ColourMatrixD SUN_field;
324+
arg = timesI(a*Ta + b*Tb + c*Tc);
325+
SUN_field = Exponentiate(arg, 2.0); // what is RealD alpha??
326+
327+
// std::cout << SUN_field*adj(SUN_field);
328+
LorentzColourMatrixD test=Zero();
329+
330+
for(int mu=0; mu<Nd; mu++){
331+
pokeLorentz(test,SUN_field,mu);
332+
}
333+
334+
// reduce field. GaugeSUunmunger<out_type,in_type>
335+
GaugeSUunmunger<LorentzColour2x3D,LorentzColourMatrixD> unmunger;
336+
LorentzColour2x3D test_rdc = Zero();
337+
unmunger(test,test_rdc);
338+
339+
//std::cout << test_rdc;
340+
341+
// reconstruct full field. GaugeSUmunger<in_type,out_type>
342+
GaugeSUmunger<LorentzColour2x3D,LorentzColourMatrixD> munger;
343+
LorentzColourMatrixD test_recon;
344+
munger(test_rdc,test_recon);
345+
346+
// round-trip test
347+
std::cout << "SUmungeing:norm2 " << norm2(test_recon-test) << std::endl;
348+
//assert(norm2(test_recon-test)<10e-7);
349+
// check result is unitary and det==1
350+
for(int mu=0;mu<Nd;mu++) {
351+
auto new_cm = peekIndex<LorentzIndex>(test_recon, mu);
352+
auto det = Determinant(new_cm);
353+
std::cout << GridLogMessage << "reconstructSU::norm2(UU^dag-1.0): " << norm2( new_cm*adj(new_cm)-1.0 ) << std::endl;
354+
//assert( abs(norm2(det)-1.0) < 1e-15 );
355+
}
356+
273357

274358
}
275359

@@ -312,8 +396,6 @@ void checkGaugeSpmungers() {
312396
pokeLorentz(test,Sp_field,mu);
313397
}
314398

315-
//std::cout << test << std::endl;
316-
317399
// reduce field. GaugeSpunmunger<out_type,in_type>
318400
GaugeSpunmunger<LorentzColourNx2ND,LorentzColourMatrixD> unmunger;
319401
LorentzColourNx2ND test_rdc = Zero();
@@ -342,8 +424,8 @@ int main (int argc, char ** argv)
342424
std::cout << GridLogMessage << "Nds is " << Nds << std::endl;
343425

344426
if constexpr(Nc>1 && Nc<4) {
345-
std::cout << GridLogMessage << "Checking SU mungers " << std::endl;
346-
check_reconstructSU();
427+
std::cout << GridLogMessage << "Checking SU(2/3) mungers " << std::endl;
428+
check_reconstruct3();
347429
checkGauge3x2mungers();
348430
}
349431

@@ -360,6 +442,11 @@ int main (int argc, char ** argv)
360442
std::cout << GridLogMessage << "Checking GaugeDoubleStored mungers " << std::endl;
361443
checkGaugeDoubleStoredMungers();
362444

445+
std::cout << GridLogMessage << "Checking reconstructSU" << std::endl;
446+
check_reconstructSU();
447+
std::cout << GridLogMessage << "Checking GaugeSUmungers" << std::endl;
448+
checkGaugeSUmungers();
449+
363450
Grid_finalize();
364451
#endif
365452
}

0 commit comments

Comments
 (0)