Saturday, March 26, 2016

Solve QM Particle-In-A-Box Problem Using Code

Rhett Allain shows you how to solve the standard 1D infinite square well problem using numerical method.

I know he is using this as a simple illustration, but it is more useful, especially to physics students, if he solves this for a finite square well.

But still, for the general public, this might be complicated enough. I wonder if someone with just computer coding but little physics can code this successfully. If you fall under this category, let me know how you did if you took up this task.



rallain said...

It might be too early (I haven't compared it with the analytical solution) but this seems to work. This is the solution to the semi-infinite square well

Really, the only difference is that you let the calculation of psi go past L - after that you need to make some checks to see that the solution doesn't blow up (because it will). If you want a more accurate solution, let xmax be bigger. I'm pretty sure this is working.


GDL said...

"I wonder if someone with just computer coding but little physics can code this successfully."

I don't fit that description (I'm familiar with both physics and programming), but I wonder if knowledge of physics is relevant? It seems to me that this is just a numerical integration of a differential equation. Many programmers are already familiar with how to do that, even if they don't really understand the nature or phenomenon described by a the differential equation. In this case, there's the additional wrinkle of finding the value of a free parameter (E) that gives you the right boundary conditions, but again most programmers know how to do that, using brute force (which the author calls "shooting method") if nothing else.

What may be more interesting is whether a programmer with little knowledge of physics can come up with a better method to figure out the right value of E. Brute force searches are notoriously inefficient, and most programmers will look for some other method and only use brute force as a last resort.