This repository contains the work done by Erica Løken, Mads Mestl and Heine Husdal for Project 3 in the course FYS3150 – Computational Physics at the University of Oslo.
In this project we investigate the dynamics of charged calcium ions (Ca⁺) inside an ideal Penning trap. A Penning trap is a device that utilizes magnetic and electric fields to confine particles, allowing for precise studies of particles, which is used by CERN to confine antimatter.
The objective is to simulate the motion of particles using the Runge-Kutta 4th order method and the Forward Euler method. We compare the two methods to the analytical solutions for a single particle to evaluate the accuracy of the methods. Object-oriented simulations are implemented to study the dynamics of one or more particles. The effects of Coulomb interactions is studied in the case of two interacting particles. Further, we investigate the resonance phenomena by introducing a time-dependent electric potential.
src/- C++ source filesinclude/- Header filespython/- Python scripts for plottingfigures/- Plots and graphsoutput/- Simulation output datareport/- Project pdf report
To compile the C++ code, navigate to the project root and run:
makeThe above was tested on linux, but it might not work out of the box on other systems due to library paths. You might need to adjust the LIBS and CXXFLAGS variables in the Makefile according to your system setup. For example, on a Mac with Homebrew-installed Armadillo you might use:
# Mac OS with Homebrew-installed Armadillo example
make LIBS='-L/opt/homebrew/Cellar/armadillo/15.0.3/lib -larmadillo' CXXFLAGS='-O3 -std=c++17 -I include'To run the compiled C++ code, navigate to the project root and run the corresponding make command.
- Single-particle simulation:
make run-single - Two-particle simulation:
make run-two - Multi-particle simulation:
make run-multi - Multi-particle simulation zoomed at around 1.39MHz:
make run-multi-zoom
For plotting, you need a python environment. To install the required packages, run:
pip install -r requirements.txtFor plotting results after running all simulations, navigate to the python/ directory and run one of the following:
- Plots from single-particle simulations:
python plot_single.py - Plots from two-particle simulations:
python plot_two.py - Plots from multi-particle simulations:
python plot_multi.py
The C++ code has been compiled and linked with
-
g++ (Ubuntu 13.3.0-6ubuntu2~24.04) -
Apple clang version 17.0.0 (clang-1700.0.13.5)