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.
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
where
where
The system we are studying is a non-relativistic particle confined in a two-dimensional domain
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.
src/- C++ source filesinclude/- Header filespython/- Python scripts for plotting and animationfigures/- Generated plots and graphsoutput/- Simulation output filesreport/- Project pdf report
All C++ programs are compiled and executed using the provided Makefile.
To compile the C++ code, navigate to the project root directory and run:
makeThe 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 stepdt– time stepT– total simulation timexc, yc– initial wave-packet centersigma_x, sigma_y– Gaussian widthspx, py– initial momentum componentsv0– 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.dataTo 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 simulationsThese 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.
For plotting, a python environment is required. To install the required packages, run:
pip install -r requirements.txtFor 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 evolutionAll plots are saved in the figures/ directory.
The C++ code has been successfully compiled and linked using
g++ (Ubuntu 13.3.0-6ubuntu2~24.04)
