Jump to content

Vis-Viva equation gives false results for speed on my hyperbolic trajectory.


Recommended Posts

I've found myself in a bit of a pickle for the past few months given that I was trying to get from Kerbin to Duna in <100 Kerbin days. Having spent a week putting my nuclear ship (both thermal and electric) named "Mira" on a hyperbolic trajectory almost literally straight to Duna (eccentricity >23), I need to take another week to slow down. Given the weak thrust of my electric engines it will by difficult to slow down precisely so that I don't miss Duna. I've been trying to do this by means of a simulation in Desmos where I've successfully mapped out both Duna's and my trajectory to sufficient precision and also my Δv-plot on a separate simulation but there is on final stumbling block:

The vis-viva equation gives me grossly incorrect results for speed. Something in the region of 51'000m/s at periapsis but my actual speed at periapsis according to KOS is 13'560m/s. No matter how I change the pluses & minuses it doesn't give correct values.

Here's my full-scale simulation including the equation marked with the note "PROBLEM AT HAND:" (all distances are in kilometers):

https://www.desmos.com/calculator/nufnmhwxak

Please help, I can't continue KSP until I've got this solved. I'm happy to give any further information to help you help me.

Edited by Tomboi
update
Link to comment
Share on other sites

Personally my main source of error in using vis-viva has been remembering to translate from the numbers in KSP, which measure distance from the surface, to radii measured from the center of the body.

I'm not familiar with that calculator tool, but it looks like you have a solar periapsis of 11,114,458,000m, is that correct?

The wiki gives the sun's radius as 261,600,000m: https://wiki.kerbalspaceprogram.com/wiki/Kerbol

That would be around a 2.4% error if not included, might be worth double checking that.

Link to comment
Share on other sites

Thanks for your input, HebaruSan. I've had a look and the 2.4% error from ignoring Kerbol's radius cannot be the source because the radius of my trajectory (called rMira in the calculator) is calculated based on the semi-major axis using this formula from Wikipedia:

https://en.wikipedia.org/wiki/Hyperbolic_trajectory#Position

I've edited the calculator now to include your correction and updated the link in the original post.

Its error is <1.7% relatively and absolutely expressed in the additional term "ccorr".

None of this explains this massive error for orbital speed ranging around 250%.

Link to comment
Share on other sites

45 minutes ago, Tomboi said:

None of this explains this massive error for orbital speed ranging around 250%.

I took a brief look at it last night, and was hoping it was of by a factor of sqrt(10). That tends to happen with metric unit conversions. Check your mu to make sure you're properly converting from m^/s^2 to km^3/s^2. That's bitten me before.

Link to comment
Share on other sites

20 hours ago, FleshJeb said:

I took a brief look at it last night, and was hoping it was of by a factor of sqrt(10). That tends to happen with metric unit conversions. Check your mu to make sure you're properly converting from m^/s^2 to km^3/s^2. That's bitten me before.

For the speed to I've added the factor 1000 to both distances to convert them back to meters.

14 hours ago, FloppyRocket said:

How did you determine the semi-major axis 'a' value?

I asked the KOS on-board computer.

Edited by Tomboi
Link to comment
Share on other sites

Hmmm... based on the semimajor axis and eccentricity you have provided, I also calculate around ~51km/s at periapsis, so I don't think the problem is in your use of the Vis-Viva equation or with your unit conversions. The periapsis height with those parameters is reasonable, too, since it falls between the orbits of Kerbin and Eve. Could the 13.56km/s your getting from KOS be referring to a different place/time/craft?

(Sorry, I don't have much experience using KOS)

Link to comment
Share on other sites

20 hours ago, FloppyRocket said:

Maybe you should ask on the kOS forum if the 'a' value is correct for hyperbolic orbits.

It has to be, it produces the correct trajectory with only a 1.6% error. The radius is pretty much correct but the Vis-viva equation is completely off for whatever reason.
I've looked at the KOS documentation and it mentions no issues regarding the semi-major axis.

 

20 hours ago, theAstrogoth said:

One mistake I noticed is that, since r_mira is negative, you need a negative sign for it in the equation in box 28. This makes the result match box 29 when the true anomaly is zero.

Alternating the plus & minuses on both radius and semi-major axis only alternates everything between 46'753m/s and 50'971m/s at ΦMira = 0. Note, that when alternating plus/minus I put the bracket in absolutes if their content becomes negative to get a real result. Here it contains all variations:

https://www.desmos.com/calculator/jo9lzskbnk

It's definitely my spacecraft that KOS is providing the numbers for, my current orbital speed is consistent with what KOS predicts.

Current flight data (ETA Periapsis: 10dKerbin 1h 57min):

Altitude: 11'500'200km from Kerbol surface || 11'569'837km from Kerbol center
Orbital Speed: 13'542.6m/s

PS: I thank everyone for helping me out! :)

Edited by Tomboi
addendum
Link to comment
Share on other sites

Would I be better off using a differential equation to predict my trajectory as a function of time? Is it possible?

Or maybe run the  numbers on KOS predicting speed at every point?

I should probably just approach it numerically, since my orbit goes out the window once I start my engines.

Edited by Tomboi
Link to comment
Share on other sites

5 hours ago, Tomboi said:

Would I be better off using a differential equation to predict my trajectory as a function of time? Is it possible?

Or maybe run the  numbers on KOS predicting speed at every point?

I should probably just approach it numerically, since my orbit goes out the window once I start my engines.

