# Kerbal Space Program - Duna Flight Math

#### collinsmark

Homework Helper
Gold Member
The Sands of Duna

<Intermission (1/2)>

An intermission of math.

Skip this post (and the next) if you are not interested in the math. But since you are reading this on Physics Forums after all, there's a good chance you are interested. If so, read on.

Collinsmark is not affiliated with Squad nor Kerbal Space Program.

Here is the justification to some claims I've made in the last few posts, and the derivation to a couple equations.

It's a straightforward calculation to find the velocity of an object in a circular orbit around a much larger object. We simply set the acceleration of gravity equal to the centripetal acceleration.

$$\underbrace{\frac{v^2}{r}}_{\mathrm{centripetal}} = \underbrace{\frac{GM}{r^2}}_{\mathrm{gravitational}}$$

Solving for $v$ gives us

$$v = \sqrt{\frac{GM}{r}} .$$

By the way, when we assume that the smaller body, say our ship, is in orbit around a much larger body, like a moon or planet (or even the Sun), like we are doing here, it is called a restricted two-body problem. The assumption that the larger body is much, much more massive than the smaller is what makes it "restricted." So when you hear of a restricted two-body, restricted three-body, or restricted n-body problem, it means the mass of the ship is small compared to the mass of the other bodies being considered, and its effect on the motion of the larger body (or bodies) can be neglected.

We can also find the potential energy, U, of our ship when it is at some height above when orbiting a moon or planet. It is assumed that the potential energy, U, is zero when the ship is far, far away from the body. As the ship approaches the body, U, decreases, meaning it becomes more negative.

We can find this potential energy by integrating the force from its initial orbital height, up to infinity. In other words, we calculate the work required to slowly lift the ship from its present orbital height up to infinity.

$$W = \int \vec {F(r)} \cdot d \vec r$$

Note that in our case, we are slowly moving the ship toward infinity, although the force is pointing in the opposite direction. That's where the negative sign comes from.

