PHAS0029 Final Assignment 2023

PHAS0029 FINAL ASSIGNMENT 2023
THE INFINITE “UNSQUARE” POTENTIAL
LAST REVISION FEBRUARY 27, 2023
1 2 3 3.1 3.2 3.3 3.4 4 5 5.1 5.2 5.3 5.4
Introduction 2
Boundary value problems: eigenvalue solutions 2 A quantum dot in vacuum: infinite square well 3
Task for session 8: Finding the ground state energy 3 Finding the ground state wavefunction 5
Finding the higher energy states Extension to 3D 6
The infinite “unsquare” well General assignment advice
Assessment 8 Referencing and bibliography Submission 8
Page limit 9
Computer Science Tutoring
1 Introduction
In the course so far we’ve used a wide variety of techniques to give you a flavour of the sort of problems that can be tackled using computational approaches.
In session 8, we’re going to look at one more new aspect of this: including boundary values in the solving of differential equations. You will then apply this to the problem for the PHAS0029 final assignment: solving the quantum-mechanical problem of a particle in an infinite potential well. You will first solve for an infinite square potential well, and use the familiar analytical solutions for this system to check that your results are correct. You will then be able to extend this to calculate for systems where there is no simple analytical solution.
Before commencing any of the tasks below, make sure you have gone through and understood the contents of the Jupyter Notebook script for session 8, which will guide you through the process of finding roots of a function using the secant method, and hence solving differential equations with boundary value conditions, both of which you will need to solve this problem. It is also recommended that you read this entire script through before commencing the Session 8 task outlined in section 3.1.
NB. Your work in session 8 should be done individually but with help from the demonstrators. That means, as always, copying someone else’s code is strictly not permitted and will be considered as academic misconduct. You will not receive a separate mark for this session but rather your work done there will contribute to your Final Assignment mark.
2 Boundary value problems: eigenvalue solutions
In this task we are going to be applying our new knowledge of boundary value problems to the one-dimensional time-independent Schrödinger equation,
−ħ2 d2ψ+V(x)ψ(x)=Eψ(x). (1) 2m dx2
Initially, we’re going to consider one of the most well-known solutions of this—for
a particle in a square potential well of width 2a with infinitely high walls. This is
shown in Fig. 1, and the potential V (x) takes the form 
Vx =0 if −a≤x≤+a, (2) ∞ if|x|>a.
You have all studied this in PHAS0022 (or an equivalent course) and should be familiar with the solutions. These solutions show that the probability of finding the particle in the region where V (x) = ∞ is zero, and thus the wavefunction must be subject to the boundary conditions of ψ = 0 at x = −a and x = +a.
Therefore this would seem to be an ideal system to solve using the same approach as we used to calculate the trajectory of a thrown ball in the Jupyter Notebook for
phas0029 final assignment 2023 2
Figure 1: The infinite square well po- tential. Within the well, the potential is zero, everywhere else the potential is infinite.

