Jump to content

Calculating The Required Speed For Circular Orbit


Beale

Recommended Posts

It's really simple right?

V = √G * M / D

For the past year I've been developing an N-body simulation for my thesis. It's more of an investigation into teaching methods, so my lack of great maths skills was never a huge problem. But, this is one little oddity that just isn't working for me.

However, for me, this little sum seems to produce ridiculously high velocities.

I.E. You can see all the planets shoot off at angles of 90 degree to the sun (The lines are the trails left behind). Except for Earth and Jupiter which currently have hard-coded "rough guesses" at velocity.

a111fa67ed.png

My code to calculate the velocity is simple also:

	
public double calculateOrbitalSpeed(SimBody _bodyA, SimBody _bodyB, double _solarMass)
{
double G = 6.674E-11;

double _distance = _bodyB.distanceTo(_bodyA);

double _velocity = Math.sqrt(G * _solarMass / _distance );

System.out.println("" + _bodyB._texture + " " + _velocity);

return _velocity;
}

Bit of an explain: BodyA is the sun, BodyB is the planet for which I am try to calculate the velocity.

The returned velocity is then applied to the planet, at a 90 degree angle relevant to the sun. I.E.

7ea37e46d8.png

So, where am I going wrong? Obviously I've made a very dumb mistake somewhere, but I can't quite pin it down.

Any clever chaps around for this kind of thing? :)

I could have pulled the values straight from wikipedia if I wasn't using very largely abstracted scales (I.E. the sun is only 33 metres big).

Edited by Beale
Link to comment
Share on other sites

The way you found the velocity seems perfectly fine, but I just have the feeling the problem may be in how you parameterized the orbits.

Do you think you could post the code on how you actually drew the lines?

Link to comment
Share on other sites

correct units?

km/h vs m/s vs something else

Most certainly. I ran into this at one point. Try using this:

double G = 6.674E-20;

E: Explanation is that you may have to normalize some values to meters or kilometers. The -11 value there works for kilometer-based calculations, IIRC, whereas the -20 works for meters (or did for me, anyway).

Edited by regex
Link to comment
Share on other sites

correct units?

km/h vs m/s vs something else

Most certainly. I ran into this at one point. Try using this:

double G = 6.674E-20;

E: Explanation is that you may have to normalize some values to meters or kilometers. The -11 value there works for kilometer-based calculations, IIRC, whereas the -20 works for meters (or did for me, anyway).

Almost certainly a unit conversion issue. Especially since you mentioned abstracted units but are using the MKS value for G.

This possibility of borked units totally glossed over me, absolutely didn't think of that! I'll have to take a deeper look what's going on.

The distances are in metres, not sure what the "velocity" units is being produced.

The current starting distances for Venus, at about 130 metres.

Giving Venus a velocity of 1.91E-6, hard-coded produces a roughly circular orbit.

Well, since the distance between the planets is equal, I can use Venus's speed to "rough guess" the speeds of the others.

863d406dc4.png

Swapping the gravitational constant to 6.674E-20 sadly didn't work, but this is for sure where things are going wrong.

I'll have a further dig through the code, many thanks guys.

The way you found the velocity seems perfectly fine, but I just have the feeling the problem may be in how you parameterized the orbits.

Do you think you could post the code on how you actually drew the lines?

No maths involved in the trails, they are just interpolated "points" left behind by the actual bodies in the N-body system.

You can get all close and personal, didn't show that in the screenshot above :)

50819e2c33.jpg

Edited by Beale
Link to comment
Share on other sites

Swapping the gravitational constant to 6.674E-20 sadly didn't work, but this is for sure where things are going wrong.
Ah crap, just remembered, I think I had to use that for surface gravity somewhere, sorry. Anyway, good luck!
Link to comment
Share on other sites

Ah crap, just remembered, I think I had to use that for surface gravity somewhere, sorry. Anyway, good luck!

Ahaha, no problem. Actually, fiddling around with the constant is producing some promising results, which might be a solution, many thanks :)

Link to comment
Share on other sites

Mercury's orbit suggests error in your gravity equation or integration routine. It might help if you post how you get the forces.

Sure thing!


