OK.
So let us begin with programming, the wave function and the ion energies of an electron living in the
box using Python three.
So first of all, make sure you have these two import commands at the very beginning because we are
going to plot some data and we are going to use NumPy for some calculations.
Now next, we will define the potential and to Schrodinger equation and initiating a equation.
We have the constants each bar and we have two constant m for the mass of the electron.
And actually, these are very difficult numbers, and we want to make it more easy for us.
So we just set them to one.
And later on, we could scale our solution to fit the actual values of these constants.
But this is not so important here.
So typically people just set them to one.
Now next, we will define our potential.
And here we have our box, which goes from X equal zero to x equal.
And for a we set the value, which will also be one in this case.
Now the potential inside of the box, we we will set to zero.
And outside of the box, the potential will be infinitely large.
And this makes it a lot easier for us, as we have learned in the analytical case, because in fact,
we only have to consider the area inside of the box because outside of the box, the potential is infinitely
large and our wave function will be zero.
So we don't have to actually define it here.
The only thing that we need to define is the wave function.
At the starting position, size is equal to zero.
So actually, this is just the X dependent solution, so the stationary part.
But still, I will call it SCI here, but in the energy killer case, we called it PHI.
Now another thing at the very left of the box, we will have to also define a first derivative.
So we call this deep sigh.
And this is equal to a value which is different from zero.
So far, it doesn't really matter how large this value is.
We will just use some value and later on we will scale our wave function so that we will get the correct
value for deep sigh.
The only thing that's important to you is that it's different from zero.
OK, so now we have to find some starting conditions, which means the value of science and the first
derivative of psi at the left part of the box.
So this means four x equal to zero.
And now we have to propagate this differential equation, which is the stationary creating equation,
so that we can calculate these two values for every other position inside of the box.
So as I told you, we start at X equal to zero.
And also we have to define some increment.
So because we cannot solve to the way function continuously from zero to a, we have to define some
value or some some increments, some steps.
So I use here eight times.
Let's let's use something like this.
So we will have to do 1000 steps until we are at the other end of the box.
Now what we also need is something to store our data.
So we have here a list for our X will use, which will be empty in the beginning and also for the values
of the way function.
We could also use another list for for deep sigh.
But actually, we are not really interested in this quantity.
This is because even the wave function itself doesn't really have a meaning, but we can use the wave
function to calculate observables and the probability density CI squared.
OK.
And now what we will use is a loop, or we use here such a wild statement.
So what we are going to do is we will increase our value of X by D X until X reaches the value of A.
So this means in the first loop X will be zero.
The second loop X will be zero plus the X and then and so on.
It will keep on increasing in increments of the X until and the last loop.
It will be equal to a.
Good.
Now, what are we going to solve?
We are going to solve the shooting equation and this means the second derivative of psi, so that's
called it dead.
So for a second derivative is equal to two times and over eight bar square.
And then we can actually combine the potential, which is zero in this case.
Time is the energy times psi.
So if you would, yeah, bring this to the other side, you would see that is exactly minus h bar square.
Over two m d deep psi is equal to E times.
So this is exactly the stationary shooting equation for this case.
OK, now we have some statement on how we can calculate deep psi.
However, what we as so we cannot really use or we cannot calculate this derivative analytically, we
could, but we don't want to do this here.
We want to do it numerically.
And there's actually the second derivative, and you can only calculate a second derivative from the
first derivative.
So before we can calculate the second derivative, we need to calculate the first derivative.
And here we use deep CI is equal to DB ci.
Plus the derivative of deep CI, which is the deep CI times v x.
OK, now we have something for the first derivative of CI.
This we can calculate from from CI itself.
So CI is equal to CI plus deep CI times d x.
So we have now and a new value of CI, which is calculated from the derivative times the increment.
Then we have the first derivative, which is calculated from the second derivative times.
The increment and the second derivative is related to the wave function itself by just creating an equation.
OK, so now this shouldn't actually work already.
What we need now is we we want to store our wax values, so we use here pens so that this value of X
for each loop is stored in our X list.
It will add a new entry and the same for sign.
So again, pens sign.
Now, what we want to also do is we want to plot.
So this is the command for plots, so we plot X list versus scientists.
And another thing that we also have to consider here, the only thing that is left that is not defined
yet is the energy.
And actually, we want to determine psi, but also we want to determine the energy.
So just means so far we don't know what the energy is.
But this is the whole trick of this method.
We will just set some value for the energy.
Let's say one, and we will just test what the wave function looks like for this energy that we have
to find here.
And then we will see if it looks reasonable in a physical way.
So let me run this notebook and see what it looks like.
So restart, run off.
OK.
OK, so here we have now our expel you and remember our box starts from zero.
Where the wave functions should be zero because we have defined it here.
And also we have some first derivative, which is different from zero, because here we have to find
it's actually one.
So this makes total sense.
And then the wave function increases in, I would say, something like assign function, which also
makes sense.
So that's already good.
But here at the other end of the box, which is X equal to a which we have set to one here, our wave
function does not go back to zero.
So it's in conflict with the other boundary condition.
And this is, of course, the case because we have not told the code that there is a boundary condition.
So let's try a different energy.
OK, so two looks already a bit better, it starts to go down three four.
OK, we are getting closer.
Five.
Oh, OK.
This looks already pretty good.
I mean, it's a bit lower than than one.
Maybe it's something like four point nine.
OK, yeah, that is actually pretty good.
So now we could also look at the cyclist and go all the way down.
So you see, we start here from zero point zero zero one and it goes back down to zero zero zero three
five.
OK, that's pretty good, actually.
And that's the whole point of this method, which is called the shooting method.
We give it an energy and then we just let the system take a shot and propagate the wave function.
And if it looks reasonable, then everything is correct and we can say, OK, this is our first eigenvalue
and this is our first I can function.