Jump to content

How does Drag and all the other math work


Recommended Posts

First time posting in the Forums, sorry if I'm making any forum-related mistakes.

Ok, so I'm new to KSP and I am currently tired of using trial and error and want to do some math instead of trying useless stuff over and over again, also trying to get a logical idea on what factors affect your rocket. I tried calculating Thrust to Weight Ratio and using it to calculate acceleration, but when I actually fired the rocket up it didn't match which I assume is because of drag.

But when I tried looking up the wiki I found lots of information about aerobraking and all that stuff, and not so much about drag affecting your craft when it's lifting off. I did find this formula FD = 0.5pv^2dA, but when I plugged in numbers it ended up to be a 5 digit number 63504, and (assuming I am correct) I have no idea how to plug this in and find out how it will affect my speed.

Anybody able to tell me how this drag formula works and how to plug it in and find out my speed?

PS: If possible, can someone tell me how the gravitational force works? I know it's 9.807 in Kerbin but does it decrease the higher up you are?

Edited by aqcrazyboy
Link to comment
Share on other sites

Alrighty...well, first and foremost, the most important equation in rocketry is the Tsiolkovsky Rocket Equation:

delta-V = ln(M/Mo)*Isp*go

Where ln is the natural logarithm, M is the current stage's total mass, Mo is the stage dry mass, Isp is the stage specific impulse of the engines and go is standard gravity (9.81 m/s2)

Learn that formula forwards and backwards. No, literally.

A key thing about Tsiolkovsky - it's actually Newton's Second Law. It's just been adjusted to account for the fact that the mass of your rocket is not a constant (it couldn't fly if it were). Delta-V is literally change in velocity; integrate it with respect to time and you have acceleration.

Thrust to weight ratio is:

TWR = Ft / (M * G), where Ft is the current thrust of your rocket, M is the total current mass of your rocket, and G is the surface gravity of the body you're either launching from or landing on. It's less important than Tsiolkovsky, but still important during takeoff and landing.

Now, your question is about drag. The formula you found is how KSP currently models drag, and it's one of those formulas whose solution is extremely time dependent. It's dependent upon the craft's velocity, atmospheric density and mass, all three of which are changing with respect to time. Note that if you could calculate the drag force at an instantaneous time you could then estimate your rate of acceleration at that time - it would be a relatively simple force balance equation (between gravity, drag and thrust).

I think a practical example is probably in order here; I'll need some time to work one up.

Gravity meanwhile is rendered the usual way - g = GM/R2, where g is gravity, G is the universal gravitational constant (6.67*10-11 I forget the units), M is the mass of the body, and R is the distance to the center of mass of the body. (GM) by itself is also known as the gravitational parameter. For Kerbin, this value is 3.5316*1012 m3/s2. The planet's equatorial radius is 600,000 m, so you plug that in:

g = GM/R^2 = 3.5316*1012 / (600,000)2 = 9.81 m/s

At a 100 kilometer orbit, the gravity is:

g = GM/R^2 = 3.5316*1012 / (700,000)2 = 7.207 m/s

Incidentally, note that gravitational force is also changing with respect to time. Yet another wrench to throw into the works.

...you are always under the gravitational influence of something in KSP, which is why I always tell people there is no such thing as infinite TWR.

Link to comment
Share on other sites

Drag in KSP is not Fd = ½ * rho * v² * Cd * A.

Actually the equation is this: ½ * (1.223 * p) * v² * d * (0.008 *m)

where p is the atmospheric pressure, v² velocity squared, d is the drag coefficient of the ship and m is the ship's mass.

To get d, you just need to drag-mass average, so simply multiplying mass1*drag1 + mass2*drag2 + ... / mass1 + mass2 + ... gives you the right d.

That number doesn't mean much afterward, but you can calculate your terminal velocity with it after. You just need to do Fd = m * g where m is the ship's mass and g the gravitational acceleration.

But you will rarely need that when playing, what you really wanna care about is your delta V :P

Link to comment
Share on other sites

Oh wow. Thanks for all that info. It'll take a little time to digest though, I'll just play around with the numbers a little and experiment a little with KSP, and maybe come back if I have any other problems.

