From 4aaafe893fb9cc9ad1018ad9dd0ada8a5c64a750 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Sat, 21 Nov 2026 23:12:13 +0100 Subject: [PATCH] Doubled cell: merge the doubled cell whenever the added class stands clear, as the other answer Where the probe's half-integer class stood clear of its null but did not rise to a quarter of the lattice's intensity, the doubled-cell hypothesis returned before the doubled cell was merged, so the user got the half cell and no file for the other answer. Simulated superstructures with natural or scaled odd classes of 1-15 % (classes clear of the null at 10-30 standard errors) and natural depositions in the doubled cell all came out in the half cell with nothing beside it. The early return is gone: a class that stands clear is Bragg intensity of the doubled lattice, so the doubled cell is integrated and merged and written as _doubled.mtz (DOUBLED_CELL_* keys) whatever the adoption decides. A class also counts as clear on its own standard errors (three resolved shells at z >= 5 and twice the empty classes) where the probe's frames do not measure the lattice at 1 - on a sweep exposed to a single-frame near 1 at its edge exactly the shells where the class is clearest drop out of that reading. The adoption is not changed. Reading the rise on the class's own z instead of the lattice's probe was tried and adopts the doubled cell of 7mzt (class 0.24 -> 0.34 of the lattice, one translation explaining it), deposited in the half cell; the quarter bar and its lattice reading stay as they were. 6z9g, 9min, 9w3y, 9i0a, 2wnn (doubled) and 7dkp, 8qj5, 6pxc, 6oww, 9rcs (half) keep their cells. Simulated (kept images): six superstructure cases out of seven - three PDB depositions in the doubled cell and three scaled classes - now carry the _doubled merge beside the half-cell answer; the case whose class clears its null in one shell only and the controls without a class do not. Battery: of the 43 sets whose class stands clear, the doubled pass costs ~15-30 s on most (14 -> 32 s, 19 -> 45 s, 27 -> 52 s), 89 -> 190 s on a 266 A rhombohedral cell, which now merges a 532 A doubled cell without running out of card memory. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HVeDQrPqZ52Tp6rzzZGxf3 --- docs/CPU_DATA_ANALYSIS_INDEXING.md | 6 ++--- docs/RUGNUX_REPORT.md | 27 +++++++++++-------- rugnux/Rugnux.h | 3 +++ rugnux/RugnuxPasses.cpp | 43 +++++++++++++++++++++--------- tests/RugnuxTest.cpp | 8 ++++++ 5 files changed, 60 insertions(+), 27 deletions(-) diff --git a/docs/CPU_DATA_ANALYSIS_INDEXING.md b/docs/CPU_DATA_ANALYSIS_INDEXING.md index 7fac4ebb2..0d9bf65e8 100644 --- a/docs/CPU_DATA_ANALYSIS_INDEXING.md +++ b/docs/CPU_DATA_ANALYSIS_INDEXING.md @@ -265,9 +265,9 @@ spot at least as well, whatever the crystal. The pass therefore keeps the **smal scheme found it, and the larger one is decided where it can be, on integrated intensities: integrated on the smaller cell, the reflections an index-2 multiple adds are one of the supercell probe's half-integer classes, read against the six others as their null (see the -[report](RUGNUX_REPORT.md#index-2-superstructure)), and the doubled-cell hypothesis merges the larger -cell and adopts it where that class grows to a quarter of the lattice's intensity or holds it at every -resolution. An index-3 or index-4 pair is kept at its smaller cell and is not tested. A row shorter than the 10 Å +[report](RUGNUX_REPORT.md#index-2-superstructure)), and where that class stands clear of them the +doubled-cell hypothesis merges the larger cell beside the smaller one and adopts it where the class grows +to a quarter of the lattice's intensity or holds it at every resolution. An index-3 or index-4 pair is kept at its smaller cell and is not tested. A row shorter than the 10 Å floor of §5.2 needs no hypothesis of its own: the search offers its cell directly (§5.2). The reverse is also tried on every rotation first pass, because the FFT can only offer the cells its peaks diff --git a/docs/RUGNUX_REPORT.md b/docs/RUGNUX_REPORT.md index d18b7a054..fcea5561a 100644 --- a/docs/RUGNUX_REPORT.md +++ b/docs/RUGNUX_REPORT.md @@ -882,15 +882,20 @@ in: a crystal whose two halves are nearly alike (a pseudo-translation) is descri spots of further lattice domains can land on the half-integer positions too. A `TRUE` is also a warning under the `SUPERCELL_POSSIBLE` flag, and the summary's `Supercell` line carries the same advice. -**Both cells merged.** Where the class stands clear of the six empty ones out to the limit (in at least -three shells where it is measured above its noise and most of its reflections are resolved from the -lattice's, at more than twice the strongest of them in standard errors) and -grows significantly with resolution to a quarter of the lattice's intensity or more in the finest shell -both are measured in - the half cell holds at low resolution and not at high, the shape of a -pseudo-translation breaking down - the run integrates and merges the doubled cell as well, on the same -orientation and geometry, and decides with both merges in hand. The size of the class does not decide -it - crystals deposited in the half cell carry classes as strong as one deposited in the doubled cell. -The doubled cell is the answer where, in the doubled merge, one translation - half a cell plus a +**Both cells merged.** Where the class stands clear of the six empty ones out to the limit, the run +integrates and merges the doubled cell as well, on the same orientation and geometry, writes both, and +decides with both merges in hand which one is the answer. Clear means: in at least three shells most of +the class's reflections are resolved from the lattice's and it stands at more than twice the strongest of +the six in standard errors, and either the lattice's own reflections are measured there on the probe's +frames ( 1) with the class above its noise, or the class reads five of its own standard errors - +on a sweep exposed to a single-frame near 1 at its edge the lattice is not measured in exactly the +shells where the class is clearest. Such a class is Bragg intensity of the doubled lattice whichever cell +is adopted, and which one to refine in is not always the data's call: crystals deposited in the doubled +cell carry classes from about 1 % to 15 % of the lattice, as weak as ones deposited in the half cell. +The doubled cell is the answer where the class grows significantly with resolution to a quarter of the +lattice's intensity or more in the finest shell where both are measured (the lattice at 1 on the +probe's frames) - the half cell holds at low resolution and not at high, the shape of a +pseudo-translation breaking down - and where, in the doubled merge, one translation - half a cell plus a small offset, fitted over the class - modulates at least half of the added class in every resolution shell, so the two halves of the cell are one content displaced - and where the doubled merge is not more symmetric than the half cell's, which a superstructure of it cannot be. A class that is there whatever the @@ -906,8 +911,8 @@ decides it. The log also names every class that stands clear of its null; the classes a superstructure occupies form a group with `0 0 0`, so where two do, their sum must as well - two that do not close mean the second is not the crystal's, three that do describe an index-4 cell, which is reported and not merged. -On a sweep too weak for the probe's 60 frames to measure the lattice's own reflections in any shell, the -probe cannot read the rise; there the class only has to stand clear of the six empty ones, its z pooled +On a sweep too weak for the probe's 60 frames to measure the lattice's own reflections ( 1) in any +shell, the probe does not read the rise; there the class only has to stand clear of the six empty ones, its z pooled over the shells from the coarsest down (at least two, a combined z of 5 and twice the strongest empty class's pooled the same way), the doubled cell is merged, and the rise is read on the doubled merge instead - the added class against the lattice's own mean intensity, shell by shell, with the same test - before the same symmetry test and diff --git a/rugnux/Rugnux.h b/rugnux/Rugnux.h index 89dd91128..6100a3181 100644 --- a/rugnux/Rugnux.h +++ b/rugnux/Rugnux.h @@ -1153,6 +1153,9 @@ std::string RefinedPassIsWorse(const ProcessResult &pass1, const ProcessResult & // Rises: the class grows significantly with resolution, the shape of a pseudo-translation breaking down; // empty where it does not, otherwise the reason in the words the run reports it in. bool DoubledCellWorthMerging(const ProcessResult::SupercellClass &sc); +// Whether the class is Bragg intensity of the doubled lattice on its own standard errors, whatever the probe +// frames' exposure: the doubled cell is then merged as the other answer even where the rise cannot be read. +bool DoubledCellStandsClear(const ProcessResult::SupercellClass &sc); std::string DoubledCellRises(const ProcessResult::SupercellClass &sc); // Lattice: the class is part of the lattice the half cell misses - a quarter of its intensity or more in // every measured shell. Empty where it is not, otherwise the reason in the words the run reports it in. diff --git a/rugnux/RugnuxPasses.cpp b/rugnux/RugnuxPasses.cpp index 4afcc4610..a99c03e76 100644 --- a/rugnux/RugnuxPasses.cpp +++ b/rugnux/RugnuxPasses.cpp @@ -1914,6 +1914,20 @@ bool DoubledCellWorthMerging(const ProcessResult::SupercellClass &sc) { return clear >= 3; } +bool DoubledCellStandsClear(const ProcessResult::SupercellClass &sc) { + // Whether the class is Bragg intensity of the doubled lattice at all, so the doubled cell is merged as + // the other answer: in at least three shells most of it is resolved from the lattice and it reads five of + // its own standard errors and more than twice the strongest of the six empty classes. Not asked: the + // lattice's on the probe's frames (DoubledCellShellMeasured), which measures the frames' + // exposure and not the class - a sweep exposed to a single-frame of 1 at its edge drops + // exactly the shells where a class rising from 0.016 to 0.34 of the lattice stands at 8-28 standard + // errors. That reading stays with the adoption below, which it calibrates. + int clear = 0; + for (const auto &sh : sc.trend) + clear += sh.z >= 5.0 && sh.resolved >= 0.5 && sh.z > 2.0 * sh.sibling_z; + return clear >= 3; +} + std::string DoubledCellRises(const ProcessResult::SupercellClass &sc) { // From the coarsest shell to the finest one both are measured in, the class has to grow by three // standard errors of the difference, and end at a quarter of the lattice's intensity or more. The @@ -2231,16 +2245,20 @@ ProcessResult Rugnux::DoubledCellHypothesis(RugnuxObserver *observer, ProcessRes // Two ways in. The probe measures the class against a lattice it measures too, and the rise is read // there (DoubledCellWorthMerging); or the sweep is too weak for the probe's frames to measure the // lattice at all, and the class only stands clear of the six empty ones - then the rise is read on the - // doubled merge (DoubledCellWorthMergingWeak, MergedDoubledClassTrend). + // doubled merge (DoubledCellWorthMergingWeak, MergedDoubledClassTrend). Where neither reads the rise but + // the class stands clear on its own standard errors (DoubledCellStandsClear), the doubled cell is merged + // as the other answer only. const bool on_probe = DoubledCellWorthMerging(*half.supercell); const bool on_merge = !on_probe && DoubledCellWorthMergingWeak(*half.supercell); - if (!on_probe && !on_merge) + if (!on_probe && !on_merge && !DoubledCellStandsClear(*half.supercell)) return half; Logger logger("Rugnux"); const auto &sc = *half.supercell; - // Only a class that could be adopted is worth the pass: one that does not rise with resolution keeps - // the half cell whatever the doubled merge shows, and a doubled merge of a large crystal is not free - // (measured: an R-centred 531 A cell ran the card out of memory). + // Whether the class could be adopted is read on the probe here, but the doubled cell is merged either + // way: a class that stands clear of its null is Bragg intensity of the doubled lattice, and which cell + // to refine in is the user's call where the class does not decide it - crystals deposited in the + // doubled cell carry classes from about 1 % to 15 % of the lattice, as weak as ones deposited in the + // half cell. So both merges are written whatever the adoption below decides. std::string rises = on_probe ? DoubledCellRises(sc) : std::string(); const std::string lattice_class = on_probe ? DoubledCellIsLattice(sc) : std::string(); if (sc.occupied.size() >= 2) @@ -2249,12 +2267,6 @@ ProcessResult Rugnux::DoubledCellHypothesis(RugnuxObserver *observer, ProcessRes sc.closed ? "close into a group with their sum" : "do not close (their sum is empty)", sc.h, sc.k, sc.l, sc.closed ? "; the index-4 cell the three describe is not merged" : ""); - if (on_probe && rises.empty() && lattice_class.empty()) { - logger.Info("Doubled-cell hypothesis: the half-integer class {} {} {} stands clear of the other classes but " - "does not grow with resolution to a quarter of the lattice's intensity, so the half cell describes " - "the crystal at high resolution too - not merged", sc.h, sc.k, sc.l); - return half; - } // The lattice the probed cell was integrated on, doubled along the class, with everything else of // that indexing - orientation, geometry, axis - kept, so the two merges differ by the cell alone. @@ -2386,9 +2398,14 @@ ProcessResult Rugnux::DoubledCellHypothesis(RugnuxObserver *observer, ProcessRes : !lattice_class.empty() && symmetry_raised ? fmt::format("the probed cell stands: {}, but the doubled merge reads {}, more symmetric than the " "half cell's {}", lattice_class, d.space_group->xhm(), half.space_group->xhm()) + : !on_probe && !on_merge + ? std::string("the probed cell stands: the added class stands clear of its null, but the probe's frames " + "do not measure the lattice in enough shells to read how it grows with resolution - the " + "doubled cell is the other answer") : rises.empty() - ? std::string("the probed cell stands: the added class, read on the doubled merge, does not grow with " - "resolution to a quarter of the lattice's intensity") + ? fmt::format("the probed cell stands: the added class, read on the {}, does not grow with resolution to " + "a quarter of the lattice's intensity, so the half cell describes the crystal at high " + "resolution too", on_merge ? "doubled merge" : "probe") : adopt && on_merge ? fmt::format("{}; and one pseudo-translation accounts for most of it over all shells ({:.2f} +- {:.2f}, " "at least half two standard errors down)", rises, tr.share, tr.share_se) diff --git a/tests/RugnuxTest.cpp b/tests/RugnuxTest.cpp index e96d5175f..d2454517f 100644 --- a/tests/RugnuxTest.cpp +++ b/tests/RugnuxTest.cpp @@ -622,6 +622,14 @@ TEST_CASE("DoubledCellDecision", "[process]") { const auto breaks_down = trend({{0.02, 17, 18}, {0.10, 38, 7}, {0.26, 36, 6}, {0.35, 45, 2.4}, {0.46, 33, 0.8}}); CHECK(DoubledCellWorthMerging(breaks_down)); CHECK(!DoubledCellRises(breaks_down).empty()); + // The same breakdown on a sweep exposed to a single-frame near 1 at its edge: the class stands + // clear on its own standard errors, so the doubled cell is merged beside the answer, but the rise is read + // only where the lattice is measured, and there it has not reached a quarter. + const auto breaks_down_weak = trend({{0.016, 18, 21}, {0.05, 27, 8.7}, {0.14, 29, 3.8}, {0.26, 28, 0.96}, + {0.34, 8, 0.04}, {0.10, 1.2, -0.03}}); + CHECK(DoubledCellStandsClear(breaks_down_weak)); + CHECK(DoubledCellRises(breaks_down_weak).empty()); + CHECK(!DoubledCellStandsClear(trend({{0.01, 4, 20}, {0.02, 5, 10}, {0.03, 2, 5}, {0.05, 1, 2}}))); // A class that stays a tenth of the lattice at every resolution: merged as well, but it does not rise. const auto flat = trend({{0.09, 10, 70}, {0.11, 23, 28}, {0.10, 24, 33}, {0.11, 24, 18}, {0.10, 23, 8}}); CHECK(DoubledCellWorthMerging(flat));