You are browsing as a guest. Sign up (or log in) to start making projects!

Space In Your Place!

  • 3 Devlogs
  • 5 Total hours

A 2D real time N-body gravitational simulation built with verlet. The project uses Python and Pygame

Ship #1

I have made an N-body simulation that simulates and plots the behavior of a plethora of bodies in different configurations. I am very proud of the Verlet integration configured in the program. It was very hard for me to figure that out but I had a lot of fun doing that.
The collisions and rendering were especially hard for me to integrate as it was my first time using Pygame. I had started the project some time ago (before I even knew about Stardance).

  • 3 devlogs
  • 5h
Try project → See source code →
Open comments for this post

1h 24m 26s logged

DEVLOG 3

final devlog for this project. so i added a help command and a way to screen shot whilst running a simulation.

DEVLOG 3

final devlog for this project. so i added a help command and a way to screen shot whilst running a simulation.

Replying to @SpaceEvee

1
Open comments for this post

47m 25s logged

DEVLOG 2

so last time, i configured the 3d plots wrong so they didnt plot anything

have fixed it now

DEVLOG 2

so last time, i configured the 3d plots wrong so they didnt plot anything

have fixed it now

Replying to @SpaceEvee

1
Open comments for this post

2h 18m 10s logged

SPACE IN YOUR PLACE!

After several months of development, I’ve finally published my first major physics project: A Planetary Body Simulation.

This is a real-time N-body gravitational simulator written in Python using Pygame. The goal of the project was to explore orbital mechanics, chaotic systems, and numerical simulation while building an interactive application that visualizes how celestial bodies move under gravity.

Features

Current systems included in the simulator:

-Solar System simulation
-Binary star system
-Three-body chaotic system
-Gravitational slingshot demonstration
-Lagrange point (L4 & L5) system
-Horseshoe orbit system
-(I want to add more)

Other features:

-Verlet integration (had to spen an AMOUNT of time to ad Verlet)
-Energy analysis (KE, PE, Total Energy)
-Velocity plotting
-Camera controls and zoom
-Trail rendering
-Configurable timestep

Physics Concepts

The simulator uses:

Newtonian gravity
N-body interactions
Orbital mechanics
Energy conservation
Chaotic dynamics

One of the most interesting things I discovered while building this project was how sensitive some systems are to numerical accuracy. Small changes in timestep can dramatically affect long-term stability, especially in chaotic systems.

New Feature Added Today!

Today I added 3D trajectory visualization.

Instead of only plotting motion in X-Y space, the simulator can now generate a 3D graph where:

X-axis = X Position
Y-axis = Y Position
Z-axis = Time

This allows orbital motion to be visualized as a path through time rather than just a flat orbit.

Stable systems produce smooth helical structures, while chaotic systems create much more complex patterns.

This was my first time working with Matplotlib’s 3D plotting tools, and integrating the graphing system with the existing simulation data took some experimentation.

🔧 Challenges During Development

Some problems I had to solve while building the simulator:

-Numerical instability
-Energy conservation issues
-Chaotic three-body behavior
-Restart system bugs
-Data collection for plotting

A lot of development time was spent debugging rather than adding features, but that ended up teaching me much more about simulation and computational physics.

What’s Next?

Potential future improvements:

-True 3D simulation (maybe)
-Adaptive timestep system
-Better visualization tools
-Collision handling
-More orbital systems

SPACE IN YOUR PLACE!

After several months of development, I’ve finally published my first major physics project: A Planetary Body Simulation.

This is a real-time N-body gravitational simulator written in Python using Pygame. The goal of the project was to explore orbital mechanics, chaotic systems, and numerical simulation while building an interactive application that visualizes how celestial bodies move under gravity.

Features

Current systems included in the simulator:

-Solar System simulation
-Binary star system
-Three-body chaotic system
-Gravitational slingshot demonstration
-Lagrange point (L4 & L5) system
-Horseshoe orbit system
-(I want to add more)

Other features:

-Verlet integration (had to spen an AMOUNT of time to ad Verlet)
-Energy analysis (KE, PE, Total Energy)
-Velocity plotting
-Camera controls and zoom
-Trail rendering
-Configurable timestep

Physics Concepts

The simulator uses:

Newtonian gravity
N-body interactions
Orbital mechanics
Energy conservation
Chaotic dynamics

One of the most interesting things I discovered while building this project was how sensitive some systems are to numerical accuracy. Small changes in timestep can dramatically affect long-term stability, especially in chaotic systems.

New Feature Added Today!

Today I added 3D trajectory visualization.

Instead of only plotting motion in X-Y space, the simulator can now generate a 3D graph where:

X-axis = X Position
Y-axis = Y Position
Z-axis = Time

This allows orbital motion to be visualized as a path through time rather than just a flat orbit.

Stable systems produce smooth helical structures, while chaotic systems create much more complex patterns.

This was my first time working with Matplotlib’s 3D plotting tools, and integrating the graphing system with the existing simulation data took some experimentation.

🔧 Challenges During Development

Some problems I had to solve while building the simulator:

-Numerical instability
-Energy conservation issues
-Chaotic three-body behavior
-Restart system bugs
-Data collection for plotting

A lot of development time was spent debugging rather than adding features, but that ended up teaching me much more about simulation and computational physics.

What’s Next?

Potential future improvements:

-True 3D simulation (maybe)
-Adaptive timestep system
-Better visualization tools
-Collision handling
-More orbital systems

Replying to @SpaceEvee

1

Followers

Loading…