Skip to content

This repository contains a Python project for simulating the behaviour of particles in a three-dimensional space. The project initialises particle positions, runs a simulation, and visualises the results through 3D graphics and plots of energy and pressure over time.

Notifications You must be signed in to change notification settings

rokasauras/particle_simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Particle Simulation and Visualisation

Description

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.

Main Features

  • 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.

Installation

  1. Clone the Repository:
    git clone https://github.com/yourusername/your-repo-name.git
    cd your-repo-name
  2. Install Dependencies:

    Ensure you have Python installed. Install the required packages using pip:

    pip install matplotlib
  3. Ensure Custom Modules are Accessible:
    • InitialPositions
    • Simulation
    • Graphics3D

Usage

  1. Import Required Modules:
    from InitialPositions import InitialPositions
    from Simulation import runSimulation
    from Graphics3D import Graphics3D
    import matplotlib.pyplot as plt
  2. Initialise Particle Positions:
    StartingXYs = InitialPositions(numberOfParticles=30)
  3. Run the Simulation:
    Data, Data2 = runSimulation(Particles=StartingXYs)
  4. Print Pressure and Energy Data:
    print(Data2[['pressure']])
    print(Data2[['energy']])
  5. 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()
  6. Plot Pressure Over Time:
    Data2[['pressure']].plot.line(
        color='black',
        linewidth=2,
        xlabel='Time',
        ylabel='Pressure',
    )
    plt.xlim([0, 100])
    plt.plot()
  7. Generate 3-Dimensional Visualisation:
    Graphics3D(df=Data)

Example Output

  • 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.

Customisation

  • Number of Particles: Adjust the number of particles by changing the numberOfParticles parameter in InitialPositions.
  • Simulation Parameters: Modify the simulation behavior by changing parameters in the runSimulation function.

Improvements

Automatically save graphs to file.

Contributing

Contributions are welcome! Please submit a pull request or open an issue to discuss any changes.

About

This repository contains a Python project for simulating the behaviour of particles in a three-dimensional space. The project initialises particle positions, runs a simulation, and visualises the results through 3D graphics and plots of energy and pressure over time.

Resources

Stars

Watchers

Forks

Languages