
7.2 The systematic row case 399
A general multi-beam simulation program will then proceed along the following
lines.
(i) Setup. Read the crystal data file, compute all symmetry operations, compute all atom
positions, and determine the electron wavelength, corrected for refraction.
(ii) Diffraction geometry. Ask the user for the incident beam direction k and the foil normal
F; for a systematic row, also ask for g.
(iii) Determine contributing beams. For the systematic row case, these are simply multiples
of g. For the zone axis orientation, we will need an algorithm based on the symmetry
of the zone axis. Either way, we will end up with a list of N contributing beams.
(iv) Compute the off-diagonal part of A. We will use the subroutine
CalcUcg (introduced
in Chapter 2) to compute the real and imaginary parts of the off-diagonal elements of
A. The routine
CalcDynMat is provided to compute the dynamical matrix for either
the Darwin–Howie–Whelan approach or the Bloch wave approach.
(v) Beam orientations. Determine the range of incident beam directions, the number of
pixels in the final image (this will determine the number of individual multi-beam
computations
to be performed), and the thickness of the foil (either constant thickness
or thickness gradient). For each incident beam direction, we will need to compute the
diagonal of A. We will also make use of symmetry relations to reduce the total number
of beam directions for which the computation will be carried out.
(vi) Solve the equations. Use your favorite solution method to obtain the amplitudes S
n
of all N beams, for each incident beam direction and/or foil thickness. Conversion to
bright field and dark field images is then straightforward.
In the following subsections, we will provide a more detailed description of the
most important steps and algorithms for the systematic row case. The reader may
download the program
SR.f90 from the website; this program implements various
solution methods for the general systematic row case, as described below.
7.2.2.2 The differential equation approach
We will use the numerical package
rksuite90, available from www.netlib.org,
to solve the system of first-order differential equations. We have already used this
package when we discussed the
lens.f90 program in Chapter 3. The reader may
consult the source code of the
SRIntegrate routine in the SR.f90 program on the
website. Pseudo code for the systematic row case is shown in PC-17 . The calling
sequence of the
rksuite90 routines is as follows:
call setup(comm,t_start,YS,t_end,tol,thres,method='M', &
task='R',message=.FALSE.)
call range_integrate(comm,f,t_want,t_got,y_got,yderiv_got,
& flag=flag)
call statistics(comm,num_succ_steps=steps)
call collect_garbage(comm)