Skip to content

Particles

Static Badge Static Badge


The goal is to simulate a system of n particles, each having a positive or negative charge. The particles move in a 2D plane within a bounded rectangle, interacting with each other based on the forces generated by their charges and distances. The rectangle has its own charge, repelling the particles and keeping them within bounds. The simulation involves the particles moving according to the forces between them and their initial velocities. At the beginning of the simulation, the particles are assigned random positions and speeds. The force \(F\) between two particles \(i\) and \(j\) is calculated as follows: \(F = |c_{i} \cdot c_{j}| / d^{2}\) where: \(c_{i}\) and \(c_{j}\) are the charges of particles i and j, \(d\) is the Euclidean distance between them.

The interaction between particles depends on the sign of their charges:

  • Particles with the same charge will attract each other.
  • Particles with opposite charges will repel each other.

Additionally, the boundary rectangle has a charge that repels the particles, ensuring they remain within the plane. More information on the problem can be found in chapter 11.2.1 of the book Foundations Of Multithreaded, Parallel, and Distributed Programming by Gregory R. Andrews (found in the university library). Note that this problem is a spin on the problem described in the book.

Implementation guidelines

  1. Implementation of the graphical interface:
    • The program should have parameters with which the graphical interface can be toggled to achieve best performance.
    • The drawing of the graphics should be done independently of the computational threads.
    • The default size of the window is 800x600px but can be adjusted manually.
    • The drawing of frames should be limited to 60 frames per second (FPS).
  2. Running the program:
    • The program can be ran in different modes (sequential, parallel, distributed) by specifying a parameter.
    • User can specify the number of particles in the simulation with a parameter.
    • The program allows setting the number of cycles the simulation runs for (compute cycles not draw).
    • The program measures run-time needed to complete.
  3. Problem specific implementation requirements
    • Every version (sequential, parallel, and distributed) measures cycles passed. Every update of positions of all particles is considered a cycle. All three implementations run the simulation until they reach a specified number of cycles.
    • The starting position of and force of particles is random. However, if the simulation is ran in all three versions, the same initial distribution of particles is used for all three versions.
    • The implementation must adapt automatically to the hardware it is being ran on (Physical CPU's, Cores, Memory, etc..).

Testing

The report must include extensive testing and explanation of results (numeric and graphical). All three versions must be tested. The tests should be performed without drawing graphics. The parameters that influence the runtime are the number of cycles the simulation should run and the number of particles. Consequently, both need to be tested independently to show how the implementation scales. Present the results with informative charts/figures and explain them in detail. The implementation should be tested in the following way:

  • Testing by limiting the number of particles Limit the number of particles to 3000 (or any other number you think is best). Set the number of cycles to 500. Run the simulation multiple times by increasing the number of cycles by 500 until the simulation takes too long to complete (reasonable amount of time should be in minutes). Every configuration should be ran at least three times, the average runtime should be considered when analyzing results.
  • Testing by limiting the number of cycles Set the number of cycles to 10,000 and number of particles to 500. For every new configuration, increase the number of particles by 500 until the computation run-time is within few minutes. Every configuration should be tested at least three times with their average considered as the result.