Example3:
/ Precession Tilt series
// This is summing over the power-spectrum of
the exit wave function
// by spinning the beam in a circle. The beam
tilt is theta (30 mrad).
// The increment in the azimuthal angle is dphi
(6 degrees)
// A table of HKL values for different thicknesses
is shown
// For illustration purposes, a precession image
is also calculated
number theta = 30 // The tilt angle in mrad
number phi = 0 // Tilt angle (degrees) with respect
to a-axis
number dphi = 6 // increments in tilt angle (degrees)
simulation sim = getsimulation() // Get the simulation
// We are making sure that everything has been calculated and
is current
sim.calculateall()
image xw = sim.loadexitwave() // Declare and load the exit wave
image im = sim. loadimage() // Declare and load
the image
image sumim = im ; sumim = 0 ; // Declare the
sum for the images and zero
image sumps = xw ; sumps = 0 ; // Declare the
sum for the powerspectrum
// and zero
Openlogwindow()
for(number thickness = 10; thickness <= 100; thickness += 10)
{
sim.setthickness(thickness)
number i = 0 // declare and initialize
our counter
for(phi = 0 ; phi < 360; phi += dphi)
{ // loop over the azimuthal angle
sim.settilt(theta,phi)
// set the tilt of the specimen
// this is equivalent
to the tilting the beam
sim.calculateexitwave()
// Calculate the new exit wave
sim.calculateimage()
// Calculate the new image
sumim += sim. loadimage()
// Add the image to the sum
xw = sim. loadexitwave()
// Load the exit wave
xw.fft() // Fourier
transform to get the frequency
// complex coefficients
xw *= conjugate(xw)
// Set the complex PowerSpectrum
// If we had used
xw.ps() to get the
// power spectrum
we would have had a real
// image in “real” space
sumps += xw //
Add the powerspectrum to the sum
i++ // Keep track
of the count
print("phi
= "+phi)
// Just to know where we are in the loop
}
sumim /= i // Divide by the number of terms
in the sum
// Create a rectangular image of size 1024
by 1024 of sampling 0.1 Å (default)
image precessionImage = sim.createimage(sumim,1024)
precessionImage.setname("Image Precession")
precessionImage.show() // Show the summed
images
sumps /= i // Divide by the number of
terms in the sum
sumps.sqrt() // To compare with the Scattering
factors
// Create a rectangular image of size
1024 by 1024 out to gMax = 4 1/Å
// with a convergence angle of 0.2 mrad
image precessionPS = sim.createfrequencyimage(sumps,1024,0.2,4)
precessionPS.setname("Power Spectrum
Precession Thickness "+
sim.getthickness())
precessionPS.show() // Show the summed
power spectrum
sumps.setname("thickness " +
sim.getthickness())
sim.createhkltable(sumps)
} |