The problem with that is that a differential equation would describe a rate that is at least partly dependent on its own rate of change, but your trajectory, at least while you're in free-fall, should be constant.  You absolutely could describe that as a differential equation, but its only solutions are trivial or degenerate in the same sense as solving for the parabola ax2 + bx + c = 1 for all x.  The variable terms drop out and you're left with a constant function for a constant output.  For a powered transfer, that's another matter, but that gets complicated quickly.

I took a look at your situation from a standpoint of specific orbital energy, and the only conclusion that I have is that you are not reporting a parameter correctly for that orbit.  I don't mean that you are failing to read the numbers correctly--bugs are the usual suspects--but something is definitely wrong.  At the given radius from the sun, your specific orbital potential energy is approximately 101 megajoules per kilogram.  Keep in mind that specific potential energy has absolutely no dependence on velocity; it is only a function of radial distance and the standard gravitational parameter.  At a minimum, your specific kinetic energy must exceed that, or it's not even a hyperbolic orbit--let alone the hyperbolic orbit that you want.

To have the semi-major axis you reported, your total specific orbital energy, which is constant for the entire orbit no matter where you are on it (and, therefore, which is also independent of velocity), is and must be approximately 1,196 megajoules per kilogram.  This should make sense; an eccentricity of 23.8 comes from a hyperbolic trajectory that is almost flat, and as such necessarily must be utterly dominated by the specific kinetic energy term.  With the velocity you gave, your specific kinetic energy is only 91.7 megajoules--that, as I mentioned above, is not enough to escape.  This is further confirmed by the fact that an orbit such as you describe has a vinf, or excess velocity at infinity, of 48,907.7 m/s.  That is the low point of the orbit's velocity.

It is possible that there is a bug in this, given that you can't totally escape from the sun, but on the other hand, the sun's sphere of influence is the only one in the game that actually is infinite (to within any acceptable approximation), so if anything, the equations ought to be most accurate for objects in solar orbit.

The only suggestion that I have for you is to re-check the data.  At this juncture, you may as well question everything.  My value for the solar standard gravitational parameter is 1.1723328 x 1018, which is the value from the wiki.  Is that value correct?  Check it.  Is the velocity being reported correctly, and as relative to the sun?  That is definitely worth a check.  Look at the visual appearance of the orbit.  Is it actually hyperbolic?  Does it look like a hyperbola with an eccentricity of 23.8?  I suspect that your orbit information is a bit askew; there's very little chance that you are confusing an orbital velocity of 13,550 m/s for one of approximately 50,000 m/s, so perhaps you've reached some kind of error relating to the magnitude of your semi-major axis.  What does Kerbal Engineer have to say about it?

Do you have a persistence file containing this mission with the Mira at its solar periapsis?  Seeing the values that the game is using to place the orbit would help to decide once and for all what it is trying to do.

Link to comment
Share on other sites

Thanks Zhetaan, I've found the problem. The reason for the confusion is as obvious as it is dumb: My game isn't remotely stock, I have a myriad of solar system mods including interstellar ones.
Because of that, the mass of Kerbol is an order of magnitude lower than in stock.

I should have drawn all my numbers from KOS instead of the Wiki. I've calculated the actual standard gravitational parameter and the speeds now line up pretty neatly. The same goes for Duna's speed at around 2000m/s instead of the stock 7147 to 7915 m/s.

BTW does anybody know what the best way is to acquire true anomaly on my hyperbolic trajectory to make it a function of time? Do I have to approximate for hyperbolic eccentric anomaly?

Updated calculator: https://www.desmos.com/calculator/q4j6vzsxnj

Edited by Tomboi
additional question.
Link to comment
Share on other sites

14 hours ago, Tomboi said:

BTW does anybody know what the best way is to acquire true anomaly on my hyperbolic trajectory to make it a function of time? Do I have to approximate for hyperbolic eccentric anomaly?

Unfortunately, there is not a closed-form equation that allows you to write true anomaly as a function of time. You have to solve Kepler’s equation numerically. I’m not aware of any good approximations of hyperbolic eccentric anomaly from mean anomaly.

i’m not familiar with desmos, so I don’t know how you would do it in your calculator, or if it’s even possible.

Link to comment
Share on other sites

16 hours ago, Tomboi said:

Thanks Zhetaan, I've found the problem. The reason for the confusion is as obvious as it is dumb: My game isn't remotely stock, I have a myriad of solar system mods including interstellar ones.
Because of that, the mass of Kerbol is an order of magnitude lower than in stock.

I should have drawn all my numbers from KOS instead of the Wiki. I've calculated the actual standard gravitational parameter and the speeds now line up pretty neatly. The same goes for Duna's speed at around 2000m/s instead of the stock 7147 to 7915 m/s.

Thanks for the update, I've been curious about what the problem was.

Link to comment
Share on other sites

On 2/7/2021 at 9:00 AM, Tomboi said:

Thanks Zhetaan, I've found the problem. The reason for the confusion is as obvious as it is dumb: My game isn't remotely stock, I have a myriad of solar system mods including interstellar ones.
Because of that, the mass of Kerbol is an order of magnitude lower than in stock.

I have to admit that the gravitational parameter is just about the last thing I would think to check, too.  I'm glad that you figured it out.

On 2/7/2021 at 9:00 AM, Tomboi said:

BTW does anybody know what the best way is to acquire true anomaly on my hyperbolic trajectory to make it a function of time? Do I have to approximate for hyperbolic eccentric anomaly?

I don't know whether desmos can do this, but Newton's method works just as well on the hyperbolic form of Kepler's equation as it does on the elliptical form.  I know that it can be calculated, but I do not know whether it is easily iterated, let alone automated.

Link to comment
Share on other sites

  • 3 weeks later...
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...