Just a bit of clarification, I don't know the terminology that well. Is dry mass the Mass of your craft after all the fuel is run out for that stage?

Time to re-learn all my physics.

Link to comment
Share on other sites

Welcome to the forum!

Recently I digged into the KSP-physics formula and put most of them in a single document.

Here is the forumspost http://forum.kerbalspaceprogram.com/threads/58531-Finding-the-best-ascent-path-for-rockets?p=872176&viewfull=1#post872176.

For the calculation of the dragforce, the speed relative to the atmosphere has to be taken and not the orbital speed.

Link to comment
Share on other sites

Drag in KSP is not Fd = ½ * rho * v² * Cd * A.

Actually the equation is this: ½ * (1.223 * p) * v² * d * (0.008 *m)

Sure it is, if you assume rho = 1.223*p, Cd = d, and A = 0.008*m. Since there's nowhere else in the game physics that any of those quantities show up, that's a perfectly consistent interpretation of the stock drag law. Scaling cross-sectional area as directly proportional to mass is a little strange and non-physical, but that's the stock drag law for you...

Link to comment
Share on other sites

Yes, dry mass is the mass of the craft when empty of propellent. Using the map screen mass readout and the resource tab, dray mass is mass - [0.005*(liquidfuel + oxidiser)]. This only works for LFO powered ships, of course, as it ignores solid fuel, xenon and monopropellent.

EDIT: tavert, I believe that the mass term is meant as an approximation of cross sectional area. Also that even though the temperature gradient changes in the atmosphere, pressure is always directly proportional to density.

Edited by Supernovy
Link to comment
Share on other sites

Right, any temperature readings from thermometers are totally decoupled from stock aerodynamics. Kerbal atmospheres behave as if they are isothermal.

For the lack of any better solution, area proportional to mass was certainly easy to implement as a placeholder. But this is a game about rockets, where mass constantly changes. Cross-sectional area should change maybe at staging events, but not by burning fuel... There's FAR if you really want physical accuracy, but it's tough to recreate its cross-sectional area and drag coefficient calculations offline without digging into the source code.

Edited by tavert
Link to comment
Share on other sites

Stock drag is extremely innacurate and a very gross estimation of it. Drag is literally applied to every part, and that's not the way it works at all. 0.008 * m is a terrible approximation of cross sectional area, and 1.22 * p is a very innacurate way of estimating atmospheric density. Doesn't take into account what the atmosphere is made of and ambient temperature. So it's innacurate at best, and applied uniformly to everything when it shouldn't.

Link to comment
Share on other sites

1.22 * p is a very innacurate way of estimating atmospheric density

Plenty accurate if the atmosphere is isothermal. Considering atmospheric pressure in KSP (which there is a separate sensor for, and shows up elsewhere like in engine Isp) follows a simple exponential curve vs altitude, that's consistent with an isothermal atmosphere. If you want to include a temperature lapse rate vs altitude, then you need a slightly more complicated barometric formula. Accounting for species concentrations and solar effects needs something even more complicated like NRLMSISE.

Link to comment
Share on other sites

Learn that formula forwards and backwards. No, literally.

Personally I'd just plug it into a spreadsheet and be done with it, but you can do the calcs by hand if you really want. The main things you'll need to calculate are just ÃŽâ€v and TWR. If you make a spreadsheet where you input dry mass, total mass, Isp and thrust then you can have it spit out your ÃŽâ€v and TWR.

The wiki has all the weights of the stock parts, and the thrust and Isp of the engines.

Link to comment
Share on other sites

Now, your question is about drag. The formula you found is how KSP currently models drag, and it's one of those formulas whose solution is extremely time dependent. It's dependent upon the craft's velocity, atmospheric density and mass, all three of which are changing with respect to time. Note that if you could calculate the drag force at an instantaneous time you could then estimate your rate of acceleration at that time - it would be a relatively simple force balance equation (between gravity, drag and thrust).

I'm probably extremely stupid here.

What do you mean by "Gravity"? Is it g=GM/R^2 or g=GM/R^2*MassofRocket?

