0% found this document useful (0 votes)
15 views8 pages

Forward Shooting HTML 250106 121350

Uploaded by

Tanmoy Banerjee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views8 pages

Forward Shooting HTML 250106 121350

Uploaded by

Tanmoy Banerjee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

The method of forward shooting will be used to determine numerically the eigenenergies of the quantum harmonic oscillator in one

dimension. We
are looking for eigenvalues of the time-independent Schrödinger equation
2 2
ℏ d
[− + V (x)] ψ(x) = Eψ(x)
2m 2
dx

1 2 2
with V = mω x .
2

We will focus mainly on the three lowest eigenenergies. This will demonstrate how "an eigenvalue has just the right value" to solve the time-
independent Schrödinger equation. Moreover, this example shows that the forward-shooting method also works for potentials V (x) for which we
do not have closed-form solutions.
First, we write the Schrödinger equation in the following form
′′ 2m 1 2 2
ψ (x) = − [E − mω x ] ψ(x),
ℏ2 2

and for simplicity, we set the values m = ω = ℏ = 1 which yields the equation
′′ 2
ψ (x) = [x − 2E] ψ(x)

Forward Shooting
We will now compute the eigenenergies of this problem by using the forward shooting method, knowing that the wave function must tend to zero
as x → ∞

First, we divide the interval we are interested in, [a, b]into n equal intervals with length
b−a
Δx =
n

which defines the coordinates xi = a + iΔx. Hence, it is natural to write the function values of ψ(x),ψ(x)′ ,and ψ(x)′′ at a point x = xi as
′ ′′
ψi ,ψ ,and ψi respectively.
i

Next, we approximate ψ′′ (x) at a point xi by using the second-order central difference method which yields
ψi+1 +ψi−1 −2ψi
′′
ψ = 2
i (Δx)

Using the simplified Schrödinger equation


′′ 2
ψ = [x − 2E] ψi
i i

We obtain

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
ψi+1 +ψi−1 −2ψi
2
= [x − 2E] ψi
(Δx)
2 i

By rearranging the previous equation, we find an equation for the function value ψi+1 based on the values of the previous two points
2 2
ψi+1 = −ψi−1 + [2 + (Δx) (x − 2E)] ψi
i

By using this formula, we can calculate iteratively all function values as long as we have two initial values to start with. In this problem, we consider
a potential which is symmetric about x = 0. Therefore, the initial values ψ0 and ψ′0 will be given at x = 0 and we approximate the next function
value ψ1 simply by

ψ1 = ψ0 + Δx ⋅ ψ
0

This then allows us to calculate ψi for higher values of i using the formula above.
We know that for a symmetric potential, the ground state, second excited state, fourth excited state etc. are symmetric, while the first excited state,
third excited state etc. are anti-symmetric.
Since the harmonic oscillator potential is symmetric about x = 0, it allows us to use the method in only one direction, focusing on x > 0 and

starting with the initial values at x = 0, namely ψ0 and ψ0 .

Ground State
Since the ground state should be symmetric about x = 0, we have to have ψ′0 = 0. We also have to choose a value for ψ0 , e.g. ψ0 = 1. The
particular choice of the value of ψ0 will not affect the energy eigenvalue because its actual value will be determined by normalization of the wave
function.

Using these two initial values, we can now compute the ground state
energy as follows
First, we choose an upper and a lower bound for the estimated ground state energy.
This is where uncertainty arises since we do not know a priori where the
eigenenergies lie.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Subsequently, we keep shooting forward to xi = b, starting at x0 = 0, with an
estimated eigenenergy E0 that is determined iteratively by the bisection method: if
the value of the wave function grows to infinity as x → ∞, we need to raise the
value of E0 ; if the value of the wave function goes to negative infinity, we need to
lower E0 .

We truncate the bisection method when a desired accuracy acc is achieved and plot
the analytical solution versus the numerical solution of the wave function.
In [3]: import numpy as np
import matplotlib.pyplot as plt

# Set common figure parameters:


newparams = {'axes.labelsize': 14, 'axes.linewidth': 1, 'savefig.dpi': 300,
'lines.linewidth': 1.0, 'figure.figsize': (8, 3),
'figure.subplot.wspace': 0.4,
'ytick.labelsize': 10, 'xtick.labelsize': 10,
'ytick.major.pad': 5, 'xtick.major.pad': 5,
'legend.fontsize': 10, 'legend.frameon': False,
'legend.handlelength': 1.5}
plt.rcParams.update(newparams)
n=1000
p = 10 # the number of points included on the x-axis
dx = 1.0/n # step length

f0= np.zeros(p*n) # array for function values of f0


f0[0] = 1.0 # initial value for f0 at x = 0
df0_0 = 0.0 # initial value for df0/dx at x = 0

x = np.linspace(0,p,p*n,True)

acc = 1e-15 # Accuracy of eigenenergy


e1 = 0.0 # Lower bound, must be positive since the potential is positive for all x
e2 = 4.0 # Upper bound
E0 = e1
deltaE0 = 1

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
while deltaE0 > acc:
for i, x_ in enumerate(x[0:-1]):
if i == 0:
f0[i+1] = f0[i]+dx*df0_0
else:
f0[i+1] = -f0[i-1]+f0[i]*(2-dx**2*(2*E0-x_**2))
# Implementation of bisection method. If the function value is out of bounds,
# a new value for the energy is chosen. When the difference between the upper
# and lower bound for the energy is smaller than the given accuracy,
# the while loop stops, yielding a result for E1.
if f0[i] > 5:
e1 = E0
E0 = e1 + (e2-e1)/2
break
elif f0[i] < -5:
e2 = E0
E0 = e2 - (e2-e1)/2
break
deltaE0 = e2-e1
print(r'The energy E0 is: %s'% E0)

