Solving 1-D Schrodinger Equation in Python (Scipy) Numerically

In summary: Again, if you are really interested in this, you should read the source code and look at the pictures.In summary, the article shows how to create a wave packet in Python and how to solve the quantum harmonic oscillator in scipy.
  • #1
corychu
2
7
I've tried to make an animation using python to demonstrate the 1-D simple harmonic oscillator and step potential examples. Hope that it can be useful for some of you. Have fun~ :)
https://blog.gwlab.page/solving-1-d-schrodinger-equation-in-python-dcb3518ce454

sho.gif


By the way, If you are interested, I also implemented a C++ version using RK4 and finite-difference scheme with Eigen library:
https://github.com/c0rychu/SchrodingerEq_1D_tutorial/tree/master/step_potential_cpp
 
Last edited:
  • Like
Likes Paul Colby, bob012345, Wrichik Basu and 2 others
Technology news on Phys.org
  • #2
corychu said:
I've tried to make an animation using python to demonstrate the 1-D simple harmonic oscillator and step potential examples. Hope that it can be useful for some of you. Have fun~ :)
https://blog.gwlab.page/solving-1-d-schrodinger-equation-in-python-dcb3518ce454

View attachment 284770

By the way, If you are interested, I also implemented a C++ version using RK4 and finite-difference scheme with Eigen library:
https://github.com/c0rychu/SchrodingerEq_1D_tutorial/tree/master/step_potential_cpp
I looked at your link but it's not completely clear (to me but it probably is to others :smile: ) what you are showing here. How did you construct this wave packet? Are the spikes at the classical boundaries? How does this simulation relate to cases G and H of the Wikipedia simulations? Thanks.

https://en.wikipedia.org/wiki/Quantum_harmonic_oscillator
 
  • #3
bob012345 said:
I looked at your link but it's not completely clear (to me but it probably is to others :smile: ) what you are showing here. How did you construct this wave packet? Are the spikes at the classical boundaries? How does this simulation relate to cases G and H of the Wikipedia simulations? Thanks.

https://en.wikipedia.org/wiki/Quantum_harmonic_oscillator
Sorry for my late reply :(

I think the goal of the article is to tell you how to implement a lowest-order finite-difference method in Python and how to call the initial-value-problem solver in scipy.

As explained in the source code, my initial wave-pack is constructed by:

psi0 = A * np.exp(-(x-x0)**2 / (2.0 * sigma**2)) * np.exp(1j * kx * x)

So, I guess if you set kx=0, it will work like a particle resting at x0. In this case, it might be correct to think of it as a particle sitting at the classical boundary.

I'm not sure about the G shown in Wikipedia. But it said H is a coherence state.

If I understand correctly, a coherence state is a gaussian wavepacket with a specific width (sigma). So, if you are interested in that, you may set the sigma by the proper formula and run the code.

On the other hand, if the width (sigma) is an arbitrary value, I guess it is called a squeezed state. (Sorry that I'm really not good at quantum optics)
 
  • Like
Likes vanhees71 and bob012345

FAQ: Solving 1-D Schrodinger Equation in Python (Scipy) Numerically

What is the Schrodinger equation?

The Schrodinger equation is a mathematical equation that describes how the quantum state of a physical system changes over time. It is used to predict the behavior of particles at the microscopic level and is a fundamental concept in quantum mechanics.

Why is it important to solve the Schrodinger equation numerically?

The Schrodinger equation is a complex equation that cannot be solved analytically for many physical systems. Therefore, numerical methods, such as the use of computer programs like Python with the Scipy library, are necessary to obtain solutions and make predictions about the behavior of quantum systems.

How does Scipy help in solving the 1-D Schrodinger equation?

Scipy is a powerful scientific computing library for Python that provides a wide range of tools and functions for numerical integration, linear algebra, optimization, and more. In the context of solving the 1-D Schrodinger equation, Scipy offers functions for integrating differential equations, which are essential for solving the time-dependent Schrodinger equation.

What are the steps involved in solving the 1-D Schrodinger equation numerically with Scipy?

The first step is to define the potential function and initial conditions for the system. Then, the spatial grid and time grid must be set up. Next, the time-dependent Schrodinger equation must be discretized and solved using Scipy's integration functions. Finally, the results can be plotted and analyzed.

Can the 1-D Schrodinger equation be solved analytically?

Yes, the 1-D Schrodinger equation can be solved analytically for some simple potential functions, such as the harmonic oscillator or the infinite square well. However, for more complex systems, numerical methods are necessary to obtain solutions.

Back
Top