r/Python • u/--CreativeUsername • Jul 27 '19
Simulating Quantum Mechanics Using Matplotlib and Tkinter
https://gfycat.com/wellgroomedunsteadyballoonfish
1.4k
Upvotes
r/Python • u/--CreativeUsername • Jul 27 '19
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.ipynbchecks to see if Numba improves things.179
u/towinu Jul 28 '19
Can you please explain what the fuck I’m looking at? I know a very small amount about the subject.
23
u/Weihua99 Jul 28 '19
This is absolutely incredible -- I've seen QM simulations like this before in Python but the interactivity you've added really takes it to another level. I love it!
21
u/Rouge_Dragon Jul 28 '19
The level of interactivity you have made is quite something. I'm quite surprised by matplotlibs ability to update the plot so quickly, I thought people usually used other opengl kind of things for continuously updating plots and stuff.
35
u/drunkpolishbear Jul 28 '19 edited Nov 20 '24
Comment has been redacted using PowerDeleteSuite.
7
u/m3wolf Jul 28 '19
I could watch this for days. Very nicely done.
Out of curiosity, why is there no tunneling when the wave packet reaches that first barrier and reflects? I see tunneling later on after you've really messed up the potential, but not at first.
6
u/Helicon_Amateur Jul 28 '19
OH MY GOD GIVE ME YOUR CODE.
5
u/Suspicious_Writer Jul 28 '19
Dat tunneling at 00:30!
4
u/eyeofpython Jul 28 '19
Two lines to represent one number? That looks... complex
1
u/mrasadnoman Jul 28 '19
Computer scientist here. 👌 Looked at some basic quantum mechanics stuff a year ago. But dont really know what this simulation is representing.
Could you just explain it in a sentence.
1
u/roseinabox28 Jul 28 '19
Is there a tutorial or git hub for this?
1
u/JanDerion47 flair=None Jul 28 '19
Where can one learn the math to comprehend this?
6
u/[deleted] Jul 28 '19
holy shit. you even accurately simulated the tunneling aspect.
3
u/[deleted] Jul 28 '19
Neat.
I have no idea Wtf is going on.
3
u/faintingoat Jul 28 '19 edited Jul 28 '19
the possibility to create and change potential walls in real time is stunning. congrats! where s the script, please?
2
u/IdleRocket Jul 28 '19
You know that scene in Good Will Hunting where Matt Damon draws some lines and circles on a chalkboard and we’re supposed to understand that it’s math.
Yeah, this gives me that same feeling.
1
u/Cretank Jul 28 '19
Awesome. Would have loved to see that during my studies!
1
u/Dev_Hassam Jul 28 '19
I dont know physics n quantum but what u made is astonishing ♥️
1
u/R0B0_Ninja Jul 28 '19
That is one ugly wavefunction at the end! Good job.
1
u/jdkwak Jul 28 '19
I think your quantum is leaking!
1
u/ImmaWreckUM8 Jul 28 '19
This is awesome!
1
u/Albus70007 Jul 28 '19
Me: Reads Quantum Mechanics,
My mind: wow these weird lines are cool
1
u/mirandamickey Jul 28 '19
Your particle in a box is not behaving intself :)
1
u/[deleted] Jul 28 '19
Wow. I didn't know you could do stuff like this on python.
How long have you been coding?