Build Packages / Create release (push) Successful in 17s
Build Packages / build:viewer:macos-arm64:nocuda (push) Successful in 3m22s
Build Packages / build:rugnux:macos-arm64:nocuda (push) Successful in 2m37s
Build Packages / build:rugnux:linux-aarch64:cuda (push) Successful in 9m33s
Build Packages / build:rugnux:linux-x86_64:cuda (push) Successful in 10m39s
Build Packages / build:viewer:linux-x86_64:nocuda (push) Successful in 11m4s
Build Packages / build:viewer:linux-x86_64:cuda (push) Successful in 13m19s
Build Packages / build:jfjoch:rocky8:nocuda (push) Successful in 17m37s
Build Packages / build:jfjoch:rocky9:nocuda (push) Successful in 18m49s
Build Packages / build:viewer:windows-x86_64:nocuda (push) Successful in 19m10s
Build Packages / build:viewer:windows-x86_64:cuda (push) Successful in 24m26s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 25m31s
Build Packages / build:jfjoch:ubuntu2404:nocuda (push) Successful in 18m54s
Build Packages / build:jfjoch:ubuntu2204:nocuda (push) Successful in 20m45s
Build Packages / Generate python client (push) Successful in 37s
Build Packages / build:jfjoch:rocky8:cuda-sls9 (push) Successful in 20m20s
Build Packages / Build documentation (push) Successful in 1m32s
Build Packages / build:rugnux:windows-x86_64:cuda (push) Successful in 14m37s
Build Packages / build:jfjoch:rocky9:cuda-sls9 (push) Successful in 21m6s
Build Packages / build:jfjoch:rocky8:cuda (push) Successful in 19m49s
Build Packages / build:jfjoch:rocky9:cuda (push) Successful in 20m29s
Build Packages / build:jfjoch:ubuntu2204:cuda (push) Successful in 17m2s
Build Packages / build:jfjoch:ubuntu2404:cuda (push) Successful in 14m27s
Build Packages / Unit tests (push) Successful in 1h18m12s
* Rugnux: Performance improvements on GPU and CPU (more of the pre-scan and of scaling on the GPU, faster CPU spot finding and crystal refinement), with unchanged results. * Rugnux: More robust processing - patches of persistently hot pixels are masked, an inconsistent merge triggers a retry at the measured beam centre, and builds targeting different CPU levels give the same results. * Rugnux: Improved scaling and merging - reflections with an overloaded pixel are dropped, as in XDS, sparse rotation sweeps are scaled more reliably, and French-Wilson amplitudes use an anisotropic Wilson prior. * Rugnux: Improved space-group determination - glide planes in groups without a centre of symmetry, screw axes from short or weak axial rows kept when a higher group is adopted, and more reliable decisions on twinned and pseudo-symmetric crystals. * Rugnux: Improved small-molecule processing - spots that grow wider than the integration disk and split spots are integrated over their measured footprint, sparse lattices are integrated on every frame, and the `.hkl` file holds unmerged scaled reflections (SHELX HKLF 4). * Rugnux: Reads Rigaku d*TREK SMV images (Saturn CCD), including detector 2theta and encoded pixel overflows; home-source (rotating-anode) datasets were added to the validation battery. * jfjoch_viewer: Fixed processing failing at the end with "Wrong JPEG library version" on Linux; the merge window shows the space group with proper subscripts and a checklist of crystal pathologies. Reviewed-on: #84 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
64 lines
2.7 KiB
C++
64 lines
2.7 KiB
C++
// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#pragma once
|
|
|
|
#include <limits>
|
|
#include <vector>
|
|
|
|
#include "XtalResidual.h"
|
|
#include "LMSolver.h"
|
|
|
|
// A soft restraint w * (g . p - p0) on one direction g of a two-component block - the beam centre or
|
|
// the detector tilt, which are the same gauge seen twice and so take the same direction (see
|
|
// XtalOptimizer).
|
|
struct XtalRefinePrior {
|
|
enum class Block { Beam, DetectorRot } block = Block::Beam;
|
|
double gx = 0.0, gy = 0.0, p0 = 0.0, weight = 0.0;
|
|
};
|
|
|
|
// The least-squares problem XtalOptimizer solves, as data: the residuals with the frame each belongs
|
|
// to, the parameter blocks with what is held and what is bounded, and the priors. The parameter arrays
|
|
// are in/out. Parameter blocks: beam(2), detector_rot(2), rot_vec(3, the spindle, refined on the sphere),
|
|
// latt_vec0(3, orientation angle-axis), latt_vec1(3, cell lengths), latt_vec2(3, cell angles) - see
|
|
// XtalResidual. The distance is a constant of the problem.
|
|
struct XtalRefineProblem {
|
|
static constexpr double kNoBound = std::numeric_limits<double>::max();
|
|
|
|
gemmi::CrystalSystem crystal_system = gemmi::CrystalSystem::Triclinic;
|
|
// Only beam and orientation free, everything else held: the reduced residual (see
|
|
// XtalResidualBeamOrientation), whose crystal half is a constant of the problem.
|
|
bool beam_and_orientation_only = false;
|
|
double distance_mm = 0.0;
|
|
|
|
std::vector<XtalResidual> residuals;
|
|
std::vector<int> frame; // per residual, an index into frame_angle_rad
|
|
std::vector<double> frame_angle_rad;
|
|
std::vector<double> weight_sq; // per residual; empty = unweighted
|
|
|
|
double beam[2] = {0, 0};
|
|
double detector_rot[2] = {0, 0};
|
|
double rot_vec[3] = {1, 0, 0};
|
|
double latt_vec0[3] = {0, 0, 0};
|
|
double latt_vec1[3] = {0, 0, 0};
|
|
double latt_vec2[3] = {0, 0, 0};
|
|
|
|
bool beam_constant = false;
|
|
bool detector_rot_constant = true;
|
|
bool rot_vec_constant = true;
|
|
bool latt_vec1_constant = true;
|
|
bool latt_vec2_constant = true;
|
|
|
|
double detector_rot_lower[2] = {-kNoBound, -kNoBound}, detector_rot_upper[2] = {kNoBound, kNoBound};
|
|
double latt_vec1_lower[3] = {-kNoBound, -kNoBound, -kNoBound}, latt_vec1_upper[3] = {kNoBound, kNoBound, kNoBound};
|
|
double latt_vec2_lower[3] = {-kNoBound, -kNoBound, -kNoBound}, latt_vec2_upper[3] = {kNoBound, kNoBound, kNoBound};
|
|
|
|
std::vector<XtalRefinePrior> priors;
|
|
|
|
LMOptions options;
|
|
};
|
|
|
|
// Solves the problem in place. The residual sums are cut into blocks that depend on the problem
|
|
// alone, so the answer is the same at any thread count.
|
|
LMSummary SolveXtalRefine(XtalRefineProblem &problem, int num_threads);
|