python代写-S 0 0
时间:2022-03-26
PHA S 0 0 2 9 F I N A L A S S I G NMENT 2 0 2 2
TH E I N F I N I T E “ U N S QUA R E ” P OT E NT I A L
L A S T R E V I S I O N MAR CH 3 , 2 0 2 2
M . S Z UM I L O @U C L . AC . U K
Contents
1 Introduction 2
2 Boundary value problems: eigenvalue solutions 2
3 Infinite square well 3
3.1 Task for session 8: Finding the ground state energy 3
3.2 Finding the ground state wavefunction 5
3.3 Finding the higher energy states 5
4 The infinite “unsquare” well 6
5 General assignment advice 7
5.1 Assessment 7
5.2 Referencing and bibliography 7
5.3 Submission 8
5.4 Page limit 9
phas0029 final assignment 2022 2
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.
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
2m
d2ψ
dx2
+ V (x)ψ(x) = Eψ(x). (1)
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,∞ if |x| > a. (2)
+a-a x
V(x)
Figure 1: The infinite square well po-
tential. Within the well, the potential
is zero, everywhere else the potential is
infinite.
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
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.
phas0029 final assignment 2022 3
Separating out the Schrödinger equation into two first-order equations yields
dψ
dx
= ϕ, (3)
dϕ
dx
=
2m
ℏ2
[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 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 assessment for the session 8 task on the submission
page on CoCalc—for session 8 you will not be assessed on your text cells, but you
will probably find it helpful to include at least some text so that both you and
your marker can tell what you’re doing. 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.
• electron mass m = 9.109 383 702× 10−31 kg
• ℏ = 1.054 571 817× 10−34 J.s
• electron charge e = 1.602 176 634× 10−19 C
phas0029 final assignment 2022 4
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.
Set the half-width of the potential well a, to be 6.5× 10−11 m, so that the well
will be 2a = 13× 10−10 m wide. 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. 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.
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. 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).
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 = −a and finishing at x = +a, with step size h = 2a/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.
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 = a. 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 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!
using the Runge Kutta function. Check the final element of these 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.
4 Hint: You will need to set an appro-
priate value for the tolerance, e/1000 is
probably a good choice.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 =
π2ℏ2n2
2m(2a)2
. (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.
phas0029 final assignment 2022 5
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. 5 Hint: plt.axvline(x=-a,
c=’#5f5f5f’,ls=’-’,lw=2.5) will
plot a thick dark grey vertical line at
x = −a. Adapt this as required.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 , 6 Note that our wavefunction is already
in a convenient form to do this, as it is
a numpy array
where an integral with limits a and b can be evaluated as
I(a, b) = h
[
1
2
f(a) +
1
2
f(b) +
n−1∑
k=1
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) =
1√
a
cos
(nπx
2a
)
n odd, (8a)
ψn(x) =
1√
a
sin
(nπx
2a
)
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.
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.
phas0029 final assignment 2022 6
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, 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.
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.
+a-a x
V(x)
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.
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
V (x) = V0
x2
a2
. (9)
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.
+a-a x
V(x)
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.
II: Finite square well: Set the potential to have the form
phas0029 final assignment 2022 7
Vx =
0 if − a/2 ≤ x ≤ +a/2,V0 if |x| > a/2, (10)
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.
III. Other potentials: Now try this for your own choice(s) of potential. There’s
no need to choose one for which the analytical results of the non-embedded
potential are known—in fact it would be more interesting to choose one which is
not solvable analytically. Explain the reason for your choice in the text
cells—what makes your chosen potential an interesting one to study? Make sure
you include a full interpretation of the physics of your results in your notebook.
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
phas0029 final assignment 2022 8
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.
• You must work on this on your own, with no help or input from staff, other
students, or anyone else.
• 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 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
Notebook.
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.
phas0029 final assignment 2022 9
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.