-
Notifications
You must be signed in to change notification settings - Fork 53
Add function to expand asymmetric unit cell of Phase #544
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
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request adds a new method, expand_asymmetric_unit(), to the Phase class to expand its asymmetric unit by including all symmetrically equivalent atoms based on the specified space group. It additionally adjusts lattice alignment within the structure and imports the necessary diffpy components to support this functionality.
- Introduces expand_asymmetric_unit() in the Phase class.
- Adjusts lattice alignment in the structure setter using placeInLattice().
- Imports and utilizes ExpandAsymmetricUnit from diffpy for symmetry expansion.
Files not reviewed (1)
- CHANGELOG.rst: Language not supported
Comments suppressed due to low confidence (2)
orix/crystal_map/phase_list.py:390
- [nitpick] The variable name 'eau' is ambiguous. Consider renaming it to a more descriptive name such as 'expansionResult' or 'expandedData' to improve code clarity.
eau = ExpandAsymmetricUnit(self.space_group, xyz)
orix/crystal_map/phase_list.py:391
- The loop iterates over self.structure while a cleared copy (diffpy_structure) is being used to accumulate results. Verify that iterating over self.structure returns the intended original atom list, as this mixing may lead to unexpected behavior.
for atom, new_positions in zip(self.structure, eau.expandedpos):
It might be an idea to set the space group to P1 after expanding, to indicate that the symmetry has been accounted for. Maybe the function instead should be called something like |
@argerlt Any chance you can comment on this? Should we be expanding this? Would it be better to have an attribute? I'm maybe not the best person to comment on this but I think we want to avoid transformations which mess with the symmetry reduced zone. I think it would be better to have one object. @property
def asymetric_unit(self):
"""Return the expanded asymetric unit"""
pass
@property
def symetric_unit(self):
"""Return the reduced symmetric unit"""
pass |
Ignore my previous response, I didn't quite follow what @CSSFrancis was suggesting. better answer: I think as this stands, this PR fine. I think overwriting the symmetry is potentially dangerous for the reasons @CSSFrancis said, and because functions that overwrite class attributes you don't expect them to can be frustrating to debug. Building on that though, I think a function that changes any class attributes in an irreversible way can be potentially problematic, so I also like the idea of class functions that return the expanded or reduced unit, which I believe is what @CSSFrancis is suggesting. If I were doing it, I think I would call the functions Some other thoughts, take or leave them:
|
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
For reviewers
__init__.py
.section in
CHANGELOG.rst
.__credits__
inorix/__init__.py
and in.zenodo.json
.