Planetary Gravity Simulation Documentation

This document serves as a guide for the Planetary Gravity Simulation. In this simulation, a central star exerts gravitational forces on numerous orbiting planets. The simulation allows you to adjust key parameters such as gravity strength and planet radius, and then observe the resulting dynamics in real time.

Overview

The simulation is presented on a black canvas and features: - A central star drawn as a yellow circle at the center of the canvas. - Many planets—by default, 100—randomly distributed around the star, rendered as white circles. Their initial velocities are calculated to produce orbital motion. - Real-time statistics including frames per second (FPS), the total number of planets, average velocity, and system energy. - User-adjustable settings via sliders for gravity strength (scaled, e.g. 5.0e6 by default) and planet radius.

How to Use the Simulation

When you interact with the simulation:

  • Adjust Gravity Strength: Use the gravity slider to change the force of attraction. The value is displayed in scientific notation (e.g., 5.0e6), reflecting the scaled strength.
  • Change Planet Radius: Modify the planet radius slider to increase or decrease the size of the planets.
  • View System Stats: Observe real-time data updates for FPS, number of planets, average velocity, and the total energy of the system.
  • Control Buttons:
    • Add 100 Planets: Inserts an additional 100 randomly placed planets.
    • Start: Begins the simulation.
    • Pause: Temporarily halts the simulation.
    • Reset: Returns the simulation variables to their original settings and clears the graph.

Physics Behind the Simulation

The simulation uses a simplified gravitational model to guide planetary motions. For each planet, the accelerations in the x and y directions are calculated by:

\[ a_x = -\frac{G \cdot dx}{r^3} \quad \text{and} \quad a_y = -\frac{G \cdot dy}{r^3} \]

where: - \(G\) is the gravity strength (after scaling, e.g., \(5.0 \times 10^6\)), - \(dx\) and \(dy\) are the differences in the planet's position relative to the center, - \(r\) is the distance from the planet to the central star.

Each planet’s initial velocity is determined based on its distance from the center to produce an orbital path close to circular.

Educational Insights

This simulation provides insight into: - Orbital Dynamics: How gravitational forces influence the trajectories of orbiting bodies. - Energy Considerations: The balance between kinetic and potential energies in a gravitational field is reflected in the computed system energy. - Scaling Effects: The ability to add more planets reveals emergent behavior and the complexity of crowded orbital systems.

Conclusion

The Planetary Gravity Simulation is an engaging tool for exploring the principles of gravitational attraction and orbital dynamics. By adjusting the gravitational strength, tweaking the planet size, and adding more bodies to the system, users gain a hands-on understanding of how gravitational forces shape celestial motion. Experiment with the controls and observe real-time changes to deepen your understanding of planetary physics!