Dynamic diffraction (Bloch wave)#
pyEMAPS simulates dynamic diffraction with the Bloch wave method, so this guide also calls it the Bloch simulation.
from pyemaps import Crystal, showBloch
if __name__ == '__main__':
silicon = Crystal.from_builtin('Silicon')
# A Bloch simulation with the default controls, except for the sampling.
try:
images = silicon.generateBloch(sampling=20)
except Exception as e:
print(f'The Bloch simulation failed: {e}')
else:
showBloch(images) # grey scale
showBloch(images, bColor=True) # with a color map
generateBloch() runs a Bloch wave simulation, here with 20
sampling points along the disk radius instead of the default 8. For all its controls and
parameters, see generateBloch().
It returns the images as a BImgList, and
showBloch(), from the display module,
shows them.
Note
generateBloch can make images at a range of sample thicknesses (sample_thickness), and save them in a raw image file (bSave). Third-party tools such as ImageJ and DigitalMicrograph can import the file. See Using results in other tools.
Note
For the scattering matrix and other details of a simulation, start a session with
beginBloch(), then call
getSCMatrix(), and end the session with
endBloch().
See Crystals for the built-in crystals you can simulate.
Displaying a series of images#
This example makes Bloch images of Silicon at six sample thicknesses and shows them as a table:
zone axis (1, 1, 1)
accelerating voltage 100 kV
sample thickness from 500 to 1750 Å, every 250 Å
40 sampling points along the disk radius
from pyemaps import EMC, SIMC, Crystal, showBloch
def generate_bloch_images(name='Silicon'):
"""Generate Bloch images at six sample thicknesses, or return None on failure."""
crystal = Crystal.from_builtin(name)
emc = EMC(zone=(1, 1, 1), vt=100, cl=1000,
simc=SIMC(excitation=(0.3, 1.0), bmin=0.1))
try:
images = crystal.generateBloch(sampling=40,
em_controls=emc,
sample_thickness=(500, 1750, 250)) # Å
except Exception as e:
print(f'The Bloch simulation failed: {e}')
return None
images.sort()
return images
if __name__ == '__main__':
images = generate_bloch_images()
if images is not None:
showBloch(images, cShow=True, layout='table', bSave=True)