r/Python • • Jul 27 '19

Simulating Quantum Mechanics Using Matplotlib and Tkinter

https://gfycat.com/wellgroomedunsteadyballoonfish
1.4k Upvotes

60 comments sorted by

View all comments

49

u/--CreativeUsername Jul 27 '19 edited Jul 28 '19

And also with numpy, sympy, and optionally numba. Github Repository:
https://github.com/marl0ny/1D-Quantum-Mechanics-Applet.

The code itself is a little messy, and I certainly haven't ironed out all bugs and quirks. Note that this uses numba, if you have it. In my experience numba either slows things down or speeds things up, depending on the computer and environment used. The notebook Performance_Test.ipynb checks to see if Numba improves things.

6

u/Fairbanksbus142 Jul 28 '19

This is wonderful! Thanks for sharing!

3

u/[deleted] Jul 28 '19

That was insane. I hope to learn much from you.

1

u/ovigo Jul 28 '19

Very cool stuff! I wonder how much effort it would be to rewrite this in Jupyter/IPython-widgets and make a web-launchable my binder.org? :)

1

u/Science-Compliance Jul 28 '19

Okay, I'm a little confused. When you drew the first barrier, I was expecting to see some of the probability distribution on the other side vis-à-vis quantum tunneling, but it acted almost as an impenetrable barrier from which the wave function was reflected. Is my intuition for quantum mechanics out of calibration, or is this something you need to address in the software? Impressive work by the way.

1

u/--CreativeUsername Jul 28 '19

The tunneling of the wavefunction across a potential barrier depends on its energy (where this energy does not need to be greater than the barrier in order for tunneling to occur). Now the energy of the wavefunction is related to the second spatial derivative d2 /dx2 , which is an indicator of how much curvature the function has. So therefore in general, the more curvature the wavefunction has, the greater its energy. On the wavefunction's firsts collision with the barrier, it has relatively little curvature and energy. In this case tunneling still happens, but the amount of the wavefunction that gets transmitted through the barrier is so vanishingly tiny that it is effectively invisible. Later on, when the wavefunction is more jittery and so therefore has greater curvature, more of the wavefunction is transmitted through the barrier, and so the tunneling effect is visible.

1

u/Science-Compliance Jul 28 '19

Thanks, I did notice the tunneling occurring toward the end. Impressive program.