1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-11-29 19:09:32 +00:00

Assertion updates to macros (mostly) with backtrace.

WIlson flow to include options for DBW2, Iwasaki, Symanzik.
View logging for data assurance
This commit is contained in:
2025-08-07 15:48:38 +00:00
parent 41f344bbd3
commit 9e6a4a4737
306 changed files with 2013 additions and 1928 deletions

View File

@@ -16,7 +16,7 @@ static void check_dimensions() {
std::cout << GridLogMessage << "Nc = " << this_n << " algebra dimension is " << this_algebra_dim << std::endl;
realA = Sp_TwoIndex<this_nc, AntiSymmetric>::Dimension + Sp_TwoIndex<this_nc, Symmetric>::Dimension;
std::cout << GridLogMessage << "Checking dim(2AS) + dim(AS) + 1 = Nc * Nc " << this_algebra_dim << std::endl;
assert ( realA == this_nc * this_nc - 1); // Nc x Nc = dim(2indxS) + dim(2indxAS) + dim(singlet)
GRID_ASSERT ( realA == this_nc * this_nc - 1); // Nc x Nc = dim(2indxS) + dim(2indxAS) + dim(singlet)
}
template<int this_nc, TwoIndexSymmetry S>
@@ -35,7 +35,7 @@ static void run_symmetry_checks() {
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);
GRID_ASSERT(norm2(e_sum) < 1e-8);
}
}
@@ -59,7 +59,7 @@ static void run_traces_checks() {
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);
GRID_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));
@@ -68,12 +68,12 @@ static void run_traces_checks() {
#endif
std::cout << GridLogMessage << "Checking orthonormality for e_{ab = " << a << "} " << std::endl;
if (a==b) {
assert(real(d_ab) - realS < 1e-8);
GRID_ASSERT(real(d_ab) - realS < 1e-8);
} else {
assert(real(d_ab) < 1e-8);
GRID_ASSERT(real(d_ab) < 1e-8);
}
assert(imag(d_ab) < 1e-8);
assert(imag(d_ab) < 1e-8);
GRID_ASSERT(imag(d_ab) < 1e-8);
GRID_ASSERT(imag(d_ab) < 1e-8);
}
}
@@ -118,8 +118,8 @@ static void run_generators_checks() {
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) ;
GRID_ASSERT ( sum < 1e-8) ;
GRID_ASSERT ( sum_im < 1e-8) ;
}
}

View File

@@ -19,9 +19,9 @@ bool has_correct_group_block_structure(const T& U) {
auto Ww = conjugate(Wstar);
auto amizero = sum(W - Ww);
auto amizeroo = TensorRemove(amizero);
assert(amizeroo.real() < 10e-6);
GRID_ASSERT(amizeroo.real() < 10e-6);
amizeroo *= i;
assert(amizeroo.real() < 10e-6);
GRID_ASSERT(amizeroo.real() < 10e-6);
}
}
@@ -32,9 +32,9 @@ bool has_correct_group_block_structure(const T& U) {
auto minusXx = conjugate(minusXstar);
auto amizero = sum(X + minusXx);
auto amizeroo = TensorRemove(amizero);
assert(amizeroo.real() < 10e-6);
GRID_ASSERT(amizeroo.real() < 10e-6);
amizeroo *= i;
assert(amizeroo.real() < 10e-6);
GRID_ASSERT(amizeroo.real() < 10e-6);
}
}
return true;
@@ -49,22 +49,22 @@ bool is_element_of_sp2n_group(const T& U) {
Sp<Nc>::Omega(Omega);
std::cout << GridLogMessage << "Check matrix is non-zero " << std::endl;
assert(norm2(U) > 1e-8);
GRID_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);
GRID_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);
GRID_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);
GRID_ASSERT(norm2(Determinant(U)) / U.Grid()->gSites() - 1 < 1e-8);
return has_correct_group_block_structure(U);
}
@@ -91,17 +91,17 @@ int main (int argc, char **argv)
std::cout << GridLogMessage << "Checking Cold Configuration " << std::endl;
Sp<Nc>::ColdConfiguration(pRNG,Umu);
U = PeekIndex<LorentzIndex>(Umu,1);
assert(is_element_of_sp2n_group(U));
GRID_ASSERT(is_element_of_sp2n_group(U));
std::cout << GridLogMessage << "Checking Hot Configuration" << std::endl;
Sp<Nc>::HotConfiguration(pRNG,Umu);
U = PeekIndex<LorentzIndex>(Umu,1);
assert(is_element_of_sp2n_group(U));
GRID_ASSERT(is_element_of_sp2n_group(U));
std::cout << GridLogMessage << "Checking Tepid Configuration" << std::endl;
Sp<Nc>::TepidConfiguration(pRNG,Umu);
U = PeekIndex<LorentzIndex>(Umu,1);
assert(is_element_of_sp2n_group(U));
GRID_ASSERT(is_element_of_sp2n_group(U));
Grid_finalize();

View File

