Celestial bodies

I'm making a simulation of the solar system. I'm making Mercury right now, but for some reason I'm guessing gravity is too strong? Mercury just falls straight into the sun. I don't know how to fix that except by changing the gravitational constant, but I want to keep it at 6.6743e-[something]. I'd appreciate it if someone tried helping me. Since I need to sleep and go to school and stuff.

Snap! celestial bodies-0511221 (berkeley.edu)

Relevant units:

  • Space = km
  • Time = seconds
  • Velocity = km/s
  • Mass = kg

EDIT: I want the user to be able to add or remove arbitrary bodies. That’s why I’m doing it like that instead of setting a defined orbit for each planet.

I got Mercury to (roughly) circle the sun by multiplying its initial vertical velocity by 1000.

Edit: G has to be 1000000th what the comment says, not 1000th, because m^2 is (km/1000)^2 = km^2/1000^2 = km^2/1000000.

Edit 2: Now instead of multiplying by 1000, I'm multiplying by 200/7, which for some reason, gives almost a circle around the sun.

Thanks for the feedback.

I set G to 6.6743e-17 but Mercury still falls straight into the sun. However it goes in a perfect circle when I multiply the initial velocity by 30 with the modified G value. Mercury shouldn't actually orbit in a perfect circle though -- its orbit is actually an ellipse. When I multiply the initial velocity by 15, it gives me an almost perfect elliptical orbit.

All the sources I've looked at say that Mercury's velocity when furthest from the sun is something below 100 km/s though. Maybe I'm accounting for time wrong.

I vaguely remember having read that the inner planets have more nearly circular orbits than the outer ones.

As the orbital speed vary, you probably need to start the simulation with exact, not avg, position (Sun at focal point) and speed combination.

And all 8 recognized planets have nearly-circular orbits. (Pluto has a more elliptical one)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.