Using Python to Calculate Transmission Probabilities for Multilayer Structures

I’m currently taking the second Quantum Mechanics for Scientists and Engineers course online from Stanford. They are both great courses taught by David Miller. The second course is looking more at applications and the third week’s topic was optical absorption by semiconductors.

Once we worked through all the physics and algebra, it was presented that these types of calculations are very easy to code and Professor Miller provided a program to calculate the transfer matrix and transmission probabilities for multilayer structures. The code he provided was for Matlab (and also for Mathcad). I have Octave, basically an open source version of Matlab, running on my Mac, so I was able to run the code provided. Mathcad is only available on Windows and installing Octave on a Mac can be a bit cumbersome, so I wanted to create a solution that could easily be run on any platform and work on my Python coding skills, which are pretty dismal.

It took a couple of days to port the Matlab code to Python but I got it running, the challenge being complex numbers in Numpy. Then a little more time to figure out Jupyter Notebooks, as my original code ran straight Python on my desktop. Here’s a link to my notebook running on Google’s Colaboratory:

htt ps://colab.research.google.com/drive/1aMV8ZYSfhraMMVnF_KiVhHFJXnMzWZnN

This link is view only, but you can easily download the code and run it in your own notebook, which will allow you to change the parameters, like the potentials, effective masses, etc. If you do run this one, you should get a graph that looks like this:

I did not attempt to make the code as efficient as possible, the goal was simply to get it to work. Comments and feedback are welcome.