You are on page 1of 8

Open in app Get started

Published in Modern Physics

Benjamin Obi Tayo Ph.D. Follow

Apr 18, 2019 · 3 min read · Listen

Save

Finite Difference Solution of the Schrodinger


Equation

Sign in to Medium with Google

Md Chand Asique
mdchandasique786@gmail.com

B.Sc Physics 101 4


phyh.adms@db.du.ac.in

Introduction
nikahat 77599
The time-independent Schrodinger equation is a linear ordinary differential equation
Open in app Get started
that describes the wavefunction or state function of a quantum-mechanical system.
The solution of the Schrodinger equation yields quantized energy levels as well as
wavefunctions of a given quantum system. The Schrodinger equation can be used to
model the behavior of elementary particles, and atoms. When combined with the
superposition principle, the Schrodinger equation accounts for the formation of
chemical bonds, and hence can be used to model molecular systems and periodic
systems such as crystalline materials.

In this article, we focus on the simple one-dimensional Schrodinger equation. We


show how the equation can be solved using the finite difference method. We shall
illustrate our example using the quantum harmonic oscillator. By changing the
potential energy of the system, the code can also be applied to other fundamental one-
dimensional models such as square well systems, and the hydrogen atom.

General Formalism

Sign in to Medium with Google

Md Chand Asique
mdchandasique786@gmail.com

B.Sc Physics
phyh.adms@db.du.ac.in

nikahat 77599
Open in app Get started

Sign in to Medium with Google

Md Chand Asique
mdchandasique786@gmail.com

B.Sc Physics
phyh.adms@db.du.ac.in

nikahat 77599
Open in app Get started

Finite Difference Implementation in Python

import necessary libraries

Sign in to Medium with Google


import numpy as np

import matplotlib.pyplot as plt


Md Chand Asique
mdchandasique786@gmail.com

define potential
B.Sc Physics energy function
phyh.adms@db.du.ac.in

nikahat 77599
def Vpot(x):
Open in app Get started
return x**2

enter computational parameters

a = float(input('enter lower limit of the domain: '))

b = float(input('enter upper limit of the domain: '))

N = int(input('enter number of grid points: '))

define x grid and step size

x = np.linspace(a,b,N)

h = x[1]-x[0]

create kinetic energy matrix

T = np.zeros((N-2)**2).reshape(N-2,N-2)

for i in range(N-2):

for j in range(N-2):

if i==j:

T[i,j]= -2

elif np.abs(i-j)==1:

T[i,j]=1

else:

T[i,j]=0

create potential energy matrix


Sign in to Medium with Google

V Md
= np.zeros((N-2)**2).reshape(N-2,N-2)
Chand Asique
mdchandasique786@gmail.com
for i in range(N-2):

B.Scfor j in range(N-2):

Physics
if i==j:

phyh.adms@db.du.ac.in
V[i,j]= Vpot(x[i+1])

else:

nikahat 77599
V[i,j]=0
Open in app Get started

create hamiltonian matrix

H = -T/(2*h**2) + V

find eigenvalues and eigenvectors, then sort them in ascending order

val,vec=np.linalg.eig(H)

z = np.argsort(val)

z = z[0:4]

energies=(val[z]/val[z][0])

print(energies)

plot wavefunctions for first 4 lowest states

plt.figure(figsize=(12,10))

for i in range(len(z)):

y = []

y = np.append(y,vec[:,z[i]])

y = np.append(y,0)

y = np.insert(y,0,0)

plt.plot(x,y,lw=3, label="{} ".format(i))

plt.xlabel('x', size=14)

plt.ylabel('$\psi$(x)',size=14)

plt.legend()

plt.title('normalized wavefunctions for a harmonic oscillator using


finite difference method',size=14)

plt.show()

Sample Output
Sign in to Mediumfor
withthe Quantum Harmonic Oscillator
Google
Using a = -6, b = 6, N = 1001, we obtain the following:
Md Chand Asique
mdchandasique786@gmail.com

B.Sc Physics
phyh.adms@db.du.ac.in

nikahat 77599
Numerical and Exact energies for first 4 lowest states.
Open in app Get started

In summary, we’ve shown that the finite difference scheme is a very useful method for
solving an eigenvalue equation such as the Schrodinger equation. We illustrated our
implementation using the harmonic oscillator system. By changing the potential
energy of the system, the code can also be applied to other fundamental one-
dimensional models such as square well systems, and the hydrogen atom.

Sign in to Medium with Google

Md Chand Asique
mdchandasique786@gmail.com

B.Sc Physics
phyh.adms@db.du.ac.in

Enjoy the 77599


nikahat read? Reward the writer.Beta
Your tip will go to Benjamin Obi Tayo Ph.D. through a third-party platform of their choice, letting them know you
appreciate their story. Open in app Get started

Give a tip

Get an email whenever Benjamin Obi Tayo Ph.D. publishes.

Your email

We couldn't process your request. Try again, or contact our support team.

Subscribe

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy
practices.

About Help Terms Privacy

Get the Medium app

Sign in to Medium with Google

Md Chand Asique
mdchandasique786@gmail.com

B.Sc Physics
phyh.adms@db.du.ac.in

nikahat 77599

You might also like