This project simulates the behavior of particles in a three-dimensional space and visualises the results. It uses custom modules to initialise particle positions, run the simulation, and display 3D graphics. Additionally, it plots the energy and pressure of the particles over time using Matplotlib.
- Initialise Particle Positions: Set up initial positions for a specified number of particles.
- Run Simulation: Execute the simulation and capture data on particle behavior.
- Visualise Results: Plot energy and pressure over time, and generate a 3D visualisation of the particle system.
- Clone the Repository:
git clone https://github.com/yourusername/your-repo-name.git cd your-repo-name
- Install Dependencies:
Ensure you have Python installed. Install the required packages using pip:
pip install matplotlib
- Ensure Custom Modules are Accessible:
- InitialPositions
- Simulation
- Graphics3D
- Import Required Modules:
from InitialPositions import InitialPositions from Simulation import runSimulation from Graphics3D import Graphics3D import matplotlib.pyplot as plt
- Initialise Particle Positions:
StartingXYs = InitialPositions(numberOfParticles=30)
- Run the Simulation:
Data, Data2 = runSimulation(Particles=StartingXYs)
- Print Pressure and Energy Data:
print(Data2[['pressure']]) print(Data2[['energy']])
- Plot Energy Over Time:
Data2[['energy']].plot.line( color='black', linewidth=2, xlabel='Time', ylabel='Energy', ) plt.xlim([0, 100]) plt.ylim([0, 2000]) plt.plot()
- Plot Pressure Over Time:
Data2[['pressure']].plot.line( color='black', linewidth=2, xlabel='Time', ylabel='Pressure', ) plt.xlim([0, 100]) plt.plot()
- Generate 3-Dimensional Visualisation:
Graphics3D(df=Data)
- Pressure Data: Prints the pressure data of particles over time.
- Energy Data: Prints the energy data of particles over time.
- Energy Plot: A line graph showing the energy of particles over time.
- Pressure Plot: A line graph showing the pressure of particles over time.
- 3D Visualisation: A graphical representation of particles in 3D space.
- Number of Particles: Adjust the number of particles by changing the
numberOfParticles
parameter inInitialPositions
. - Simulation Parameters: Modify the simulation behavior by changing parameters in the
runSimulation
function.
Automatically save graphs to file.
Contributions are welcome! Please submit a pull request or open an issue to discuss any changes.