In high-energy physics and nuclear engineering, deterministic equations often fall short when modeling quantum behaviors or particle-detector interactions. To bridge this gap, computational physics relies heavily on stochastic methods—specifically, Monte Carlo simulations.
Before starting my upcoming nuclear and particle physics framework at Czech Technical University in Prague (ČVUT, FJFI), I developed an independent C++17 project to simulate the stochastic nature of radioactive isotope decay.
The Algorithm: From Quantum Probability to Code
Instead of relying on the standard macro-level exponential decay law ($N(t) = N_0 \cdot e^{-\lambda t}$), this simulation models the system at an individual atomic level. Every active atom is treated as an independent state evaluated against a specific decay probability using pseudo-random number generation (PRNG).
To achieve high scientific precision, the simulation circumvents the outdated and non-uniform rand() function, utilizing the Mersenne Twister (std::mt19937) engine paired with std::random_device for high-entropy seeding.
Core Architecture (C++17 Implementation)
The core logic evaluates the survival of each atom at every discrete time step:
- Engine:
std::mt19937generating uniform distribution between $[0.0, 1.0]$. - Condition: If $P_{random} < P_{decay}$, the atom undergoes a state change (decays).
- Optimization: Compiled under Linux with
-O2optimization flags for high-performance execution.
Verification and Results
When executed, the micro-level atomic probabilities converge flawlessly into the macro-level physical decay curve, validating the law of large numbers. The simulation prints a real-time ASCII/Unicode progress bar tracking the geometric depletion of the active material directly in the Linux terminal.
The complete open-source code repository, including build instructions and terminal visualization scripts, is available for peer review on my GitHub.
Project Portfolio
Keywords: #ComputationalPhysics #MonteCarlo #NuclearEngineering #Cpp17 #Linux

Leave a comment