Skip to content

unitcell: read cell_sg, find R axes, warn when the cell lacks the symmetry - #680

Merged
jonwright merged 3 commits into
FABLE-3DXRD:masterfrom
jadball:unitcell-cell-sg
Oct 30, 2026
Merged

jonwright merged 3 commits into
FABLE-3DXRD:masterfrom
jadball:unitcell-cell-sg

Conversation

@jadball

@jadball jadball commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Claude written - careful!

Third of the sym_u PRs proposed in #675. Uses sym_u.laue_rotations from #678.

cell_sg in par files

  • unitcell(..., sgname=None) is a new optional keyword for an xfab space group name (cell_sg in a par file). It overrides the lattice letter or number for the space group and the hkls. So R-3mr (rhombohedral axes) now reaches the rings and indexing; before, only transformer's theory peaks used it.
  • unitcell_from_parameters reads cell_sg, and to_par_dict writes it. Files without it work as before.
  • A more specific name is fine (F + Fm-3m). An incompatible one (I + Fm-3m, or 229 + Fm-3m) logs a warning; the name wins, as in xfab.

Integer R space groups on rhombohedral axes now use those axes. Results change: with 166 and a (5, 5, 5, 70, 70, 70) cell, the reflections with d* < 1 go from 350, with the hexagonal-axes centring wrongly applied, to 438. Hexagonal-axes cells are unchanged.

Symmetry check. When a space group is given, a warning is logged if its Laue rotations change the cell's metric tensor by more than 1e-5 (relative). Examples: P2₁/c with unique axis c, or 225 with a ≠ b. It's only a warning: xfab has only the standard settings, so such cells can't be fixed automatically. Grain and strained cells are built with "P", so they're not checked.

tensor_map.sym_ops_from_phase now takes the axes from unitcell.cell_choice, so there is one rule.

Not changed:

  • transformer still handles cell_sg its own way.
  • Hall symbols / non-standard settings in cell_sg are left for later.

Tests: test/test_cell_sg.py covers rhombohedral and hexagonal R axes, name vs letter/number, cells without their symmetry, and the par round trip. Passes on Python 3 (numpy 1.26) and Python 2.7. In the full Python 3 suite the new warnings fired 0 times.

🤖 Generated with Claude Code

jadball and others added 3 commits October 30, 2026 15:47
…metry

- unitcell(..., sgname=None): an xfab space group name, cell_sg in a .par
  file. It overrides symmetry for the space group and the hkls, so a name
  like R-3mr (rhombohedral axes) is used for the rings, not only by
  transformer. A lattice letter or number that does not match it is logged.
  unitcell_from_parameters reads cell_sg, to_par_dict writes it.
- With a space group number, an R group whose cell is on rhombohedral
  axes now uses them. Before, 166 on a 5,5,5,70,70,70 cell gave 350
  reflections with d* < 1 instead of 438.
- With any space group, a warning is logged when the Laue rotations
  change the cell's metric (e.g. P21/c with unique axis c).
- tensor_map.sym_ops_from_phase uses unitcell.cell_choice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@jonwright jonwright left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great - thanks!

@jonwright
jonwright merged commit dc8b3a0 into FABLE-3DXRD:master Oct 30, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants