Download as pdf or txt
Download as pdf or txt
You are on page 1of 57

Q UANTUM C HARGE S TATES IN C AVITIES

Thomas Ruttle

Department of Physics,
U NIVERSITY OF Y ORK

May, 2010
Abstract
The aim of this project was to identify the energy eigenvalues of
the states that bind charged quantum particles to nearby planar
surfaces for a variety of systems. This was achieved by using
the image method to construct the potentials for these systems,
then using computational methods to solve TISE to get the ener-
gies. For a test system of an electron bound to a single surface,
the results were found to accurately reflect previous work; for
a system consisting of an electron confined in the cavity be-
tween two parallel surfaces, a variety of interesting results were
reached that both confirmed and expanded previous work; and
for systems containing both an electron and a proton, results
were achieved, albeit slowly (due to the computational power
required to generate them), that confirm previous findings.
1

Introduction

A charged quantum particle can become bound with a nearby planar sur-
face, creating a series of surface states. The energy eigenvalues of these
states have been known since the 1970’s[1] for a system comprising a single
electron bound to a single surface, and since then there has been work done
on discovering similar states with a variety of different systems possessing
different geometries and composition of particles. Some examples of this
work include: systems of two parallel plates, which have been investigated
by Babiker[2] and Ganesan[3]; plates intersecting to form wedges[4]; and
systems of two or more charges near plates[5], though there are many
more[6, 5].
A possible reason for much of the activity in this area is that as nano-
technology improves, systems of this type will become more and more
relevant. The system of two intersecting plates, for example, is one that is
encountered regularly in Scanning Tunnelling Microscopy[4] when the tip
of the microscope comes into contact with surface roughness. Moreover,
with ongoing developments in the field of quantum computing, such as the
use of surface states as qubits[7], the importance of systems such as these
becomes apparent.
The purpose of this project is to do further work with some of these
systems. More specifically: for each system looked at, the goal is to discover
the energy eigenvalues of the surface states created by a bound particle
in the vicinity of a planar surface. This will be achieved by solving the
Time Independent Schrödinger Equation (TISE) for each system, which will
have to be done computationally, as analytical solutions do not exist for
these problems. In order to get to the stage where TISE can be solved, the
potential affecting the studied particle must first be calculated.

1
The Method of Images
The first Uniqueness Theorem of electrostatics states:
”The solution to Laplace’s equation in some volume v is uniquely
determined if the potential V is specified on the boundary sur-
face S”[8].
This means that if a potential for any electrostatic system satisfies Laplace’s
equation while maintaining the the correct value at the boundaries then it
must be equal to the unique potential for that system. This theorem affords
us a lot of freedom when it comes to solving problems involving stationary
charges, as we are thus able to change the geometry of any system we
are looking at. As long as the boundary conditions are met and Laplace’s
equation is satisfied, the potential of the system will remain the same no
matter how the system is changed. An example of this theorem in use is
the ’Method of Images’, created by W. Thompson in 1872[9].
The simplest system for which this method can be used consists of
a point charge located at a distance d from an arbitrary position on a
grounded semi-infinite conducting surface. In order to satisfy Laplace’s
equation for the region z < d, the boundary conditions mandate that the
potential, V (z), must be zero when z = d, and must approach zero when
z << d[8]. In this case, the most convenient system to use that meets
these requirements ’replaces’ the surface with a second charge, equal and
opposite to the first, located at z = 2d (as displayed in figure 1.1).
The potential between the real charge and the ’image’ charge, and hence
the potential between the charge and the conducting plate, can be calculated
using the Coulomb Law:
q1 q2
V (r ) = − (1.1)
4πe0 |ri,j |

The system is symmetric in all but the z-direction, so the real charge
can move freely in both the x- and y-planes. As such, this system presents
a one-dimensional problem. For the case where an electron is located at
z = −d, the potential takes the form:

e2 1
V (z) = − × (1.2)
4πe0 (2d) 2
It is important to note that the image charge doesn’t really exist; it is
merely a mathematical tool used to make a potentially challenging problem
simpler. The total charge induced in the plate is the charge of the electron,

2
Figure 1.1: A simple system demonstrating the method of images, in which a
system consisting of a charge near a semi-infinite plate is substituted
with one consisting of two equal and opposite charges.

−e, and the energy of the system is half that of a system consisting of two
charges[8]. The factor of a half in equation (1.2) accounts for the unreal
nature of the image charges: they aren’t contributing any charge to the
interaction with their real counterparts so we multiply by 12 to prevent
double counting. We are thus left with the self-energy of the electron,
which in this case is the total potential of the system[4]. Using this potential,
computational methods can now be used to solve TISE and search for the
surface states.

3
2

Methodology

This section will go over the process of constructing the potentials of a


system in more detail, and will then outline the computational methods
that will be used.

Defining a System
Consider a system with a second planar surface, parallel to the first, placed
at z = −d. The origin of the system is fixed at the point midway between
the two plates, z = 0, and the electron can move freely in the x- and
y-planes, but its movement in the z-plane is restricted to −d < z < d.
While this is still a one-dimensional problem, the second surface makes it
much more complicated, since each image charge will create an equal and
opposite image charge of it’s own at an equal and opposite distance behind
the opposite plate, which in turn will create its own image charge and so
on (shown in figure 2.1). Hence, in order to calculate the total potential
of the system, the contribution of every image charge must be considered.
This means that two infinite series must be constructed: one representing
the contribution of the images located at z > d; the other representing the
contribution of the images located at z < −d1 .
It is implied by the definition of Uniqueness Theorem that, in order
for the method of images to apply, a closed surface must be defined upon
which the boundary conditions of Laplace’s equation can be tested. The
surface, S, that will be used for this particular problem (shown in figure
2.1) is constructed immediately inside the two surfaces and crosses over
the cavity between the surfaces at ±∞.
1 The total charge on both plates must still be −q and the total energy of the system is
1
2n that of a system consisting of n charges.[9]

4
There are two types of boundary condition that can be used to describe
this problem: Dirichlet Boundary Conditions and Neumann Boundary
Conditions. For the former, the potential on the surface must be specified,
and for the latter the electric field eigenvalue must be defined[10] 2 .
The two plates are grounded so the surface potential across them must
be zero. Since the potential of the system must be continuous 3 and two
sides of the surface are immediately inside the two plates, the potential on
these two sides, S1 and S3, is zero. The sides S2 and S4, which are defined
as being at the extremes of the volume over which Laplace’s equation must
be satisfied, are thus an infinite distance away from the electron, so the
potential on these edges is also zero[11]. The potential on the surface is zero
at every point so the Dirichlet Boundary Conditions have been met, so the
potential calculated as a solution to this problem, assuming it is formulated
properly, will be correct4 .
In a 1993 paper[2], Babiker investigates a system similar to this, but
the cavity formed by the two conducting plates is filled by a material with
semiconducting properties. This means that all interactions between the
electron and its images will take place across a dielectric boundary. This
change to the system adds a coefficient, γ, to the charge possessed by the
images. It will be included in my calculations for completeness, but for
most it will be set equal to one5 .
γ, the dielectric factor, is defined as:
e1 − e2
γ= (2.1)
e1 + e2
where e1 and e2 are the electrical permittivities of the semiconducting
middle layer and the two outer conducting layers respectively. It is assumed
that e2 > e1 .
Babiker, in an earlier paper, also specified a list of assumptions to be
made when investigating a system such as this. I would like to make
mention of it here as these factors will not make a contribution to the
calculations I will be making either. Any contributions to the potential
2 Laplace’s equation cannot be solved uniquely with both the potential and the elec-
tric field eigenvalue (Cauchy Boundary Conditions) specified arbitrarily for a closed
surface[10]
3 If the potential weren’t continuous, the Electric Field, E = −∇V, would go to

infinity[11].
4 It is important to note that there can never be any images inside the surface, as this

would change the charge density in the area over which Laplace’s equation is to be solved,
which would violate Uniqueness Theorem. The potential would thus be invalid for the
system[8].
5 This models two perfect conductors with a vacuum between them.

5
from the following sources will be ignored: Roughness of the surface,
dependence of the system upon temperature and retardation effects[12].
In the same paper, Babiker stated that calculating the Potential of a
system using the method of images was only successful once the charge
was a sufficient distance away from the plate. If the electron is less than a
certain distance (|d − z| = Rc . 3a B ) from the surface, it can be chemisorbed
into it, and the potential calculated using the method of images is no
longer applicable. When the electron is beyond this critical distance, but
still close enough to the surface to be affected by its images, the system
can be included in what McRae[13] refers to as the ’Weak Overlap’ (WO)
picture. Results that occur beyond this region will be included so as to keep
the boundary conditions in place and the wavefunctions continuous, but
should be assumed to be wildly inaccurate until the affects of chemisorbing
on the system can be evaluated.

Calculating the Potential


In order to calculate the potential of the system described by Babiker and
displayed in figure 2.1, an equation that sums the contribution of all the
image charges on both sides of the two surfaces must be constructed. To
begin with, only the contributions from the first- and second-order im-
age charges6 , of which there are four in this particular system, will be
considered. Each image has a charge of:

q = (−1)n+1 γn e (n = 0, 1, 2) (2.2)

To calculate the potential, it is simply a matter of adding together the


inter-particle Coulomb potentials:

2γ2
 
2 γ γ
V ( z ) = − e0 + − (2.3)
4( d + z ) 4( d − z ) 8d

where:

e2
e02 =
4πe1
The first term in the potential represents the interaction of the electron
with its first-order image charges in the z < −d plane; the second term
6 Theorder of the image is denoted by the powers of the γ-factor associated with the
charge of that image

6
Figure 2.1: A system similar to that studied by Babiker[2], in which an electron is
held in a semiconducting layer (permittivity e1 ) sandwiched by two
grounded semi-infinite conducting surfaces (permittivity e2 ). Also
displayed is the imagined closed surface at which the Boundary Con-
ditions of Laplace’s equation will be evaluated. This figure displays
the first two orders of image charges of the infinite orders created by
the ’mirroring’ effect of the two plates.

represents this interaction in the z > d plane; the third term is the sum of the
contributions of the second-order image charges. It is immediately obvious
that the interaction of the electron with the two second-order images is
independent of the electron’s position, z. This is a useful consequence of
the system’s symmetry, and remains true for all even-orders of images.
The potential for the full system of images is presented by Babiker[2] as
an infinite sum which, when adjusted to the system presented here, takes
the form:

( )
γ 2k−1 γ 2k−1 2γ 2k
Vtotal (z) = −e02 ∑ + − (2.4)
k =1
4((2k − 1)d + z) 4((2k − 1)d − z) 8kd

7
Which, for k = 1, is equation 2.3.

The Hydrogen Atom


Adding a second charge presents us with a two-dimensional problem: the
potential is now dependent on the electron’s position in both the x- and
z-planes. As the electron remains the only dynamic particle in the system,
the potential consists solely of its interaction with the proton and with its
own image & the image of the proton, as pictured in figure 2.2:

γe02
i) e+ e− →
4( d − z )
γe02
ii ) Z − e− → −p
x2 + (2d − z)2
e02
iii ) Z + e− →
ρ
( )
e2 γ γ
Vtotal ( x, z) = − 0 − e02 −p (2.5)
ρ 4( d − z ) x2 + (2d − z)2

where ρ√is the distance between the electron and the proton. It is defined
by ρ = x2 + z2 where x is the component of the electron-proton distance
parallel to the surface and z is the component of the proton-electron distance
perpendicular to the surface.
In a 1981 paper, Babiker also investigates a system consisting of a hydro-
gen atom close to a planar surface[12]. Instead of summing the Coulomb
interactions, he uses the Coulomb-Green’s function to calculate the self-
energy of both particles and the Coulomb interactions of the electron with
the proton and its images. Using this method, he constructs the following
potential:
( )
e02 γ γ e2 γ2
Vtotal ( x, z) = − − e02 −p − 0 (2.6)
ρ 4( d − z ) x2 + (2d − z)2 4d

The final term in this potential is the self-energy of the proton (i.e.,
the proton’s interaction with its image). If the Adiabatic approximation
(m p  me ) is used, as it is in papers by Babiker[12] and Simonovic[5], then
this term disappears and we are left with equation (2.5).

8
x

å1 å2

x e- ãe+
iii ii

+ -
P ãP
0

z
0 z d 2d-z 2d
Figure 2.2: A system consisting of a hydrogen atom in the vicinity of a planar
surface located at z = d. The solid, tagged lines represent those inter-
actions that I will be considering for the potential.

This assumption is not universally used when tackling this problem.


Both Ganesan[3] and Amin[6] retain the proton self-energy during their
calculations. However it seems, prima facie, that removing this term would
be more consistent with the other systems since as x → ∞, the potential
should tend towards that of a single electron near a single plate, which it
won’t if this term is included, since it has no x-dependence.

The Hydrogen Atom in the Cavity Between Two


Surfaces
Combining the methods used for the previously described systems, the
total potential for a system consisting of a hydrogen atom confined in the

9
cavity between two surfaces can be constructed:


(
e02 2γ2k
Vtotal ( x, z) = − − e02 ∑ −
ρ k =1
8kd
γ2k−1 γ2k−1 γ2k
+ +p −p
4((2k − 1)d − z) x2 + (2(2k − 1)d − z)2 x2 + (4kd − z)2
)
γ2k−1 γ2k−1 γ2k
+ +p −p
4((2k − 1)d + z) x2 + (2(2k − 1)d + z)2 x2 + (4kd + z)2
(2.7)

If we take the k = 1 case (as shown in figure 2.3), we get:

e02 2γ2

2
V ( x, z) = − − e0 −
ρ 8d
γ γ γ2
+ +p −p
4( d − z ) x2 + (2d − z)2 x2 + (4d − z)2
)
γ γ γ2
+ + p − p (2.8)
4( d + z ) x2 + (2d + z)2 x2 + (4d + z)2

Of the nine terms in equation 2.8, some are immediately recognisable


from previous systems: the second, third, and sixth terms are the same
as those in equation 2.3; and the first, third, and fourth terms are from
equation 2.5. The seventh term represents the interaction between the
electron and the first-order proton in the z < −d plane and the fifth and
eighth terms represent the interactions between the electron and the second-
order proton images.
One further variable to add to the system is the position of the proton.
The system as a whole is x-independent7 hence the position of the proton
in the x-plane is arbitrary, so the position of the proton can be represented
solely by its position along the z-axis, z p , which has limits (−d < zp < d).
7 Only the electron-proton distance is important in the x-direction, not the location of
the system as a whole relative to the surface

10
Figure 2.3: A system consisting of a hydrogen atom held between two parallel
surfaces, including all first- and second-order images.

This term can be added to all the electron-proton interaction terms like so:


(
e02 2γ2k
Vtotal ( x, z) = − − e0 ∑ −
2
ρ k =1
8kd
γ2k−1 γ2k−1 γ2k
+ +p −p
4((2k − 1)d − z) x2 + (2(2k − 1)d − z − zp)2 x2 + (4kd − z + zp)2
)
γ2k−1 γ2k−1 γ2k
+ +p −p
4((2k − 1)d + z) x2 + (2(2k − 1)d + z + zp)2 x2 + (4kd + z − zp)2
(2.9)

where:
 p
x2 + (z − zp)2 for z > zp
ρ= p 2 (2.10)
x + (zp − z)2 for z < zp

11
The systems outlined here are fairly simple in their geometries, and are
made simpler still by the assumptions being made about them. Many more
complicated systems can be constructed, but using the image method the
potential affecting the dynamic particles of the systems can be calculated.

The Time Independent Schrödinger Equation


The Shooting Method
h̄2 2
− ∇ ψ + Vψ = Eψ (2.11)
2m
Now that the potential has been calculated, it can be used in conjunction
with TISE to discover more information about the system. The trouble is
that in order to solve TISE, we must provide two of the three factors that
comprise it. The potential, V, we already have, but we still need either the
energy of the particle, E, or the particle’s wavefunction, ψ. We do know
certain things about these two factors, however: we can specify boundary
conditions such that the wavefunction must be zero both at, and a large
distance from, all surfaces, and in order for it to be an eigenfunction it must
be continuous at all points. Furthermore, the energy of the electron will
be within a certain range which can be identified quite easily through trial
runs.
Using this information, the energy can be guessed, and thus we only
need to calculate the wavefunctions to verify solutions of TISE. In order to
do this, a rearranged TISE is required:

2m
∇2 ψ = − (− E + V )ψ = kψ (2.12)
h̄2
If this second-order differential equation can be solved, a trial wave-
function can be built for whatever estimated energy we choose. If the
wavefunction meets the criteria above (zero at the boundaries and contin-
uous at all points) then it is an eigenfunction and we will have found an
energy eigenvalue for a particular surface state of that system. Of course,
merely guessing the energy is unlikely to find a solution, so the wavefunc-
tions for a large variety of energies must be trialled, and the correct results
picked out. Solving problems with known boundaries in this manner is
called ’The Shooting Method’.

12
Runge-Kutta
In one dimension, ∇2 ψ can be written as two coupled differential equations:
∂ψ(z)
(i ) = s(z)
∂z
∂2 ψ ( z ) ∂s(z)
(ii ) 2
= = f ( ψ ( z ), z )
∂z ∂z
A single-order differential equation can be solved using finite difference
methods, and can then be rearranged into a way of finding the next point
of a function:
ψ(z + h) − ψ(z)
s(z) ≈ (2.13)
h
→ ψ(z + h) = ψ(z) + (h × s(z)) (2.14)
where h = δz, the step size. Similarly:
s(z + h) = s(z) + (h × f (ψ(z), z)) (2.15)
= s(z) + (h × k(z) × ψ(z)) (2.16)
This is the Euler method. k(z) can be calculated since the energy and
the potential (which in one-dimension is a function of z) are known, so
∂ψ(z)
provided that values for ψ(0) and ∂z |z=0 are supplied, the rest of the
wavefunction can be calculated, one step at a time. The former is easy to
get, as the boundary conditions specify that ψ(0) = 0. The latter must be
supplied by the program, which is a weakness of these methods that will
be revisited later.
While the Euler method is a useful method to derive, it is unacceptable
for serious use: it is a ’first-order’ method (i.e., it possesses an error of
O(h2 )) and is unstable over even moderately small step sizes[14]. More
commonly used is the fourth-order Runge-Kutta method which, as the
name implies, possesses an error of O(h5 ). For a one-dimensional second-
order differential equation, it takes the following form:
1
ψ(z + h) = ψ(z) + ( a1 + 2( a2 + a3) + a4) (2.17)
6
1
s(z + h) = s(z) + (b1 + 2(b2 + b3) + b4) (2.18)
6
where:
a1 = h × s(z) ; b1 = h × k(z) × ψ(z)
a2 = h × (s(z) + b1
2) ; b2 = h × k (z + 2h ) × (ψ(z) + a1
2)
b2 h a2
a3 = h × (s(z) + 2 ) ; b3 = h × k(z + 2 ) × (ψ(z) + 2 )
a4 = h × (s(z) + b3) ; b4 = h × k (z + h) × (ψ(z) + a3)

13
While the Euler method evaluates the gradient of the function at the
initial point, advances the variable by a step and then re-evaluates, the
Runge-Kutta method evaluates the gradient at the initial point, then sends
out two ’trial’ points (one above and one below the projection of the next
point) to the midpoint of the step and a third ’trial’ point at the projected
end point. As such, it evaluates the function four times per step, which
explains its higher accuracy. Higher orders of the method are possible, but
there is a trade-off in the speed of the algorithm. The fourth-order Runge-
Kutta algorithm is generally deemed to possess the best balance of speed
and accuracy[14] and given the number of energy values the program may
have to trial, efficiency is key.

Other Methods
The Runge-Kutta algorithm is a fairly generic method for numerically
solving differential equations, but since it doesn’t make use of any of the
properties unique to TISE it is unlikely to be the most efficient method for
this particular task. The Numerov method, by contrast, takes advantage of
the structure of TISE, as it is useful for solving equations of the form:

∂2
 
+ k(z) ψ(z) = 0 (2.19)
∂z2

which is a rearrangement of equation (2.12). When equations of this form


are expanded using the Taylor series, their symmetry means that many of
the terms cancel each other out, leaving an equation that offers an error of
O(h6 ) with only two evaluations per step:

y(z + h) = 2y(z) − y(z − h) + (h2 × k(z) × ψ(z)) (2.20)

where:

k ( z ) h2
 
y(z) = 1− ψ(z)
12

Although this seems like an ideal alternative to Runge-Kutta (fewer steps


and higher accuracy), the presence of the ψ(z − h) & V (z − h) terms mean
that this method is not self-starting, i.e., it requires another method to
generate the first couple of terms. The extra coding required and the need
to integrate two different methods is probably not worth the benefits in this
case.

14
TISE in Two-Dimensions
When considering systems containing a hydrogen atom, the the wavefunc-
tion and potential have a dependence on both z and x. Rather than adapt
the Runge-Kutta algorithm to account for this, the x-dependence of the po-
tential will be treated like a constant for each wavefunction calculated, but
many wavefunctions will be calculated with varying values of x. With ade-
quate sampling of points on these wavefunctions, a grid can be constructed,
which would be transformed into a matrix that represents the wavefunc-
tion in two-dimensions. In order to normalise this matrix, a normalised
one-dimensional wavefunction that runs parallel to the surfaces will need
to be calculated, and can then be used to weight the others. Weighting
is required due to the arbitrary starting point of the first differential of
the wavefunction, s(0). In effect, because s(0) is chosen arbitrarily, the
wavefunctions will be normalised with respect to themselves but not to
each other.

Outline of Program
In order to carry out this investigation, a program will be written that,
when given a starting energy value, will run the Runge-Kutta algorithm for
the range −d < z < d (for systems with only one surface, the particle will
be started at a sufficient distance from the surface, and with a sufficiently
small, but non-zero, starting value), then assesses the quality of the wave-
function it calculates according to the criteria outlined above. It should
then systematically repeat this process for a series of energies between this
minimum energy and the maximum possible energy, E = 0, and identify
those energies that produce complete eigenfunctions. It should then repeat
all of this for different systems with various initial conditions.

Selection of Correct Energies


For each energy, the program will set the Runge-Kutta algorithm running in
the +z direction from the left starting point until it reaches some arbitrary
point in the cavity, then break and for the same energy start a wavefunction
from the surface on the right running in the −z direction until it reaches
this same arbitrary point. The two partial wavefunctions don’t necessarily
have to meet at this point, but they have to form a continuous wave when
normalised. In order to check this, the following calculation is performed

15
at the point at which the two wavefunctions meet:

s( p) L s( p) R
χ= − (2.21)
ψ( p) L ψ( p) R

where z = p is the position of the joining point. If the wavefunction were


perfectly continuous, χ would be equal to zero. In reality, the aim of the
program is to find the energy that results in the minimum value of χ for
each system. In theory the best way to do this would be to use tiny step
sizes when incrementing the trial energies, but this would be inefficient.
Instead, the program should search for points where χ crosses from positive
to negative (i.e., where the gradients of the wavefunctions change relative
to each other), then drill down to find the energy as close to the exact
crossing point as possible.

Nodes
Since the program may be tasked with finding more than one energy
eigenvalue for any system, it is not enough to simply program it to find
the most continuous trial wavefunction; it has to be able to identify the
best wavefunction for a specific range of energies. The best way to do
this is to count the number of nodes possessed by each wavefunction as
it is calculated. For a S.H.O., the number of nodes (not including the
nodes at the boundaries) represents the energy level, n, minus one (where
n = 1, 2, 3, ...) so for example, the wavefunction of the ground state for
a S.H.O. shouldn’t have any nodes, while the first excited state should
ψ(z)
possess one. The simple way to identify a node is to calculate ψ(z−h) . If
the result of this calculation is negative then a node can be identified and
counted between (z − h) and z.

Normalisation
As stated above, the un-normalised partial wavefunctions don’t need to
be of the same scale or even the same sign. In normalising them, the total
sum under both wavefunctions should be equal to one, and together they
should form a continuous line. This normalisation will be achieved by
multiplying the value of every point on one of the wavefunction halves by
the ratio of the values at the joining point, then by squaring each point on
both halves, and finally by summing the value of every point and dividing

16
each point through by this total:
n o2
ψ( p) R
ψ( p) L
× ψ(z) L
ψ(z) L → (2.22)
sum
ψ(z)2R
ψ(z) R → (2.23)
sum
where:
( )
2 p d
ψ( p) R
sum =
ψ( p) L
× ∑ hψ(q)2L + ∑ hψ(q)2R
q=−d q= p

Adaptive Step Size


In order to further optimise the running of the program, the Runge-Kutta
algorithm can be coupled with an adaptive step size. Ideally, the program
should use the smallest possible step size to collect the maximum amount
of data about the wavefunction at all points in the cavity but, there will be
certain sections where the wavefunction isn’t changing much, and other
sections where it it changing a lot over a small area. For maximum efficiency,
the density of steps should be at a maximum where the wavefunction is
changing rapidly. This is the reasoning behind the use an adaptive step size.
The principle behind it is that for each step, the Runge-Kutta algorithm is
applied once to find the value of ψ(z + h) and is then applied again to find
the value of ψ(z + 2h ). These values are fed into the following formula:
1
15 δ 5
hcheck = h (2.24)

h
16 ψ(z + h) − ψ(z + 2 )

where δ is the acceptable error for each step, supplied by the user. If
h < hcheck then hcheck will be used as the new step size, otherwise the step is
repeated, starting with a step size of 2h . In this way, when the wavefunction
is rapidly changing, the step size is reduced until the error in the step falls
below that set by the user, and when the wavefunction is relatively constant,
the step size increases until it reaches the acceptable error level.
This does mean that the program will have to apply the Runge-Kutta
algorithm at least twice per step, which could negatively affect the speed of
the program is inappropriate initial conditions are set. Also, the program
will have coded to be a very flexible, as there will be no way of knowing
before running it how many steps there will be for each energy level, or

17
how big each step will be. However, the likely overall benefits in speed
and accuracy far outweigh any potential drawbacks.

Units
In order to speed up calculations, the program will use atomic units in all
its calculations. This means that within the program, the following symbols
are redefined:
1
me = e = h̄ = =1 (2.25)
4πe0
4πe0 h̄2
→ The Bohr Radius, a0 = =1 (2.26)
m e e2
m e e4
→ The Hartree Energy, Eh = =1 (2.27)
(4πe0 h̄)2
e2
→ e02 = =1 (2.28)
4πe0
2m
→ k = − 2 (− E + V ) = 2(− E + V ) (2.29)

So any quantities that need to be entered into the system (for example,
the width of the cavity, the position of the proton and the range of energies)
will need to be converted into the units in equation 2.25 above before they
can be used in any calculations. For the most part this will mean dividing
all distances by a factor of 0.529... to convert them from a.u. (10−10 m) to a0
and dividing all energies by 27.211... to convert them from eV (1.6 × 10−19 J)
to Eh . It is also crucial to do the inverse when outputting the results, either
in graphs or print-outs.

Sources of Error
Aside from the error of O(h5 ) inherent within the Runge-Kutta algorithm,
there are many other sources of errors that can be introduced by compu-
tational methods. The two most direct are the factor of δ built into the
adaptive step size regime and the step size over which the energy is trialled.
Although the latter is fixed to an extent, in that if the step size is set too large
then the correct energy won’t be trialled and no results will be returned,
so at crossing points of χ the energy step will be halved and then halved
again until the exact minimum point is discovered. The trouble is that no
matter how small the step size gets, it won’t find the exact crossing point,

18
so a capping point to how small the energy step can get (and hence how
accurate the energy level will be for the particular system) must be added.
As the electron nears a surface, the distance between it and its image
tends towards zero, so the potential, which contains the reciprocal of the
distance, tends towards infinity. Infinity is a difficult concept to deal with
computationally, so a perturbation, ∆, is added in order that instead of
tending towards infinity, the potential tends towards some small but real
point instead:

γ γ 4
→ → − when z = d (2.30)
4( d − z ) 4{d − (z + ∆)} ∆

Although it is possible to make this value small enough that rounding


errors all but cancel it out (the program will be coded using double precision
so error values smaller than 10−16 will be overshadowed by rounding
errors), it is still a source of error that will be built into the code.
When considering a hydrogen atom, the potential calls for an infinite
sum to be calculated that describes the interactions of all the images with
the electron. It is not possible to calculate an infinite sum, so the sum must
be capped at some point.

Hardware & Software


The program will be written in the Fortran90 programming language, as I
have some previous experience using it. Fortran is also particularly suited
to this kind of work as it was designed for use and efficiency at numeric
computation[14] and is among the most popular languages for use with
high performance computing.
While the code is being written, it will be compiled and tested on
a laptop running Kubuntu 10 with an Intel Core Duo T2050 processor
(1.60GHz per core) and 1Gb memory. Once the code is finished, it will be
uploaded to the University of York Edred cluster, which runs at 2.2Ghz per
core. In order to make use of the cluster environment, the program should
read all of its default values from a file, so that multiple instances of the
same code can be sent to different cores simultaneously. The compilers
used will be g95 on the cluster and NAGFor on the laptop.

19
3

Results and Discussion

The results obtained using the methods outlined above are presented here
by order of the system to which they pertain. The system consisting of an
electron and a single surface has been included here as a test to verify that
the program is working as it should. The results for this system can be
easily compared to the results attained others as they are readily available.
All results have been collected using a δ value (the error in the Runge-Kutta
adaptive step size) of 0.01.

Electron, One Surface


The ground state energy for this system should be E(1) = −0.85eV and
E (1)
energy levels of excited states should then follow the pattern n2 . Table
3.1 presents the expected results and the results obtained by the program
for the ground state and first two excited states:

E(0)
n n2
,
eV Result, eV Error, %
1 -0.85000 -0.85036 0.04235
2 -0.21250 -0.21253 0.01411
3 -0.09444 -0.09200 2.65217

Table 3.1: The energy eigenvalues, both predicted and attained, for a system
consisting of an electron near a single surface.

For a reasonably unchallenging cycle, these results are impressively


close to their target values. By decreasing the step size of the trialled en-
ergies, the accuracy of these results can be improved dramatically. For

20
example, by dividing the step size by ten (and reducing the range of en-
ergies trialled), a new result was obtained: E(3) = −0.09448eV, which is
a much better result than the one presented in table 3.1. After the energy
eigenvalues have been collected, their eigenfunctions can be plotted as a
function of z. To make the data more readable, the eigenfunctions have
been given vertical separation by setting their origins at their associated
energy eigenvalues. These results can be seen in figure 3.1. Note that
number of nodes of the wavefunction pertains to n − 1.

-0.1

-0.2

-0.3

Energy, eV
-0.4
’Potential’
’Ground State’
’First Excited State’ -0.5
’Second Excited State’
-0.6

-0.7

-0.8

-0.9

-25 -20 -15 -10 -5 0 5 10 15 20 25


z, a.u.

Figure 3.1: The normalised eigenfunctions of the ground state and first two excited
states for an electron bound to a surface located at z = d = 25a.u.. The
eigenfunctions have been adjusted so that their origins are at their
respective energy eigenvalues (as laid out in table 3.1).

Given the accuracy of these results, it is clear that the program is be-
having as it should. It can now be put to task running models for more
complicated systems.
Before that, however, there is still some analysis that can be done on
the results for this system. If, for example, the trial energy is plotted
against χ (which assesses the quality of the wavefunction), some interesting

21
4
3
2
1
0

n
-1 -0.9 -0.8 -0.7 -0.6 -0.5 -0.4 -0.3 -0.2 -0.1 0
Energy, eV

Figure 3.2: Plot showing how χ changes with energy for a system of an electron
near a single plane located at z = d = 15a.u.. The disturbances in the
line are asymptotic, which could be seen more easily with a smaller step
size. The black dots show the locations of the energy eigenvalues and
the discontinuous green line shows the number of nodes, n, possessed
by the wavefunctions at those energies.

patterns emerge (see figure 3.2). The figure shows that there is a slight
downwards slope in χ, which registers even-energy states (n = 2, 4, 6, ...)
when it changes sign. But at odd energy eigenvalues (which have even
eigenfunctions), χ suddenly displays asymptotic behaviour, then returns
to slightly above its original position1 . This is why it is important that the
step size for the energy loop is kept to a minimum: there is little warning
when these asymptotes are about to occur and, if they are missed, there is
no way of knowing it. One reason that the lines in figures 3.1 and 3.3 finish
at different values of d is because, as d is increased, these asymptotes get
thinner and thinner until they essentially turn into delta-functions. When
1 Itis difficult to see in figure 3.2, but the vertical line upon which the E(3) point is
situated contains a small horizontal section close to and crossing the axis.

22
this happens, the step size for the energy loop needed to catch them has to
be so small as to slow the program down dramatically. The other reason
for not continuing the lines to higher values of d, which pairs with the first,
is that the two factors that most affect the speed of the program are the
energy value trialled and the width of the cavity. Hence, in order for the
program to run at a reasonable rate, these two values must be balanced
accordingly (i.e., for high values of d, only lower energy regions should be
investigated, whereas for a lower value of d, there is more freedom as to
the energy range chosen). Given that there is no new interesting data to be
found in extending the lines (they should all tend towards their respective
E (1)
values of n ), it would be a waste of computing time to do so.

Electron, Two Surfaces


This system is far more sensitive to its initial conditions than its one-surface
relative. In the latter, the starting position of the electron is not particularly
important: if it is set too close to the surface, the program simply will not
find the energy eigenvalues of some or all of the surface states. In the
two-surface system (which at large values of d should resemble the one-
surface system), if the cavity is too narrow, the wavefunctions can begin
to warp and change shape as the peaks at each surface start to superpose.
To investigate this behaviour, the program has a running mode whereby it
will find the energy eigenvalues for each surface state as d is changed. The
results of this can be seen in figure 3.3:
It is clear from this figure that, if the lines are collected into three pairs,
there are features common to all of them. All three pairs of lines have one
line that enters the picture at lower values of d, plummets down from zero
to some minimum and then curves back up and straightens out to converge
upon a point. The other line in the pair enters the picture around the point
where the first line reaches its minima, then quickly falls and (with no
minimum) straightens out to join the first line in converging upon a point.
If we consider the system as an electron with its two first-order image
charges, and treat the rest of the images as a perturbation, what we have is
essentially the dihydrogen cation, H2+ (i.e., an electron in the vicinity of two
protons). If we were to investigate the energy states of an electron in the
H2+ system as a function of proton-proton distance, we would see a very
similar pattern to the one in the complete image-system, with the first line
representing the bonding molecular orbit and the second line representing
the anti-bonding molecular orbit.
What this means is that in the complete image-system, which is symmet-

23
0
-0.1
-0.2
-0.3
-0.4
’Ground State’
’First Excited State’ -0.5
’Second Excited State’

Energy, eV
’Third Excited State’ -0.6
’Fourth Excited State’
’Fifth Excited State’ -0.7
-0.8
-0.9
-1
-1.1
-1.2
-1.3

0 5 10 15 20 25 30 35 40 45 50 55 60
d, a.u.

Figure 3.3: Plot showing the relationship between the energy eigenvalues for
various surface states and the distance from the origin, d of two surfaces
which confine an electron (i.e., the cavity formed by the two surfaces is
2d wide).

rical and features n-peaks at each boundary, the first line, which enters the
picture earlier and goes down to a minimum before planing out, represents
the addition of these peaks, and the second line, which enters the picture
later and falls before planing out with no minimum, represents the subtrac-
tion of these peaks. Looking at figure 3.3 this makes sense: the minimum
on the ’bonding’ line represents the point at which the peaks are perfectly
in phase, which also explains why the ’anti-bonding’ line should be zero at
this point. It also makes sense that the ’anti-bonding’ lines should represent
all the wavefunctions with an odd number of nodes, as each wavefunction
under the anti-bonding regime will possess a sustained area with a proba-
bility density of zero (which is what a node represents) anywhere the peaks
overlap, while the wavefunctions under the ’bonding’ regime will not, and
so will have one less node.
Once the cavity is wide enough that the peaks no longer overlap, the

24
distinction between the ’bonding’ and ’anti-bonding’ regimes disappears,
and the paired states become degenerate. They will tend towards their
equivalent values in the one-surface system. Figure 3.4 depicts the first
few eigenfunctions, adjusted to their respective energy eigenvalues as
before, for a variety of cavity widths. They have been chosen because they
represent important points in figure 3.3.

Hydrogen Atom
It has been shown that, given enough time, the program can produce
incredibly accurate results. The trouble is that even for systems as simple
as the electron near one surface, to get a full set of results for values of
d > 15a.u. for a reasonable accuracy can take hours. In order to find the
wavefunctions for the hydrogen atom, the requisite energy eigenvalue
needs to be found for each value of x and then an extra value needs to be
found for the weighting wavefunction. Thus to produce a 20 × 20 grid
for the 2D wavefunction in a 20a.u. cavity (i.e., d = 10a.u.) would require
running the program twelve times (the wavefunction will be symmetric
about x = 0, but the x = 0 term will need to be calculated), then normalised,
and the wavefunctions sampled at appropriate points, then plotted. Even
with the cluster at my disposal, this is a timely process.
Before setting the program to work on these systems, it is important to
verify that it isn’t doomed to failure before it begins. Figures 3.7 and 3.8
show some of the potentials experienced by the electron of a hydrogen atom
near a single surface and between two surfaces respectively. Each figure
shows the effect of incrementally moving the proton towards a surface in
these systems (the system with two surfaces is symmetrical in this regard).
Note that in both systems, when the proton is positioned at the surface,
the potential appears as if the proton weren’t there at all. These images of
the potentials are very similar to those produced by Ganesan in his 1996
paper on the same subject[3], which is unsurprising given that he derived
his using a similar image method (though his potential does contain the
extra proton self-energy term; see above). Given that the potentials are at
least of the correct form, the program should be set to work on calculating
the wavefunctions that they affect.
Figures 3.7 and 3.8 show the ground state eigenfunctions for a hydrogen
atom in the vicinity of a surface and in a cavity of width 2d = 10a.u.,
respectively. The proton is located at the origin, x = z = 0, in both cases. I
suspect that looking for higher energy states, increasing the cavity width,
or moving the proton from the origin would all produce more interesting

25
0 0
-0.1 -0.1
-0.2 -0.2
-0.3 -0.3
-0.4 -0.4
-0.5 -0.5
-0.6 -0.6
-0.7 -0.7
-0.8 -0.8
-0.9 -0.9
-1 -1
-1.1 -1.1
-1.2 -1.2

-20 -15 -10 -5 0 5 10 15 20 -20 -15 -10 -5 0 5 10 15 20

(a) d = 1.5 (b) d = 3.0

0 0
-0.1 -0.1
-0.2 -0.2
-0.3 -0.3
-0.4 -0.4
-0.5 -0.5
-0.6 -0.6
-0.7 -0.7
-0.8 -0.8
-0.9 -0.9
-1 -1
-1.1 -1.1
-1.2 -1.2

-20 -15 -10 -5 0 5 10 15 20 -20 -15 -10 -5 0 5 10 15 20

(c) d = 4.5 (d) d = 8.0

0 0
-0.1 -0.1
-0.2 -0.2
-0.3 -0.3
-0.4 -0.4
-0.5 -0.5
-0.6 -0.6
-0.7 -0.7
-0.8 -0.8
-0.9 -0.9
-1 -1
-1.1 -1.1
-1.2 -1.2

-20 -15 -10 -5 0 5 10 15 20 -20 -15 -10 -5 0 5 10 15 20

(e) d = 13.2 (f) d = 17.5

Figure 3.4: This series of graphs shows the eigenfunctions for surface states cre-
ated by an electron in a cavity between two material planes (y-axis:
Energy, eV), and how their shapes change with the width of the cavity
(x-axis: z, a.u.). The two plates are located at ±d. The black line shows
the potential experienced by the electron, the red line is the ground
state, the green line is the first excited state, the blue line is the second
excited state and the purple line is the third excited state. There are
several computational artefacts that can be seen in these graphs, for
example the disturbance in the ground state on figure 3.4(c).
26
V(z,x) V(z,x)

0 0

-0.2 -0.2

-0.4 -0.4

-0.6 -0.6

-0.8 -0.8
5 5
-1 -1

-5 -4 0 -5 -4 0
-3 -2 x / a0 -3 -2 x / a0
-1 0 -1 0
1 2 1 2
z / a0 3 4 -5 z / a0 3 4 -5
5 5

(a) z p = 0.0 (b) z p = 2.5

V(z,x) V(z,x)

0 0

-0.2 -0.2

-0.4 -0.4

-0.6 -0.6

-0.8 -0.8
5 5
-1 -1

-5 -4 0 -5 -4 0
-3 -2 x / a0 -3 -2 x / a0
-1 0 -1 0
1 2 1 2
z / a0 3 4 -5 z / a0 3 4 -5
5 5

(c) z p = 4.0 (d) z p = 5.0

Figure 3.5: A selection of potentials (z-axis, up the page: V, eV) in two dimensions
(x-axis, into the page: x, a.u. ; y-axis, across the page: z, a.u.) as expe-
rienced by an electron near a single surface (located at z = d = 5a.u.)
with a proton at x = 0 ; z = zp.

27
V(z,x) V(z,x)

0 0

-0.2 -0.2

-0.4 -0.4

-0.6 -0.6

-0.8 -0.8
5 5
-1 -1

-5 -4 0 -5 -4 0
-3 -2 x / a0 -3 -2 x / a0
-1 0 -1 0
1 2 1 2
z / a0 3 4 -5 z / a0 3 4 -5
5 5

(a) z p = 0.0 (b) z p = 2.5

V(z,x) V(z,x)

0 0

-0.2 -0.2

-0.4 -0.4

-0.6 -0.6

-0.8 -0.8
5 5
-1 -1

-5 -4 0 -5 -4 0
-3 -2 x / a0 -3 -2 x / a0
-1 0 -1 0
1 2 1 2
z / a0 3 4 -5 z / a0 3 4 -5
5 5

(c) z p = 4.0 (d) z p = 5.0

Figure 3.6: A selection of potentials (z-axis, up the page: V, eV) in two dimensions
(x-axis, into the page: x, a.u. ; y-axis, across the page: z, a.u.) as expe-
rienced by an electron confined within a cavity between two surfaces
(located at z = ±d = ±5a.u.) with a proton at x = 0 ; z = zp.

28
Probability Density
0.008
0.007
0.006
0.005
0.004
0.003
0.002
0.001
0 -5
-5 -3
-1 0
z, a.u. 1 x, a.u.
3 5
5

Figure 3.7: The two-dimensional ground state eigenfunction for an electron bound
to a surface located at z = d = 5a.u. and a proton located at the origin,
z = x = 0.

figures, but as a proof of concept that the program works correctly, these
figures do the job.
The trouble comes when trying to extract the energies from these two-
dimensional wavefunctions. The way the wavefunctions were constructed
means that each row of x-values has an energy associated with it. The ques-
tion is how to use this information to construct a total energy eigenvalue for
the whole equation. In theory, given that we possess the matrix of h x |ψ|zi
values, it should be possible to solve TISE again to get an energy value for
each point on the matrix:
n 2  2  o
h̄ ∂2
− 2m ∂
∂x2
+ ∂z2
+ Vx,z ψx,z
= Ex,z (3.1)
ψx,z
Finite difference methods can be used to solve the differential equations.
The result should, if everything worked perfectly, be exactly the same for
every point on the matrix, which would be the energy for the wavefunction

29
Probability Density
0.01
0.009
0.008
0.007
0.006
0.005
0.004
0.003
0.002
5
0.001 3
0 1
-5 -1 z, a.u.
0 -3
x, a.u. 5 -5

Figure 3.8: The two-dimensional ground state eigenfunction for an electron con-
fined within a cavity between two surfaces located at z = ±d = ±5a.u.
and bound to a proton located at the origin, z = x = 0.

as a whole. A little deviation could be averaged out, as even a rough


estimate of the energy would be interesting. The results are presented in
figure 3.9.

30
Energy, eV
-0.5

-0.4

-0.3

-0.2

-0.1
5
0 3
-5 1
0 -1 z, a.u.
-3
x, a.u. -5
5

Figure 3.9: This is a plot of the energy matrix calculated using equation 3.1. It
should be a flat plane representing the total energy of the ground state
eigenfunction of an electron confined within a cavity between two
planes located at z = ±d = ±5a.u. and a proton located at the origin,
z = x = 0. Instead there are two huge peaks that roughly correspond
to the peaks of figure 3.8.

31
4

Conclusions

The previous chapter shows two things: firstly, it shows that the image
method is suitable for calculating the potentials of systems such as the ones
looked at during the course of this project; secondly, the program, which
was written to solve TISE for one-dimensional boundary value problems
(the code for which can be found in the appendix), has proven itself an
adaptable problem-solving tool. Given enough time, there is no reason it
couldn’t go on to solve some of the more complicated systems mentioned
above.
Future work in this area could start with finding a way to extract the en-
ergy from the two-dimensional wavefunction, or alternatively by adapting
the Runge-Kutta algorithm to be fully two-dimensional. It would also be
of interest to see how the Numerov method compares to the Runge-Kutta
method in terms of efficiency (in both writing and running), accuracy, and
flexibility. Moreover, it would be nice to see the impact of the two variables
for which no results have been found: γ and z p .
In terms of the aims laid out in the introduction, this project has been
very successful in that it has reaffirmed older results for systems consisting
of an electron near a surface[15, 12] and those for the hydrogen atom[12]
near a surface. But further than this it has taken the methods laid out by
other works and produced results that are expanded in scope and more
accurate. Figure 3.3, for example, displays results similar to those obtained
by Babiker[2] for the ground state and first two excited states of an electron
in a cavity for a limited range of cavity widths, and then adds the next three
energy levels. It is in these expanded results that the general pattern of the
bonded and anti-bonded states can be seen, which gives a new perspective
on the whole system.
There is certainly more work to be done on systems such as these,
and I think that the work done during this project will provide a useful

32
foundation for such work to build on.

Acknowledgements
I wish to thank Mohamed Babiker, Joseph Beaver, Adelle Hay, Matthew
Hodgeson and Matthew Probert for their assistance and support.

33
Bibliography

[1] C. C. Grimes, T. R. Brown, M. L. Burns, and C. L. Zipfel, Phys. Rev. B


13, 140 (1976).

[2] M. Babiker, Journal of Physics: Condensed Matter 5, 2137 (1993).

[3] K. Ganesan and K. T. Taylor, Journal of Physics B: Atomic, Molecular


and Optical Physics 29, 1293 (1996).

[4] Martin-Haugh, S., Quantum States in Wedges, PhD thesis, University


of York, 2009.

[5] N. S. Simonovic, Journal of Physics B: Atomic, Molecular and Optical


Physics 30, L613 (1997).

[6] M. Amin and M. El-Aasser, Brazilian Journal of Physics 39, 301 (2009).

[7] L. Tian, P. Rabl, R. Blatt, and P. Zoller, Phys. Rev. Lett. 92, 247902
(2004).