@@ -19,9 +19,9 @@ bool has_correct_group_block_structure(const T& U) {
auto Ww = conjugate(Wstar);
auto amizero = sum(W - Ww);
auto amizeroo = TensorRemove(amizero);
assert(amizeroo.real() < 10e-6);
GRID_ASSERT(amizeroo.real() < 10e-6);
amizeroo *= i;
assert(amizeroo.real() < 10e-6);
GRID_ASSERT(amizeroo.real() < 10e-6);
}
}
@@ -32,9 +32,9 @@ bool has_correct_group_block_structure(const T& U) {
auto minusXx = conjugate(minusXstar);
auto amizero = sum(X + minusXx);
auto amizeroo = TensorRemove(amizero);
assert(amizeroo.real() < 10e-6);
GRID_ASSERT(amizeroo.real() < 10e-6);
amizeroo *= i;
assert(amizeroo.real() < 10e-6);
GRID_ASSERT(amizeroo.real() < 10e-6);
}
}
return true;
@@ -49,22 +49,22 @@ bool is_element_of_sp2n_group(const T& U) {
Sp<Nc>::Omega(Omega);
std::cout << GridLogMessage << "Check matrix is non-zero " << std::endl;
assert(norm2(U) > 1e-8);
GRID_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);
GRID_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);
GRID_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);
GRID_ASSERT(norm2(Determinant(U)) / U.Grid()->gSites() - 1 < 1e-8);
return has_correct_group_block_structure(U);
}
@@ -86,7 +86,7 @@ void test_group_projections(T U) {
U = U + Delta * identity;
U = ProjectOnSpGroup(U);
assert(is_element_of_sp2n_group(U));
GRID_ASSERT(is_element_of_sp2n_group(U));
name = "ProjectOnGeneralGroup";
std::cout << GridLogMessage << "Testing " << name << std::endl;
@@ -94,7 +94,7 @@ void test_group_projections(T U) {
U = U + Delta * identity;
U = Sp<Nc>::ProjectOnGeneralGroup(U);
assert(is_element_of_sp2n_group(U));
GRID_ASSERT(is_element_of_sp2n_group(U));
name = "ProjectOnSpecialGroup";
std::cout << GridLogMessage << "Testing " << name << std::endl;
@@ -102,7 +102,7 @@ void test_group_projections(T U) {
U = U + Delta * identity;
Sp<Nc>::ProjectOnSpecialGroup(U);
assert(is_element_of_sp2n_group(U));
GRID_ASSERT(is_element_of_sp2n_group(U));
name = "ProjectSpn";
std::cout << GridLogMessage << "Testing " << name << std::endl;
@@ -110,7 +110,7 @@ void test_group_projections(T U) {
U = U + Delta * identity;
ProjectSpn(U);
assert(is_element_of_sp2n_group(U));
GRID_ASSERT(is_element_of_sp2n_group(U));
}
template <typename T>
@@ -129,9 +129,9 @@ bool has_correct_algebra_block_structure(const T& U) {
auto Ww = conjugate(Wstar);
auto amizero = sum(W - Ww);
auto amizeroo = TensorRemove(amizero);
assert(amizeroo.real() < 10e-6);
GRID_ASSERT(amizeroo.real() < 10e-6);
amizeroo *= i;
assert(amizeroo.real() < 10e-6);
GRID_ASSERT(amizeroo.real() < 10e-6);
}
}
for (int c1 = 0; c1 < nsp; c1++) {
@@ -141,9 +141,9 @@ bool has_correct_algebra_block_structure(const T& U) {
auto minusXx = conjugate(minusXstar);
auto amizero = sum(X + minusXx);
auto amizeroo = TensorRemove(amizero);
assert(amizeroo.real() < 10e-6);
GRID_ASSERT(amizeroo.real() < 10e-6);
amizeroo *= i;
assert(amizeroo.real() < 10e-6);
GRID_ASSERT(amizeroo.real() < 10e-6);
}
}
@@ -159,7 +159,7 @@ bool is_element_of_sp2n_algebra(const T& U) {
Sp<Nc>::Omega(Omega);
std::cout << GridLogMessage << "Check matrix is non-zero " << std::endl;
assert(norm2(U) > 1e-8);
GRID_ASSERT(norm2(U) > 1e-8);
aux = U - adj(U);
std::cout << GridLogMessage << "T - Tda = " << norm2(aux)
@@ -168,12 +168,12 @@ bool is_element_of_sp2n_algebra(const T& U) {
aux = U + adj(U);
std::cout << GridLogMessage << "T + Tda = " << norm2(aux)
<< " (supposed to vanish)" << std::endl;
assert(norm2(aux) - 1 < 1e-8);
GRID_ASSERT(norm2(aux) - 1 < 1e-8);
std::cout << GridLogMessage << "Check that Omega T Omega + conj(T) = 0 "
<< std::endl;
aux = Omega * U * Omega + conjugate(U);
assert(norm2(aux) < 1e-8);
GRID_ASSERT(norm2(aux) < 1e-8);
return has_correct_algebra_block_structure(U);
}
@@ -196,7 +196,7 @@ void test_algebra_projections(T U) {
U = U + Delta * identity;
U = SpTa(U);
assert(is_element_of_sp2n_algebra(U));
GRID_ASSERT(is_element_of_sp2n_algebra(U));
name = "TaProj";
std::cout << GridLogMessage << "Testing " << name << std::endl;
@@ -205,7 +205,7 @@ void test_algebra_projections(T U) {
U = U + Delta * identity;
Sp<Nc>::taProj(U, tmp);
U = tmp;
assert(is_element_of_sp2n_algebra(U));
GRID_ASSERT(is_element_of_sp2n_algebra(U));
}
int main(int argc, char** argv) {