$$U = -\int_r^{\infty}G \frac{Mm}{{r'}^2} dr'$$

Evaluating the integral gives us

$$U = - G \frac{Mm}{r} .$$

The kinetic energy is the good 'ol $T = \frac{1}{2}mv^2$, once we've chosen a suitable frame of reference. For the rest of this post, it's assumed that our frame of reference is that of the planet or moon the ship is orbiting, unless otherwise stated.

So the total energy of the ship is the ship's kinetic plus potential energy.

$$E = T + U = \frac{1}{2}mv^2 - G \frac{Mm}{r^2}$$

It is often convenient to normalize this to energy per unit mass of the ship, by dividing by m. (This is particularly useful for those intervals of time when the ship is not burning any fuel and thus its mass remains constant.) That gives us

$$\epsilon = \frac{1}{2}v^2 - \frac{GM}{r},$$

which brings us to our derivation of the standard escape equation in Figure 103.

[Figure 103: Standard escape equation]

We know that eventually, when the ship is far away from the moon/planet, and traveling at its final, free-space velocity, $v_{fs}$ that its potential energy has dropped to zero. So in the end, the ship's total energy is all kinetic energy. Its initial (normalized) potential energy is simply $-\frac{GM}{r_{or}}$. But what we don't know yet is its initial kinetic energy immediately after the burn. We know that before the burn, its orbital velocity is $v_{or}$. Immediately after the burn, its velocity is $v_{or} + \Delta v$.

So we apply conservation of energy. We know that the ship's total energy is the same immediately after the burn as it is when the ship eventually reaches its final speed, $v_{fs}$.

$$\frac{1}{2} v_{fs}^2 = \frac{1}{2} \left( v_{or} + \Delta v \right)^2 - \frac{GM}{r_{or}}$$

Substituting $v_{or}^2$ in for $\frac{GM}{r_{or}}$ gives

$$\frac{1}{2} v_{fs}^2 = \frac{1}{2} \left( v_{or} + \Delta v \right)^2 - v_{or}^2.$$

Multiplying by 2 and rearranging produces

$$\left( v_{or} + \Delta v \right)^2 = v_{fs}^2 + 2 v_{or}^2.$$

And with a touch more algebra we find,

$$\Delta v = \sqrt{v_{fs}^2 + 2 v_{or}^2} - v_{or}$$

which is the standard escape equation.

Note that when we take the derivative of $\Delta v$ with respect to $v_{or}$ and set that equal to zero, we find a minimum at $v_{or} = \frac{v_{fs}}{\sqrt{2}}$. Plugging those back into our equation, we find that that minimum is $\Delta v_{min} = v_{or} = \frac{v_{fs}}{\sqrt{2}}$.

What that implies is that there is an optimal, orbital height for your ship to escape, if you are using the standard escape strategy (a single burn to escape). Assuming that you already know your final escape speed, the optimal orbital radius (for a circular orbit, and one you plan to use a standard escape with) is

$$r_{optimal} = 2 \frac{GM}{v_{fs}^2}$$

Of course, KSP doesn't display orbital height in terms of radius to the center of the planet/moon. Rather it displays it as height above sea-level. So if you want to go by the height that KSP displays, you need to take the radius of planet/moon into account. Doing that gives

$$h_{optimal} = 2 \frac{GM}{v_{fs}^2} - r_{planet}$$

where $r_{planet}$ is the radius of the moon/planet.

For every given planet or moon, you can find its radius and its standard gravitational parameter GM on the KSP wiki: http://wiki.kerbalspaceprogram.com/wiki/Main_Page.

You know that you have it right if you create a maneuver node in your present, circular orbit, for your desired destination, and the Δv displayed on the maneuver node equals (or nearly equals) your present orbital speed.

But what if you don't yet know your desired $v_{fs}$? That's okay, you can calculate it. Create a maneuver node to your desired destination and jot down the Δv and your present orbital speed, $v_{or}$. Then solve,

$$v_{fs} = \sqrt{ \left( v_{or} + \Delta v \right)^2 - 2 v_{or}^2}$$

There's some serious implications to all of this. I've heard it said that "Minmus makes a great place to put a refueling station because it is near the edge of Kerbin's SOI, making it easier to escape." Ahh! No! That makes it a horrible place to put a refueling station, if you plan to escape the Kerbin system using the standard escape strategy.* With a standard escape, you'll use less fuel escaping if you start from a lower orbit.

*(There is one exception to this: asteroids. Asteroids travel in nearly the same orbit as Kerbin, so the ship's $v_{fs}$ is almost zero, with respect to Kerbin. So yes, a Minimus output would work quite well for asteroid redirect missions. But that's about it, if you limit yourself to standard escapes. On the other hand, if you want to use the fancy-shmancy escape, Minmus has advantages because it is so high above Kerbin. More on that in the next post.)

And, when using the standard escape, the ideal orbital height is closer to Kerbin, the farther the destination is, orbital wise. Putting it another way, the greater $v_{fs}$, the optimal orbital height is lower, all else the same (assuming standard escape).

If you work out the math, you'll find that the Mun would make a great place for a refueling station for the purpose of going to Duna, using a Hohmann transfer to Duna (Minmus is way to high for a standard escape to Duna). For planets that are farther way than Duna, even the Mun is too high for an optimal, Direct escape. So for planets beyond Duna, either put your refueling stations in a lower Kerbin orbit, or be prepared to do the fancy-shmancy via Kerbin, on the way out of the system.

The things to take home with you regarding the standard escape are:
• There is an optimal, orbital height for entering and leaving a system for a given $v_{fs}$, when using the standard arrival or standard escape (single burn). This is great place to park massive service modules and massive refueling stations. Parking massive service modules/refueling stations in other orbital heights, either higher or lower, will require the ships to burn more fuel on arriving and escaping, assuming the standard arrival or standard escape (single burn).
• This optimal height is dependent on the destination. More correctly, it is dependent on the $v_{fs}$ needed when escaping the system. (Assuming that the same type of orbit is used on arriving, the arrival $v_{fs}$ should be the same as the escape $v_{fs}$, btw.) And of course it is also dependent on the standard gravitational parameter, GM, of the moon/planet you are orbiting.
• All that said, there is the potential to save even more fuel by parking in yet higher orbits, if you use the fancy-shmancy arrival/escape, which we'll talk about in the second half of the intermission.

[Edit: By the way, for the record, I am not a big fan of having refueling stations around Kerbin. They will invariably require more fuel used, overall, if you take into account the cost of getting the stations into orbit in the first place, and all the fuel needed to put the remaining fuel in orbit. That said, refueling stations can have tremendous advantages around systems with multiple moons like Jul. And if you ever attempt to take off from Eve (a large, gravitationally strong planet), you'll definitely want some fuel waiting in orbit. I know that many KSP players are fans of single-ship (or single-stage) to orbit (SSTO) crafts, and while I've never been a big fan of SSTOs, refueling stations can also be good for those.]

Last edited:
Related Aerospace and Astronautics Engineering News on Phys.org

#### collinsmark

Homework Helper
Gold Member
The Sands of Duna

<Intermission (2/2)>

Skip this post if you are not interested in the math (there's also a touch of history in this one). But since you are reading this on Physics Forums, there's a good chance you are interested. If so, read on.

First, some history

Below is Isaac Newton's vis viva equation (It's alive! ):

$$v^2 = GM \left( \frac{2}{r} - \frac{1}{a} \right)$$

where,
$r$ is the distance from the smaller, orbiting body to the larger body,​
$a$ is the semi-major axis of the ellipse traced out by the smaller, orbiting body.​
$GM$ is the standard gravitational parameter of the larger body (which is Newton's, gravitational constant times the mass of the larger body).​
and $v$ is the velocity of the smaller body at the given position of it's orbit (its speed for a given value of $r$).​

From a historical point of view, the relationship embodied in his vis viva equation changed the world forever after, at least indirectly if not more.

You might not be familiar with this equation, and perhaps have never even heard of it. It's not the equation for which Newton is best known. But from a historical point of view Newton's vis viva relationship is paramount to a revolutionary change. The vis viva relationship is the first to show how a force could cause a moon/planet to orbit in a ellipse. But historically, it was involved in much more.

It was on an August day in 1684 when Edmond Halley (eventually of Halley's comet fame), paid a call on a young Issac Newton. Halley and Newton had already met some years before. Newton had made a small name for himself by his studies with light and inventing the reflecting telescope. The purpose of Halley's visit this time was to inquire if Newton had made progress with the problem of how a gravitational force might cause an orbiting body to move in an ellipse around it.

Both Newton and Halley knew that planets move in ellipses. This had been known for more than a half century by the work of Johannes Kepler's Astronomia nova. When traveling to visit Newton, Halley might have even suspected that the gravitational force obeys the inverse square law (although that's difficult to say for sure). Inverse square law or not, Halley himself failed to show how a force (of whatever sort) would cause a planet to move around the Sun in an ellipse. Hence the reason for calling on Newton.

So when Halley arrived in Cambridge that day in 1648, he asked Newton about it. Newton said that he had already solved it, and that the result was laying around in his notes somewhere. Newton couldn't find the relationship in his notes, but said he'd forward them on when he found them.

In November of that year, Newton did forward the relationship and related material (either reproducing or re-deriving them) to Halley in De motu corporum in gyrum ("On the motion of bodies in an orbit"). Halley was impressed to say the least, and urged Newton to create a more detailed version, assuring him it would be published by the Royal Society.

Isaac Newton followed Halley's advice and created the much more detailed Philosophiæ Naturalis Principia Mathematica. This work, I'm sure you've heard of. It contains Newton's laws of motion, his universial law of gravity (including the vis viva equation, along with the inverse square law and the rest), and is the very basis of Newtonian physics that we still use today.

The story doesn't simply end with the publication. The Royal Society was broke at the time, and did not have the money to publish Newton's masterpiece. Halley himself had to raise most of the publication expenses, much of them coming out of his own pocket. Apparently, the Royal Society even offered to compensate Halley in the form of unsold copies of fish books.

But it all started with Edmund Halley's short visit to Isaac Newton that one August day, looking for something along the lines of what we now call the vis viva equation.

I won't derive the vis viva equation here, since there is already a good derivation on the Wiki site: http://en.wikipedia.org/wiki/Vis-viva_equation. But that's a good place to start with our fancy shmancy-equation derivation.

The fancy-shmancy

[Figure 104: Fancy-shmancy escape equation]

It's a pretty straightforward derivation if we first derive the Δv of each burn individually, and invoke Newton's vis viva equation.

We know that the ship's velocity immediately after the first burn is $v_{or} - \Delta v_1$. Just after the first burn, the ship's path is elliptical, with the major axis equal to $r_{or} + r_{lo}$. The ellipse's semi-major axis is half that, making $a = \frac{r_{or} + r_{lo}}{2}$. Plugging those into the vis viva equation at apoapsis gives

$$\left(v_{or} - \Delta v_1 \right)^2 = GM \left( \frac{2}{r_{or}} - \frac{2}{r_{or} + r_{lo}} \right).$$

Next we can make a few substitutions, to express the equation into their circular orbit velocities, instead of their radius counterparts, by noting,

$$r_{or} = \frac{GM}{v_{or}^2}, \ \ r_{lo} = \frac{GM}{v_{lo}^2}.$$

Keep in mind that $v_{or}$ and $v_{lo}$ are not the velocities of the ship at apoapsis and periapsis of the ship, when this ship is in this elliptical orbit. Rather those represent the velocity the ship would have if the ship was orbiting at either of those radii, in a circular orbit. We're representing things in terms of those velocities since they are easy to calculate, and even easy to measure directly.

Making the substitutions,

$$\left(v_{or} - \Delta v_1 \right)^2 = GM \left( \frac{2 v_{or}^2}{GM} - \frac{1}{GM} \frac{2 v_{or}^2 v_{lo}^2}{v_{or}^2 + v_{lo}^2} \right)$$

and simplifying

$$\left(v_{or} - \Delta v_1 \right)^2 = 2 v_{or}^2 - \frac{2 v_{or}^2 v_{lo}^2}{v_{or}^2 + v_{lo}^2}$$

and more simplification on the right hand side,

$$\left(v_{or} - \Delta v_1 \right)^2 = \frac{2 v_{or}^2 \left( v_{or}^2 + v_{lo}^2 \right)}{v_{or}^2 + v_{lo}^2} - \frac{2 v_{or}^2 v_{lo}^2}{v_{or}^2 + v_{lo}^2} = \frac{2 v_{or}^4}{v_{or}^2 + v_{lo}^2}$$

and taking the square root,

$$v_{or} - \Delta v_1 = \sqrt{\frac{2 v_{or}^4}{v_{or}^2 + v_{lo}^2}} = v_{or}^2 \sqrt{\frac{2 }{v_{or}^2 + v_{lo}^2}}$$

thus

$$\Delta v_1 = v_{or} - v_{or}^2 \sqrt{\frac{2}{v_{or}^2 + v_{lo}^2}}.$$

Keep that one handy. We'll come back to that.

But first, as an intermediate step, we need to find the ship's speed at periapsis. Let's call it $v_{peri}.$ And for that, the vis viva equation comes to the rescue again. The set up of the right hand side of the equation is the same as last time, except now $r = r_{lo}$ rather than $r_{or}$.

$$v_{peri}^2 = GM \left( \frac{2}{r_{lo}} - \frac{2}{r_{or} + r_{lo}} \right)$$

Making the same substitutions as before, and the same sort of simplifications,

$$v_{peri} = v_{lo}^2 \sqrt{\frac{2}{v_{or}^2 + v_{lo}^2}}.$$

Recall the orbital energy equation,

$$\epsilon = \frac{1}{2} v^2 - \frac{GM}{r}.$$

We can invoke conservation of energy again here. The left hand side of the equation below is the energy when the ship is far, far away from the planet/moon, and the right hand side of the equation is immediately after the second burn.

$$\frac{1}{2}v_{fs}^2 = \frac{1}{2} \left( v_{peri} + \Delta v_2 \right)^2 - \frac{GM}{r_{lo}}$$

Making our standard substitution,

$$\frac{1}{2}v_{fs}^2 = \frac{1}{2} \left( v_{peri} + \Delta v_2 \right)^2 - v_{lo}^2$$

Solving for $\Delta v_2$ gives

$$\Delta v_2 = \sqrt{ v_{fs}^2 + 2 v_{lo}^2} - v_{peri}$$

And finally making the $v_{peri}$ substitution from what we calculated earlier,

$$\Delta v_2 = \sqrt{ v_{fs}^2 + 2 v_{lo}^2} - v_{lo}^2 \sqrt{\frac{2}{v_{or}^2 + v_{lo}^2}}.$$

Now we can combine our $\Delta v_1$ and $\Delta v_2$ to make our $\Delta v_{total}.$

$$\Delta v_{total} = \Delta v_1 + \Delta v_2$$
$$= \sqrt{v_{fs}^2 + 2 v_{lo}^2} + v_{or} -v_{or}^2 \sqrt{\frac{2}{v_{or}^2 + v_{lo}^2}} -v_{lo}^2 \sqrt{\frac{2}{v_{or}^2 + v_{lo}^2}}$$
$$= \sqrt{v_{fs}^2 + 2 v_{lo}^2} + v_{or} - \left( v_{or}^2 + v_{lo}^2 \right) \sqrt{\frac{2}{v_{or}^2 + v_{lo}^2}}$$

And one last simplification yields,

$$\Delta v_{total} = \Delta v_1 + \Delta v_2 = \sqrt{v_{fs}^2 + 2 v_{lo}^2} + v_{or} - \sqrt{ 2 v_{or}^2 + 2 v_{lo}^2 }$$

And remember, $v_{lo}$ can either be calculated using $v_{lo} = \sqrt{\frac{GM}{r_{lo}}}$, or directly measured. It's likely that at some point or another, you will have a ship in low, circular orbit around the planet/moon in question. Simply jot down its orbital velocity while it's in that low, circular orbit, and that's your $v_{lo}$ that you can use later, if you wish to do fancy-shmancy escape calculations.

A couple of final things:
• Note that this equation does not have a local minimum. Instead, $\Delta v_{total}$ keeps getting smaller for higher orbits, eventually settling out at $\sqrt{v_{fs}^2 + 2 v_{lo}^2} - \sqrt{2} \left(v_{lo} \right)$, for extremely high orbits.
• When $v_{or} = \frac{v_{fs}}{\sqrt{2}}$, the total $\Delta v$ is the same as the standard escape. So for orbits lower than this critical value, use the standard escape. For higher orbits, use this fancy-shmancy escape if you wish to save fuel.
And now back to our story. ...

Full Series
Part 1: Introduction and Basics
Part 2: Efficient Launch Into Orbit
Part 3: Rocket Design Basics
Part 4: Rocket Design and Orbital Mechanics
Part 5: Getting to the Mun
Part 6: Getting to the Mun P2
Part 7: Preparing to Land on the Mun
Part 8: Mun Touchdown
Part 9: Staying on the Mun
Part 10: Preparing to Leave the Lander
Part 11: Walking on the Mun
Part 12: Leaving the Mun
Part 13: Rendezvous and Docking
Part 15: Preparing for Docking
Part 16: Docking and Lander Reunion
Part 18: Entering Earth's Orbit
Part 19: Landing Back on Earth
Part 20: Launch for Duna
Part 21: Duna Probe Launch
Part 22: Duna Rocket Launch
Part 23: Duna Burn and Periapsis
Part 24: Duna Oberth Effect
Part 25: Duna Mid-course Corrections
Part 26: Using Gravity to Orbit Duna
Part 27: Landing on Duna
Part 28: Exploring Duna
Part 29: Launching Off Duna
Part 30: Fast Return Path From Duna
Part 31: Advanced Duna Flight Math
Part 32: Burn 2 Escape Duna
Part 33: Returning to Earth From Duna

Last edited by a moderator: