This repository contains my worked out solutions to the exercises assigned during a lab on numerical simulation I attended in the summer semester of 2021.
Each lab session consisted of solving a number of exercises, and then report the results obtained. Generally I divided my workflow in two parts:
C++
programs for the most computationally expensive workPython 3
jupyter notebooks for data visualization and remarks on the results
What follows is an overview on how the repository is organized and how the different parts depend on one another.
The C++
source code is separated from the notebooks, because I wrote some custom settings for the visualization, which are easier to access/modify if all the notebooks are located in the same directory.
Every lab has its own C++
directory and jupyter notebook
, called respectively lab_x
and lab_x.ipynb
.
Here's a list of the contents of each lab:
- Random distribution sampling + Buffon's experiment simulation
- Monte Carlo integration + 3D Random Walks
- Black-Sholes' theory vs. Monte Carlo simulation
- Molecular Dynamics simulation of Lennard-Jones interacting Argon sample
- Metropolis algorithm applied to the Hydrogen atom electron position probability distributions
- 1D Ising model
- Monte Carlo simulation of the Canonical (NVT) Ensemble
- Quantum Variational Monte Carlo for ground energy estimation + Path Integral Monte Carlo/Ground State
- Travelling Salesman Problem (TSP) solved using a Genetic Algorithm
- TSP solved with simulated annealing + parallel search with MPI library
- Neural Network (NN) Regression with Keras (
python3
only) - Handwritten digit recognition with Direct NN + Convolutional NN (
python3
only)
The jupyter notebooks are located in the folder notebooks/
and contain the presentation of each problem, followed by the strategy I employed to solve it and a visual representation of the results I obtained.
The naming is straightforward: the notebook corresponding to the exercises of the 1st lab session is called lab_01.ipynb
, the one corresponding to the 2nd lab session lab_02.ipynb
, and so on.
Although the notebooks can be previewed directly from GitHub, I included in them some interactive features and a couple of aesthetic changes which are not available in the default static rendering of the notebooks provided by GitHub. In other words, I warmly suggest to clone the repository and open the notebooks locally for a better experience.
In the notebooks I do not go into the details of the C++
code I developed for solving the problems, nonetheless, all the source files are present in the repository, organized by lab session. The next section goes into the details of how to access, compile and execute the source code.
For each exercise I put together a C++
project to complete the "heavy lifting" part, and for most of them I used an object-oriented approach, and one of the best-practices with OOP is to divide the project in different source files, which are then linked at compile time. I did exactly that, following this general structure:
- main source file (
ex_x.y.cpp
, wherex
= # lab session andy
= # exercise), located inlab_x/src/
- header (
.h
) files for functions/classes declarations, located ininclude/
(possibly used by more than one exercise) - source (
.cpp
) files for functions/classes implementations, located insrc/
Makefile
, located in eachlab_x
directory (different labs can have differentMakefile
s).
Remark: The implementations of functions/classes used in the exercises are not in the same directory as the source code of the exercises, this way they're globally accessible to all projects. What needs to be present in each lab directory is the Makefile
, which contains all the specific dependencies for the projects in that lab.
The executables and object files are not present in the repository, due to possible incompatibilities with the user's machine, but they can be obtained with the procedure explained right below.
The compilation of each lab folder is straightforward: just write the command make
from a Terminal located in the folder where the Makefile
is and press Enter
. The command for running the executables is just as simple: make run
.
That's it, enjoy!