Controlling randomisation with a ‘seed’
and techniques for randomisation.
In some options random numbers are used to produce random (often called Monte Carlo) distributions of energies or angles or positions (for example for thermionic cathodes or secondary electrons or round beams).
The randomisation can be controlled with a ‘seed’ (and if the value of the seed is not changed then the randomisation is the same for every run) or it can be different for every run (in which case the seed is set by the date and time). The seed can have any value.
When random distributions are being used for more than one purpose (thermionic cathodes or secondary electrons or round beams), the same value of the seed should be used for them all.
Techniques used to evaluate probability distributions.
Many of the probability distributions used in the CPO programs are ‘invertible’ (see for example A L Garcia, Numerical Methods for Physics, 2nd edition, Prentice Hall, New Jersey, 1994, ISBN 0-13-906744-2).
Consider a variable x for which P(x)dx is the probability that x lies in the interval x to x + dx.
If a function R can be found for which
dR = P(x)dx
then the probability distribution for R is uniform in the interval 0 to 1 and so R is effectively a random number in this interval (and is produced by a random number generator, sometimes called a Monte Carlo generator).
As an example, consider the Boltzmann distribution. In the direction z perpendicular to the plane of the emitter the probability that a particle is emitted with the momentum component pz in the range pz to pz + dpz is
P(pz)dpz = (pz/mkT)exp(-(pz*pz/2mkT)dpz.
Therefore we can put
R = -exp(-(pz*pz/2mkT) = -exp(-Ez/kT).
Ez = -kT.ln(R),
where R is a random number in the range 0 to 1 and therefore Ez is in the range infinity to 0. So using a random number generator for R we can generate a random set of values of Ez that have the correct probability distribution.
In the transverse x and y directions the probability for the total transverse momentum pt is
P(pt)dpt = (pt/mkT)*exp(-(pt*pt/2mkT)*dpt
px = pt.cos(è), py = pt.sin(è).
Et = -kT.ln(Rt), px = sqrt(2mEt)cos(è), py = sqrt(2mEt)sin(è),
è = 2ðRa
and where Rt and Ra are both random numbers in the interval 0 to 1.
Another example is the simulation of the Lambert cosine law, for 3D systems. The probability of emission into a solid angle domega at an angle è to the perpendicular is cos(è)domega/ð. If we consider an annulus in the interval è to è + dè the solid angle is domega = 2ðsin(è)dè and so we can put
P(è)d(è) = sin(2è)dè.
R = -0.5cos(2è)
and so cos(2è) is uniformly distributed, in this case over a range of 2, from -1 to 1 (more formally we should put R = 0.5(1 - cos(2è) ).
For distributions that are not invertible we have to use pre-calculated arrays of values -see for example the information on secondary electrons.