Schrödinger Equation Solver [WIP]

Schrödinger Equation Solver [WIP]

Quantum Mechanic Simulator

Description

This is a simulator for quantum mechanics. It is still work in progress.

Goals

  • Simulate a free particle
  • Simulate a particle in a potential
    • Infinite potential well
    • Finite potential well
    • Step potential
    • Tunneling
    • Harmonic oscillator
    • Hydrogen atom
  • 2D simulation
  • Calculate the eigenvalues and eigenfunctions of a given potential and plot them
  • Get a linear combination of eigenfunctions
  • Time dependent Potential
  • Save the animation as a video
  • Implement a Terminal UI

Theory

Schrödinger's Equation

The Schrödinger's Equation is a partial differential equation that describes how the quantum state of a physical system evolves over time. It is defined as

i \hbar \frac{\partial}{\partial t} |\psi(t)\rangle = \hat{H} |\psi(t)\rangle

where \(\hat{H}\) is the Hamiltonian operator of the system. It is the sum of the kinetic energy and the potential energy of the system.

\hat{H} = \frac{\hat{p}^2}{2m} + V(\hat{x}) = -\frac{\hbar^2}{2m} \frac{\partial^2}{\partial x^2} + V(x)

Technologies used

  • Python
  • Numpy
  • Matplotlib (for plotting/animate the results)
  • Scipy (for efficient matrix operations and solving the linear system)

Challenges and Solutions

  • Finding a starting point for the project:
    • I found two blog posts [1], [2] where the Authors implemented something similar. I used this as a starting point for my project.
  • The runtime to calculate the results was too long (30s for 1000 time steps):
    1. First Problem was, that I transformed a Numpy array into a Scipy Sparse CSC matrix in every iteration. This was the biggest bottleneck. I solved this by transforming the Numpy array into a Scipy Sparse CSC matrix once and then using this matrix in every iteration. This reduced the runtime from 30s to 2.5s. (Improvement-factor: 12)
    2. The second problem was, that I used the 'sp.sparse.linalg.solve' function which is efficient for sparse matrices, but there is a more efficient algorithm for tridiagonal matrices. I transformed the matrix into a band matrix and solved the linear system with the ' sp.linalg.solve_banded'. This reduced the runtime from 2.5s to 1s. (Improvement-factor: 2.5)
  • Both optimizations together reduced the runtime from 30s to 1s. (Improvement-factor: 30)
  • Finding time to work on the project:
  • Due to college I had to pause the project for a few months. The good thing is, that in the meantime I learned a lot about computational physics and numerical methods in college courses, which will definitely help me to improve the project.

Installation

How to use

Sources

Date22.02.2024
GitHub Link

More Projects