-
Notifications
You must be signed in to change notification settings - Fork 26
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
Fix simulations of rotated structure #60
Fix simulations of rotated structure #60
Conversation
…imulate-rotate-structure Merges small changes to reduce testing warnings
To get this PR locally use (Step 1 in the command line instructions box on the PR)
Then install this version of diffisms: |
MWE test case.
|
…imulate-rotate-structure Tests fail without later commits
@EirikOpheim this should be easier for you to test after this merge - please do let us know if there are further issues. |
Thanks Duncan, I have been struggeling to get git working properly the last couple of days, but Håkon helped me yesterday, so I guess I should be able to check out branches soon. Now that it is included in the master branch I can run the tests. I will let you know how it goes. Eirik |
I run into problems with the function peaks_from_best_vector_match() in pyxem.indexation_utils() as this function also depends on the removed function "Simulate_rotated_structure()". Do we have to implement similar changes for this function? Is there a way to just ignore this dependency, while I am testing the changes to diffsims? |
Can you be more specific please? Probably yes we'll need to introduce similar changes for that - please raise a bug report issue for this. What issue is it causing you for this? |
Sure, I am sorry for writing a bit vague. The issue is that I can no longer import pyxem, after updating diffsims. I get " ImportError: cannot import name 'simulate_rotated_structure' from 'diffsims.utils.sim_utils' ". The function 'simulate_rotated_structure' was removed in this bugfix. The only place in sim_utils where simulate_rotated_structure is used is in the function peaks_from_best_vector_match(). I am not using this function in my notebook, but I believe that users who update diffsims will not be able to import pyxem with the current version. (I also updated pyxem to make sure I had the newest version.) I can raise a bug report for this problem in pyxem. |
Oh right, yeah that'll be an issue for pyxem - but also easy to fix by updating the imports in pyxem, do you know how to do that? A PR fixing it would be better than an issue reporting it if possible? |
I am not quite sure how to do that, I am sorry! What we want to do is to change the function peaks_from_best_vector_match to no longer depend on simulate_rotated structure, and then remove the import, right? I will go through some tutorials on git today, so that hopefully I can contribute more with PR's and stuff in the coming months. Maybe it is best if you or Philip could make the PR for this issue? :) |
Yes that's what needs to happen - just make a branch, make the changes, commit, push, PR - the same as when you did it before? Since you're not using the function - in your local copy of pyxem you can just remove the import in the short term to let you move forwards. I might be able to get to this on Monday. |
The first time I made changes I did so on a branch in github.com and then pushed it, but I guess I could do the same thing again. I will remove the function in my local copy and go on with the testing, and then try and implement the same changes in a pyxem PR. Have a nice weekend! |
Ok - I think if you intend to contribute code to pyxem over the course of your project (as discussed elsewhere) then you need to learn this basic git/github workflow sooner rather than later. There is a little info here: https://github.com/pyxem/starter-pack Are you working on Windows or Mac? If so, I'd recommend you use Github Desktop (https://desktop.github.com/) Since this particular bug is a fairly simple example and one that you've found yourself - it's kind of an ideal first contribution. So if contributing is an important project goal for you I think it would be good for you to fix this. Does that sound ok? |
I agree that I should learn tu use github workflow as soon as possible. I am working on ubuntu, so it should not be too hard, I think. I had some issues relating downloaded packages from git to anaconda, but I am sure I will figure it out! It sounds ok to me that I should perform the bugfix :) |
My test notebook shows that the result is now consistent with the orix tool for handling symmetry. Well done @pc494! |
Great! Is have you checked that for a few crystal systems? We need to be sure it's not just cubic cases for example! |
I checked for the monoclinic crystal system now, using this cif file to describe the structure: For a some reason indexer.correlate() gave an error message related to kwargs, allthough no keyword arguments were given. I thought I'd mention this, as I do not 100% trust the results I got, although they look sensible. To work around the error I copied the indexer.correlate function to my notebook and removed the kwarg input as follows: (Copied from the indexer.correlate and removed kwargs where they appear)
With these matching_results and using the orix symmetry C2h I get the following image: It looks like something is wrong here, but I am not sure if it is related to the rotation of structures or something else. The lines of code written above ran exceptionally fast, so I suspect that something might have gone wrong, as usually indexer.correlate takes around 5 minutes to run and this ran in 30 seconds. |
This should be raised as a bug within pyxem. MWE* + a stacktrace (ie - copy paste the error message) should help us figure it out.
Starting at the top of this problem: *MWE == Minimum Working Example, |
I can raise a bug in the pyxem forum with a MWE and a stacktrace.
|
Point (3) reminds me of pyxem/orix#18 - have you tried plotting plots in the style of the left hand one (ie - distance to (0,0,0)) for both "true" and "matched" and visually comparing? |
Good idea! I will try! |
I think this is excellent news and more or less closes the diffsims component of this problem? I'll leave you to open the upstream pyxem issue and the downstream orix issue is already covered by pyxem/orix#18) |
I am sorry, I think my comment was not so clear. I have just plotted the same image twice, it should be compared to the left image of |
Thanks @EirikOpheim, I'm back up to speed. Would you be able to email me the notebook you're working from here? |
Sure! |
I found a bug in the code I have been using for testing with a new crystal system, so the plots I have posted today should be ignored. |
Thanks for this @EirikOpheim - I think that this suggests the code at least may now be correct and that remaining issues are wider project work - so I'll send you an e-mail about that. |
name: Fix simulations of rotated structure
about: Following on from #46, #56 , #57 and #59 this PR attempts to solve our rotations problems
Release Notes
What does this PR do? Please describe and/or link to an open issue.
Previously,
.calculate_ed_data()
took a structure rotate to the correct orientation. It appears that doing this with diffpy (rather than pymatgen as in old-pyxem) is problematic. Also theoretically it's a bit of a challenge. A cleaner option seems to be to calculate all reciprocal lattice points in the standard orientation - ie.reciprocal()
of the standard lattice & then at the output stage rotate the cartesian coordinates.An obvious advantage is illustrate by a 90 degree z-axis rotation of a cubic structure with (h00) types absent. In the old layout, it's hard to keep track of which is 'a' and which is 'b' - here we have two aligned arrays
index =
[[1,0,0],[0,1,0]]
and the coordinates - for rotation (0,0,0) the cartesian_coordinates =
[[a*,0,0],[0,b*,0]]
for rotation (0,0,90) we get
[[0,a*,0],[-b*,0,0]]
Describe alternatives you've considered
Lots, none of which really worked.
Are there any known issues? Do you need help?
Work in progress?
If you know there is more to do, make a checklist here:
simulate_rotated_structure()
going, which can now be deleted.