MuMech / MechJeb2

MechJeb2 - KSP mod
Other
988 stars 251 forks source link

"Limit to Terminal Velocity" setting references vertical, not surface, velocity. #409

Closed adammartinez271828 closed 5 years ago

adammartinez271828 commented 10 years ago

MechJeb's "limit to terminal velocity" setting limits the craft's vertical, not surface, velocity. This results in overacceleration and low-to-mid altitudes if your craft is not pointed vertically.

To replicate: build an overengined craft, activate the limit to terminal velocity setting, max the throttle to gain some altitude, and turn to zero pitch. Your surface velocity will accelerate way beyond terminal velocity, but your vertical velocity will stay below terminal velocity.

Anatid commented 10 years ago

Yes, it limits vertical velocity, not total velocity. In the case of a rocket ascending straight up you can prove a rule that says that ascending at terminal velocity is the most fuel-efficient strategy. For an actual gravity-turn-like ascent, the math is much more complicated and I don't know of any derivation of an optimal throttle strategy. My guess is that the rule "keep vertical velocity equal to terminal velocity" is more fuel-efficient than the rule "keep total velocity equal to terminal velocity." So that's what MJ implements.

So this is by design. Of course we can change it if there's some demonstration that the "total velocity" throttle strategy is actually more efficient.

Schnobs commented 9 years ago

I just did a few test runs; same craft, same ascent path (rudder controlled by mechjeb), but throttle was either controlled by MJ (terminal-vertical) or kOS (terminal-surface). Two runs each, and every time I let kOS spit out some flight data a) at flameout and b) at apoapsis.

The craft in question was a 800u tank, LVT-30 engine, plus SAS, kOS, and stayputnik. It has excessive TWR; under mechjeb control, it was eventually going at 3x terminal velocity. If that is wasteful, one should notice.

2x vertical speed set to terminal velocity: time: 97s - alt: 27927m - apo: 130298 - peri: -382798 - ecc: 0.5415 orbital velocity: 1948 time: 308s - alt: 116921m - apo: 116922 - peri: -399635 - ecc: 0.5631 orbital velocity: 1467

time: 97s - alt: 27927m - apo: 130299 - peri: -382797 - ecc: 0.5415 orbital velocity: 1948 time: 308s - alt: 116962m - apo: 116962 - peri: -399630 - ecc: 0.5631 orbital velocity: 1467

2x surface speed set to terminal velocity: time: 120s - alt: 29797m - apo: 98555 - peri: -336581 - ecc: 0.4523 orbital velocity: 1968 time: 302s - alt: 89546m - apo: 89547 - peri: -356678 - ecc: 0.4783 orbital velocity: 1635

time: 120s - alt: 29790m - apo: 98423 - peri: -336279 - ecc: 0.4518 orbital velocity: 1968 time: 302s - alt: 89341m - apo: 89341 - peri: -356515 - ecc: 0.478 orbital velocity: 1635

Now, which of the resulting orbits has more energy? I frankly don't know how to calculate that. Do I even provide the right data?

jamesmyatt commented 9 years ago

I think that the following calculations show that the second option has more energy. https://docs.google.com/spreadsheets/d/10x2UY8aNC0yR4p2aoYbvBDbxuKvkp7m9zdHTCpPt_vA/edit?usp=sharing

However, it may be that the two follow sufficiently different paths though the atmosphere.

Schnobs commented 9 years ago

Ascent path was controlled by mechjeb in both cases, with identical parameters (no corrective steering though, so the actual path is bound to be different).

The difference in energy seems to be slight, on the order of 3% -- and that on a rocket that had excessive thrust to throw away. Most of my serious rockets don't have enough TWR to exceed terminal velocity by much or for long. So I'd say that it hardly really matters.

K3BaRZ4s commented 9 years ago

I wrote up a proof that shows, for maximum fuel efficiency (given beforehand the velocity-angle as a function of altitude, which is the MechJeb ascent profile): the "total velocity" must equal the "terminal velocity".

https://www.sendspace.com/file/bo4oyk

So, it's true that the best is "vertical velocity" = "terminal velocity" when an ascent is purely vertical. However, the case of any arbitrary (non-vertical) ascent has "total velocity" = "terminal velocity". I was surprised the math comes out this way, but it does. The physics let a correct answer also be a simple answer - it usually doesn't happen!

I was thinking about what happens if only vertical-velocity is limited, in seeking fuel efficiency... This allows unlimited horizontal velocity => unlimited total velocity => unlimited drag force => unlimited loss of delta-V to air friction. In practice however, the rocket does well with just the vertical-velocity control during the lower part of the ascent: the atmosphere is much thicker there .. so terminal velocity is fairly small and, so, really constrains that rocket speed... and the rocket's ascent remains mostly vertical there (so the pure-vertical analysis applies). Then, in practice, the upper part of the ascent asserts an "efficient speed" that is more often way higher than the rocket could hope to attain -> Then the best policy quickly becomes just "go as fast as you can", regardless of whether your ascent analysis is purely vertical or angled (because you will never reach the very large speed recommended by either analysis). So the current MechJeb rule is already applying the correct "signal" of "give me max throttle from here on out", even on (most of) the upper ascent.

lamont-granquist commented 5 years ago

This is no longer accurate in post-KSP 1.0 non-soupy atmosphere. You want to break through the Mach barrier as fast as possible and reduce gravity losses and benefit from Oberth, particularly for orbital-class launchers. For sounding rockets, in Real Solar System or real-sized solar systems, then throttling down can reach higher altitudes with intermediate thrust, but the ballistic coefficient of orbital class rockets is way too large (and the Ascent AP isn't really suitable for sounding rockets).