Jump to content

On the particulars of drag in 1.2pre (measurements done on build 1553)


Gaarst

Recommended Posts

Hello! I'm extremely new to KSP, and I was hoping to find how drag works in KSP because I like to analyze games and make my own calculations. Drag is a far more obscure mechanic than thrust, velocity, mass, and gravity, so I'd like to know how the game calculates it. Is this equation here still accurate? Is it what the game uses? http://wiki.kerbalspaceprogram.com/wiki/Atmosphere#Drag

And, I assume, cross-sectional area is the area that is exposed by the part as viewed from the direction it's moving toward? Is that right?

And the other major component of the linked equation, assuming it's how the game works underneath, is atmospheric density. Does in-game density vary with altitude just the same as in U.S. standard atmosphere model, which the article also links to here? Except perhaps, that the atmosphere is shrunk by a minor proportion at all altitudes as I read somewhere else? http://www.braeunig.us/space/atmmodel.htm

The purpose, is calculations for progression of thrust, mass, velocity, trajectory, all that, and part choices optimized for price, or availability, or whatever I want. Assuming the drag equation is correct, I need to find or make an altitude - density function that is true to the game. I'm also assuming, that there's no mechanics of shifting humidity or temperature, therefore densities at different altitudes are always the same.

Edited by Aru
Link to comment
Share on other sites

3 hours ago, Aru said:

I'm also assuming, that there's no mechanics of shifting humidity or temperature, therefore densities at different altitudes are always the same.

Can confirm that density is a function of altitude. The best way to get the answers to your other questions would be to look in the game files at the code. 

Link to comment
Share on other sites

6 hours ago, LordKael said:

Can confirm that density is a function of altitude. The best way to get the answers to your other questions would be to look in the game files at the code. 

Or install telemachus and make a graph of atmospheric density measurements.

Link to comment
Share on other sites

11 hours ago, Aru said:

And, I assume, cross-sectional area is the area that is exposed by the part as viewed from the direction it's moving toward? Is that right?

Almost.

It's calculated using "drag cubes", either implied by the shape but in some cases modified in the parts definition.

So it's not only pure cross section, but also shape (as in pointy stuff generates less drag than blunt ones).

Link to comment
Share on other sites

On 10/3/2016 at 1:27 AM, Kertech said:

I was wondering whether the detached shockwave affect would interfere with aeroheating, would be interesting to measure heating of a part at a given altitude and speed, probably beyond my time constraints though! 

I can anecdotally confirm that the "antenna spike" design for Mk2 cockpits still work to reduce heating, if not drag. It can even be used sacrificially, giving you a fair bit more potential acceleration.

Link to comment
Share on other sites

2 hours ago, Jarin said:

I can anecdotally confirm that the "antenna spike" design for Mk2 cockpits still work to reduce heating, if not drag. It can even be used sacrificially, giving you a fair bit more potential acceleration.

Tested this with the linear rcs port on nose, it increased drag a bit, a guess the same as it would other places, the heat tolerance became far higher a lot, benefit with the linear rcs is that it handles 2600 degree. 

I think the in game effect is a lot that an part in front take heating and reduce the heating on parts behind even if not inline and same form factor as is required to reduce drag. 
An small part will not take up so much heat and it probably radiate a lot of it to the large part behind. 

Link to comment
Share on other sites

I made that altitude-density function, based on U.S. Standard Atmosphere and reduced altitudes to 80%, as it says in the wiki. It looks very similar to the shape of the pressure curve. And, I gathered that sea level is 600 km from center of mass everywhere (sphere, not ellipsoid), gravity is exactly 9.81 m/s^2 (instead of 9.80665), gravitational constant is the same, and from these things Kerbin mass is calculated as 9.81/G*(6e5)^2 ~= 5.29151337e22 kg. All that's left to simulate ascent, is to understand the drag system. I've been looking at DragCube, DragCubeList, DragCubeSystem, but it seems to only be about graphics. Could someone point me toward the code for the mechanics?

edit: Oh, and I got sidereal velocity at equator as (6e5m + altitude)*2*pi*427 / (426*6*60*60s), which ~= 174.942627 m/s at altitude 0.

edit: Now I learn that the engines have complex profiles for thrust, so I guess I will have to figure that out too if I want to properly simulate and optimize things. (Image taken from another post.)

nWGupvO.png

Edited by Aru
Link to comment
Share on other sites

Aaaand now I learn that temperature depends on more than just altitude, it varies by time of day and by latitude. Guess I'll have to try to figure that out too. The closest I could find to anything about mechanics, was DragCubeSystem.CalculateAerodynamics, which increments a variable "drag" by this.dragCurve.Evaluate. The only thing in the whole file that sounds promising. But, dragCurve is an instance of AnimationCurve, which is graphics stuff that comes straight from the Unity engine. Ugh. I'm having a hard time finding these things, so if anyone could tell me where to look for the code for 1] drag mechanics, 2] engine thrust-pressure profiles, or 3] how temperature varies by latitude and time of day, I would appreciate it, because I need all three. My objective is to fully simulate ascent from Kerbin (and also orbit and interplanetary travel, but that really doesn't need any additional information). I have trudged through an awful lot of compiled C# for other games, so all I really need is to know where to look, because it's not as obvious as I was hoping.

Very late edit: I'm not really any closer to this simulation now, but just in case this matters for anyone, AnimationCurve is a cubic Hermite spline - a spline of cubic polynomials. Unity uses it for animation, KSP uses it for many different things, including evaluating atmospheric pressure and temperature, and probably engine profiles. An AnimationCurve contains many keys, which have 4 numbers each: time (altitude), value (pressure / temperature), and slope on each side of the point. The two slopes are usually identical, else it has a discontinuous first derivative (a jerky animation, if used for positions in an animation). Pressure is based on a single celestial-body-specific AnimationCurve (atmospherePressureCurve), temperature is far more complex as it is calculated from several factors: distance and angle to Kerbol, and two body-specific AnimationCurves (atmosphereTemperatureCurve and atmosphereTemperatureSunMultCurve). Density is then a function of pressure and temperature. The drag mechanics are as elusive as ever. Presumably, it is "extern" and calculated by something written outside of C# for better performance.

Edited by Aru
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...