Session 8—we could transform Eq. (1) into two first-order equations, guess some initial values, and iterate until we find a solution that fulfils the boundary condition at x = +a.
Separating out the Schrödinger equation into two first-order equations yields
dψ = φ, (3)
dφ = 2m [V (x) − E]ψ(x). (4)
We know one initial boundary condition, that ψ = 0 at x = −a. We would therefore need to guess an initial condition for φ, and then vary this with the secant method (or another root-finding method) until we find a solution where ψ(x = +a) = 0.
Unfortunately, this approach won’t work. The Schrödinger equation is a linear equation, so if we have a solution ψ, any multiple of ψ will also be a solution. Conversely, a multiple of any candidate wavefunction ψ that doesn’t fulfil the boundary condition of ψ(x = +a) = 0 will also not fulfil the condition.
This is because the Schrödinger equation is an eigenvalue equation—it only has solutions at particular values of the energy E. For other values, there are no solutions that fulfil the boundary conditions.
The approach we will adopt, therefore, is not to search for an initial condition on φ that will give us the required solution, but instead to search on values of E. As the only effect of φ’s initial condition is to multiply the wavefunction by a constant, we can choose any starting value. We can then normalize the wavefunction once we have found a solution if needed.
3 A quantum dot in vacuum: infinite square well
3.1 Task for session 8: Finding the ground state energy
You now have all the information you need to start on the assignment. The first part of the assignment is to calculate the energy of the ground state, and this will form the task for Session 8. You can get help from the demonstrators for this part of the task during the Session 8 live session only. You must not share or discuss your work in any way with other students, and please make sure you are fully familiar with the at UCL guidance on academic integrity before you start work.
You can find the rubric for the final assessment (including the parts done during the session 8) on the submission page on CoCalc. Your session 8 task will form the starting point of your final assignment, and you should implement the feedback from your session 8 task in your final version.
Start by creating a new notebook from scratch. You will need to define the following physical constants.
phas0029 final assignment 2023 3
Programming Help, Add QQ: 749389476
• electron mass m = 9.109 383 702 × 10−31 kg • ħ=1.054571817×10−34 J.s
• electron charge e = 1.602 176 634 × 10−19 C
You can include more digits of precision than this if you wish, but please work in SI units. When quoting energies however, you should convert to electronvolts (eV) by dividing the value in Joules (J) by e.
An excellent real-life example of infinite square well confinement is a quantum dot. A quantum dot (QD) is a crystal of semiconductor material whose diameter is on the order of several nanometers – a size which results in its free charge carriers experiencing “quantum confinement” in all three spatial dimensions. The electronic properties of quantum dots are intermediate between those of bulk semiconductors and of discrete molecules and closely related to their size and shape. This allows properties such as the band gap, emission color, and absorption spectrum to be highly tuneable, as the size distribution of quantum dots can be controlled during fabrication.
For the first part of the assignment, consider an electron confined in a cubic quantum dot with side length d = 50nm. Assume the electron cannot escape the dot (infinite potential) and consider confinement in one dimension only. Set the centre of the well at position x = 0. Use N = 2000 for the number of Runge-Kutta calculation points.
For an infinite square well, we know that the particle will never be outside the well, where V (x) = ∞, and as V (x) = 0 inside the well, we could just ignore this in the calculations. However, later in the task you will calculate for other forms of V (x), so write a suitably-named and documented function that will return a value of V (x) = 0 for all values of x, the function input1.
We’ve already split the Schrödinger equation into two first-order equations, Eqs. (3) and (4). You will need to write another function, just like the ones you used in Sessions 6 and 7, to calculate the right-hand side of these equations2.
Now you need a Runge Kutta function. You can reuse the fourth-order function you already have (make sure this is clear in the comments), but you will probably want to make some changes. In particular, you can put the initial conditions within the function. You can use any initial condition you choose for φ—explain what effect this choice has in the text cell commentary. Instead of running over an array of time-points, the loop will now run over an array of N x-points starting at x = −d/2 and finishing at x = +d/2, with step size h = d/N. The Runge Kutta function will need to return an array of the wavefunction values representing ψ(x), although note that we don’t actually need to return an array to represent
φ(x) = dψ/dx. You may find it easier to work with a = d/2 instead of d directly, to be able to simply reuse your functions in the later part of the assignment.
As in the script for Session 8, you will need to write code to iterate using the secant method until you find a value of E that gives the required ψ(x) = 0 at x = d/2. To do this, you’ll need two initial guesses for the energy (I’d suggest using variable names E1 and E2)3, then calculate corresponding wavefunction arrays using the Runge Kutta function. Check the final element of these
1 Hint: you just need one line in the function at the moment: return 0.0. Make sure you remember the docstring as well though.
2 Hint: This function will need three ar- guments as inputs: a vector r of ψ and φ, a value of x, and a value for the en- ergy E, which appears in the RHS of equation (4).
phas0029 final assignment 2023 4
3 Hint: choose initial guesses that are reasonably close to the initial ground state energy, otherwise you may find the eigenvalue of one of the excited states instead!