// Calculate force
public void addForce(SimBody
{
SimBody a = this;
double EPS = 3E4;
double dx = b._rx - a._rx;
double dy = b._ry - a._ry;
double dist = Math.sqrt(dx*dx + dy*dy);
double F = (G * a._mass * b._mass) / (dist*dist + EPS*EPS);
a._fx += F * dx / dist;
a._fy += F * dy / dist;
}

The simulation uses a Barnes-Hut quadrant subdivision system, so it's not always direct integration(?) going on.

Mercury's orbit in the above pictures is probably because I've put a random value for it's speed and it wouldn't produce a circle, but instead it's halfway through an eliptical orbit. If I'm making any sense...?

Since all the bodies are so close, there's a helluva lot of perturbation going on.

3af3b2df76.png

Edited by Beale
Link to comment
Share on other sites

Without the intention of derailing the thread but your life will be a lot easier if you store velocities and positions through a vector class that takes care of all the drudgery of adding vectors together and multiplying them with scalars. First of all you won't have all the .x .y clutter and second of all it will make it easier when you decide to switch from two to three dimensions.

I would not be shocked if the language of your choice has such class somewhere in a standard library for starters.

Link to comment
Share on other sites

Are you taking the square root of the whole product?

Yup!

That's correct right?

I did try SQRT(G*M)/D and it unfortunately didn't work.

Without the intention of derailing the thread but your life will be a lot easier if you store velocities and positions through a vector class that takes care of all the drudgery of adding vectors together and multiplying them with scalars. First of all you won't have all the .x .y clutter and second of all it will make it easier when you decide to switch from two to three dimensions.

I would not be shocked if the language of your choice has such class somewhere in a standard library for starters.

Yup, though I don't have the intention to switch to a 3D simulation, I've been considering switching to a Vector2, which would simplify some little nuggets here and there.

I've been using the separate X and Y values as a leftover from switching the graphics framework I was using (Java2D -> LibGDX), I don't think there is a default Vector2 in Java (Unless I missed it horribly).

Generally I really have difficulties with matrix mathematics, and I find it a lot easier to check things are being calculated right if I stick to using scalars (though I admit that's a bit of a silly strategy).

Still, it will be fairly trivial to do that once I get the damn thing working :D

Is it just me or in Mercury's orbit the Sun is at the center and not in one of the two focuses/foci?

I'm not quite sure what you say sorry!

Do you mean the camera focus?

Edited by Beale
Link to comment
Share on other sites

You're taking the square root of GM? Alone?

Or not?

If if you look at it by putting the equation for rotational acceleration equal to the Gravity at a set distance, you should be good....

- - - Updated - - -

How have you scaled the mass of the sun? Are you trying to get a new G? I would recommend solving for it in the gravitational equations... It'll be bigger and not smaller, by the way. ( last I did it...)

Link to comment
Share on other sites

…I'm not quite sure what you say sorry!

Do you mean the camera focus?

He's saying the Sun is not in fact the center of revolution in the solar system, the barycenter (?) is, and the Sun also orbits that point. Pinning the Sun at the center may be introducing side effects. The developer of the Principia mod has found that these side effects are non-negligible.

Link to comment
Share on other sites

You're taking the square root of GM? Alone?

Or not?

If if you look at it by putting the equation for rotational acceleration equal to the Gravity at a set distance, you should be good....

- - - Updated - - -

How have you scaled the mass of the sun? Are you trying to get a new G? I would recommend solving for it in the gravitational equations... It'll be bigger and not smaller, by the way. ( last I did it...)

I'm taking the square root of GM/R, the whole thing.

_velocity = Math.sqrt(G * _solarMass / _distance );

I don't quite understand the second part, could you go into a little further detail?

Many thanks :)

He's saying the Sun is not in fact the center of revolution in the solar system, the barycenter (?) is, and the Sun also orbits that point. Pinning the Sun at the center may be introducing side effects. The developer of the Principia mod has found that these side effects are non-negligible.

Okay I understand a little better.

The sun in the simulation is just a body like any of the others, it will move under the influence of the others, particular Jupiter and Saturn.

So, should be good?

Link to comment
Share on other sites

How you scale the mass will be a determining factor in what happens. Is it the same density as our Sun? The same mass? Or what?

Okay, the mass is: 330000

330000 what exactly, Earth masses. That's probably the guts of the problem.

The mass value is Earth masses, I.E. the Earth in the simulation has a mass of 1

Should density affect the simulation?

Sun size is 33 metres.

Link to comment
Share on other sites

33 meters radius or diameter?

oops, sorry. 33 Metres in diameter.

Although, this is just the scale of the 3D model, the size is purely cosmetic at this point (No collisions implemented).

What is meant by

"If if you look at it by putting the equation for rotational acceleration equal to the Gravity at a set distance, you should be good...."

That sounds promising.

Edited by Beale
Link to comment
Share on other sites

You might want to use G in Earth units...

Try using 1.02762349819005e-23 as your G and convert everything to true mass values...

Keeping the units in Earth masses and using 1.02762349819005e-23

Unfortunate results?

facecb6a95.png

Thats an equation.

V^2/r = GM/r^2

Ah okay! It's re-arranged.

Maths is... not my strong point. How may I apply this?

Link to comment
Share on other sites

The new G value I gave you was specifically for true masses. As is the normal G value. Either make G in Earth units, or use true mass values.

I've misunderstood, I though G in Earth masses was 1.02762349819005e-23?

And 6.674E-11 was for true masses?

How may I get G in Earth masses?

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...