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

Issues related to lower frequency amplitude points in diffraction patterns. #116

Closed
startingbird opened this issue Sep 12, 2023 · 7 comments

Comments

@startingbird
Copy link

Hi Toma,
I tried to calculate the diffraction pattern of a 101010 FCC Fe after rotating its supercell. Since the program obtains the diffraction pattern by calculating the Fourier transform of the exit wave, this results in a large number of bright spots due to low frequencies in the calculated image. What can be done to solve this problem?
Also, I recalculated the Fourier transform of the exit wave using numpy, and the calculations show that the amplitude spectrum does not match the diffraction profile obtained from the abtem calculations.

@jacobjma
Copy link
Member

Hi,

The large number of spots would be a result of low symmetry, which is expected when you rotate a crystal in an arbitrary direction. Rotating crystals in arbitrary directions with multislice is not trivial. We are working on making this possible, but it is not available right now. I need to know what atomic model you are trying to simulate and why you want to simulate this to give a more detailed answer.

Also, I recalculated the Fourier transform of the exit wave using numpy, and the calculations show that the amplitude spectrum does not match the diffraction profile obtained from the abtem calculations.

Our code is very well tested against this. Can you check it again? if you continue to get the same issue, send me the code, and I will try to reproduce it.

@startingbird
Copy link
Author

I don't think these square bright spots are caused by a lack of symmetry in my crystal structure, but by limitations in the FFT code itself, as mentioned in this link below.
https://homepages.inf.ed.ac.uk/rbf/HIPR2/fourier.htm

I'm trying to use abtem to generate some diffraction maps at different rotation angles to train my deep learning model, and I've been unsuccessful, so I'm now refocusing on the part of the abtem code that deals with the FFT. Below is my code.

`import matplotlib.pyplot as plt
import ase
from ase.io import read
from ase.build import mx2
from ase.build import bulk
import abtem
from abtem import *
from abtem.structures import orthogonalize_cell
from abtem.waves import Waves
from ase.cluster import wulff_construction
from ase import Atoms
import ase.data
from scipy import constants
from abtem import *
import numpy as np
import h5py
from abtem.visualize import show_atoms
from abtem.device import get_array_module, get_device_function, asnumpy

a2 = ase.io.read("/home/phD/xiankang/abtem/examples/data/Fe_Im-3m.cif")
repetitions = (10,10,10)
atoms=a2.copy()

atoms *= repetitions

atoms.center(vacuum=None, axis=2)
show_atoms(atoms)

atoms.rotate(60, 'z', center='cop')
atoms.rotate(50, 'x', center='cop')

fig, (ax1,ax2,ax3) = plt.subplots(1, 3, figsize=(15, 10))
show_atoms(atoms,plane='xy',ax=ax1)
show_atoms(atoms,plane='xz',ax=ax2)
show_atoms(atoms,plane='yz',ax=ax3)

gridpoints = 2048
potential = Potential(atoms, gpts = gridpoints,projection='infinite', parametrization='kirkland', cutoff_tolerance=1e-3, sampling=.05)
potential.build()
wave = PlaneWave(
energy=300e3 # acceleration voltage in eV
)

exit_wave = wave.multislice(potential)

exit_wave.array.shape
ctf = CTF(
energy = wave.energy,
semiangle_cutoff = 100, # mrad
focal_spread = 40, # Å
defocus = -160, # Å
Cs = -7e-6 * 1e10, # Å
)
image_wave = exit_wave.apply_ctf(ctf)
image_wave.intensity().show()

diffracte=exit_wave.diffraction_pattern(max_angle=50, block_zeroth_order=2)

diffracte.show(power=.25)

a = get_array_module(exit_wave)
abs2 = get_device_function(a, 'abs2')
pattern = asnumpy(abs2(exit_wave.array))
dif = np.fft.fft2(pattern)
f_transform_shifted = np.fft.fftshift(dif)
magnitude_spectrum = np.log(np.abs(f_transform_shifted)+1)
plt.imshow(magnitude_spectrum)
phase_spectrum = np.angle(f_transform_shifted)
phase_spectrum = np.log((abs(phase_spectrum)+1)*180/np.pi)
plt.imshow(phase_spectrum)
`

@startingbird
Copy link
Author

In this image below, this chequering is more pronounced due to low frequency signals.
Snipaste_2023-09-13_16-13-25

@TomaSusi
Copy link
Member

Please also provide the .cif file so that we can reproduce the simulation.

@startingbird
Copy link
Author

Hi Toma, This is the .cif file I used for my simulation, I converted it to text because github doesn't support this format.
I have re-run the simulation again, this picture is what I got by doing a Fourier transform on the wave function of the exit plane, I tried to do a THRESHOLD to reduce the low-frequency signal but it doesn't seem to do much. Perhaps, this is what Jacob was talking about, and it is an effect due to the crystal structure. However, I am very lacking in knowledge about TEM experiments, so I have to ask for your help. Thanks again for your support and the abTEM software. Also, I am interested in the question of rotating the crystal structure at arbitrary angles, would you be willing to provide more details. Because currently, I am trying to rotate the crystal at an arbitrary angle and keep the orthogonal structure for diffraction pattern simulation. Maybe there is something wrong with my understanding, the method I am using is to create a larger supercell and then intercept the part I want from that supercell.

Fe_Im-3m.txt
Snipaste_2023-09-18_21-50-24

@TomaSusi
Copy link
Member

Thanks for the structure file and the code.

Your rotated structure model is unphysical – the atoms do not fit into the simulation cell and thus the structure is not periodic:

download

Furthermore, the atoms that fall outside the simulation cell are in fact wrapped into the cell, making them overlap and causing an entirely unphysical potential.

download

Any simulation of exit waves or diffraction patterns for such a structure is nonsensical and thus we cannot conclude anything from what you see there.

As Jacob mentioned above, arbitrary rotations in multislice simulations are very tricky, and while we are working on a solution, it's not ready to be shared yet. For specific rotation angles along high-symmetry axes, you might be able to use orthogonalize_cell as described here, but it will not be a general solution by any means.

@TomaSusi
Copy link
Member

Please keep an eye on the related issue to hear when we are able to share our general solution:
#111

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

3 participants