jfjoch_tests: Add more tests
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 12m25s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 13m32s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 13m50s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 13m51s
Build Packages / Generate python client (push) Successful in 19s
Build Packages / Create release (push) Has been skipped
Build Packages / build:rpm (rocky8) (push) Successful in 13m58s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 14m10s
Build Packages / Build documentation (push) Successful in 40s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 14m55s
Build Packages / build:rpm (rocky9) (push) Successful in 14m51s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 7m16s
Build Packages / Unit tests (push) Successful in 53m54s

This commit is contained in:
2026-02-04 11:14:32 +01:00
parent e0b7594429
commit 787e781eb2
2 changed files with 101 additions and 0 deletions
+52
View File
@@ -471,4 +471,56 @@ TEST_CASE("ResPhiToPxl_poni_rot") {
out = geom.ResPhiToPxl(2.0, 0.7567);
CHECK(geom.PxlToRes(out.first, out.second) == Catch::Approx(2.0));
CHECK(fabs(geom.Phi_rad(out.first, out.second) - 0.7567) < 0.001 );
}
TEST_CASE("DiffractionGeometry_DetectorToRecip_RecipToDetector_tilted") {
// Verify roundtrip consistency with non-zero rot1/rot2
DiffractionGeometry geom;
geom.BeamX_pxl(1000).BeamY_pxl(1000).DetectorDistance_mm(150)
.PixelSize_mm(0.075).Wavelength_A(1.0)
.PoniRot1_rad(0.05).PoniRot2_rad(-0.03);
// Test multiple points across the detector
std::vector<std::pair<float, float>> test_points = {
{500, 500}, {1500, 500}, {500, 1500}, {1500, 1500},
{800, 1200}, {1200, 800}, {300, 1700}, {1700, 300}
};
for (const auto& [x, y] : test_points) {
Coord recip = geom.DetectorToRecip(x, y);
auto [proj_x, proj_y] = geom.RecipToDector(recip);
CHECK(proj_x == Catch::Approx(x).margin(0.001));
CHECK(proj_y == Catch::Approx(y).margin(0.001));
}
}
TEST_CASE("DiffractionGeometry_PONI_matrix_consistency") {
// Verify that the PONI rotation matrix gives consistent results
// when used for both forward and inverse transformations
DiffractionGeometry geom;
geom.BeamX_pxl(1000).BeamY_pxl(1000).DetectorDistance_mm(100)
.PixelSize_mm(0.075).Wavelength_A(1.0)
.PoniRot1_rad(0.04).PoniRot2_rad(-0.025);
const auto& poni_rot = geom.GetPoniRotMatrix();
const auto poni_rot_T = poni_rot.transpose();
// Test: poni_rot * poni_rot^T should be identity (orthogonal matrix)
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) {
Coord ei, ej;
ei[i] = 1.0f;
ej[j] = 1.0f;
float expected = (i == j) ? 1.0f : 0.0f;
CHECK((poni_rot * (poni_rot_T * ej))[i] == Catch::Approx(expected).margin(1e-6));
}
}
// Test: S0 vector transformation
Coord S0 = geom.GetScatteringVector();
// For beam along z, S0 = (0, 0, 1/λ)
CHECK(S0.x == Catch::Approx(0.0f));
CHECK(S0.y == Catch::Approx(0.0f));
CHECK(S0.z == Catch::Approx(1.0f));
}