wavefunction arrays—are they equal to zero? If not, update the guesses E1 and E2 using the secant method until you find an energy that does fulfil the boundary conditions4 .
If all has gone well, your code will converge on the ground state reasonably quickly. To check your result, compare it with the analytical solution for the ground state energy, by recalling that the eigenvalues of this system are given by:
En = 2md2 . (5)
This is the point that we anticipate most of you will be able to reach by the end of Session 8, and this is what you should submit as your session 8 task. Make sure you read the submission instructions for the session 8 task below carefully.
From this point onwards, you have to complete the task entirely on your own, with no help from demonstrators, other students, or anyone else.
3.2 Finding the ground state wavefunction
Now calculate and plot, on an appropriately labelled plot, the ground state wavefunction. You may wish to represent the walls of the infinite square well potential on the plot as well5.
As we noted earlier when discussing the arbitrary choice of initial condition for φ, our wavefunction as calculated is not normalised. It would be useful to write a function that will normalize the wavefunction, so that
|ψ(x)|2dx = 1. (6)
You can achieve this by calculating the value of the integral on the left-hand side of Eq. (6), and then dividing the wavefunction through by the square root of this value. The easiest way of calculating the integral is to use the trapezoidal rule6 , where an integral with limits a and b can be evaluated as
􏰆1 1 n−1 􏰇
I(a,b)=h 2f(a)+2f(b)+􏰈f(x+kh) . (7)
Having done this, compare your calculated wavefunction with the known ground state wavefunction, remembering that the normalized wavefunctions of the system are given by
ψn(x) = 􏰊d/2 cos d n odd, (8a)
ψn(x) = 􏰊d/2 sin d n even. (8b)
If all has gone well, you should find an excellent match between your numerical results and the analytical solutions we already knew.
4 Hint: You will need to set an appropri- ate value for the tolerance, e/100000 is probably a good choice.
phas0029 final assignment 2023 5
c=’#5f5f5f’,ls=’-’,lw=2.5) will plot a thick dark grey vertical line at x = −a. Adapt this as required.
6 Note that our wavefunction is already in a convenient form to do this, as it is a numpy array
plt.axvline(x=-a,

3.3 Finding the higher energy states
Once you are satisfied that your ground state solutions are correct, try finding the first few excited states (n = 2, 3, 4, as a minimum), and verify that these are also correct. Think about the best way to choose initial guesses for these states, bearing in mind that you want to come up with a general method that works for any potential, including ones where there is no analytical solution available for comparison. Comment on your chosen method for determining the initial guesses for the energies for these eigenstates. Once more, plot these solutions and compare with the analytical solutions.
Does your method also work to find eigenstates for large n? Check this explicitly for at least two states in the range 18 ≤ n ≤ 28.
3.4 Extension to 3D
A true quantum dot needs to be considered in all three dimensions, which means the Schroedinger’s equation becomes a partial differential equation. Thankfully, we can separate the dimensions and solve for each individually. The analytical solution for the final energy states of a cubic dot with side length d is then expressed as:
2 2 2 π2ħ2
Enx,ny,nz = (nx + ny + nz) 2md (9)
where nx,ny and nz are three discrete quantum numbers – one corresponding to each dimension. Since we can vary each quantum number separately, the 3D case gives us many more energy levels than 1D approximation.
Calculate the first 10 energy levels in a 3D quantum dot, present them in a suitable format and comment on their values.
One of the most desired properties of quantum dots is the tunable wavelength of the emitted light. Considering the first transition only (from E112 to E111), discuss how the light emitted by a quantum dot changes with its physical properties. (You may wish to supplement your comments with an appropriate graph).
4 The infinite “unsquare” well
Hopefully now you have code that works well to solve for the eigenstates of the infinite square well. However, you probably found it a fair amount of work to calculate answers that we already knew from a relatively simple analytical solution. In fact, the main point of doing this was to confirm that your numerical version does indeed work as expected, before going on to calculate for systems that aren’t easily solvable analytically. This is what you will do now, and then compare your results to the systems you have already met.
We are going to keep the infinite square walls of the potential well in 1D, which guarantee that the particle cannot be found in the V (x) = ∞ region. This means we can keep the boundary conditions of the original problem.
phas0029 final assignment 2023 6

However, we are going to change the base of the potential well so that it is no longer square—in effect, we are going to embed another potential within the square well. An example of this is shown in Fig. 2.
This opens up the possibility of solving for a wide range of systems for which there is no simple analytical solution. By starting with embedded potentials with familiar forms, you will be able to explore the similarities and differences from the analytical solutions and get a feel for the physics of the new, embedded system. You will then be able to extend this to any (arbitrary) embedded potential.
You can implement this simply by writing a new Python function for the form of the potential.
For each potential, calculate at least the lowest three eigenstates (include some of the higher eigenstates if you wish), and plot the wavefunctions. In a separate plot, plot the both the potential itself and the energy eigenvalues overlaid as horizontal lines.
Compare these results both qualitatively and quantitatively, where possible, to the form of the wavefunctions you’d expect for the standard form of these potentials. Make sure you fully analyse and explain the similarities and differences between the two forms in your text cell commentary.
I. Harmonic potential: Set the potential to have the form x2
V (x) = V0 a2 . (10)
This will give you a harmonic potential embedded within the infinite square well, as shown in Fig. 3. Again, you’ll need to pick an appropriate value for V0. Around 700e is a good starting point for this, but experiment to find a value you think is most appropriate to demonstrate interesting physics. Compare your eigenvalue and wavefunction results explicitly with the analytical solutions for a pure harmonic potential. In what way do your results differ? Why? Fully discuss and interpret the similarities and differences in your text cells.
II: Finite square well:
Set the potential to have the form
if −a/2≤x≤+a/2, if |x| > a/2,
Figure 3: A harmonic potential embed- ded in the infinite well. Note that the particle is still constrained within the in- finite walls indicated by the black lines.
This will give you a finite square well embedded within the infinite square well. You’ll need to pick an appropriate value for V0. Around 600e is a good starting point, but experiment to find a value you think gives the most interesting results. You may also want to experiment with the width of the finite square well. How do your results differ from the known results for a normal finite square well, and why? Discuss and interpret the similarities and differences in your text cells.
phas0029 final assignment 2023 7
Figure 2: Potentials can be embedded within our infinite square well, as shown by the blue line. We can calculate for any arbitrary potential defined within the surrounding infinite square well.

5 General assignment advice
Submit your work as a fully self-contained Jupyter Notebook. Your notebook should have a similar writing style to a formal report—i.e. use complete and grammatically correct sentences, avoid bullet lists, and use formal scientific language.
Pay particular attention to your text cell commentary, which is highly weighted for assessment. Additionally, because this task is fairly open-ended, we’ll only be able to tell what you’ve done, and why you’ve chosen to do it in that way, if you use the text cells to tell us. Likewise, make sure your code is fully commented, as you may not get full credit if we can’t figure out what it does.
Your notebook should not include any interactive code requiring user input.
5.1 Assessment
You will find a preview of the marking rubric for the assignment on Moodle, where you can see the criteria that will be used to grade your work, their relative weightings, and most of the level descriptors for each criterion.
5.2 Referencing and bibliography
Everything in your submission must be either entirely your own original work, or have the source explicitly acknowledged and suitably referenced:
• If you re-use sections of code from the course scripts or your previous submissions, you must note this explicitly in the comments for that section of code. When referring to your own previous submissions, use your Student Number rather than your name, as this assignment is assessed anonymously.
• There is a separate notebook available on Moodle that contains the equations from this script typeset in LATEX form. You may copy and paste equations from this notebook, as long as they are referenced appropriately.
• Use the Harvard bibliography style to reference all external sources (for example textbooks, lecture notes, or websites) you refer to. An example of how to implement this in a Jupyter notebook is included in the notebook of equations. You should also refer to the “Harvard” section of the UCL referencing guide http://www.ucl.ac.uk/library/docs/guides/references-plagiarism for full examples of how to cite various different types of sources, or you may also find this pdf reference guide a useful, more concise, summary for how to cite various resources:.
5.3 Submission
This is an individual assignment.
phas0029 final assignment 2023 8
Programming Help
• You must work on this on your own, with no help or input from staff, other students, or anyone else (except discussions with demonstrators in the first part of the assignment as described in the text).
• You may not make any posts on social media or e-mail, consult in any way with any other person, or engage in any other form of academic misconduct.
• Everything in your submission must be completely your own work, or have the source explicitly acknowledged and suitably referenced as above
We will be using several methods to check for plagiarism, copying, and collusion. This includes checking your code as well as text for similarities in structure, style and contents.
This assignment will be graded anonymously. Please make sure that:
• your name does not appear anywhere in your submission;
• your submission title starts with your student number; and
• you include your student number at the start of your submitted Jupyter
You can only submit one file on Moodle, so it will not be possible to upload additional figure files. You may include images as linked URLs (as, for example, in the script for session 08), and make sure that the original source of the image is made very clear and included in your references. If you want to include figures you have created yourself, you will need to upload these to an external hosting service (e.g. Imgur, Flickr, etc) and ensure that the images are public. In this case please make it clear in the accompanying text that you have created this image yourself.
This is an individual assignment. You must work on this on your own, with no help from staff or other students.
5.4 Page limit
There is a page limit of the equivalent of 60 sides of A4 paper for the final assignment.
You can find out how to determine the page count for your completed notebook by following the procedure laid out at the bottom of the Moodle page for the Final Assignment.
phas0029 final assignment 2023 9