Build Packages / Build documentation (push) Successful in 48s
Build Packages / build:portable:linux-x86_64:nocuda (push) Successful in 15m47s
Build Packages / build:portable:linux-x86_64:cuda (push) Successful in 23m19s
Build Packages / build:portable:windows-x86_64:nocuda (push) Successful in 18m47s
Build Packages / build:portable:macos-arm64:nocuda (push) Successful in 5m54s
Build Packages / build:rugnux:linux-aarch64:cuda (push) Successful in 11m27s
Build Packages / build:jfjoch:ubuntu2204:cuda (push) Successful in 26m59s
Build Packages / Unit tests (push) Successful in 1h50m25s
Build Packages / Validation Battery (push) Successful in 46m38s
Build Packages / build:jfjoch:rocky8:nocuda (push) Successful in 32m52s
Build Packages / build:jfjoch:rocky9:nocuda (push) Successful in 32m32s
Build Packages / build:jfjoch:ubuntu2204:nocuda (push) Successful in 28m34s
Build Packages / build:jfjoch:ubuntu2404:nocuda (push) Successful in 29m19s
Build Packages / build:jfjoch:rocky8:cuda-sls9 (push) Successful in 30m11s
Build Packages / build:jfjoch:rocky9:cuda-sls9 (push) Successful in 33m58s
Build Packages / build:jfjoch:rocky8:cuda (push) Successful in 31m26s
Build Packages / build:jfjoch:rocky9:cuda (push) Successful in 34m4s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 32m17s
Build Packages / Generate python client (push) Successful in 32s
Build Packages / Create release (push) Successful in 9s
Build Packages / build:jfjoch:ubuntu2404:cuda (push) Successful in 31m50s
Build Packages / build:portable:windows-x86_64:cuda (push) Successful in 19m38s
* jfjoch_broker (experimental): Live Rugnux covers serial collections from DECTRIS detectors; a rotation collection too large for the image buffer falls back to standard per-image processing with a warning, and a stream that ends without its end message finishes the collection instead of hanging it. * jfjoch_broker (experimental): Live Rugnux settings to build the solvent during refinement and to process a rotation collection as stills, a Clear action for the last result, a `_report.txt` for live rotation runs, R-free reported for the refined model, and ice-ring detection on by default for rotation as in the command line. * jfjoch_broker (experimental): More complete and reproducible live serial merges, analysed for twinning, pseudo-translation and anisotropy, with merging statistics by resolution shell in the live status. * jfjoch_writer: Live results with large models are written reliably; update jfjoch_writer together with jfjoch_broker. * Rugnux: Several masters can be processed together with `--force-still`, including grid scans; more robust and faster merging of several sweeps; improved twinning, pseudo-translation, anisotropy, anomalous-signal and space-group decisions. * Rugnux: Molecular replacement places the copies of a multi-copy solution together; the pseudo-translation warning quotes the Patterson peak and is not raised once a model is placed; the report advises on extending the rotation or reorienting the crystal where the coverage would gain from it. * Web frontend: Light and dark modes, a phone layout, a hideable page list, a redesigned Rugnux live page with step-through of the Fo-Fc peaks in the structure view. * jfjoch_viewer: A broker URL given on the command line follows the running collection. Reviewed-on: #97 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
119 lines
6.3 KiB
C++
119 lines
6.3 KiB
C++
// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include <catch2/catch_test_macros.hpp>
|
|
#include <catch2/matchers/catch_matchers_floating_point.hpp>
|
|
|
|
#include "../image_analysis/indexing/SweepCoverage.h"
|
|
#include "../image_analysis/indexing/SpindleCuspLoss.h"
|
|
|
|
using Catch::Matchers::WithinAbs;
|
|
|
|
namespace {
|
|
// lambda = 1 A against d_min = 1 / (2 sin 15 deg) puts theta_max at exactly 15 deg.
|
|
constexpr double WVL = 1.0;
|
|
const double D_MIN = 1.0 / (2.0 * std::sin(15.0 * M_PI / 180.0));
|
|
const Coord S0(0, 0, 1.0f / static_cast<float>(WVL));
|
|
|
|
GoniometerAxis Spindle(const Coord &axis) {
|
|
return GoniometerAxis("omega", 0.0f, 0.1f, axis, {});
|
|
}
|
|
}
|
|
|
|
// The roots are where the lattice, turned the way the predictor turns it, meets the Ewald sphere.
|
|
TEST_CASE("SweepCoverage_CrossingAngles", "[Rugnux][Spindle]") {
|
|
const Coord u(1, 0, 0);
|
|
const GoniometerAxis gonio = Spindle(u);
|
|
const Coord s(0.21f, -0.35f, 0.08f); // |s| ~ 0.42 < 1/d_min at theta_max 15 deg: crosses twice
|
|
const auto roots = EwaldCrossingAngles_deg(s, u, S0);
|
|
REQUIRE(roots.size() == 2);
|
|
for (const double a : roots) {
|
|
const CrystalLattice latt(s, Coord(0, 1, 0), Coord(0, 0, 1));
|
|
const Coord turned = latt.Multiply(gonio.GetTransformationAngle(-static_cast<float>(a))).Vec0();
|
|
CHECK_THAT((turned + S0).Length(), WithinAbs(S0.Length(), 1e-4));
|
|
}
|
|
// Along the spindle, or too steep for its own shell: never.
|
|
CHECK(EwaldCrossingAngles_deg(Coord(0.3f, 0, 0), u, S0).empty());
|
|
CHECK(EwaldCrossingAngles_deg(Coord(0.5f, 0.05f, 0), u, S0).empty());
|
|
}
|
|
|
|
TEST_CASE("SweepCoverage_Forecast", "[Rugnux][Spindle]") {
|
|
const CrystalLattice latt(UnitCell{40, 50, 60, 83, 95, 102});
|
|
const auto &p1 = *gemmi::find_spacegroup_by_name("P 1");
|
|
const Coord axis(1, 0, 0);
|
|
const GoniometerAxis gonio = Spindle(axis);
|
|
|
|
SECTION("a full turn measures everything outside the blind cone") {
|
|
const auto f = ForecastSweepCoverage(p1, latt, gonio, S0, D_MIN, 0, 360);
|
|
REQUIRE(f.has_value());
|
|
CHECK_THAT(f->measured_fraction, WithinAbs(f->asymptote_fraction, 1e-9));
|
|
const auto cusp = SpindleUnrepairedFraction(p1, latt, axis, WVL, D_MIN);
|
|
REQUIRE(cusp.has_value());
|
|
CHECK_THAT(f->asymptote_fraction, WithinAbs(1.0 - cusp->lost_unique_fraction, 0.01));
|
|
CHECK(!f->DegreesTo(f->asymptote_fraction + 0.01).has_value());
|
|
}
|
|
|
|
SECTION("P1 needs 180 degrees under Friedel's law, and the second half is the first") {
|
|
// Dauter (1999): with Friedel pairs merged, 180 degrees completes a triclinic crystal; the
|
|
// extra 2 theta_max is only for measuring both mates.
|
|
const auto half = ForecastSweepCoverage(p1, latt, gonio, S0, D_MIN, 0, 180);
|
|
REQUIRE(half.has_value());
|
|
CHECK_THAT(half->measured_fraction, WithinAbs(half->asymptote_fraction, 1e-9));
|
|
const auto quarter = ForecastSweepCoverage(p1, latt, gonio, S0, D_MIN, 0, 90);
|
|
REQUIRE(quarter.has_value());
|
|
CHECK(quarter->measured_fraction < 0.9 * quarter->asymptote_fraction);
|
|
const auto to_all = quarter->DegreesTo(quarter->asymptote_fraction - 1e-9);
|
|
REQUIRE(to_all.has_value());
|
|
CHECK(*to_all <= 90.0);
|
|
CHECK(*to_all >= 60.0);
|
|
const auto a = ForecastSweepCoverage(p1, latt, gonio, S0, D_MIN, 0, 40);
|
|
const auto b = ForecastSweepCoverage(p1, latt, gonio, S0, D_MIN, 180, 220);
|
|
REQUIRE((a.has_value() && b.has_value()));
|
|
CHECK_THAT(a->measured_fraction, WithinAbs(b->measured_fraction, 0.01));
|
|
// The curve is monotone and reaches the asymptote by a full turn
|
|
for (size_t k = 1; k < a->fraction_at.size(); k++)
|
|
CHECK(a->fraction_at[k] >= a->fraction_at[k - 1]);
|
|
CHECK_THAT(a->fraction_at.back(), WithinAbs(a->asymptote_fraction, 1e-9));
|
|
}
|
|
|
|
SECTION("a diad on the spindle is the rotation itself and halves nothing") {
|
|
const CrystalLattice mono(UnitCell{40, 50, 60, 90, 100, 90}); // P2, unique axis b
|
|
const auto &p2 = *gemmi::find_spacegroup_by_name("P 2");
|
|
const GoniometerAxis on_b = Spindle(mono.Vec1());
|
|
const auto f = ForecastSweepCoverage(p2, mono, on_b, S0, D_MIN, 0, 180);
|
|
REQUIRE(f.has_value());
|
|
CHECK_THAT(f->measured_fraction, WithinAbs(f->asymptote_fraction, 1e-9));
|
|
const auto q = ForecastSweepCoverage(p2, mono, on_b, S0, D_MIN, 0, 90);
|
|
REQUIRE(q.has_value());
|
|
CHECK(q->measured_fraction < 0.9 * q->asymptote_fraction);
|
|
CHECK(q->DegreesTo(q->asymptote_fraction - 1e-9).value_or(999) <= 90.0);
|
|
CHECK(q->DegreesTo(q->asymptote_fraction - 1e-9).value_or(0) >= 60.0);
|
|
}
|
|
|
|
SECTION("a diad perpendicular to the spindle: 90 degrees plus the cone, started with the diad across the beam") {
|
|
// b along y: perpendicular to the spindle (x) and to the beam (z) at angle 0. Dauter's 90 degrees
|
|
// for this mounting holds from the right start; the same length started 45 degrees later is not.
|
|
const CrystalLattice mono(UnitCell{40, 50, 60, 90, 100, 90});
|
|
const auto &p2 = *gemmi::find_spacegroup_by_name("P 2");
|
|
const GoniometerAxis x_axis = Spindle(Coord(1, 0, 0));
|
|
const auto right = ForecastSweepCoverage(p2, mono, x_axis, S0, D_MIN, 0, 90 + 2 * 15 + 1);
|
|
REQUIRE(right.has_value());
|
|
CHECK(right->measured_fraction >= right->asymptote_fraction - 0.01);
|
|
const auto wrong = ForecastSweepCoverage(p2, mono, x_axis, S0, D_MIN, 45, 45 + 90 + 2 * 15 + 1);
|
|
REQUIRE(wrong.has_value());
|
|
CHECK(wrong->measured_fraction < wrong->asymptote_fraction - 0.01);
|
|
CHECK(wrong->measured_fraction < right->measured_fraction - 0.01);
|
|
}
|
|
}
|
|
|
|
TEST_CASE("SweepCoverage_SecondSweepTilt", "[Rugnux][Spindle]") {
|
|
// theta_max = 15 deg: the double cones of half-angle 15 deg about two axes are disjoint once the
|
|
// axes are 30 deg apart, and overlap in a sliver just short of that.
|
|
const double tilt = SecondSweepTilt_deg(WVL, D_MIN, 0.0);
|
|
CHECK(tilt >= 25.0);
|
|
CHECK(tilt <= 30.0);
|
|
// A tolerance only shortens it, and a coarser limit (a narrower cone) needs less.
|
|
CHECK(SecondSweepTilt_deg(WVL, D_MIN, 0.01) <= tilt);
|
|
CHECK(SecondSweepTilt_deg(WVL, 2.0 * D_MIN, 0.0) < tilt);
|
|
}
|