Overall simulation process flow.
A C++ simulation demonstrating basic particle interactions within a containment field, focusing on parallel processing concepts and providing opportunities for debugging and optimization practice.
This project simulates the behavior of particles confined within a 2D square field. Key features include:
- Particle movement and collision physics (simplified).
- A containment field applying forces to keep particles inside.
The force magnitude increases as the particle approaches the boundary. It is proportional to the field strength and depends on the particle's distance from the nearest edge, reaching its maximum strength just inside the boundary and dropping to zero at the exact center of the field.
Containment field force direction relative to particle position.
- Basic parallel processing using C++ threads and a thread manager.
- Configuration loading from a JSON file (
config.json). - Simple ASCII-based visualization of particle density in the terminal.
- Intentionally included bugs and areas for performance improvement for educational purposes.
The expected output of the simulation is as follows:
Expected simulation preview in terminal.
- C++17 compatible compiler (GCC, Clang, MSVC)
- CMake (version 3.10 or higher)
- Git (for fetching dependencies)
# 1. Clone the repository (if you haven't already)
# git clone https://github.com/CodeJam-by-CSE/University-C-.git
# cd University-C-
# 2. Create a build directory
mkdir build
cd build
# 3. Configure the project with CMake
cmake ..
# 4. Build the project (e.g., using Make)
make
# On Windows with Visual Studio, you might open the generated solution file
# or use: cmake --build .This will create a main executable in the build directory:
quantum_simulator_app: The main simulation application. It will also copyconfig.jsonto the build directory.
Navigate to the build directory and run the application:
./quantum_simulator_appThe simulation will run in the terminal, showing an ASCII representation of particle density. It uses parameters from the config.json file located in the same directory.
.
├── include/ # Header files (.h)
│ ├── Config.h
│ ├── ContainmentField.h
│ ├── Particle.h
│ ├── Simulation.h
│ └── ThreadManager.h
├── src/ # Source files (.cpp)
│ ├── ContainmentField.cpp
│ ├── main.cpp # Application entry point
│ ├── Particle.cpp
│ ├── Simulation.cpp
│ └── ThreadManager.cpp
├── CMakeLists.txt # Build configuration script
├── config.json # Simulation configuration file
└── README.md # This file
The ThreadManager class in this project is incomplete. You MUST use and implement this class for parallelization in the project. Do not use any other parallelization techniques (like OpenMP, std::async, cuda etc.) You must implement the thread management functionality using the provided ThreadManager class. All parallelization in the project should go through this class. In some test cases we use that class.
Good luck with debugging and optimizing the simulation!