[8] D. J. Griffiths, Introduction to Electrodynamics, 3rd Ed. (Prentice-Hall,


Englewood Cliffs, London, 1998), chap. 3.

[9] E. Weber, Electromagnetic Theory (Dover Publications, 1965), chap. 21.

[10] J. D. Jackson, Classical Electrodynamics, 3rd Ed. (Wiley, 1999), chap. 1,2.

[11] K. Wyk, Solutions To Problems Of Jackson’s Classical Electrodynamics,


1999.

[12] M. Babiker, Solid State Communications 38, 463 (1981).

[13] E. G. McRae, Rev. Mod. Phys. 51, 541 (1979).

[14] W. Press, Numerical Recipes in Fortran (Harper Perennial, New York,


1992).

34
[15] P. Echenique, J. Pitarke, E. Chulkov, and V. Silkin, Journal of Electron
Spectroscopy and Related Phenomena 126, 163 (2002).

35
A PPENDICES

The appendices consist entirely of the Fortran90 code for the


program described in the ’Methodology’ section. It has been
extensively commented and exported to pdf to make it easier to
read. I hope I have succeeded in making it so.
1 PROGRAM Cavity_Electrostatics
2
3 IMPLICIT NONE
4
5 INTEGER, PARAMETER :: dp=kind(1.0d0)
6 INTEGER :: En, zn, p=0, n, b, nodes, s, a, div, m, dn, ios, xn
7 REAL(dp) :: Eh, a0, k2, V, safe, Seth, error, join, small
8 REAL(dp) :: zmin, zmax, ystartL, ystartR, rat, ysum, diff, vysum, vdiff
9 REAL(dp) :: xmin, xmax, xinc, zp, dzp, zpmin, zpmax, zpinc
10 REAL(dp) :: E, Emax, Emin, bestE, vE
11 REAL(dp) :: d, dmin, dmax, dinc, dd, yout
12 REAL(dp), ALLOCATABLE, DIMENSION(:,:) :: ev
13 PARAMETER (Eh=27.211384523_dp, a0=0.52917721082_dp) ! Eh is used to convert Hartree Energy into
eV, a0 is used to convert Bohr Radii into Angstrom
14
15 PRINT*, "------------------------------"
16
17 OPEN(unit = 2, file = "parts", iostat=ios) ! Open the file containing the
instructions of which process to run
18
19 DO
20
21 PRINT*, "****************************"
22
23 IF (ios > 0) THEN
24 PRINT*, "ERROR in opening file"
25 PRINT*, "****************************"
26 PRINT*, "------------------------------"
27 STOP
28
29 ELSE
30 READ(2,*,end=10) s, m, dn, dd, dzp, Emin ! Read the file and extract s (the system
we are using), m (the variable we are investigating), dn (which energy level we are looking
for). If finished, move to the end of the loop
31
32 ENDIF
33
34 SELECT CASE(s) ! Add a little notification to state which system we are modelling
35 CASE DEFAULT
36 PRINT*, "SOMETHING HAS GONE WRONG!", s
37 EXIT
38 CASE(1)
39 PRINT*, "Electron, One Surface"
40 CASE(2)
41 PRINT*, "Electron, Two Surfaces"
42 CASE(3)
43 PRINT*, "Hydrogen, One Surface"
44 CASE(4)
45 PRINT*, "Hydrogen, Two Surfaces"
46 END SELECT
47 SELECT CASE(m)
48 CASE DEFAULT
49 PRINT*, "SOMETHING HAS GONE WRONG!", m
50 EXIT
51 CASE(1)
52 PRINT*, "Looking for surface states."
53 CASE(2)
54 PRINT*, "Varying d and looking for E(",dn,")."
55 CASE(3)
56 PRINT*, "Varying zp and looking for E(",dn,")."
57 CASE(4)
58 PRINT*, "Running the code once for testing purposes."
59 END SELECT
60
61 PRINT*, "****************************"
62 PRINT*, "------------------------------"
63
64
65 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
66 ! Define the system !
67 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
68
69
70 ! Set the default values for which the program will run
71 Emax = -0.0_dp / Eh ! This is the maximum energy that the loop will run to
72 Emin = - Emin / Eh ! Read from file: The starting point of the energy loop
73 dzp = dzp / a0 ! Read from file: The default position of the proton
74 dd = dd / a0 ! Read from file: The default distance of the surface from the origin
75
76 ! Set the parameters that determine the accuracy of the program
77 error = 0.01_dp ! Set the allowable error for a given value of h
78 safe = 0.1_dp ! This is the value of the condition that a trial wavefunction has to meet
79 xn = 10 ! xn * 2xn are the dimensions of the array that will store the values of the 2D
wavefunction
80 zn = 100 ! This is the minimum number of iterations that the z loop will go through
81 En = 10000) ! This is the minimum number of iterations that the energy loop will go through
82 small = 1.0E-10_dp ! This is the smallest number acceptable in this program
83
84 ! Set the range over which the wavefunctions will be plotted
85 zmax = dd
86
87 IF (s == 3) THEN
88 zmin = 2.0_dp * (-dd) ! For the case of the hydrogen atom near a single surface,
we want to start the electron further from the proton
89
90 ELSE
91 zmin = -dd ! Otherwise, put the second surface an equal and opposite distance to the
centre point as the first surface
92
93 ENDIF
94
95 ! Set the minimum and maximum distances of the surface(s) from the origin
96 dmax = 30.0_dp / a0
97 dmin = 1.0_dp / a0 ! R > Rc (~ 2-3a0) -> Weak overlap picture
98
99 ! Set the spread of the 2D wavefunction in the x-direction
100 ! If the grid is to be a square, z will go from -dd to dd, so we want x to do the same. However,
we don't want to start is at these points as the weighting wavefunction shouldn't necessarily be
zero at the boundaries, so start it from further away.
101 xmax = 2.0_dp * dd
102 xmin = - 2.0_dp * dd
103
104 ! Set the range of values for the position of the Proton in the cavity
105 zpmax = dd ! This is the maximum possible value of zp
106 zpmin = 0.0_dp ! The energies attained from moving the proton should be symmetrical
whether it is moved left or right
107
108 ! Set the initial conditions of the left and right wavefunctions
109 ystartR = 0.0_dp
110
111 IF ((s == 2).OR.(s == 4)) THEN
112 ystartL = 0.0_dp ! The wavefunction must be zero at the boundaries
113
114 ELSE
115 ystartL = 0.01_dp ! When there is only one surface, there is no boundary condition
on the left.
116
117 ENDIF
118
119 ! Set variables to their default values
120 n = dn
121 zp = dzp
122 d = dd
123 join = d / 10.0_dp ! This is the point at which the left wavefunction meets the right
wavefunction
124 bestE = Emin
125 b = 0
126
127 IF (m == 1) THEN ! When looking for surface states...
128 div = 5 ! The number of points we will look for
129 CALL VzvsE(zmin,zmax,0.0_dp,0.0_dp,d,Emin,zn,s) ! Write the values for the
potential to a file
130
131 ELSEIF (m == 2) THEN ! When varying the width of the cavity...
132 div = int(dmax - dmin) ! Amounts to a point per tic
133 dinc = (dmax - dmin) / 20.0_dp ! Increment for use when varying the width of the
cavity
134
135 ELSEIF (m == 3) THEN ! When varying the position of the proton...
136 div = int(dd) / 2.0_dp
137 zpinc = (zpmax - zpmin) / div ! Increment for use when varying the position of
the proton
138 CALL TDVzvsx(zmin,zmax,xmin,xmax,zp,d,Emin,s) ! Write the values of the two-
dimensional potential to a file
139
140 ELSEIF (m == 4) THEN ! When running the code through once...
141 div = 1
142 ! CALL VzvsE(zmin,zmax,0.0_dp,0.0_dp,d,Emin,zn,s)
143 ! CALL TDVzvsx(zmin,zmax,xmin,xmax,zp,d,Emin,s)
144
145 ENDIF
146
147 ALLOCATE(ev(div,2)) ! The array that will contain the results
148 ev = 0.0_dp ! Set all values in the eigenvalue array to zero
149
150 ! A check of the variables we have set
151 IF ((zmax < zmin).OR.(Emax < Emin).OR.(dmax < dmin).OR.(xmax < xmin)) THEN
152 PRINT*, "****************************"
153 PRINT*, "Max's must be bigger than Min's!"
154 PRINT*, "****************************"
155 PRINT*, "------------------------------"
156 STOP
157
158 ENDIF
159
160 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
161 ! Run The Program !
162 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
163
164 DO a = 1, div ! Loop over the number of points we are looking for
165
166 IF (m == 1) THEN ! If we are looking for surface states, increment n with
the loop
167 n = a-1
168
169 ELSEIF (m == 2) THEN ! If we are varying the width of the cavity, increment d
170 d = dmin + (a-1)*dinc
171 zmax = d ! Be careful to remember to keep the boundary conditions in place!
172
173 IF (s == 3) THEN
174 zmin = 2.0_dp * (-d) ! For the system of a hydrogen atom near a
surface, start z slightly further away so the electron's starting point isn't in the
potential well of the proton.
175
176 ELSE
177 zmin = -d
178
179 ENDIF
180
181 ELSEIF (m == 3) THEN ! If we are varying the position of the proton, increment
zp
182 zp = zpmin + (a-1)*zpinc
183
184 ENDIF
185
186 IF ((s == 3).OR.(s == 4)) THEN ! When dealing with the Hydrogen atom, we are
looking for the energy of a 2D system
187 CALL
TDEnergyLoop(zmax,zmin,zn,Emax,Emin,En,xmin,xmax,xn,zp,safe,ystartL,ystartR,error,small,s,
n,a,bestE)
188
189 ELSE
190
191 IF (a == 0) THEN
192 PRINT*, "These are the energy values for the first iteration:"
193 PRINT*, " E(eV) " , " n " , " x(a0) " , " d(a0) "
194
195 ENDIF
196
197 CALL
EnergyLoop(zmax,zmin,zn,Emax,Emin,En,safe,ystartL,ystartR,0.0_dp,join,error,d,small,s,n,a,
bestE,zp) ! Find the energy for a 1D system given the parameters
198
199 ENDIF
200
201 ev(a,2) = bestE ! Put that value into the results array
202
203 IF (m == 1) THEN ! If looking for surface states, add the energy level to the
results array
204 ev(a,1) = n
205
206 ELSEIF (m == 2) THEN ! If varying the width of the cavity, add the current
width to the results array
207 ev(a,1) = d
208 WRITE(((s*1000)+int(100*Emin*Eh)+int(n)),*) d*a0, E*Eh ! Write the energy as a
function of the width to a file
209
210 ELSEIF (m == 3) THEN ! If varying the position of the proton, add its current
posisition to the results array
211 ev(a,1) = zp
212
213 ELSEIF (m == 4) THEN
214 ev(a,1) = n
215 ! ev(a,1) = d
216 ! ev(a,1) = zp
217
218 ENDIF
219
220 ! Add a counter so the productivity of the program can be assessed
221 IF (a == 1) THEN
222 PRINT*, "... and so on. Only ",(div-a)," iterations left to go! E = ", ev(a,2)*Eh,"eV"
223
224 ELSEIF ((a /= 0).AND.((div-a) > 0)) THEN
225 PRINT*, "Still Working! Only ",(div-a)," iterations left to go! E = ", ev(a,2)*Eh,"eV"
226
227 ENDIF
228
229 END DO
230
231
232 PRINT*, "RESULTS!"
233 PRINT*, "------------------------------"
234
235 !!!!!!!!!!!!!!!!!!!!!!!!!!!!
236 ! Print the results !
237 !!!!!!!!!!!!!!!!!!!!!!!!!!
238
239 DO p = b+1, div ! Loop over all the results from the above loop
240
241 IF ((ev(p,2) /= 0.0_dp).AND.(abs(ev(p,2)) < abs(Emin))) THEN ! If the position
in the array contains a result...
242 b = p ! Set the position marker
243 E = ev(b,2) ! Extract the energy from the array
244
245 IF (m == 1) THEN ! If looking for energy states...
246 n = ev(b,1) ! Extract the state from the array
247 CALL
rk4loop(zn,zmin,zmax,ystartL,ystartR,E,0.0_dp,join,error,d,small,rat,yout,nodes,s,b,di
ff,ysum,zp) ! Write the wavefunctions for each energy level to a file
248 WRITE((s*100),*) n, E*Eh ! Write the energy of each state to a file
249 PRINT*, "E(",int(n),") = ",E*Eh,"eV." ! Print the results
250
251 ELSEIF (m == 2) THEN ! If varying the width of the cavity...
252 d = ev(b,1)*a0 ! Extract the width from the array
253 WRITE(((s*100)+10+int(n)),*) d, E*Eh ! Write the energy as a function
of the width to a file
254 PRINT*, "E(",int(n),") = ",E*Eh,"eV; d = ", d, "au." ! Print the
results
255
256 ELSEIF (m == 3) THEN ! If varying the position of the proton
257 zp = ev(b,1)*a0 ! Extract the position from the array
258 WRITE(((s*100)+20+int(n)),*) zp, E*Eh ! Write the energy as a function
of the position to a file
259 PRINT*, "E(",int(n),") = ",E*Eh,"eV; zp = ", zp, "au." ! Print the
results
260
261 ELSEIF (m == 4) THEN ! If testing...
262 n = ev(b,1)
263 CALL
rk4loop(zn,zmin,zmax,ystartL,ystartR,E,0.0_dp,join,error,d,small,rat,yout,nodes,s,n+in
t(d*a0),diff,ysum,zp)
264 PRINT*, "E(",int(n),") = ",E*Eh,"eV. d = ",d*a0," au"
265 WRITE(1,*) d*a0, E*Eh
266 ENDIF
267
268 ENDIF
269
270 ENDDO
271
272 IF (b == 0) THEN ! If no results have been found...
273 PRINT*, "No Eigenvalues Found!"
274
275 ENDIF
276
277 PRINT*, "------------------------------"
278
279 DEALLOCATE(ev)
280
281 ENDDO
282
283 10 CLOSE(2, iostat=ios) ! Close the file we've been reading from
284
285 IF (ios /= 0) THEN
286 PRINT*, "ERROR in closing file"
287 PRINT*, "****************************"
288 PRINT*, "------------------------------"
289 STOP
290
291 ELSE
292 PRINT*, "All finished. ^_^"
293 PRINT*, "****************************"
294 PRINT*, "------------------------------"
295
296 ENDIF
297
298 END PROGRAM Cavity_Electrostatics
299
300
301 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
302 ! Begin Subroutine '2DEnergyLoop' !
303 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
304
305
306 SUBROUTINE
TDEnergyLoop(zmax,zmin,zn,Emax,Emin,En,xmin,xmax,xn,zp,safe,ystartL,ystartR,error,small,s,n,a,best
E)
307
308 IMPLICIT NONE
309
310 INTEGER, PARAMETER :: dp=kind(1.0d0)
311 INTEGER, INTENT(IN) :: s, n, zn, En, a, xn
312 REAL(dp), INTENT(IN) :: zmax, zmin, Emax, Emin, safe, ystartL, ystartR, error, small, zp, xmin,
xmax
313 REAL(dp), INTENT(OUT) :: bestE
314 REAL(dp) :: a0, Eh, rat, diff, ysum, d, join, x=0.0_dp, norm, xysum, xdiff, xyout, V
315 REAL(dp) :: E, yout, vdiff, vysum, vE, xinc, z, eps, xr, zr, zinc
316 INTEGER :: nodes, q, p, j
317 REAL(dp), ALLOCATABLE, DIMENSION(:,:) :: wf, Earr
318 PARAMETER (Eh=27.211384523_dp, a0=0.52917721082_dp)
319
320
321 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
322 ! When calculating a 2D plot, find the Energy of the vertical !
323 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
324
325 zr = zmax - zmin
326 xr = xmax - xmin ! In most cases, xrange = zrange since we are plotting over a
square grid
327
328 xinc = xmax / (2.0_dp * xn) ! Since x is symmetrical in the +ve and -ve, we can
increment it from 0 to d
329 zinc = zr / (2.0_dp*xn) ! To get a nice even grid, we should have double the number of z
points because we are extending from -d to d
330
331 d = zr / 2.0_dp ! Set the width of the cavity
332 join = d / 10.0_dp ! Set the point at which the two trial wavefunctions meet
333
334 bestE = 0.0_dp ! Reset value
335
336 IF (a == 1) THEN
337 PRINT*, "These are the energy values for the vertical wavefunction:"
338 PRINT*, " E(eV) " , " n " , " x(a0) " , " d(a0) "
339 q = 1
340
341 ELSE
342 q = 0
343
344 ENDIF
345
346 ! This section calculates the Ground State Energy for a particle travelling in the x direction and
uses it to calculate the normalising factors for the resulting wavefunction
347 CALL EnergyLoop(xmax,xmin,zn,Emax,Emin,En,safe,0.0_dp,0.0_dp,-(zr/4.0_dp),(xr/20.0_dp),error,
(xr/2.0_dp),small,10,0,q,bestE,zp)
348 vE = bestE
349
350 CALL rk4loop(zn,xmin,xmax,0.0_dp,0.0_dp,vE,-(zr/4.0_dp),(xr/20.0_dp),error,
(xr/2.0_dp),small,rat,yout,nodes,10,q,diff,ysum,zp)
351 vdiff = diff
352 vysum = ysum
353
354 PRINT*, "------------------------------"
355
356 IF (vE == Emin) THEN ! If no ground state can be found, the program should be stopped
and the parameters changed
357 PRINT*, "****************************"
358 PRINT*, "No Ground State found for weighting."
359 PRINT*, "****************************"
360 PRINT*, "------------------------------"
361 STOP
362
363 ELSE
364 PRINT*, "Ground State Energy of vertical wavefunction: ",vE*Eh,"eV."
365
366 ENDIF
367
368 PRINT*, "------------------------------"
369
370
371 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
372 ! Calculate the expectation value at each point on the 2D grid !
373 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
374
375
376 PRINT*, "These are the energy values for the first iteration:"
377 PRINT*, " E(eV) " , " n " , " x(a0) " , " d(a0) "
378
379 bestE = Emin ! Reset value
380
381 ALLOCATE (wf(2*xn+1,2*xn+1)) ! This is the array that will hold the expectation values
for each point on the grid
382 wf = 0.0_dp ! Set the array to zero
383
384 ALLOCATE(Earr(2*xn+1,2*xn+1)) ! This is the array that will hold the energy values for
each point on the grid
385 Earr = 0.0_dp ! Set the array to zero
386
387 DO q=1, xn+1 ! First calculate the the wavefunctions for a given value of x
388
389 x = (q-1) * xinc ! Increment x with the loop, ranging from 0 to xmax = d
390
391 CALL
EnergyLoop(zmax,zmin,zn,Emax,Emin,En,safe,ystartL,ystartR,x,join,error,d,small,s,n,q,bestE,zp)
! Calculate the Energy value of a the wavefunction for a given value of x
392
393 IF (bestE /= Emin) THEN ! If a result is found...
394
395 ! This section will run through the vertical wavefunction until it gets to the x-value that we are
interested in. It will then return the expectation value at that point, which is subsequently
normalised.
396 IF (x < join) THEN
397 CALL rk4loop(xn,xmin,x,0.0_dp,0.0_dp,vE,-(zr/4.0_dp),(xr/20.0_dp),error,
(xr/2.0_dp),small,rat,yout,nodes,10,1,diff,ysum,zp)
398 norm = (yout)**2.0_dp / vysum
399
400 ELSE
401 CALL rk4loop(xn,x,xmax,0.0_dp,0.0_dp,vE,-(zr/4.0_dp),(xr/20.0_dp),error,
(xr/2.0_dp),small,rat,yout,nodes,10,1,diff,ysum,zp)
402 norm = vdiff * (yout)**2.0_dp / vysum
403
404 ENDIF
405
406 ! Calculate the horizontal wavefunction and find the normalisation values
407 CALL
rk4loop(zn,zmin,zmax,ystartL,ystartR,bestE,x,join,error,d,small,rat,yout,nodes,s,1,diff,ys
um,zp)
408 xdiff = diff
409 xysum = ysum
410
411 DO j=1, 2*xn+1 ! Now looping over z...
412
413 z = zmin + (j-1) * zinc ! Increment z with the loop, ranging from -d to d
414
415 ! This section will run through the wavefunction until it gets to the z-value that we are
interested in. It will then return the expectation value at that point, which is subsequently
normalised.
416 IF (z < join) THEN
417 CALL
rk4loop(zn,zmin,z,ystartL,ystartR,bestE,x,join,error,d,small,rat,yout,nodes,s,1,di
ff,ysum,zp)
418 xyout = (yout)**2.0_dp / xysum
419
420 ELSE
421 CALL
rk4loop(zn,z,zmax,ystartL,ystartR,bestE,x,join,error,d,small,rat,yout,nodes,s,q,di
ff,ysum,zp)
422 xyout = xdiff * (yout)**2.0_dp / xysum
423
424 ENDIF
425
426 ! Use the normalised x-value to weight the normalised z-value, and write it to the array, for both
+ve and -ve x
! Use the normalised x-value to weight the normalised z-value, and write it to the array, for both
426 +ve and -ve x
427 IF ( abs(x) < small ) THEN
428 wf(xn+1,j) = norm * xyout
429
430 ELSE
431 wf(xn+q,j) = norm * xyout
432 wf(xn-q+2,j) = norm * xyout
433
434 ENDIF
435
436 ENDDO
437
438 ENDIF
439
440 ! Add a counter so we can check on how the program is running
441 IF (q == 1) THEN
442 PRINT*, "... and so on. Only ",(xn-q)," iterations left to go! E = ", bestE*Eh,"eV"
443
444 ELSEIF ((q /= 0).AND.((xn-q) > 0)) THEN
445 PRINT*, "Still Working! Only ",(xn-q)," iterations left to go! E = ", bestE*Eh,"eV"
446
447 ENDIF
448
449 ENDDO
450
451 PRINT*, "------------------------------"
452
453
454 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
455 ! Calculate the energy of the 2D wavefunction !
456 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
457
458
459 DO q = 1, (2*xn+1) ! For all values of x in the array...
460
461 DO j = 1, (2*xn+1) ! For all values of z in the array...
462
463 x = (xmin/2.0_dp) + (q-1) * xinc
464 z = zmin + (j-1) * zinc
465
466 IF ((j > 3).AND.(q > 3).AND.(j < (2*xn - 1)).AND.(q < (2*xn - 1))) THEN
467 IF ((abs(wf(q-1,j)) > small).AND.(abs(wf(q+1,j)) > small)) THEN
468 IF ((abs(wf(q,j-1)) > small).AND.(abs(wf(q,j+1)) > small)) THEN
469
470 ! Use the rearranged TISE to calculate the energy from the wavefunction and the potential.
471
472 eps = (-1.0_dp/2.0_dp) * (wf(q+1,j) - 2.0_dp*wf(q,j) + wf(q-1,j)) / xinc**2.0_dp
473 eps = eps + (-1.0_dp/2.0_dp) * (wf(q,j+1) - 2.0_dp*wf(q,j) + wf(q,j-1)) / zinc**2.0_dp
474 eps = eps + ( V(z,x,d,s,zp) * wf(q,j) )
475
476 Earr(q,j) = eps / wf(q,j)
477
478 ENDIF
479 ENDIF
480 ENDIF
481
482 IF (zp == 0.0_dp) THEN ! If m=2 then...
483 WRITE((s*100)+50+a,*) x*a0, z*a0, wf(q,j) ! Write values to a file
484 WRITE((s*100)+80+a,*) x*a0, z*a0, Earr(q,j)
485
486 ELSE ! Elseif m=3 then...
487 WRITE((s*200)+50+a,*) x*a0, z*a0, wf(q,j) ! Write the values to a file
488 WRITE((s*200)+80+a,*) x*a0, z*a0, Earr(q,j)
489
490 ENDIF
491
492 ENDDO
493
494 ENDDO
495
496 bestE = SUM(Earr, abs(Earr)>small)/COUNT(abs(Earr)>small) ! In theory, the energy
value should be the average of the contents of the energy array
497
498 DEALLOCATE(Earr)
499
500 DEALLOCATE(wf)
501
502 END SUBROUTINE ! End Subroutine '2DEnergyLoop'
503
504
505 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
506 ! Begin Subroutine 'EnergyLoop' !
507 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
508
509
510 SUBROUTINE
EnergyLoop(zmax,zmin,zn,Emax,Emin,En,safe,ystartL,ystartR,x,join,error,d,small,s,n,a,bestE,zp)
511
512 IMPLICIT NONE
513
514 INTEGER, PARAMETER :: dp=kind(1.0d0)
515 INTEGER, INTENT(IN) :: s, n, zn, En, a
516 REAL(dp), INTENT(IN) :: zmax, zmin, Emax, Emin, safe, ystartL, ystartR, x, join, error, d, small,
zp
517 REAL(dp), INTENT(OUT) :: bestE
518 REAL(dp) :: a0, Eh, rat, lrat, diff, ysum
519 REAL(dp) :: E, Einc, SetEinc, lE, Ecross
520 REAL(dp) :: ratcross, Ewin, ratwin, bestrat, yout
521 INTEGER :: nodes
522 PARAMETER (Eh=27.211384523_dp, a0=0.52917721082_dp)
523
524 ! Use the above coeffients to set everything to its correct starting point
525 E = Emin ! The initial value of E
526 SetEinc = (Emax - Emin) / En ! The increment of the energy loop
527 Einc = SetEinc
528 lE = E
529 Ecross = E
530 Ewin = E
531 bestE = E
532
533 bestrat = safe
534
535 DO
536
537 ! Stop looping when E reaches SetEmax
538
539 IF (E-Emin >= Emax-Emin) THEN
540 EXIT
541
542 ENDIF
543
544
545 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
546 ! For each value of E, Run RK4 !
547 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
548
549
550 CALL rk4loop(zn,zmin,zmax,ystartL,ystartR,E,x,join,error,d,small,rat,yout,nodes,s,0,diff,ysum,zp)
551
552
553 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
554 ! Analysis of RK4 results !
555 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
556
557 IF (a == 1) THEN
558 PRINT*, E*Eh, x*a0, nodes-1, d*a0, zp*a0, rat ! Only print the values on
the first run through, to ensure that the program is running correctly and to give
some idea of speed
559
560 ENDIF
561
562 ! If we are stuck in a loop where the step size is getting too small, reset the loop to
starting values from the current energy
563
564 IF (abs(Einc) < small) THEN
565 Einc = SetEinc
566
567 IF ( (E < Ecross) .OR. (E < Ewin) ) THEN
568
569 IF (Ecross > Ewin) THEN
570 E = Ecross
571 rat = ratcross
572
573 ELSE
574 E = Ewin
575 rat = ratwin
576
577 ENDIF
578
579 ENDIF
580
581 ! If the wavefunction has the same number of nodes as for a previous Energy Eigenvalue
that the algorithm found but is more accurate then replace the previous found values
582
583 ELSEIF (((nodes-1)>n).AND.((abs(rat)<safe).AND.(abs(abs(E/bestE)-1.0_dp)>small))) THEN
584 EXIT
585
586 ELSEIF (((nodes-1) == n).AND.((abs(rat)<bestrat).AND.(abs(abs(E/bestE)-1.0_dp)>small)))
THEN
587 bestE = E
588 bestrat = abs(rat)
589
590 Ewin = E
591 ratwin = rat
592
593 Einc = Einc/2.0_dp
594 E = lE - Einc
595 rat = lrat
596
597 ! If the condition has not been met, but it has crossed from positive to negative, or
vice-versa, (ie, it is close to a minimum) then set the previous value of E as the start
of the loop and the current value of E as the end of the loop, and change the increment in
order to drill down to the minima.
598
599 ELSEIF (((nodes-1) == n).AND.((rat/lrat < 0.0_dp).AND.(abs(abs(E/Ecross)-1.0_dp) >
small))) THEN
600 Ecross = E
601 ratcross = rat
602
603 Einc = Einc/2.0_dp
604 E = lE - Einc
605 rat = lrat
606
607 ELSEIF ( ( (E>Ewin+Einc) .AND. (E>Ecross+Einc) ) .AND. ( Einc < SetEinc ) ) THEN
608 Einc = SetEinc
609
610 ENDIF
611
612 ! If none or any of these conditions has been met then increment the loop and continue
613
614 lrat = rat
615 lE = E
616 E = E + Einc
617
618 END DO ! End the Energy loop
619
620 END SUBROUTINE ! End Subroutine 'EnergyLoop'
621
622
623 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
624 ! Begin Subroutine 'rk4loop' !
625 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
626
627
628 SUBROUTINE
rk4loop(zn,zmin,zmax,ystartL,ystartR,E,x,join,error,d,small,rat,yout,nodes,s,b,diff,ysum,zp)
629
630 IMPLICIT NONE
631
632 INTEGER, PARAMETER :: dp=kind(1.0d0)
633 INTEGER, INTENT(IN) :: s, b, zn
634 REAL(dp), INTENT(IN) :: zmin, zmax, ystartL, ystartR, E, x, join, error, d, small, zp
635 REAL(dp), INTENT(OUT) :: rat, yout, ysum, diff
636 INTEGER, INTENT(OUT) :: nodes
637 REAL(dp) :: y, h, dy, ly, ldy, step, grad, hcheck, dyh, dyL, dyR, yh, yL, yR, Eh, a0, Seth
638 REAL(dp) :: z=0.0_dp, ratL=0.0_dp, ratR=0.0_dp, ysumL=0.0_dp, ysumR=0.0_dp
639 INTEGER :: side, u
640 PARAMETER (Eh=27.211384523_dp, a0=0.52917721082_dp)
641
642
643 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
644 ! Reset values for each iteration of the rk4 loop !
645 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
646
647
648 yout = 0.0_dp
649
650 Seth = (zmax-zmin)/zn ! The initial value for h, the step between points at which the
wavefunction is sampled
651
652 IF ((b > 0).AND.(s /= 3).AND.(s /= 4)) THEN ! If we are writing the values of
wavefunctions to a file
653 u = 4
654
655 ELSE ! If we are just calculating the wavefunctions
656 u = 2
657
658 ENDIF
659
660 DO side=1,u
661
662 IF ( ( side == 1 ).OR.( side == 3 ) ) THEN ! This is for the wavefunction starting on
the right
663 y = ystartL
664 h = Seth
665 dy = ystartL + 1.0_dp
666 z = zmin
667 ysumL = 0.0_dp
668
669 nodes = 1 ! The number of nodes are only reset here because I am interested
in the total number of nodes of the completed wavefunction
670
671 ELSEIF ( ( side == 2 ).OR.( side == 4 ) ) THEN ! This is for the wavefunction
starting on the left
672 y = ystartR
673 h = -Seth ! This wavefunction is running in the opposite direction to the
other one so the step is negative
674 dy = ystartR + 1.0_dp
675 z = zmax
676 ysumR = 0.0_dp
677
678 ENDIF
679
680 ly = 0.0_dp
681 ldy = 0.0_dp
682
683 DO
684
685 ! Stop looping when z reaches the join point from either the left or the right
686
687 IF ((((side==1).OR.(side==3)).AND.((z>=join).OR.(z>=zmax))).OR.(((side==2).OR.
(side==4)).AND.((z<join).OR.(z<zmin)))) THEN
688 EXIT
689
690 ENDIF
691
692 ! Run rk4 with step size h
693
694 CALL rk4(y,dy,h,z,x,E,d,step,grad,s,zp)
695
696 yh = step
697 dyh = grad
698
699 ! Run rk4 with step size h/2
700
701 CALL rk4(y,dy,(h/2.0_dp),z,x,E,d,step,grad,s,zp)
702
703 ! Compare the results of the two runs to determine what the step size should be
704
705 hcheck = (15.0_dp/16.0_dp) * h * ( abs(error/abs(step-yh))**(0.2_dp) )
706
707 IF (abs(hcheck) < abs(h)) THEN
708 h = (h/2.0_dp) ! Run this step again with the step size halved
709
710 ELSE
711 ly = y ! Set the 'previous value' of y to the current value of y
712 ldy = dy
713 y = yh
714 dy = dyh
715
716 z = z + h ! Since rk4 calculates the value of y at z+h, this should be the
value written to the data files
717
718 ! If the wavefunction crosses from positive to negative, count it as a node
719 IF ( ( (z>zmin) .AND. (z<zmax) ) .AND. ( ly/y < 0.0_dp) ) THEN
720 nodes = nodes + 1
721
722 ENDIF
723
724 IF (b > 0) THEN
725
726 IF (side == 1) THEN
727 ysumL = ysumL + abs(h*(y**2.0_dp)) ! Calculate the area under the
graphs
728
729 ELSEIF (side == 2) THEN
730 ysumR = ysumR + (abs(h*(y**2.0_dp)))
731
732 ELSEIF (side == 3) THEN
733 WRITE(((s*100)+10*int(d*a0)+b),*) (z*a0), ((E*Eh) + 5.0_dp * ( y**2.0_dp /
ysum ) ) ! Write to a file the expectation value of the
(normalised) wavefunction at each point along the z-axis
734
735 ELSEIF (side == 4) THEN
736 WRITE(((s*100)+10*int(d*a0)+b),*) (z*a0), ((E*Eh) + 5.0_dp * ( diff *
y**2.0_dp / ysum ) ) ! Write to a file the expectation value of the
(normalised) wavefunction at each point along the z-axis
737
738 ENDIF
739
740 ENDIF
741
742 h = hcheck ! Change to the new increment
743
744 ENDIF
745
746 ! If the increment is too small, stop the loop
747
748 IF (abs(h) < small) THEN
749 PRINT*, "h is too small! h = ", h
750 EXIT
751
752 ENDIF
753
754 END DO
755
756 ! Calculate the values that will leave the loop, diff, ysum, yout
757
758 IF ( side == 1 ) THEN
759 dyL = dy
760 yL = y
761
762 ELSEIF ( side == 2 ) THEN
763 dyR = dy
764 yR = y
765
766 IF (b > 0) THEN
767 diff = abs(yL/yR)**2.0_dp
768 ysum = ysumL + (ysumR * diff)
769
770 ENDIF
771
772 ENDIF
773
774 IF ((((side==1).OR.(side==3)).AND.(z>=zmax)).OR.(((side==2).OR.(side==4)).AND.(z<zmin))) THEN
775 yout = y
776 EXIT
777
778 ENDIF
779
780 END DO
781
782 ! If the condition is minimised to within specifications and the number of nodes in the
wavefunction is correct (or it is better than the previous value)...
783 ! In this case, we are using the shooting method, so we match the joining points and then compare
the slope of the curve at the join
784
785 ratL = dyL/yL
786 ratR = dyR/yR
787
788 ! Calculate 'rat' (also known as 'Chi') to assess the quality of the wavefunction
789
790 rat = ratL - ratR
791
792 END SUBROUTINE ! End Subroutine 'rk4loop'
793
794
795 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
796 ! Begin Subroutine 'rk4' !
797 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
798
799
800 SUBROUTINE rk4(y,dy,h,z,x,E,d,step,grad,s,zp)
801
802 IMPLICIT NONE
803
804 INTEGER, PARAMETER :: dp=kind(1.0d0)
805 INTEGER, INTENT(IN) :: s
806 REAL(dp), INTENT(IN) :: y, dy, h, z, E, d, x, zp
807 REAL(dp) :: g1, g2, g3, g4, s1, s2, s3, s4, k2
808 REAL(dp), INTENT(OUT) :: step, grad
809
810 ! This is the Fourth-Order Runge-Kutta Method
811
812 s1 = h * dy
813 g1 = h * k2(z,x,E,d,s,zp) * y
814
815 s2 = h * ( dy + (g1/2.0_dp) )
816 g2 = h * k2((z+(h/2.0_dp)),x,E,d,s,zp) * ( y + (s1/2.0_dp) )
817
818 s3 = h * ( dy + (g2/2.0_dp) )
819 g3 = h * k2((z+(h/2.0_dp)),x,E,d,s,zp) * ( y + (s2/2.0_dp) )
820
821 s4 = h * ( dy + g3 )
822 g4 = h * k2((z+h),x,E,d,s,zp) * ( y + s3 )
823
824 step = y + ( ( s1 + 2.0_dp * ( s2 + s3 ) + s4 ) / 6.0_dp ) ! This is the value of y
at n+1
825 grad = dy + ( ( g1 + 2.0_dp * ( g2 + g3 ) + g4 ) / 6.0_dp ) ! This is the first
differential of y, y', at n+1
826
827
828 END SUBROUTINE ! End Subroutine 'rk4'
829
830
831 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
832 ! Begin Subroutine TDVzvsx !
833 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
834
835
836 SUBROUTINE TDVzvsx(zmin,zmax,xmin,xmax,zp,d,Emin,s)
837
838 IMPLICIT NONE
839
840 INTEGER, PARAMETER :: dp=kind(1.0d0)
841 INTEGER, INTENT(IN) :: s
842 REAL(dp), INTENT(IN) :: zmin, zmax, d, Emin, xmax, xmin, zp
843 REAL(dp) :: z, V, zinc, xinc, Eh, a0, x
844 PARAMETER (Eh=27.211384523_dp, a0=0.52917721082_dp)
845
846 x = zmin
847 z = zmin
848 zinc = (zmax-zmin)/500.0_dp
849 xinc = (xmax-xmin)/500.0_dp
850
851 ! Write the value of 'V(z,x)' to a file for many z and x
852
853 DO
854
855 IF (x > zmax) THEN
856 EXIT
857
858 ELSE
859
860 DO
861
862 IF (z > zmax) THEN
863 EXIT
864
865 ELSEIF (V(z,x,d,s,zp) >= -1.3_dp) THEN
866 WRITE((s*10+int(d*a0)),*) (z*a0), (x*a0), V(z,x,d,s,zp)
867
868 ENDIF
869
870 z = z + zinc
871
872 END DO
873
874 ENDIF
875
876 x = x + xinc
877 z = zmin
878 ENDDO
879
880 PRINT*, "DONE!"
881
882 END SUBROUTINE ! End Subroutine 'TDVzvsx'
883
884 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
885 ! Begin Subroutine VzvsE !
886 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
887
888 SUBROUTINE VzvsE(zmin,zmax,x,zp,d,Emin,zn,s)
889
890 IMPLICIT NONE
891
892 INTEGER, PARAMETER :: dp=kind(1.0d0)
893 INTEGER, INTENT(IN) :: s, zn
894 REAL(dp), INTENT(IN) :: zmin, zmax, d, Emin, x, zp
895 REAL(dp) :: z, V, Seth, Eh, a0
896 PARAMETER (Eh=27.211384523_dp, a0=0.52917721082_dp)
897
898 z = zmin
899 Seth = (zmax-zmin)/zn
900
901 ! Write V(z) to a file for many values of z
902
903 DO
904
905 IF (z > zmax) THEN
906 EXIT
907
908 ELSEIF (V(z,x,d,s,zp) >= -1.3_dp) THEN
909 WRITE((s*10+int(d*a0)),*) (z*a0), V(z,x,d,s,zp)
910
911 ENDIF
912
913 z = z + Seth/1000.0_dp
914
915 END DO
916
917 END SUBROUTINE ! End Subroutine 'VzvsE'
918
919
920 !!!!!!!!!!!!!!!!!!!!!!!!!!!!
921 ! Begin Function 'k2' !
922 !!!!!!!!!!!!!!!!!!!!!!!!!!!
923
924
925 REAL(kind(1.0d0)) FUNCTION k2(z,x,E,d,s,zp)
926
927 IMPLICIT NONE
928
929 INTEGER, PARAMETER :: dp=kind(1.0d0)
930 INTEGER :: s
931 REAL(dp) :: z, Potential, V, m, hbar, E, d, x, zp
932 PARAMETER (m=1.0_dp, hbar = 1.0_dp) ! This is the system I shall be using for
calculations
933
934 ! TISE, (d^2/dz^2)y = -(k^2)y where k^2 = ( 2m/(hbar^2) ) * ( V - E )
935
936 k2 = ( (2.0_dp*m) / (hbar**2.0_dp) ) * ( - E + V(z,x,d,s,zp) )
937
938 END FUNCTION ! End Function 'k2'
939
940
941 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
942 ! Begin Function 'Potential' !
943 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
944
945
946 REAL(kind(1.0d0)) FUNCTION V(zadj,xadj,d,s,zp)
947
948 IMPLICIT NONE
949
950 INTEGER, PARAMETER :: dp=kind(1.0d0)
951 INTEGER :: k, kend, s
952 REAL(dp) :: d, z, x, rho, yend, zadj, xadj, zp
953 REAL(dp) :: e02, delta, kadj
954 REAL(dp), PARAMETER :: e=1.0_dp, ec=1.0_dp ! e is the elementary charge and ec is the
Coulomb force constant = 1 / ( 4 * pi * epsilon0 )
955
956 e02 = e**2.0_dp * ec
957
958 ! Delta is added to z and x to prevent the potential from tending towards infinity at z=0
959
960 yend = -1.0E14_dp
961 delta = 1.0_dp / yend
962
963 ! Set the offset values of x and z to prevent V from going to infinity
964
965 IF (zadj < 0.0_dp) THEN
966 z = zadj - delta
967 ELSE
968 z = zadj + delta
969 ENDIF
970
971 IF (xadj < 0.0_dp) THEN
972 x = xadj - delta
973 ELSE
974 x = xadj + delta
975 ENDIF
976
977 ! In the 2D picture, the proton-electron distance depends on where each is relative to the other
978
979 IF (z >= zp) THEN
980 rho = ( x**2.0_dp + (z - zp)**2.0_dp )**0.5_dp
981 ELSE
982 rho = ( x**2.0_dp + (zp - z)**2.0_dp)**0.5_dp
983 ENDIF
984
985 kend = 10
986 V = 0.0_dp
987
988
989 !!!!!!!!!!!!!!!!!!!!!!!!!
990 ! Single Surface !
991 !!!!!!!!!!!!!!!!!!!!!!!!
992
993
994 IF (s == 1) THEN
995
996 V = 1.0_dp / ( 4.0_dp * ( d - z ) )
997
998 V = - e02 * V ! The factor of a half accounts for the self-energy of the system
999
1000
1001 !!!!!!!!!!!!!!!!!!!!!!!!
1002 ! Two Surfaces !
1003 !!!!!!!!!!!!!!!!!!!!!!!
1004
1005
1006 ELSEIF (s == 2) THEN
1007
1008 DO k = 1, kend
1009
1010 kadj = ( 2.0_dp * k ) - 1.0_dp
1011
1012 V = V + 1.0_dp / ( 4.0_dp * ( ( kadj * d ) + z ) )
1013 V = V + 1.0_dp / ( 4.0_dp * ( ( kadj * d ) - z ) )
1014 V = V - 2.0_dp / ( 8.0_dp * k * d )
1015
1016 END DO
1017
1018 V = - e02 * V
1019
1020
1021 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1022 ! Hydrogen Atom, Single Surface !
1023 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1024
1025
1026 ELSEIF (s == 3) THEN
1027
1028 V = 1.0_dp / ( 4.0_dp * ( d - z ) )
1029 V = V - ( 1.0_dp / ( x**2.0_dp + ( ( 2.0_dp * d ) - z - zp )**2.0_dp )**0.5_dp )
1030
1031 V = V + ( 1.0_dp / rho )
1032
1033 V = - e02 * V
1034
1035
1036 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1037 ! Hydrogen Atom, Two Surfaces !
1038 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1039
1040
1041 ELSEIF (s == 4) THEN
1042
1043 DO k = 1, kend
1044
1045 kadj = ( 2.0_dp * k ) - 1.0_dp
1046
1047 V = V + ( 1.0_dp / ( 4.0_dp * ( ( kadj * d ) + z ) ) ) ! e-e+ left
1048 V = V + ( 1.0_dp / ( 4.0_dp * ( ( kadj * d ) - z ) ) ) ! e-e+ right
1049 V = V - ( 2.0_dp / ( 8.0_dp * k * d ) ) ! e-e- left, e-e- right
1050 V = V - ( 1.0_dp / ( ( 2.0_dp * ( kadj * d ) + z + zp )**2.0_dp + x**2.0_dp )**0.5_dp )
! e-P- left
1051 V = V - ( 1.0_dp / ( ( 2.0_dp * ( kadj * d ) - z - zp )**2.0_dp + x**2.0_dp )**0.5_dp )
! e-P- right
1052 V = V + ( 1.0_dp / ( ( ( 4.0_dp * k * d ) + z - zp )**2.0_dp + x**2.0_dp )**0.5_dp )
! e-P+ left
1053 V = V + ( 1.0_dp / ( ( ( 4.0_dp * k * d ) - z + zp )**2.0_dp + x**2.0_dp )**0.5_dp )
! e-P+ right
1054
1055 END DO
1056
1057 V = V + ( 1.0_dp / rho ) ! e-P+
1058
1059 V = - e02 * V
1060
1061
1062 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1063 ! Hydrogen Atom, Two Surfaces, movement in x-plane !
1064 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1065
1066
1067 ELSEIF (s == 10) THEN
1068
1069 DO k = 1, kend
1070
1071 kadj = ( 2.0_dp * k ) - 1.0_dp
1072
1073 V = V + ( 1.0_dp / ( 4.0_dp * ( ( kadj * d ) + x ) ) ) ! e-e+ left, now constant
w.r.t. z
1074 V = V + ( 1.0_dp / ( 4.0_dp * ( ( kadj * d ) - x ) ) ) ! e-e+ right, now constant
w.r.t. z
1075 V = V - ( 2.0_dp / ( 8.0_dp * k * d ) ) ! e-e- left, e-e- right, always constant
w.r.t. z
1076 V = V - ( 1.0_dp / ( ( 2.0_dp * ( kadj * d ) + x + zp )**2.0_dp + z**2.0_dp )**0.5_dp )
! e-P- left
1077 V = V - ( 1.0_dp / ( ( 2.0_dp * ( kadj * d ) - x - zp )**2.0_dp + z**2.0_dp )**0.5_dp )
! e-P- right
1078 V = V + ( 1.0_dp / ( ( ( 4.0_dp * k * d ) + x - zp )**2.0_dp + z**2.0_dp )**0.5_dp )
! e-P+ left
1079 V = V + ( 1.0_dp / ( ( ( 4.0_dp * k * d ) - x + zp )**2.0_dp + z**2.0_dp )**0.5_dp )
! e-P+ right
1080
1081 END DO
1082
1083 V = V + ( 1.0_dp / rho ) ! e-p+
1084
1085 V = - e02 * V
1086
1087 ENDIF
1088
1089
1090 END FUNCTION ! End Function 'Potential'
Department of Physics

PROJECT REPORT

I certify that any substantive contributions from the work of others are clearly
identified and attributed, and that with these exceptions, this work is wholly my own.
I also certify that to the best of my knowledge my work has not been used in the
assessed work of others without attribution.

I confirm that I have read and understood the information concerning academic
misconduct in the Undergraduate Handbook (Section 4).

Signed ...................................................................................................................

Name (Print)..........................................................................................................

Date..............................................................

Time (if past deadline)..................................

You might also like