Link to comment
Share on other sites

You have to equate the forces:

Force of drag = Force of gravity (weight)

½ * (1.223 * p) * v2 * d * (0.008 *m) = GMm/r2

4.892*10-3*pdmv2 = GMm/r2

4.892*10-3*pdv2 = GM/r2

At this point, the mass of the rocket cancels out, the only relevant parameter depending on the rocket is the overall drag, d. V2 in this case is the terminal velocity.

Link to comment
Share on other sites

You have to equate the forces:

Force of drag = Force of gravity (weight)

½ * (1.223 * p) * v2 * d * (0.008 *m) = GMm/r2

4.892*10-3*pdmv2 = GMm/r2

4.892*10-3*pdv2 = GM/r2

At this point, the mass of the rocket cancels out, the only relevant parameter depending on the rocket is the overall drag, d. V2 in this case is the terminal velocity.

Ahh. Thanks for the info. I'll keep that in mind when I need to aerobrake.

Link to comment
Share on other sites

Personally I'd just plug it into a spreadsheet and be done with it, but you can do the calcs by hand if you really want. The main things you'll need to calculate are just ÃŽâ€v and TWR. If you make a spreadsheet where you input dry mass, total mass, Isp and thrust then you can have it spit out your ÃŽâ€v and TWR.

The wiki has all the weights of the stock parts, and the thrust and Isp of the engines.

To be fair, I use a spreadsheet myself. And I have it set up so that one one workbook it tells me how much delta-V I have given x amount of fuel, and on another I have it set up to tell me how much fuel I need to get x-amount of delta-V. Forwards and backwards.

To get the "backwards" to work, I make the assumption that a full fuel tank weighs nine times as much as it does when it's empty; true for every liquid fuel tank in KSP except the Oscar-B and Round-8. I also have it shoot out results in factors of "FL-T100 equivalents", since that's the smallest tank for which the assumption holds true and the other tanks are basically multiples of it.

I'm probably extremely stupid here.

What do you mean by "Gravity"? Is it g=GM/R^2 or g=GM/R^2*MassofRocket?

Gravity: g=GM/R^2. Your rocket's mass wouldn't factor into that particular calculation, but its altitude would.

...you also asked me about dry mass, and yes, that's the mass of a stage when it's out of fuel.

Seret is also right about TWR; it is worth keeping an eye on during your launch. Ideally, you want to keep it somewhere between 1.8 and 2.2 or so; that minimizes fuel losses to gravity and drag. In the vanilla game, the gee meter gives you a rough indication of how that's going: during the vertical part of the launch, you generally want to keep the gees about halfway between the first and second mark (i.e. between 1-2G); my own observation has been that this should be closer to the one gee mark. Once you make your gravity turn, you want it to stay roughly at the top of the green zone. If it climbs out of the green, throttle back a bit to minimize fuel losses to drag.

Edited by capi3101
Link to comment
Share on other sites

If you want to get into the math without necessarily waiting for the old math texts to show up, and at the risk of making a shameless plug, I've run through several of them in the Krash Test Kerbals vids.

Also you can check in on Specialist290's drawing board, which will point you to several other sources that will briefly explain the equations and methods behind the Kerbal madness.

Link to comment
Share on other sites

If you want to get into the math without necessarily waiting for the old math texts to show up, and at the risk of making a shameless plug, I've run through several of them in the Krash Test Kerbals vids.

As purpletarget has already done me the kindness of plugging my own little project, I'm going to return the favor by seconding his recommendation of the Krash Test Kerbals video series, as it is indeed quite a handy resource if you want to dig into the nuts and bolts of how the game's physics work.

On the subject of atmospheric drag in particular: A while back I was working with another user on testing and debugging an atmospheric drag calculator, and we managed to fine-tune the aerodynamic equations to be quite precise for a simple 2D prograde / retrograde simulator. Unfortunately, around the time we started working on translating it into an actual plugin that could run 3D predictions based on direct input from the game itself, he got busy, and I haven't heard anything from him since. I'll have to see if I can get in touch with him again and if he's still up for continuing the plugin.

Link to comment
Share on other sites

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...