Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function to expand asymmetric unit cell of Phase #544

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

viljarjf
Copy link
Contributor

Description of the change

Adds Phase.expand_asymmetric_unit(), which adds all symmetrically equivalent Atom entries into Phase.structure.
This already exists in diffsims (ReciprocalLatticeVector.sanitize_phase(), with a #TODO to upsteam into orix. However, I don't think the implementation in diffsims is entirely correct, seeing as the discrepancy between diffsims' and diffpy's axis alignment convention does not seem to be accounted for.

This expansion seems to be performed automatically when reading from a cif which includes symmetry information. I added a test for this, which includes the cif-file test-cases as raw strings. If there is another preferred way to do this please let me know. I saw the cif_file-fixture, but I felt making these single-use files into fixtures was unnecessary.

Additionally, I found Structure.placeInLattice(), which does the same as #469 for both coordinates and ADPs.

Progress of the PR

Minimal example of the bug fix or new feature

>>> phase = Phase(
      structure=Structure(
          atoms = [Atom("Si", xyz=(0, 0, 1))],
          lattice=Lattice(4.04, 4.04, 4.04, 90, 90, 90)
      ),
      space_group=227,
  )
  >>> phase.structure
  [Si   0.000000 0.000000 1.000000 1.0000]
  >>> phase.expand_asymmetric_unit()
  >>> phase.structure
  [Si   0.000000 0.000000 0.000000 1.0000,
   Si   0.000000 0.500000 0.500000 1.0000,
   Si   0.500000 0.500000 0.000000 1.0000,
   Si   0.500000 0.000000 0.500000 1.0000,
   Si   0.750000 0.250000 0.750000 1.0000,
   Si   0.250000 0.250000 0.250000 1.0000,
   Si   0.250000 0.750000 0.750000 1.0000,
   Si   0.750000 0.750000 0.250000 1.0000]

For reviewers

  • The PR title is short, concise, and will make sense 1 year later.
  • New functions are imported in corresponding __init__.py.
  • New features, API changes, and deprecations are mentioned in the unreleased
    section in CHANGELOG.rst.
  • Contributor(s) are listed correctly in __credits__ in orix/__init__.py and in
    .zenodo.json.

@viljarjf viljarjf mentioned this pull request Jan 27, 2025
13 tasks
@hakonanes hakonanes self-requested a review January 29, 2025 14:14
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.

1 participant