This simulation project was developed as part of the Object-Oriented Programming course in the Physics section at EPFL
- Project Description
- Features
- Requirements
- Installation
- Usage
- File Structure
- Conception
- Credits
- License
The Particle System Simulation models the behavior of particles within a rectangular enclosure. The particles have defined positions, velocities, and masses, and the simulation tracks their movements and collisions over time. Please note that we take 0.1 nm as a basic unit.
Two collision detection methods are implemented:
- Continuous Checking: Continuous checking of particle positions and triggering collisions if particles are within a certain distance.
- Cell-based Checking: Dividing the enclosure into cells and checking for collisions within each cell.
- Simulates particle motion and collisions within a 3D enclosure.
- Supports two different collision detection methods. (our first one is in
$O(n^2)$ and the second one$O(n)$ - Uses object-oriented programming principles with classes for particles, the system, and the enclosure.
- Particle.h: Defines the
Particleclass with properties and methods for particles. - Particle.cc: Implementation of the
Particleclass. - System.h: Defines the
Systemclass that manages a collection of particles. - System.cc: Implementation of the
Systemclass. - finalTestSimulation.cc: Main file to run the simulation with sample particles.
- Vector3D.h: Utility class for 3D vector operations.
- Enclosure.h: Defines the
Enclosureclass representing the simulation space. - RandomGenerator.h: Utility class for generating random numbers.
Particles are modeled as material points with specific positions and velocities. We suppose that we both know their velocity and position at each moment (which is actually impossible due to Heisenberg's uncertainty principle).
The enclosure is a rectangular parallelepiped, centered at the origin. Particles are constrained within the enclosure boundaries. We gave a number for each side of this box so that we know which side is touched when there is a collision with the box.### Enclosure
The enclosure is a rectangular parallelepiped, centered at the origin. Particles are constrained within the enclosure boundaries.
As we put the origin in the middle of the parallelepiped, the conditions that we check to make sure that a particle is within the boundaries are:
$(\lvert x \rvert \leq \frac{\text{length}}{2})$ $(\lvert y \rvert \leq \frac{\text{width}}{2})$ $(\lvert z \rvert \leq \frac{\text{height}}{2})$
For collisions with the walls, we check at each moment whether any of the particles touch a wall (with a margin of epsilon) or if they have passed through it. This situation might occur if we use time intervals that are too large or if particles have excessively high velocities. Our goal is to avoid such cases through careful design and parameter selection.
Two different models for detecting collisions between particles were proposed during the project, and we have implemented both:
-
Continuous Position Checking: This method continuously monitors the positions of all particles and detects a collision if two particles come within a certain distance epsilon of each other.
-
Cell-Based Checking: This method divides the enclosure into a grid of cells. For each cell, it checks whether multiple particles are present, which would trigger a collision. This method is more efficient than the continuous checking approach and is suitable for larger systems or higher particle densities.
For more detailed information on these collision detection methods, please refer to the relevant sections in the documentation.
Uses a vector of unique_ptr to manage particles, ensuring no duplicate particles and simplifying memory management.
This project was developed by @FrankDiPascalli for the Object-Oriented Programming course at EPFL.
