Molecular Dynamic Simulator - Simulates the molecular dynamics of atoms.
This is an academic project focused on developing a molecular dynamics simulator. Currently, it simulates Lennard-Jones (LJ) forces using a (less efficient) all-pairs algorithm on a 2D Boltzmann lattice of atoms. Half an assignment for a project in object-oriented programming and on the other hand a hobby project related to simulations. Lab assignment for Dr. Carrascoza - Bioinformatics 2nd semester, object-oriented programming.
Am not familiar with Docker yet, so here's a breakdown of the "toolchain" dependencies needed for the project: Those are the files required to:
-
run the main program, this is a zip archive with Google test framework library and external libraries(inih, matplotplusplus). https://drive.google.com/file/d/1qWKXbvHN7cqKYxY8W0PSXjXOvH26tP9q/view?usp=sharing
-
visualize the atom coordinates, this is a zip with python scripts https://drive.google.com/file/d/1tgm48HFup8QAHkeGqLZC07GnXcTWbKDC/view?usp=sharing
Velocities and accelerations are randomly assigned, preventing the exact reproduction of simulations at present.
Each iteration is saved with coordinates, physical properties, and velocity distribution for later analysis.
A separate Python script utilizing Pygame generates a visual representation of the atomic plane.
Color coded made by python script:
draw_atoms_velocity_sensitive.py
No colour coded by python script:
draw_atoms_no_color_coded.py
This project is in its initial stages. The ultimate goal is a 3D simulation of water and solutes, but the current focus is on achieving a stable 2D simulation of atoms.
The 2D simulation functionality is still under development.
The project employs a director-builder pattern to create a simulation object. The computeForces
function calculates the forces acting on the atoms.
CLion
Likely GCC (as used by CLion)
pygame
The program is not only intended for Windows environment and JetBrains CLion IDE. installation youtube instruction
The configuration file can be modified to obtain different simulation results.
Doxygen documentation is not yet available.
Unit tests are still under development. The Google Test framework is being considered for implementation.
Feel free to fork the project or report issues for collaboration. No formal oversight exists yet.
The code is freely reusable. The license for the book-based portions is still under consideration.
This project is heavily inspired by the book: The Art of Molecular Dynamics Simulation
- Rapaport DC. The Art of Molecular Dynamics Simulation. 2nd ed. Cambridge University Press; 2004.
--
First Iteration: The initial challenge arose when we needed to create 3D simulations using methods originally designed for 2D. As a quick solution, we implemented a very primitive object-oriented paradigm with a deeply hierarchical structure.
Second Iteration: The structure became an issue again when we had to incorporate design patterns for the final project submission. To address this, we rewrote the program, adding design patterns like Factory and Builder.
Third Iteration: The third challenge was related to making the base class too generic, which hindered further development. To overcome this, we:
Created a UML diagram before coding. Added design patterns to promote code reusability, modularity, and scalability. Implemented a CI/DI framework with Google tests. Divided the work into modules responsible for multithreading, inter-module communication, physics, etc.
Lessons Learned:
Early planning: Creating a UML diagram from the beginning can prevent architectural issues. Design patterns: They are essential for maintainable and extensible code. Testing: A comprehensive test suite is crucial for catching regressions. Modularization: Breaking down the system into smaller, well-defined modules improves understanding and maintainability.