dyadkin b6c0b486f8
ci linux-qt5 / build-test (push) Successful in 44s
ci macos / build-test (push) Successful in 1m20s
ci win / build-test (push) Successful in 1m20s
ci linux-qt6 / build-test (push) Successful in 45s
Compare referenced peaks
2026-11-12 15:43:58 +01:00
2026-11-12 15:43:58 +01:00
2026-11-10 17:31:29 +01:00
2022-10-18 11:06:50 +02:00
2026-07-03 15:35:52 +02:00
2026-10-21 15:05:03 +02:00

crymon

crymon is a C++ library for crystallography calculations used at synchrotron beamlines. It is part of the Pylatus meta-package and provides Bragg neighbour search, CCP4 geometry handling and a crystallography package with unit cells, point groups and space groups.

Overview

The library implements geometry calculations for four-circle diffractometers. The parfile structure holds instrument parameters such as wavelength, detector distance, orientation and UB matrix. Mat3 and Vec3 are the 3x3 matrix and 3-vector value types used throughout the code. BraggNeighborsSearcher computes reflections that fall on the detector for a given delta and returns their hkl indices, pixel coordinates and extinction.

The CCP4 module builds a reciprocal-space map (a volume or a layer) from a parfile and a slice definition, exposing cell, B, U, G and UU matrices and accumulating detector frames into voxels.

The crystallography component is a port of Mantid Geometry. It implements unit cells, point groups, space groups, symmetry operations, symmetry elements and related utilities.

Components

  • parfile.h - instrument parameter struct used by Bragg search and CCP4, shared through cmake-tools (base/parfile.h).
  • crymon/mat3.h / crymon/mat3.cpp - Vec3 and Mat3 value types: rotations about the axes, multiplication, inversion, determinant, transpose, Cholesky decomposition, cross and dot products.
  • crymon/braggneighbors.h / crymon/braggneighbors.cpp - BraggNeighbor struct, BraggNeighbors vector and BraggNeighborsSearcher with calculate/run/stop API and a Qt results signal.
  • crymon/ccp4.h / crymon/ccp4.cpp - t_slice definition, Ccp4Header and the Ccp4Geometry class: addArray, map and accessors for the matrices, per-pixel buffers, header and payload.
  • crymon_crystallography - static library built from crystallography/:
    • unitcell.h - unit cell with lattice system detection
    • pointgroup.h, spacegroup.h, symmetryoperation.h, symmetryelement.h
    • matrix.h, v3d.h, v3r.h, quat.h, cyclicgroup.h, productofcyclicgroups.h
    • groups.h, angleunits.h, physicalconstants.h, tolerance.h

Build

Requires CMake 3.27+, C++17, Qt 5 or 6 Core and cmake-tools for dependency resolution. Dependencies are resolved via cmake-tools:

  • Qt5/6 Core
  • llr for the SiVec buffers
  • Boost 1.89.0
  • GSL
  • qtsingleton for the crystallography target

When crymon is built as a submodule of a larger package, the parent is expected to provide cmake-tools and the llr target; standalone builds download both.

Typical build:

cmake -S . -B target/release -DCMAKE_BUILD_TYPE=Release
cmake --build target/release -j

Options:

  • -DCRYMON_BUILD_TESTS=ON - build GoogleTest suite in tests/
  • -DCRYMON_BUILD_CRYSTALLOGRAPHY=ON - build crymon_crystallography target

The library is installed as libcrymon.a with headers in include/crymon. Crystallography headers are installed to include/crymon/crystallography.

Usage

Bragg neighbour search:

parfile par = { /* fill wavelength, alpha, beta, d1, d2, distance, xc, yc, ub, ... */ };
double delta = 0.003;
BraggNeighborsSearcher bns;
const BraggNeighbors &n = bns.calculate(par, delta);
for (size_t i = 0; i < n.size(); ++i) {
    const BraggNeighbor &b = n[i];
    // b.h, b.k, b.l, b.x, b.y, b.ext
}

CCP4 geometry:

t_slice slice = { /* thickness, qmax, dQ, scale, p0, p1, pc, x, y, z, downsample, n_voxels, type, lorentz */ };
Ccp4Geometry geo(slice, par);
SiVec<double> frame(par.inhor * par.inver);
// fill the frame, negative pixels are masked
geo.addArray(frame, angle, osc);
geo.map();
// write geo.header() followed by geo.voxels() for a volume or geo.pixels() for a layer

Crystallography:

Mantid::Geometry::UnitCell uc(4, 4, 4, 90, 90, 90);
auto sys = uc.latticeSystem();

License

GPL-3.0+

S
Description
Calculations for single crystal diffraction
Readme
1,006 KiB
0 Stars 1 Watchers 0 Forks
Languages
C++ 88.9%
Objective-C 8.2%
CMake 1.5%
C 1.4%