Simulating N-Body Gravity Interactions: A Challenge in Computational Physics

Click For Summary
SUMMARY

The discussion focuses on simulating N-body gravity interactions in computational physics, specifically addressing the challenges faced when extending a single-body gravity simulation to multiple bodies. The user initially implemented a working model for the Earth rotating around the Sun but encountered issues when attempting to calculate net gravitational forces from multiple celestial bodies. The equations provided for force, acceleration, velocity, and position updates are based on Newton's law of universal gravitation, but the user’s approach to summing forces from multiple planets is flawed, leading to incorrect results.

PREREQUISITES
  • Understanding of Newton's law of universal gravitation
  • Familiarity with basic physics concepts such as force, acceleration, and velocity
  • Proficiency in programming, particularly in scripting languages used for simulations
  • Knowledge of numerical methods for solving differential equations
NEXT STEPS
  • Research "N-body simulation algorithms" to understand more efficient methods for calculating gravitational interactions.
  • Learn about "Runge-Kutta methods" for improving the accuracy of position and velocity updates in simulations.
  • Explore "vector mathematics" to enhance the calculation of forces and accelerations in multi-body systems.
  • Investigate "collision detection techniques" to handle interactions between bodies in a simulation environment.
USEFUL FOR

Students and enthusiasts in computational physics, software developers working on physics simulations, and anyone interested in understanding complex gravitational interactions in multi-body systems.

DrCheeto
Messages
2
Reaction score
0

Homework Statement


Hi for fun, and to understand physics better I have scripted a program that replicate gravity exerted from one force (ex the Earth rotating around the sun) and it works well. But now I want to have mutliple bodies that affect gravity and using the same equations it isn't working. To find net gravity I am just finding the force of gravity between say Earth and sun1 and sun2 then adding them up clearly this is wrong because it does not work at all.

Homework Equations


Here is my equations

Code:
        'Force
        Ftmp = (G * Ball.Mass * Planet.Mass) / (nDist * nDist)
        Force.X = Ftmp * (Ball.Pos.X - Planet.Pos.X) / nDist
        Force.Y = Ftmp * (Ball.Pos.Y - Planet.Pos.Y) / nDist
        
        'Acceleration
        Acceleration.X = Force.X / Ball.Mass
        Acceleration.Y = Force.Y / Ball.Mass
        
        'Velocity
        Ball.Velocity.X = Ball.Velocity.X + Acceleration.X
        Ball.Velocity.Y = Ball.Velocity.Y + Acceleration.Y
        
        'New Position
        Ball.Pos.X = Ball.Pos.X - Ball.Velocity.X
        Ball.Pos.Y = Ball.Pos.Y - Ball.Velocity.Y
        
        'Return new information
        Gravity = Ball

The Attempt at a Solution


My attempt was basically this
Code:
for ncount = 1 to 3
        Ftmp = (G * Ball.Mass * Planet(ncount).Mass) / (nDist * nDist)
        Force.X = force.x + Ftmp * (Ball.Pos.X - Planet(ncount).Pos.X) / nDist
        Force.Y = force.y + Ftmp * (Ball.Pos.Y - Planet(ncount).Pos.Y) / nDist
next
 
Physics news on Phys.org
Can anyone help me?
 

Similar threads

  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 19 ·
Replies
19
Views
5K
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 7 ·
Replies
7
Views
5K