The Finite Difference Method and Schrodinger's Equation
If we separate the time-dependent part of the wavefunction from the spatial part of the wavefunction, we can analyze the eigenvalues of the spatial wavefunction using the time-independent Schrodinger equation:
We can find exact solutions for the time-independent Schrodinger equation for simple potentials (square wells, square barriers, harmonic oscillators, etc.). However, we usually cannot find an exact solution for more complicated potential distributions. In these cases, we have to turn to numerical methods. In this post, we are going to use the finite difference method to solve the one-dimensional, time-independent Schrodinger equation.
The Schrodinger Equation
Recall that the Hamiltonian operator acting on the wavefunction of the particle yields the energy of the particle:
The Hamiltonian is simply the sum of the kinetic and potential energies:
We know that the kinetic energy of the particle is and the potential energy of the particle is .
Recall that the momentum operator is for a position dependent wavefunction. We can then expand the Hamiltonian:
The Finite Difference Method
We can find an approximate solution to the Schrodinger equation by transforming the differential equation above into a matrix equation. If we divide the x-axis up into a grid of n equally spaced points , we can express the wavefunction as:
where each gives the value of the wavefunction at the point . Now, all we have to do is express the Hamiltonian as a matrix operator.
Let’s look at the kinetic energy term first. Suppose that the distance between each grid point is . We remember that the first derivative of a function is just the slope of the function. If we are on some grid point, we can find the forward slope (between the current grid point and its neighbor to the right) or the backward slope (between the current grid point and its neighbor to the left).
The second derivative is simply the derivative of the first derivative. We can find the second derivative of the wavefunction at a given grid point by using the forward and backward derivatives above:
Thus, in our case, we can write a kinetic energy operator as:
We note that if we multiply this kinetic energy operator and the wavefunction vector, we get the correct expression for the second derivative at every grid point.
If we have periodic boundary conditions, we need to make sure that we connect the first and last gird points with an off-diagonal term:
Next we can focus on the potential energy operator. If there were no kinetic energy in the system, we would expect the energy at each grid point to equal the potential energy . Thus, the matrix V must be diagonal with the potential energy at each point along the diagonal:
The Hamiltonian is then the sum of the kinetic and potential energies. Once we have the Hamiltonian, we can use an eigenvalue solver to determine the final solution for the wavefunction.
I created a short Matlab script to calculate the three lowest energy states of the Schrodinger equation given some potential energy distribution. It plots the wavefunction onto the potential energy distribution so that we can see how the changing potential affects the probability of finding the particle at a certain position.
The source code can be found on the Cupcake Physics GitHub page. All of the instructions for changing the parameters of the simulation are included in the script. Feel free to play around with the code and create your own custom potentials!