# Physics Simulation

1. Sep 3, 2007

I've written a couple of small physics simulations in the past (hey, everyone has to have a hobby) and now I'm trying to write something a little more complex so decided to attempt to write an program that simulates the motion of the planets and moons in our solar-system entirely procedurally - initially I'm starting off with just the Earth and the Sun.

With the initial values as follows:
Mass Sun: 1.989x10^30kg
Mass Earth: 5.976x10^24kg
Mean distance between the Earth and the Sun: 1.496x10^8km

I'm using Newton's law of Universal Gravitation to calculate the gravitational force between the sun and the earth as 3.54476x10^28N

I then use F=ma to calculate the earth's acceleration towards the sun and visa versa:
Earth towards Sun: 5.93166x10^3ms-1
Sun towards Earth: 1.78218x10^-2ms-1

My problem is, I'm not sure if these results are correct and after a good hour of scouring google and a small pile of physics textbooks I can't seem to find the correct values for my calculations to check these with. If anyone can check the math for me or point me to a site with these values i'd appreciate it greatly.

cheers

2. Sep 4, 2007

3. Sep 6, 2007

### premagg

Did u check for the centrifual force?
And one more thing u will obviously get a very small accelaration of sun towards earth.

4. Sep 6, 2007

### genneth

They seem okay. Btw, for orbiting systems, Verlet integration is a very good way to go, as it preserves energy in this case.

5. Jul 12, 2011

### Uglybb

No you went wrong somewhere you should have got 3.54476E22N

Did you remember to convert the kilometers to meters? 1.496E8km = 1.496E11m

The easiest way to do it is in scientific notation simple do the maths on the number and add and subtract the exponentials

Mass Sun: 1.989E30 kg
Mass Earth: 5.976E24 kg
Mean distance between the Earth and the Sun: 1.496E11 m
Gravitational constant 6.673E-11 m3 kg-1 s-2

F = G x M1 x M2 / (R x R)

= 6.673E-11 x 1.989E30 x 5.976E24 / (1.496E11 x 1.496E11)

= 79.317E43 / 2.238E22

= 35.441E21 Newtons

(now correct to 1 decimal place for proper scientific notation)
= 3.5441E22 Newtons

If you want to cheat and not do the maths :-)
http://www.ajdesigner.com/phpgravity/newtons_law_gravity_equation_force.php

6. Jul 12, 2011

### chrisbaird

Strictly speaking, the force due to gravity is not constant because the distance between a planet and the sun is not constant. The planets do not travel in perfect circles, but in ellipses. So it is best to recalculate the gravitational forces at every time step. This is especially true when you start adding other planets to the simulation, because they exert gravitational forces on each other and do not have constant separations. If you approach the problem generally and apply total forces and find total accelerations for each body (don't treat the sun as special), then you can use the same code to simulate beautiful binary star system trajectories.

By the way, you don't have to program in centrifugal force because it is a fictional force. If you program the gravitational accelerations properly, the apparent effect that we can centrifugal force will appear automatically.

7. Jul 13, 2011

### D H

Staff Emeritus
Note well: The hijack isn't your fault, cephron.

The last time the OP was here was September 3 in 2007, so close to 4 years ago.