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

Question about fetching diffraction pattern from ReciPro in an automated way #36

Open
OverEthanol opened this issue Jul 31, 2024 · 3 comments

Comments

@OverEthanol
Copy link

Hi,

I am working on indexing of spot and Kikuchi patterns in transmission mode in a SEM using the technique called on-axis Transmission Kikuchi Diffraction (TKD). Given the low acceleration voltage in SEM, it is almost crucial that we use electron diffraction pattern simulated via dynamical electron diffraction.

Currently, there exist some Python packages that can perform the spot and Kikuchi patterns separately, however, not all of them have a built-in dynamical electron diffraction simulation. Therefore, I would like to ask, if it is possible that, given a list of crystal orientation defined in Euler angles, to feed the list of orientations into Recipro and obtain the corresponding diffraction pattern at the given acceleration voltage, detector distance, and size of the reciprocal space in an automated way?

Thank you for the help in advance and hope that you can help me out on this ^^

@seto77
Copy link
Owner

seto77 commented Aug 9, 2024

I'm sorry for not getting back to you sooner.

ReciPro can output a pattern of electron diffraction spots based on a dynamical theory from any Euler angle. Of course, you can freely set the acceleration voltage, camera length, and output resolution.

image

Unfortunately, however, the Kikuchi line simulation only supports kinematical calculations. To treat the Kikuchi line dynamically, it is necessary to accurately treat the inelastic scattering process inside the specimen, which is a bit difficult.

I am currently working on the implementation of EBSD simulations. If that is successful, I will be able to handle TKD simulations soon. Please wait in anticipation.

@OverEthanol
Copy link
Author

Thank you very much for the reply Seto san!

Yes I understand that ReciPro can take in a set of Euler angle and output the corresponding diffraction image given the camera length, electron wavelength, etc. However, my question is more on: Is it possible to automate such process?

For example, I wish to input a list of Euler angles, such as:

  • $(90, 90, 90)$
  • $(90, 90, 91)$
  • ...
  • $(90, 90, 180)$

and save the diffraction image output (e.g. as a 2D gray-scale array with the same pixel grid as our detector grid) by ReciPro:

  • diffraction_pattern_90_90_90.png
  • diffraction_pattern_90_90_91.png
  • ...
  • diffraction_pattern_90_90_180.png

so that the images can be used for orientation mapping by dictionary indexing/template matching in Python packages such as pyxem, KikuchiPy, py4DSTEM, etc.

Do you think such thing is possible? And what could be some potential coding challenge related to it?

Or maybe this approach is inefficient and stupid, and some other approach can be better?

@seto77
Copy link
Owner

seto77 commented Aug 10, 2024

ReciPro has a simple macro feature that allows you to write loops and conditionals in Python syntax.

image
image

For example, the following macro may achieve what you want. (Please select a crystal to be calculated in advance.)

#Open the "Diffraction Simulator"
ReciPro.DifSim.Open()
#Set the wave source.
ReciPro.DifSim.Source_Electron()
#Set the intensity calculation mode.
ReciPro.DifSim.Calc_Dynamical()
#Set the Bloch wave number.
ReciPro.DifSim.NumberOfDiffractedWaves = 100
#Set the image size, resolution, and camera length.
ReciPro.DifSim.ImageWidth = 800
ReciPro.DifSim.ImageHeight = 800
ReciPro.DifSim.ImageResolutionInMM = 0.02
ReciPro.DifSim.CameraLength2 = 60

#Loop the Euler angle "phi" from -180° to 180° in 60° steps.
for phi in range(-180, 180, 60):
        #Loop the Euler angle "theta" from 0° to 180° in 60° steps.
        for theta in range (0, 180, 60):
                #Loop the Euler angle "psi" from -180° to 180° in 60° steps.
                for psi in range(-180, 180, 60):
                        #Set crystal orientation with loop variables phi, theta, and psi.
                        ReciPro.Dir.EulerInDegree(phi, theta, psi)
                        #Loop the "Thickness" from 10 nm to 40 nm in 10 nm steps.
                        for thickness in range (10, 40, 10):
                                ReciPro.DifSim.Thickness = thickness
                                #Set an appropriate file name and save the file in an appropriate location.
                                filename = 'd:/' + str(phi) + '_' + str(theta) + '_' + str(psi) +'_' + str(thickness) + '.png'
                                ReciPro.DifSim.SaveAsPng(filename)
#Reset the Euler angles.
ReciPro.Dir.EulerInDegree(0, 0, 0)

Smaller loop steps may cause an explosion in computation time. Adjust the steps carefully.

At this time, not all functions inside ReciPro can be called from the macro. It is easy to add them, so please do not hesitate to contact me.

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

No branches or pull requests

2 participants