# Modeling Quantum Tunneling With Python

Everybody loves quantum tunneling. It’s just cool. It would be like having a ball rolling towards a hill. Imagine that ball doesn’t have enough kinetic energy to make it over the hill and down to the other side. However, when you look for the ball — sometimes you can find it on the other side the hill (where the grass is greener).

So, how do you model this type of interaction in python? I’m going to go over all the details. Do you know why? If I don’t, I’m going to forget this stuff the next time I teach quantum mechanics.

# 1D Schrödinger Equation

The wave function for a particle must be a solution to the 1D Schrödinger equation.

We can partially solve this equation by first assuming that Ψ can be a product of a function that only depends on x (ψ(x)) and a function that only depends on time (f(t)).

With a little bit of algebra, we get the following expression.

IF the potential (V) only depends on x and not t, then the left side of this equation only depends on position and the right side only depends on time. So, if x changes then the right side would remain the same. The opposite would be true for the left side. That means that both sides of this equation must be equal to a constant. We can call this constant E — yes, that’s the energy.

I’ll skip a lot of the details (so we can get to the python stuff), but this gives the following time dependent equation and function:

This leaves us with the following space-dependent equation.

We need to find the function ψ that works with this differential equation. In certain situations we could solve this equation (like in the infinite square well) but otherwise we will have to use some tricks.

# Finite Difference Solution

The trick we are going to use to ψ is the finite difference method. Imagine that I have a region of space with a wave function. I can break this wave function into finite elements.