-
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
Add ReciprocalLatticePoint class storing structure, Miller indices and related quantities #111
Add ReciprocalLatticePoint class storing structure, Miller indices and related quantities #111
Conversation
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
|
||
|
||
def get_xray_structure_factor(phase, hkl, scattering_parameter): | ||
"""Assumes structure's lattice parameters and Debye-Waller factors |
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 xray? Its using atomic scattering factors for electrons right?
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.
Yes, that wording is part of the WIP... I've adopted both the X-ray and Doyle-Turner approach from EMsoft, although only the X-ray Doyle-Turner calculation is included in this PR. Will add it to the TODO list until I find some better way to do it.
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 in the long run we'd like to support both X-rays and electrons, because it's pretty trivial here.
Maybe a "radiation" attribute for the ReciprocalLatticePoint class and this method can just stay as "get_structure_factor" as that terminology applies to both xrays and electrons so long as the right atomic scattering factors are taken?
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.
A radiation
attribute sounds like a good idea, I'll add it to the todo list.
Should the get_structure_factor()
function take a parametrization
parameter to chose which atomic scattering parametrization to produce atomic scattering factors with?
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.
Sorry, my comments here are not entirely correct... The get_xray_structure_factor()
uses kinematical X-ray scattering factors, while I will push a more involved scattering factor calculation soon, based on EMsoft's approach where they use Doyle-Turner atomic scattering parametrization. That is the reason for the naming. The plan was to include a method
parameter in the calculate_structure_factor()
either passing xray
or doyleturner
for different calculations of the factors.
Relevant code in EMsoft https://github.com/EMsoft-org/EMsoft/blob/develop/Source/EMsoftLib/diffraction.f90#L456.
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've now added the computation of the atomic scattering factor and structure factor using Doyle-Turner parametrization as done in EMsoft (https://github.com/EMsoft-org/EMsoft/blob/develop/Source/EMsoftLib/diffraction.f90#L496).
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.
Considering my comments yesterday were incorrect, I want to postpone a radiation
attribute.
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'm a little confused about this - as far as I can see the only parameterization of the atomic scattering factor that you've put in this PR is the Doyle-Turner one? That 1968 paper considered both X-rays and electrons.
So you mean that get_xray_structure_factor
is getting the X-ray version of the Doyle-Turner parameterization and the get_doyleturner_structure_factor
is getting the electron version of the Doyle-Turner parameterization using the Mott formula?
Where is the reference to kinematical
coming from here? I think the Doyle-Turner parameterization you're using is an evaluation of the atomic scattering factor within the first Born approximation (i.e. kinematical) whether you're taking the X-ray version or the electron version?
To me the atomic scattering factor is just defined as being in the first Born approximation and this makes sense because that quantity is relevant both in kinematical theories of electron diffraction and dynamical theories of electron diffraction from crystals. See e.g. https://iopscience.iop.org/article/10.1088/0034-4885/42/11/002/pdf?casa_token=V2KN7WTLBSoAAAAA:VfkDr5GYF5qm4izwAFbAYgOcTwDVuOEBOjmSRk1QNrnfqEdXEEsrTRUf5HWCXVYtrL07fuQgNyLE
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 must admit that I've adapted the Doyle-Turner structure factor calculation from EMsoft (https://github.com/pyxem/diffsims/pull/111/files#diff-97bd368539d6d77fc0a03e1bc2c8691bR103). I've made this fact clear by referencing EMsoft in relevant docstrings. The atomic scattering factors are the same, for both methods, yes. The "kinematical" comes from the statement in EMsoft comments here: https://github.com/EMsoft-org/EMsoft/blob/develop/Source/EMsoftLib/diffraction.f90#L384.
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Sorry to not have been very forthcoming on some of the diffsims questions here, I think the basic answer is something to the effect of, the architecture will be overhauled (although keeping |
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
No problem. I've made some design choices in the latest commit:
|
Thoughts on introducing the
|
I agree with the principle of having a module for code relating to calculating the structure factor. But I'm not keen on the name
+1 on this. On some other assorted points:
Overall this is looking really good and will certainly improve the architecture ultimately. |
Thanks for your suggestions, @dnjohnstone! Yes, let's figure out where this can be used in another PR.
|
Ok, I would argue that the
diffsims/diffsims/utils/sim_utils.py Line 276 in 8482796
|
Just a thought on naming, is there a reason we've stuck to singulars: |
I find the case where I have one point in |
Yeah, I think it's approximately consistent with orix at least to stay singular? |
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
I assume that |
…e-hkl-and-such Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
I'm not sure how to handle the different atomic scattering parameter parametrizations in diffsims. I find three, namely from Kirkland, Lobato and International Table? And the Doyle-Turner ones will make it four? We should make a unified API, and perhaps place a module
But I think this should be done in a separate PR. |
Probably not, I was hoping to automate that sort of clean up in the next batch of coding (0.4 for diffsims)
Yes, this section is due a refactor, again probably in the 0.4 cycle. Do you have a route to make progress here without those changes? |
Well, my route forward is basically not to touch existing atomic scattering parameters, and just write tests for the added functionality as is. So the Apart from that I guess the function naming @dnjohnstone referenced in the review above (#111 (comment)), although I'm not entirely sure which naming is best, as commented below his comment. |
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
OK - I think we should just say that these things stay as they are for this PR and we revisit. So does that get us to just finishing the testing and we merge? |
Great. I'll open an issue to discuss the module structure and API after this is merged.
Yup, writing them now. |
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
I'm now satisfied with the class, and coverage is 100%. There are lots of potential improvements for the class. E.g. more tests of symmetrically equivalent planes etc. for different crystal systems should be added... |
Signed-off-by: Håkon Wiik Ånes hwaanes@gmail.com
Release Notes
What does this PR do? Please describe and/or link to an open issue.
This was initially a PR to
kikuchipy
pyxem/kikuchipy#197, but was moved here because of reasons discussed in #80. My plan is to use this functionality to create a suitable set of Miller indices for EBSD stuff, like getting plane traces on the detector, which then can be used for e.g. visually checking whether an indexing is correct, integrate intensities along certain families of planes, etc.The
ReciprocalLatticePoint
class simplifies Miller indices handling, like creating a suitable set of families by considering unique indices under symmetry. When a crystal structure (space group, lattice, atoms) and a set of indices are defined, derived class properties include gspacing, dspacing, structure factors, multiplicity, whether the reflection is allowed. OneReciprocalLatticePoint
object stores all indices.It is based upon EMsoft's gnode/reciprocal lattice point class (see e.g. https://github.com/EMsoft-org/EMsoft/blob/develop/Source/EMsoftLib/typedefs.f90#L1238).
Example usage:
Describe alternatives you've considered
symmetrise()
method should be moved to a neworix.vector.Miller
class inheriting fromorix.vector.Vector3d
?unique()
using "symmetry" should perhaps be moved toVector3d.unique()
?Are there any known issues? Do you need help?
Don't know the best place for this in the code. I feel that this should be its own module (or part of a new module), available via
diffsims.crystallography.ReciprocalLatticePoint
. Having a clear import structure is important, and hiding this away in e.g.diffsims.utils.sim_utils.ReciprocalLatticePoint
is unclear.In general, I find the diffsims package structure difficult to navigate. Also, I think the use of an ever growing
utils
module is a bad idea, because whatever the coder doesn't find a suitable place for is "temporarily" put into that module.Work in progress?
I've not used
diffsims
previously, therefore I need help with the following:Other things:
Make use of existing atomic scattering parametrizations inAnother PR.diffsims
get_structure_factor()
function to use different atomic scattering parametrizationsReciprocalLatticePoint.allowed
attributeReciprocalLatticePoint.theta
attribute to store the Bragg angle (half the Kikuchi band width) by providing an acceleration voltage