Skip to content

ericaloken/Project5-FYS3150

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Exploring Quantum Slit Interference of the 2D Schrödinger Equation via the Crank—Nicolson Method

This repository contains the work of Erica Løken, Mads Mestl and Heine Husdal for Project 5 in the course FYS3150 – Computational Physics at the University of Oslo.

Project introduction

The quantum slit experiment is one of the famous experiments in physics demonstrating the wave-particle duality of particles. In this project we explore quantum interference numerically by solving the dimensionless 2D time-dependent Schrödinger equation, given by

$$ i\frac{\partial u}{\partial t} = -\frac{\partial^2 u}{\partial x^2} - \frac{\partial^2 u}{\partial y^2} + v(x,y)u, $$

where $u(x,y,t)$ is the wave function and $v(x,y)$ is the potential. This equation is discretised using the Crank—Nicolson method, which yields the linear system

$$ A\mathbf{u}^{,n+1} = B\mathbf{u}^{,n}, $$

where $A$ and $B$ are sparse matrices. This system is solved using the SuperLU sparse solver provided by the Armadillo C++ library.

The system we are studying is a non-relativistic particle confined in a two-dimensional domain $[0,1]\times [0,1]$. The system is initially described by a Gaussian wave packet. The wave packet propagates through single, double and triple slits in the domain. These slits are implemented numerically by assigning a large potential $v_0 = 10^{10}$ to grid points corresponding to the slit walls, while the potential is zero elsewhere and in the slit openings. As the wave function evolves in time, parts of the wave packet will be transmitted through the slits while the remainder is reflected. We obtain the probability density $p(x,y;t) = |u(x,y,t)|^2$, which reveals the famous interference pattern on a virtual detector, demonstrating the wave-particle duality of electrons.

The main objectives of this project is to solve the 2D Schrödinger Equation using the Crank—Nicolson method and simulate the evolution of the quantum wave packet through different slit configurations. We aim to study the interference pattern on a detector profile and visualise the simulation in animations and plots.

The code developed for this project is written in C++ for the simulations and Python for post-processing and visualisation. To illustrate the resulting interference patterns, a sample animation of the double-slit simulation is shown below.

Double-slit probability animation

Folder structure

  • src/ - C++ source files
  • include/ - Header files
  • python/ - Python scripts for plotting and animation
  • figures/ - Generated plots and graphs
  • output/ - Simulation output files
  • report/ - Project pdf report

Compiling and running C++ code

All C++ programs are compiled and executed using the provided Makefile.

Compiling the code

To compile the C++ code, navigate to the project root directory and run:

make

This builds a single executable build/main generated from src/main.cpp.

Command-line arguments for main.cpp

The main program accepts 12 positional command-line arguments controlling the simulation:

h dt T xc sigma_x px yc sigma_y py v0 slit_number output_filename

Where:

  • h – spatial step
  • dt – time step
  • T – total simulation time
  • xc, yc – initial wave-packet center
  • sigma_x, sigma_y – Gaussian widths
  • px, py – initial momentum components
  • v0 – barrier height (0 = no wall, 1e10 = wall with slits)
  • slit_number – number of slits (0, 1, 2, 3)
  • output_filename – file containing the full time evolution results

An example of a run would be:

./build/main 0.005 2.5e-5 0.002 0.25 0.05 200.0 0.5 0.20 0.0 1e10 2 output/data_double_slit.data

Running the code

To run the compiled C++ code, navigate to the project root and run the corresponding make commands:

make run-compare         # run simulations with and without barrier
make run-slits           # run single, double and triple slit simulations

These will compile the program and then run build/main with the exact command-line arguments used to generate the figures in the project report. They will output the results to the output/ directory using filenames expected by the Python plotting scripts.

Plotting results using Python

For plotting, a python environment is required. To install the required packages, run:

pip install -r requirements.txt

For plotting results after running all simulations, from the project root run:

python3 python/plot_probs_deviation.py   # plot deviation of probabilities
python3 python/plot_time_evolution.py    # plot snapshots of probability
python3 python/plot_detector.py          # plot detector profile
python3 python/animate_probs.py          # create animation of full time evolution

All plots are saved in the figures/ directory.

Compiler information

The C++ code has been successfully compiled and linked using

  • g++ (Ubuntu 13.3.0-6ubuntu2~24.04)

About

Exploring Quantum Slit Interference of the 2D Schrödinger Equation via the Crank—Nicolson Method

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors