From 16d9a8b82e6516b6aa4117b9552fb74f105275a1 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Sun, 15 Nov 2026 03:39:51 +0100 Subject: [PATCH 1/4] A fixed space group fixes the lattice: index in its class, never promote With -S the lattice is put in the Bravais class of the user's group at indexing (LatticeSearchForGroup) instead of the most symmetric class the metric supports, and nothing promotes or demotes it afterwards: no centring the group does not have, no metrically-hexagonal re-expression, no length-equality demotion pass, no triclinic pseudo-symmetry adoption. A primitive group on a lattice with no primitive cell of its system (P2 on a C-centred monoclinic lattice, P3 on a rhombohedral one) is put on the centred cell of that system taken as primitive, so the positions the centring extinguishes are predicted and merged as asked. Stills with a group but no cell follow the same rule. Without -S every path is unchanged. On a triclinic small-molecule set whose metric is monoclinic C (-C -S P1) the lattice stays triclinic through indexing, refinement, integration and merging, P 1 on the given setting, where forcing the monoclinic-C metric gave an unusable merge. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01UqXYdJDrM65gxsCn2PrbfK --- image_analysis/IndexAndRefine.cpp | 4 ++- .../lattice_search/LatticeSearch.cpp | 20 ++++++++++++ image_analysis/lattice_search/LatticeSearch.h | 7 +++++ .../rotation_indexer/RotationIndexer.cpp | 31 +++++++++---------- tests/LatticeSearchTest.cpp | 30 ++++++++++++++++++ 5 files changed, 74 insertions(+), 18 deletions(-) diff --git a/image_analysis/IndexAndRefine.cpp b/image_analysis/IndexAndRefine.cpp index afdd25420..4c8ff1155 100644 --- a/image_analysis/IndexAndRefine.cpp +++ b/image_analysis/IndexAndRefine.cpp @@ -370,7 +370,9 @@ IndexAndRefine::IndexingOutcome IndexAndRefine::DetermineLatticeAndSymmetry(Data }; outcome.lattice_candidate = latt; } else { - auto sym_result = LatticeSearch(latt); + // A space group given without a cell still names the lattice's class (LatticeSearchForGroup). + const auto fixed = sg ? LatticeSearchForGroup(latt, *sg) : std::nullopt; + const auto sym_result = fixed ? *fixed : LatticeSearch(latt); outcome.symmetry = LatticeMessage{ .centering = sym_result.centering, .niggli_class = sym_result.niggli_class, diff --git a/image_analysis/lattice_search/LatticeSearch.cpp b/image_analysis/lattice_search/LatticeSearch.cpp index de3e127c3..505992cdd 100644 --- a/image_analysis/lattice_search/LatticeSearch.cpp +++ b/image_analysis/lattice_search/LatticeSearch.cpp @@ -547,6 +547,26 @@ std::optional LatticeSearchForClass(const CrystalLattice &L } +std::optional LatticeSearchForGroup(const CrystalLattice &L, const gemmi::SpaceGroup &sg) { + const char centring = sg.centring_type(); + const auto system = sg.crystal_system(); + const auto lattice_system = system == gemmi::CrystalSystem::Trigonal && centring == 'P' + ? gemmi::CrystalSystem::Hexagonal : system; + if (auto r = LatticeSearchForClass(L, lattice_system, centring)) + return r; + // A primitive group on a lattice with no primitive cell of the group's system - P 2 on a C-centred + // monoclinic lattice, P 3 on a rhombohedral one - is described on a centred cell of that system + // taken as primitive: the positions the centring extinguishes are then predicted and merged, as + // the group asks, and carry no intensity. + if (centring == 'P') + for (const char c : {'C', 'A', 'B', 'I', 'F', 'R'}) + if (auto r = LatticeSearchForClass(L, c == 'R' ? gemmi::CrystalSystem::Trigonal : system, c)) { + r->centering = 'P'; + return r; + } + return std::nullopt; +} + int LatticePointGroupOrder(gemmi::CrystalSystem system) { switch (system) { case gemmi::CrystalSystem::Monoclinic: return 2; diff --git a/image_analysis/lattice_search/LatticeSearch.h b/image_analysis/lattice_search/LatticeSearch.h index 5cf6588b6..da6ee8451 100644 --- a/image_analysis/lattice_search/LatticeSearch.h +++ b/image_analysis/lattice_search/LatticeSearch.h @@ -50,6 +50,13 @@ std::optional LatticeSearchForClass(const CrystalLattice& L // Order of the lattice point group, so "lower symmetry" is a well-defined comparison // (gemmi's enum orders Trigonal after Tetragonal, which have 6 and 8 rotations). +// The lattice of a space group the user fixed, searched for in L's metric: L is put in the setting of +// the group's own Bravais class and never promoted past it (a P 1 run stays triclinic on a metrically +// monoclinic cell). A trigonal-P group sits on a hexagonal-P lattice; a primitive group the lattice +// has no primitive cell for is put on a centred cell of its system, labelled 'P'. Empty where the +// metric cannot carry the group's system at all. +std::optional LatticeSearchForGroup(const CrystalLattice &L, const gemmi::SpaceGroup &sg); + int LatticePointGroupOrder(gemmi::CrystalSystem system); // Whether the conventional metric of this class asserts an equality between cell LENGTHS (a = b, and diff --git a/image_analysis/rotation_indexer/RotationIndexer.cpp b/image_analysis/rotation_indexer/RotationIndexer.cpp index fa6c7e111..a2d0a5ec3 100644 --- a/image_analysis/rotation_indexer/RotationIndexer.cpp +++ b/image_analysis/rotation_indexer/RotationIndexer.cpp @@ -313,17 +313,16 @@ void RotationIndexer::RunIndexingLocked() { // conventional hexagonal axes (LatticeSearch can land on the ortho-hexagonal C setting) so the // 3-fold is not hidden from scaling. // - // A user-fixed space group is deliberately NOT stamped on here. The group names the symmetry; - // it does not say which basis the FFT candidate came back in, and the conventional cell above - // was reduced for whatever class the METRIC matched. Relabelling that cell with the group's - // system and centring leaves the constrained refine snapping the wrong angles to the ideal - // ones: measured, a C-centred orthorhombic cell relabelled primitive monoclinic indexed 1 of - // 60 validation frames and an F-cubic one relabelled trigonal indexed 0 of 60, where the same - // frames index at 36/60 and 51/60 without a group. The group is applied where it belongs - to - // the scaling and the merge. + // A space group the user fixed decides the class: its own Bravais lattice is searched for in + // the candidate's metric (LatticeSearchForGroup), so the candidate is put in that class's + // setting rather than relabelled, and no promotion past it - a centring the group does not + // have, a metrically hexagonal cell - fires. Only where the metric cannot carry the group's + // class does the metric decide, and the scaling then reports the conflict. const bool demote_class = experiment.GetIndexingSettings().GetLatticeClassDemoted(); + const auto &fixed_sg = experiment.GetGemmiSpaceGroup(); auto build_sr = [&](const CrystalLattice &cand) -> LatticeSearchResult { - auto ls = LatticeSearch(cand); + const auto fixed = fixed_sg ? LatticeSearchForGroup(cand, *fixed_sg) : std::nullopt; + auto ls = fixed ? *fixed : LatticeSearch(cand); // The other hypothesis about a promotion that rests on a = b: walk the characters again // granting NO length equality at all, and take the class the metric carries on its angles // alone. Not the same as striking one class out - the tetragonal-P lattice also has a @@ -331,7 +330,7 @@ void RotationIndexer::RunIndexingLocked() { // very equality in question. The caller runs this as its own pass and keeps whichever pass // realises the lower held-out positional residual. The hexagonal re-expression below is a // promotion of the same kind, so it is not applied here. - if (demote_class && ClassImposesLengthEquality(ls.system)) + if (!fixed && demote_class && ClassImposesLengthEquality(ls.system)) return LatticeSearch(cand, /*dist_tolerance=*/0.0); // A primitive hexagonal lattice is written in ONE setting, the one derived from its reduced // cell, whichever route named the class. Its twelve equivalent settings are the same @@ -340,7 +339,7 @@ void RotationIndexer::RunIndexingLocked() { // under them, so a setting chosen afresh from each pass's strained cell lets the two // passes differ in setting and the guard compare rows that are not the same rows. if ((ls.system == gemmi::CrystalSystem::Hexagonal && ls.centering == 'P') - || (!IsHexagonalSystem(ls.system) && IsMetricallyHexagonal(ls.primitive_reduced))) { + || (!fixed && !IsHexagonalSystem(ls.system) && IsMetricallyHexagonal(ls.primitive_reduced))) { ls.conventional = HexagonalConventional(ls.primitive_reduced); ls.system = gemmi::CrystalSystem::Hexagonal; ls.centering = 'P'; @@ -416,12 +415,10 @@ void RotationIndexer::RunIndexingLocked() { const auto conv_uc = w.sr.conventional.GetUnitCell(); const float length_bound_A = 1.2f * static_cast(std::max({conv_uc.a, conv_uc.b, conv_uc.c})); w.constrained = make_data(w.sr.conventional, w.sr.system, length_bound_A); - // Pseudo-symmetry guard: also refine unconstrained (triclinic) on the primitive cell. Run it - // with a user-fixed space group too. The metric promotion the constrained refine acts on is - // decided by the geometry, not by the group, so it can be false whether or not a group was - // given - and without this cell there is nothing to catch it with, which is how a fixed - // group turned crystals the de-novo path indexes at 60/60 into runs that index none. - w.has_tri = (w.sr.system != gemmi::CrystalSystem::Triclinic); + // Pseudo-symmetry guard: also refine unconstrained (triclinic) on the primitive cell, which + // catches a false metric promotion. With a space group the user fixed there is no + // promotion to catch - the class is the group's - and no other lattice may be adopted. + w.has_tri = !fixed_sg && w.sr.system != gemmi::CrystalSystem::Triclinic; if (w.has_tri) w.tri = make_data(w.sr.primitive_reduced, gemmi::CrystalSystem::Triclinic, length_bound_A); w.viable = true; diff --git a/tests/LatticeSearchTest.cpp b/tests/LatticeSearchTest.cpp index 72bafb701..f8f2217c5 100644 --- a/tests/LatticeSearchTest.cpp +++ b/tests/LatticeSearchTest.cpp @@ -756,3 +756,33 @@ TEST_CASE("AngleEqualityDeparture_deg measures what an orthorhombic promotion of tetra.system = gemmi::CrystalSystem::Tetragonal; CHECK(AngleEqualityDeparture_deg(tetra, sr.primitive_reduced) == 0.0); } + +TEST_CASE("LatticeSearch - a given triclinic cell that is metrically monoclinic C is honoured in P1") { + // A triclinic cell, Niggli-reduced, whose metric carries a two-fold: the same lattice is C-centred + // monoclinic, 21.0 6.3 9.8 90 106 90, and that is what the metric alone names it. + const CrystalLattice given(UnitCell(6.3, 9.8, 10.9623, 105.3083, 106.6992, 90.0)); + const auto by_metric = LatticeSearch(given); + CHECK(by_metric.system == gemmi::CrystalSystem::Monoclinic); + CHECK(by_metric.centering == 'C'); + + // Fixed in P 1 the lattice is not promoted: it stays triclinic, on the given cell. + const auto p1 = LatticeSearchForGroup(given, gemmi::SpaceGroup(*gemmi::find_spacegroup_by_name("P 1"))); + REQUIRE(p1.has_value()); + CHECK(p1->system == gemmi::CrystalSystem::Triclinic); + CHECK(p1->centering == 'P'); + check_uc(p1->conventional.GetUnitCell(), 6.3, 9.8, 10.9623, 105.3083, 106.6992, 90.0, 1e-3, 1e-2); + + // Fixed in C 2 it is put in the group's own class. + const auto c2 = LatticeSearchForGroup(given, gemmi::SpaceGroup(*gemmi::find_spacegroup_by_name("C 1 2 1"))); + REQUIRE(c2.has_value()); + CHECK(c2->system == gemmi::CrystalSystem::Monoclinic); + CHECK(c2->centering == 'C'); + + // Fixed in P 2, a group the lattice has no primitive monoclinic cell for: it is put on the C-centred + // cell taken as primitive, twice the volume, so the positions the centring extinguishes are kept. + const auto p2 = LatticeSearchForGroup(given, gemmi::SpaceGroup(*gemmi::find_spacegroup_by_name("P 1 2 1"))); + REQUIRE(p2.has_value()); + CHECK(p2->system == gemmi::CrystalSystem::Monoclinic); + CHECK(p2->centering == 'P'); + CHECK(std::abs(p2->conventional.CalcVolume()) == Catch::Approx(2.0 * std::abs(given.CalcVolume())).epsilon(1e-3)); +} From 1b8667e317ba6967fc6b5c1d17aa8edb0dc1aae2 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Sun, 15 Nov 2026 03:39:51 +0100 Subject: [PATCH 2/4] Auto mode: a triclinic winner on a centred lattice is merged on the primitive cell P 1 has no centred setting in the group table, so when the space-group search finds no symmetry on a lattice indexed centred it won on the centred cell itself and kept the positions the centring adds as observations. It now goes through the existing doubled-cell reduction with the lattice's centring. Only runs without -S that end triclinic on a centred lattice change; none in the reference battery runs does. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01UqXYdJDrM65gxsCn2PrbfK --- rugnux/RugnuxScaleMerge.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/rugnux/RugnuxScaleMerge.cpp b/rugnux/RugnuxScaleMerge.cpp index ea07e8a7c..e8861fda4 100644 --- a/rugnux/RugnuxScaleMerge.cpp +++ b/rugnux/RugnuxScaleMerge.cpp @@ -3155,12 +3155,26 @@ bool Rugnux::ScaleMergeAndSymmetry(PipelineLocals &p) { // search there. The enumeration is untouched, so no candidate that JUDGES another moves and // no chi2 reference changes; the doubled setting still wins its own table, and only the cell // its answer is expressed on is corrected. + // + // P 1 is the same case without the signal. The table has no centred setting of it, so on a + // centred lattice whose intensities carry no symmetry it wins on the centred cell itself and + // keeps the positions the centring adds as observations - measured, 0.28 on them + // against 7.0 on the lattice's own nodes, half the merge noise. The lattice's centring stands + // in for the group's there. + const char indexed_centring = end_msg.rotation_lattice_type.has_value() + ? end_msg.rotation_lattice_type->centering : 'P'; + const bool triclinic_on_centred = sg_search.best_space_group.has_value() + && sg_search.best_space_group->crystal_system() == gemmi::CrystalSystem::Triclinic + && indexed_centring != 'P'; if (!commit_reindex && sg_search.best_space_group.has_value() - && sg_search.best_space_group->number > 1 + && (sg_search.best_space_group->number > 1 || triclinic_on_centred) && end_msg.rotation_lattice.has_value() && end_msg.rotation_lattice_type.has_value()) { const gemmi::SpaceGroup won = *sg_search.best_space_group; constexpr double den3 = static_cast(gemmi::Op::DEN) * gemmi::Op::DEN * gemmi::Op::DEN; - const double det = won.basisop().det_rot() / den3; + const double det = triclinic_on_centred + ? 1.0 / (indexed_centring == 'F' ? 4 : indexed_centring == 'R' ? 3 : 2) + : won.basisop().det_rot() / den3; + const char centring = triclinic_on_centred ? indexed_centring : won.centring_type(); const int multiple = static_cast(std::lround(1.0 / det)); // 2 for C 1 1 2_1, 4 for F 1 if (det < 0.99 && multiple >= 2 && multiple <= 4) { // Reduce, then classify. The character table is reached through a Niggli reduction @@ -3171,7 +3185,7 @@ bool Rugnux::ScaleMergeAndSymmetry(PipelineLocals &p) { // too (that is how it got here), and an unrestricted search would hand it straight // back. const auto cand = LatticeSearchForClass( - end_msg.rotation_lattice->ToPrimitive(won.centring_type()), + end_msg.rotation_lattice->ToPrimitive(centring), won.crystal_system(), 'P'); // Change of basis from the doubled conventional setting straight to the reduced one, // P[i][j] = conv_real[i] . doubled_reciprocal[j], as everywhere else here - except From 304f2556acb8082cb9425def411db67f815e9f63 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Sun, 15 Nov 2026 07:28:04 +0100 Subject: [PATCH 3/4] A fixed space group: no sub-lattice or long-axis change, and -C sets the axes With -S the first pass no longer asks the sub-lattice / twin-composite hypothesis or the long-axis hypothesis: the lattice, its volume included, is the one the group's class gave at indexing. With -C as well, a group whose axes are not all alike is put on the given cell's axes rather than on the axes the absences prefer, so the written cell is the user's setting (P2/c forced on a C2/c crystal keeps a and c as given instead of swapping them). Runs without -S are unchanged. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01UqXYdJDrM65gxsCn2PrbfK --- rugnux/RugnuxFirstPassRescues.cpp | 7 +++++-- rugnux/RugnuxScaleMerge.cpp | 20 +++++++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/rugnux/RugnuxFirstPassRescues.cpp b/rugnux/RugnuxFirstPassRescues.cpp index 54eeacc0f..8b403339a 100644 --- a/rugnux/RugnuxFirstPassRescues.cpp +++ b/rugnux/RugnuxFirstPassRescues.cpp @@ -212,7 +212,7 @@ void Rugnux::FirstPassRun::StartLongAxisSearch(std::unique_ptr indexing_bound_A)) @@ -273,7 +273,7 @@ void Rugnux::FirstPassRun::JoinLongAxisSpeculation() { // Not when a cell was given: the standard pass was already sized for it (RaiseFFTBoundForKnownCell). auto Rugnux::FirstPassRun::LongAxisHypothesis(FirstPass standing) -> FirstPass { JoinLongAxisSpeculation(); - if (rx.cancelled_ || rx.experiment_.GetUnitCell().has_value()) + if (rx.cancelled_ || rx.experiment_.GetUnitCell().has_value() || rx.user_fixed_sg_) return standing; const auto start = std::chrono::steady_clock::now(); const LongAxisReach reach = LongAxisBound(); @@ -961,6 +961,9 @@ namespace { } auto Rugnux::FirstPassRun::SubLatticeHypothesis(FirstPass best) -> FirstPass { + // A space group the user fixed fixes the lattice, its volume included. + if (rx.user_fixed_sg_) + return best; // Asked again of each sub-lattice it adopts: a cell doubled along two or three axes is a sub-lattice // of index 4 or 8, reached one halving at a time. Each cell on the way is first asked whether it is // the coincidence lattice of two twin domains: two domains of a cell take fewer nodes than any diff --git a/rugnux/RugnuxScaleMerge.cpp b/rugnux/RugnuxScaleMerge.cpp index e8861fda4..4dcd8a49c 100644 --- a/rugnux/RugnuxScaleMerge.cpp +++ b/rugnux/RugnuxScaleMerge.cpp @@ -1197,14 +1197,24 @@ bool Rugnux::ScaleMergeAndSymmetry(PipelineLocals &p) { axial.reserve(summed.size()); for (const auto &[hkl, sum] : summed) axial.push_back({hkl, sum.first / std::sqrt(sum.second)}); - const gemmi::Op cob = SeatGroupByAbsences(*result.consensus_cell, *user_fixed_sg_, axial); + // With the cell given too, the setting is the user's: the cell goes onto the given cell's axes. + gemmi::Op cob = gemmi::Op::identity(); + if (user_cell_) { + const auto ops = CellMappingOperators(gemmi::UnitCell(*result.consensus_cell), gemmi::UnitCell(*user_cell_)); + if (!ops.empty()) + cob = ops.front(); + } else + cob = SeatGroupByAbsences(*result.consensus_cell, *user_fixed_sg_, axial); if (!(cob == gemmi::Op::identity())) { reseat_integrated(cob); const auto &uc = *result.consensus_cell; - logger.Info("The fixed space group {} names its symmetry elements by axis, and the absences " - "on the {} axial and zonal reflections put them on other axes of this cell than " - "the indexing did: reindexed by {} to a={:.3f} b={:.3f} c={:.3f} alpha={:.2f} " - "beta={:.2f} gamma={:.2f}", user_fixed_sg_->xhm(), axial.size(), + const std::string why = user_cell_ + ? std::string("the given cell puts them on other axes") + : fmt::format("the absences on the {} axial and zonal reflections put them on other axes", + axial.size()); + logger.Info("The fixed space group {} names its symmetry elements by axis, and {} of this cell " + "than the indexing did: reindexed by {} to a={:.3f} b={:.3f} c={:.3f} alpha={:.2f} " + "beta={:.2f} gamma={:.2f}", user_fixed_sg_->xhm(), why, IndexTriplet(HklOperator(cob)), uc.a, uc.b, uc.c, uc.alpha, uc.beta, uc.gamma); } } From 506e4bd8dd42aa13eb077d824288efb476adba48 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Sun, 15 Nov 2026 07:53:45 +0100 Subject: [PATCH 4/4] -C without -S: angles read literally, a cell with no 90/120 deg angle is P 1 A cell given with -C and no -S is taken at its word: an angle is 90 or 120 deg only where it was typed so. A cell with no such angle, and not three equal angles (rhombohedral), names a triclinic lattice, so the run fixes P 1 and keeps the lattice and setting exactly as -S P1 does. Cells with a typed 90 or 120 deg, and runs without -C, are unchanged. docs/RUGNUX_CLI.md: the -C and -S rules (fixed group = lattice and setting kept; literal -C angles). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01UqXYdJDrM65gxsCn2PrbfK --- docs/RUGNUX_CLI.md | 4 ++-- rugnux/rugnux_cli.cpp | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/RUGNUX_CLI.md b/docs/RUGNUX_CLI.md index 7da5065ff..924816198 100644 --- a/docs/RUGNUX_CLI.md +++ b/docs/RUGNUX_CLI.md @@ -269,10 +269,10 @@ For very long axes the direction grid's angular resolution binds well below 500 | `--force-still` | Treat a rotation (goniometer) dataset as independent stills instead of rotation; several masters are then read as one stills run | | `-X, --indexing-algorithm ` | `Auto` (default) \| `FFT` \| `cuFFT` \| `FFTW` \| `FFBIDX` \| `None`, case-insensitive. `FFT` is the de-novo FFT search, on the GPU (cuFFT) where there is one and `--no-gpu` is not given, otherwise on the CPU (FFTW); `cuFFT` and `FFTW` name one implementation each; `cuFFT` needs a GPU and is refused without one. `FFBIDX` (known cell, `-C`) runs on the GPU where there is one and otherwise on the CPU. `Auto` takes `FFBIDX` on stills with a known cell, and `FFT` otherwise. `FFBIDX` without a cell (`-C`, or one from `-z`) resolves to `None` and indexes nothing, with no error. On rotation data `-X` is not consulted: the FFT search runs on the GPU where there is one and on the CPU otherwise, so `Auto`, `FFT`, `cuFFT` (with a GPU) and `FFTW` (without one, or under `--no-gpu`) are accepted and any other value stops the run at indexing; `FFBIDX` and `None` are for stills | | `-F` | Short for `-X FFT`, kept for old command lines | -| `-C, --unit-cell ` | Reference unit cell `"a,b,c,alpha,beta,gamma"` (required by `ffbidx`). On rotation data it also widens the FFT search to cover the cell given, at both ends: the longest axis looked for is raised to reach it, and `--fft-min-unit-cell` is lowered to admit it. A candidate that is an integer supercell of the cell given (a twin's coincidence lattice, a row taken at a multiple of its length) is stepped down to it. On stills the run always uses it: the geometry refinement takes it as a prior (1 % on the lengths, 1° on the angles the crystal system leaves free), and the log warns - with both numbers - where the frames refine its shape more than 3 % / 3° away, or where a sample of frames indexed de novo puts materially more spots on the lattice than the cell given ([§7.7](CPU_DATA_ANALYSIS_INDEXING.md#77-stills-a-given-cell-and-the-detector-modules)) | +| `-C, --unit-cell ` | Reference unit cell `"a,b,c,alpha,beta,gamma"` (required by `ffbidx`). On rotation data it also widens the FFT search to cover the cell given, at both ends: the longest axis looked for is raised to reach it, and `--fft-min-unit-cell` is lowered to admit it. A candidate that is an integer supercell of the cell given (a twin's coincidence lattice, a row taken at a multiple of its length) is stepped down to it. On stills the run always uses it: the geometry refinement takes it as a prior (1 % on the lengths, 1° on the angles the crystal system leaves free), and the log warns - with both numbers - where the frames refine its shape more than 3 % / 3° away, or where a sample of frames indexed de novo puts materially more spots on the lattice than the cell given ([§7.7](CPU_DATA_ANALYSIS_INDEXING.md#77-stills-a-given-cell-and-the-detector-modules)). Without `-S` the angles are read literally: an angle is 90° or 120° only where it is typed so (`90` or `90.00`, not `90.03`). A cell with no such angle, and not three equal angles, names a triclinic lattice, and the run behaves as with `-S P1` | | `--fft-min-unit-cell ` | Shortest cell axis the FFT search accepts, Å (default: 10; accepted 5-40). A candidate with a shorter axis is discarded — but on rotation data a row shorter than the floor, down to 3 Å, is recognised under the multiple of it the search reports past the floor, so a small-molecule cell is indexed without this flag. `-C` lowers the floor on its own to cover the cell given. On stills a crystal below the floor cannot be indexed unless this is lowered | | `--min-indexed-spots ` | Spots a frame must have on the lattice before it counts as indexed (default: 6, minimum 4). It sets the reported indexing rate and the count the rotation first pass ranks candidate lattices by; whether the run has a lattice at all is decided on the pooled spots instead ([§4.1](CPU_DATA_ANALYSIS_INDEXING.md#41-indexed-spot-decision-inlier-test)), and integration is not gated by it | -| `-S, --space-group ` | Space group number (`96`) or Hermann-Mauguin symbol (`P43212`) — for indexing and scaling. On serial stills whose group admits two indexings, it also lets the crystals be put on one from the data ([the indexing ambiguity](RUGNUX_ADVANCED.md#the-indexing-ambiguity)) | +| `-S, --space-group ` | Space group number (`96`) or Hermann-Mauguin symbol (`P43212`) — for indexing and scaling. On serial stills whose group admits two indexings, it also lets the crystals be put on one from the data ([the indexing ambiguity](RUGNUX_ADVANCED.md#the-indexing-ambiguity)). A fixed group fixes the lattice: indexing puts the crystal in the group's own Bravais class and nothing promotes, demotes, reduces or doubles it afterwards. A primitive group on a lattice with no primitive cell of its system (P2 on a C-centred monoclinic crystal, P3 on a rhombohedral one) is merged on the centred cell, and the positions the centring extinguishes are kept (they read about zero). With `-C` as well, the cell is written on the given cell's axes | | `-r, --geom-refine ` | Geometry refinement: `none` \| `orientation` \| `beam_and_lattice` (default; on rotation data restrained toward the sweep's geometry, [§7.4](CPU_DATA_ANALYSIS_INDEXING.md#74-multi-stage-tightening-of-inlier-tolerance)) \| `flex` (try all three per image, keep whichever indexes the most spots; alias `multi`) | | `-R, --two-pass-rotation[=num]` | Two-pass offline rotation indexing (default for goniometer data; optional first-pass image count, default 100) | | `--force-rotation-lattice ` | Force rotation lattice (9 floats, Å), skipping the first pass | diff --git a/rugnux/rugnux_cli.cpp b/rugnux/rugnux_cli.cpp index 5d1cb6a2a..ea83ffeb2 100644 --- a/rugnux/rugnux_cli.cpp +++ b/rugnux/rugnux_cli.cpp @@ -1943,6 +1943,19 @@ int RugnuxInputRun::PrepareRugnuxInput() { : fmt::format("no GPU visible - {} CPU threads, which is much slower", nthreads)); console->Rule('-'); + // A cell given with -C and no -S is read literally: an angle is 90 or 120 deg only where it was + // typed so. A cell with no such angle, and not the three equal angles of a rhombohedral cell, names + // a triclinic lattice, so its group is P 1 - and the lattice and setting are then kept as for -S P1. + if (fixed_reference_unit_cell && space_group == nullptr) { + const auto &c = *fixed_reference_unit_cell; + const auto special = [](double x) { return x == 90.0 || x == 120.0; }; + if (!special(c.alpha) && !special(c.beta) && !special(c.gamma) + && !(c.alpha == c.beta && c.beta == c.gamma)) { + space_group = gemmi::find_spacegroup_by_number(1); + logger.Info("The cell given with -C has no angle of 90 or 120 deg, so it names a triclinic " + "lattice: space group P 1"); + } + } if (space_group != nullptr) logger.Info("Using space group {} (number {})", space_group->hm, space_group->number);