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-Vec3andMat3value types: rotations about the axes, multiplication, inversion, determinant, transpose, Cholesky decomposition, cross and dot products.crymon/braggneighbors.h/crymon/braggneighbors.cpp-BraggNeighborstruct,BraggNeighborsvector andBraggNeighborsSearcherwithcalculate/run/stopAPI and a Qtresultssignal.crymon/ccp4.h/crymon/ccp4.cpp-t_slicedefinition,Ccp4Headerand theCcp4Geometryclass:addArray,mapand accessors for the matrices, per-pixel buffers, header and payload.crymon_crystallography- static library built fromcrystallography/:unitcell.h- unit cell with lattice system detectionpointgroup.h,spacegroup.h,symmetryoperation.h,symmetryelement.hmatrix.h,v3d.h,v3r.h,quat.h,cyclicgroup.h,productofcyclicgroups.hgroups.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
SiVecbuffers - 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 intests/-DCRYMON_BUILD_CRYSTALLOGRAPHY=ON- buildcrymon_crystallographytarget
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+