-
Notifications
You must be signed in to change notification settings - Fork 126
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
Remove symmetry elements for SaveINS #38605
base: release-next
Are you sure you want to change the base?
Conversation
Can we get a milestone on this so we know whether we're trying to get it into v6.12 or not? |
@@ -0,0 +1 @@ | |||
- Fix :ref:`SaveINS<algm-SaveINS-v1>` that saved all symmetry records to file. Only the minimum are needed that can be generated by translation/rotation corresponding to the lattice type. |
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.
I think this needs to move a level deeper, into the Bugfixes
folder
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.
Thanks for this @zjmorgan - I wasn't aware of this specification from SHELX, or the online tool you link in the PR. Just some small suggestions!
|
||
def _symmetry_matrix_vector(self, symop): | ||
"""Symmetry rotation matrix and translation vector""" | ||
W = np.linalg.inv(np.vstack([symop.transformHKL(V3D(*vec)) for vec in np.eye(3)])) |
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.
Minor, but could have more informative variable names throughout - it looks like W
is the symmetry operators transformation matrix (which you'd think we should have a getter for on the C++ side) and w
is the translation part?
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.
Good suggestion. I changed the names to W_mat
and w_vec
S1 = self._symmetry_operation_key(W1, w1) | ||
if S1 not in latt_type_ops_set: | ||
# identity(/inversion) rotation symmetry operator | ||
for rot in self.ROTATION_OPS[latt_sign]: |
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.
Seems like this is a repeat of earlier just with sym_op
instead of rot
(is that correct?)
mantid/Framework/PythonInterface/plugins/algorithms/SaveINS.py
Lines 195 to 201 in 80dd7f9
for rot in self.ROTATION_OPS[latt_sign]: | |
W2, _ = self._symmetry_matrix_vector(rot) | |
# lattice centering translation symmetry operator | |
for cent in self.CENTERING_OPS[latt_numb]: | |
_, w2 = self._symmetry_matrix_vector(cent) | |
# equivalent symmetry operator generated from rotation and translation | |
S3 = self._symmetry_operation_key(np.eye(3), np.zeros(3), W2, w2) |
Could it be refactored into a separate function?
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.
I re-organized the code a bit so it is easier to follow.
W_dict[S3] = W1 | ||
w_dict[S3] = w1 | ||
# bias toward identity | ||
if np.linalg.det(W1) > np.linalg.det(W_dict[S3]): |
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.
Why is this check necessary - are the rotations and translations not equivalent to what is already in the dictionary?
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.
Even though they are equivalent, I bias toward the operation with simpler notation
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.
"-x+y,-x,z" is simpler than "-x+y+1/3,-x+2/3,z+2/3"
@@ -140,5 +173,67 @@ def PyExec(self): | |||
f_handle.write("HKLF 2\n") # tells SHELX the columns saved in the reflection file | |||
f_handle.write("END") | |||
|
|||
def _symmetry_operation_key(self, W1, w1, W2=np.eye(3), w2=np.zeros(3)): | |||
"""Symmetry element key (9 element tuple) for comparison""" |
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.
Perhaps a bit more explanation as to why this works as a unique identifier?
Me either! Here is what I found /https://macxray.chem.upenn.edu/LATT.pdf |
Description of work
SaveINS
incorrectly includes all symmetry elements and should not include identity, inversion, or any that can be generated by the lattice centering translations.Summary of work
Redundant symmetry elements that can be generated by the underlying centering condition or rotoinversion should be removed. In addition, identity does not need to be included.
To test:
Run the additional system tests. Or, run this example. Choose any space group. Go to link https://cci.lbl.gov/cctbx/shelx.html and enter the same space group symbol. Cross check that it gives the same symmetry operators. Order does not matter.
Reviewer
Please comment on the points listed below (full description).
Your comments will be used as part of the gatekeeper process, so please comment clearly on what you have checked during your review. If changes are made to the PR during the review process then your final comment will be the most important for gatekeepers. In this comment you should make it clear why any earlier review is still valid, or confirm that all requested changes have been addressed.
Code Review
Functional Tests
Does everything look good? Mark the review as Approve. A member of
@mantidproject/gatekeepers
will take care of it.Gatekeeper
If you need to request changes to a PR then please add a comment and set the review status to "Request changes". This will stop the PR from showing up in the list for other gatekeepers.