Thursday, May 1, 2014

On The Fuel-Optimal Ascent Speed in Kerbal Space Program


Kerbal Space Program is a sandbox-style spaceflight simulator game developed by Squad. The player designs and assembles spacecraft by piecing together a wide range of components, and then launches and flies them. The game places an emphasis on the realistic modelling of various physics, including structural failure of components, aerodynamic lift and drag, and accurate orbital mechanics. It should come as no surprise to learn that I absolutely love this game.

It is widely known and claimed that the most fuel efficient ascent speed for a spacecraft in Kerbal Space Program is the terminal velocity. However, not many people can actually explain exactly why this is. The whole thing has given rise to a number of misconceptions about terminal velocities and aerodynamic drag, so I felt I had to clear these up.

I'll also go through the math to calculate the actual fuel optimal ascent speed (which just happens to be equal in magnitude, but opposite in direction to the terminal velocity), because I couldn't find it explained anywhere else. I didn't really believe the claims until I did the math myself, so hopefully this will help those who are not convinced by all the half-baked whishy-washy arguments out there.


    1. What is the terminal velocity?

Many people seem to think that the terminal velocity is the maximum speed a rocket can reach. I don't know where this comes from, but it's absolutely false. The terminal velocity of an object is the speed at which an object will fall through air in the absence of all forces other than gravity and air resistance. That is, the only forces acting on the object are gravity and air resistance, or aerodynamic drag. Finding the terminal velocity is as simple as equating the weight of the object (a constant) to the drag (which varies with the square of the speed), and solving for speed. If an object is falling faster than the terminal velocity, air resistance will cause it to slow down. If it's falling slower than the terminal velocity, gravity will speed it up.

To get an object to fall faster than the terminal velocity, one simply needs needs to apply a downward force in addition to gravity.

Another thing to note is that the terminal velocity is always directed down. That's because at the terminal velocity, gravity and drag are equal in magnitude, but directly opposed.


    2. What does this have to do with going up?

The terminal velocity applies only to falling objects in the absence of other forces, so what is the relevance of the terminal velocity when your rocket is going up? The answer is, not much. It's just a useful reference point. Below the terminal velocity, your engines are doing more work to overcome gravity than drag. Above the terminal velocity, your engines are doing more work against drag than gravity. At the terminal velocity, exactly 50% of the work your engines do goes to overcoming gravity, and exactly 50% goes to overcoming drag. There's no reason why you can't just apply more thrust to ascend faster, or less thrust to ascend slower.


    3. Calculating the terminal velocity

From here on out, we're doing math. Hopefully this doesn't scare you off. As we've already pointed out, the terminal velocity occurs when the weight of the object acting downwards exactly balances the drag acting upwards. The weight is given by


where is the object's mass, and is the gravitational acceleration (which we can assume is constant if we're considering only very small changes in altitude).

The drag depends on several factors: the air density, , the cross-sectional area of our rocket, , the drag coefficient, , and the square of the object's velocity, . The equation is


The terminal velocity occurs when these two forces are equal. That is, when


To find the terminal velocity, we simply solve for to get



    4. Calculating the optimal ascent speed

We're now going to calculate the optimal ascent speed. As far as we're aware (at this stage), that has nothing to do with the terminal velocity, so we're going to start from scratch.

To do this, we're going to try find the mass of fuel that needs to be burnt to increase altitude by a small amount, and then use some basic calculus to find the speed that minimizes that. First, we'll need an expression for the change in altitude at a given speed. That's easy to do if we assume that the speed is constant. This is approximately true, provided we're considering a very small change in altitude:


where is the speed, and is the time taken to change the altitude.

We don't actually know what this change in time is, so we'd like to find another expression for it, preferably one that doesn't involve speed. To do that, we're going to make use of the rocket's impulse:


If we assume that we're looking at a very short period of time, so that the thrust is approximately constant, then this simplifies to


Now we need to calculate this impulse. Fortunately, the impulse, as you might guess, is very closely related to the specific impulse, which is a property of the engine, and is readily available for various engines in KSP. The specific impulse is defined as the impulse delivered per unit weight (at standard gravity, , which is the gravity at sea level on Kerbin) of propellant burned. Therefore, we can calculate the impulse from the weight of fuel burned, and the specific impulse of the engine:


Substituting this into our expression for impulse above, and solving for the time, we get


And so our expression for the change in altitude at a given speed becomes


So, solving for the amount of fuel burned, we get an expression for the fuel required to increase altitude by a certain amount at any given speed:


We don't know how much thrust we need to produce to maintain the optimum velocity. However, we can calculate what this value needs to be based on the two assumptions we've already made. We've assumed that the thrust is constant, and we've assumed that the velocity is constant. This means that thrust will be exactly balanced by the sum of the rocket's weight, and drag, . Therefore, we can write the thrust as


Since we're considering a very short period of time, we can assume that the weight of the rocket is constant. We've already got expressions for weight and drag, but we'll repeat them here. They are


and


We can substitute these into our equation for thrust to get


Then we can substitute that into our expression for fuel required to get


This can be simplified to give a simple expression for the fuel required to increase altitude by a small amount at any given speed.


We want to find the speed that minimizes the fuel required. This is a standard optimisation problem, and means we need to set the derivative of the objective function to zero.


That derivative is fairly easy to get with basic calculus. It leaves us with the following equation to solve:


This is easy to solve. Move the first term across to the other side, cancel and on each side and then multiply through by . This leaves the following expression:


Does that look familiar? It should. This is the exact same equation we had to solve to calculate the terminal velocity. The term on the left is simply the weight, and the term on the right is the drag. This means that the speed that minimises the fuel required to increase in altitude just happens to be the speed at which weight and drag are equal.

This means that the velocity that gives a fuel optimal ascent is equal in magnitude to the terminal velocity, but in the opposite direction.

If you enjoyed this post, then don't forget to like, tweet, +1, or upvote on reddit. If you have any questions, comments or complaints, post them using the form below.
. . . . . . . . . . . . . . . . . . . . . . . .



No comments: