MechJeb2

MechJeb2

4M Downloads

Gravity losses error

futrtrubl opened this issue · 11 comments

commented

MechJeb shows gravity losses increasing even when engines not firing. To reproduce go into an eccentric orbit, after periapsis as you gain altitude and orbital speed decreases it counts that decrease as gravity losses. It doesn't seem to take into account gravitational potential gains.
Probably best to only base this stat on thrust vector and gravity vector. Formula to use based on http://ganeff.com/astrodynamics-knowledgebase/olfar/4-celestial-mechanics/gravity-losses/ seems to be (time interval * gravity * sinɤ) where ɤ is the angle from the plane that is normal to the gravity vector to the thrust vector or more simply angle between thrust and gravity vectors -90 degrees. Not sure how to handle negative ɤs or thrust less than gravity.

commented

#1797 gravity loss runs constantly, which is correct (because gravity runs constantly).

commented

It's not when the gravity loss calculation runs that's the problem, it's the calculation itself that is wrong. That there are no gravity losses when there is no thrust is the example and proof.
Gravity losses is the deltaV lost to counteracting gravity. Think of a stationary vehicle thrusting up at 1g in a 1g field. All that thrust goes into just maintaining its position and is lost, not converted to speed or potential energy. Conversely compare that to a craft in an eccentric orbit, as it travels away from the body it isn't losing energy as the kinetic energy is reversibly converted to potential.
If you do not believe me then look at other sources:
"In astrodynamics and rocketry, gravity loss is a measure of the loss in the net performance of a rocket while it is thrusting in a gravitational field. In other words, it is the cost of having to hold the rocket up in a gravity field.

Gravity losses depend on the time over which thrust is applied as well the direction the thrust is applied in." from https://en.wikipedia.org/wiki/Gravity_loss
"In the coast phase the gravity loss is zero." from page 7 of https://web.stanford.edu/~cantwell/AA284A_Course_Material/Karabeyoglu%20AA%20284A%20Lectures/AA284a_Lecture7_Gravity_Loss.pdf

commented

Conversely compare that to a craft in an eccentric orbit, as it travels away from the body it isn't losing energy as the kinetic energy is reversibly converted to potential.

It doesn't lose energy, but it does lose velocity. How do you want to measure gravity loss? If it's in terms of energy then sure it can be zero for a coasting craft in an eccentric orbit. But if it's in terms of speed, it should directly follow what I said 10 years ago

current speed = initial orbital speed + delta-v expended - gravity losses - drag losses - steering losses

Then gravity losses should keep accounting for gravity minus the centripetal term from horizontal velocity, unchanging in a circular orbit but variable otherwise. Gravity losses would go up as you ascend towards apoapsis in an eccentric orbit and slow down, then gravity losses go back down as you descend towards periapsis and speed up.

commented

Just look at the sources, it is a loss of deltaV. They give the calculations and they state explicitly that it only happens during thrust. And the conversion of kinetic to potential energy isn't a loss of energy from the system, while gravity losses are.
But if you want to argue that the lecture on Gravitational Loss in the Advanced Rocket Propulsion course at Stanford University is wrong then there is nothing more I can say.

commented

I'm tempted to flip "gravity loss" back to the meaning of "losses while under thrust due to gravity" (so people can do easy accounting against how efficient their rocket engines are) and introduce "gravity drag" to mean "the constant drag-like force from gravity" (so people can do easy accounting against what their velocity winds up at).

commented

That page and MJ use different conventions for gravity losses. With the convention MJ is using, gravity losses are entirely independent of thrust. When your velocity vector is not perpendicular to the direction of gravity, gravity will either decrease your speed if your altitude is increasing, or increase your speed if your altitude is decreasing. This is what MJ is integrating out as gravity losses.

commented

Then it is still an error if they use a bad definition of gravity loss. I haven't found another source that uses a definition of gravity loss other than the thrust that is expended to counteract the force of gravity.

commented

Gravity doesn't turn off when you shut off the engines. With the current definition, you should obtain current speed = initial orbital speed (so for launches, this is the rotational speed of Kerbin's surface at KSC) + delta-v expended - gravity losses (by MJ's thrust-independent calculation) - drag losses - steering losses.

For any definition of gravity losses that depends on thrust, this relationship will not hold. So those other definitions of gravity losses seem much less useful to me.

commented

Then it should be renamed to something other than gravity loss since it is not the universally accepted meaning of gravity loss. In which case I would like to make the feature request of gravity loss as it is understood in rocketry and orbital mechanics.

commented

I think we've both misread the original reference you linked to. gamma is not in fact the angle to the thrust vector, it is the flight path angle, so only depends on velocity. See https://github.com/MuMech/MechJeb2/blob/master/MechJeb2/MechJebModuleFlightRecorder.cs#L102 for what MechJeb is integrating: the component of gravitational acceleration (mislabeled as force, but it's the local gravity info item in m/s^2 here https://github.com/MuMech/MechJeb2/blob/master/MechJeb2/VesselState.cs#L46) antiparallel to vessel velocity (oddly surface velocity, I'll have to think about that...), minus the component of centrifugal acceleration parallel to vessel velocity.

commented

This has been mostly fixed, but its waiting on a patch in my branch to land to actually turn off gravity losses with zero thrust.