Jump to content

Questions about KSP Drag Model


CrashChris

Recommended Posts

Hi Guys

 

I am working on a control code in krpc, where i need to precicly predict the drag coefficient in each stage of flight since i want to determine the impact position and velocity to calculate an ideal landing burn. (I know, there are mods that do exactly the same, but i want to learn how to do this by myself)

 

I did some tests to measure the atmospheric properties used in KSP but i don‘t really understand them.

My results are the following:

1) The pressure as a function of altitude is nearly an exponential function

2) The temprature distribution is similar to the one at earth

3) The density is calculated fom 1) and 2) using the assumption of an ideal gas

 

So far so good, because everything is convertable to formulae

Then, i measured the dragcoefficient times surface over different mach numbers staying at the same altitude. The results are, as expected from the real world: At transsonic speeds, drag increases dramaticly, falling down again for supersonic/hypersonic speeds:

const_Alt.png

(The wobbles and the narrow peak at 0.6 are coming from minimal steering, that changes the angle of attack)

But here is my first problem: How can this relation be calculated for the KSP physics / how is it calculated internally? Does anybody know this?

 

Finally, I meausred the drag coefficient times surface for different altitudes while staying at the same mach number, using a PID controller.

The coeefficient increases dramatically for high altitudes and there are also some strange wobbles around 35km as it can be seen here:

const_Mach.png

And this relation is my biggest trouble, because i have no idea, how to calculate this effects. I know, that both effects are coming from the changing Reynolds number but i cannot find any source, that gives a hint how this is approximated in KSP.

I am basicly looking for a formula, that calculates the drag coefficient at a specific flight phase in relation of a constant "standard" drag coefficient, mach number, temperature and altitude.

I checked the corresponding part of the mechjeb landing code and realized, that mechjeb uses the KSP API to get the drag calculations.

Is there any chance, to get reasonable predictions without using the KSP API (since i don‘t want to write my code in C#)?

 

Many thanks in advance,

Chris


Edited by CrashChris
Fixed Resolution of Plots
Link to comment
Share on other sites

15 minutes ago, CrashChris said:

Is there any chance, to get reasonable predictions without using the KSP API (since i don‘t want to write my code in C#)?

No.

You can get very rough estimations by analyzing the drag on the fly though. Should your algorithm be robust enough, and the vessel have control authority and thrust reserve, that could suffice in some cases (SSTO landing), but it doesn't look like what you're trying to achieve.

No such formula exists. Algorithm does exist, and it involves poking quite ugly, stateful C# API.

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