#Plot:
p1, = plt.plot(x, np.exp(-x**2/2), 'g:') # analytical eigenfunction
p2, = plt.plot(x, f0, 'b') # computed eigenfunction
p3, = plt.plot(x, 0.5*x**2, 'r') # potential
plt.plot(-x, np.exp(-x**2/2), 'g:', -x, f0, 'b', -x,0.5*x**2, 'r') # same as above for negative x-values
plt.legend([p1, p2, p3],['Analytical wavefunction', 'Calculated wavefunction', r'Potential $V(x)$'])
plt.xlabel(r'$x$')
plt.ylabel(r'$\psi(x)$')
plt.ylim([-0.5, 3])
plt.xlim([-6, 6])
plt.title('Wavefunction for Ground State of Harmonic Oscillator')

The energy E0 is: 0.500332214879553


Out[3]: Text(0.5, 1.0, 'Wavefunction for Ground State of Harmonic Oscillator')

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
First Excited State

For the first excited state, we have to choose different initial values. Since this is an anti-symmetric function, we must have ψ0 = 0, while ψ0 can

be chosen freely this time, e.g. ψ0 .
Since we are looking for the first excited state, we know that E1 > E0 , which means we can choose E0 as our lower bound.
Choosing an appropriate upper bound can be the tricky part since it should be lower than the eigenenergy of the second excited state.

In [4]: f1 = np.zeros(p*n)
f1[0] = 0.0
df1_0 = 1.0

e1 = E0
e2 = 2.0
E1 = e1
deltaE1 = 1
while deltaE1 > acc:
for i, x_ in enumerate(x[0:-1]):
if i == 0:
f1[i+1] = f1[i]+dx*df1_0
else:
f1[i+1] = -f1[i-1]+f1[i]*(2-dx**2*(2*E1-x_**2))
if f1[i] > 5:
e1 = E1

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
E1 = e1 + (e2-e1)/2
break
elif f1[i] < -5:
e2 = E1
E1 = e2 - (e2-e1)/2
break
deltaE1 = e2-e1

print(r'The energy E1 is: %s' % E1)


p1, = plt.plot(x, x*np.exp(-x**2/2), 'g:')
p2, = plt.plot(x, f1, 'b')
p3, = plt.plot(x, 0.5*x**2, 'r')
plt.plot(-x, -x*np.exp(-x**2/2), 'g:', -x, -f1, 'b', -x, 0.5*x**2, 'r')
plt.legend([p1, p2, p3],['Analytical wavefunction', 'Calculated wavefunction', r'Potential $V(x)$'])
plt.xlabel(r'$x$')
plt.ylabel(r'$\psi(x)$')
plt.ylim([-1,1.5])
plt.xlim([-6,6])
plt.title('Wavefunction for First Excited State')

The energy E1 is: 1.5001498587221596


Out[4]: Text(0.5, 1.0, 'Wavefunction for First Excited State')

Second Excited State

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
For the second excited state, we know that E2 > E1 , and that the wavefunction is symmetric. Hence, we can use the same initial conditions as
for the ground state. Again, choosing an appropriate upper limit is critical.

In [5]: f2 = np.zeros(p*n)
f2[0] = 1.0
df2_0 = 0.0

e1 = E1
e2 = 3.0
E2 = e1
deltaE2 = 1
while deltaE2 > acc:
for i, x_ in enumerate(x[0:-1]):
if i == 0:
f2[i+1] = f2[i]+dx*df2_0
else:
f2[i+1] = -f2[i-1]+f2[i]*(2-dx**2*(2*E2-x_**2))
if f2[i] < -5:
e1 = E2
E2 = e1 + (e2-e1)/2
break
elif f2[i] > 5:
e2 = E2
E2 = e2 - (e2-e1)/2
break
deltaE2 = e2-e1

# Notice that the two last conditions here are different from the two above!
# The reason is that the wavefunction now has roots for x ≠ 0, and approaches the x-axis from below.

print(r'The energy E2 is: %s' % E2)

p1, = plt.plot(x, -(2*x**2-1)*np.exp(-x**2/2), 'g:')


p2, = plt.plot(x, f2, 'b')
p3, = plt.plot(x, 0.5*x**2, 'r')
plt.plot(-x, -(2*x**2-1)*np.exp(-x**2/2), 'g:', -x, f2, 'b', -x,0.5*x**2, 'r')
plt.legend([p1, p2, p3],['Analytical wavefunction', 'Calculated wavefunction', r'Potential $V(x)$'])
plt.xlabel(r'$x$')
plt.ylabel(r'$\psi(x)$')
plt.ylim([-1.5,2])

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
plt.xlim([-6,6])
plt.title('Wavefunction for Second Excited State')

The energy E2 is: 2.5009550642267624


Out[5]: Text(0.5, 1.0, 'Wavefunction for Second Excited State')

From the analytical solution of the harmonic oscillator potential, we know that the eigenenergies are
a 1
En = ℏω(n + )
2

with ℏ = ω = 1, we find Ena = (n + 1/2) , which is in excellent agreement with the results obtained above! We also see from the plots of the
eigenfunctions that they are in excellent agreement with the analytical eigenfunctions.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD

You might also like