Jump to content

KSP and Scale Heights?


-ctn-

Recommended Posts

Okay, I have a question regarding KSP, scale heights, and the KSP wiki pages.

I came into this problem because I've been adding to the Outer Planets Mod's wikia page, and it uses an Infobox/Body template that calculates atmosphere height by scale height.

So here's my issue - the OPM wikia's template takes the scale height and does this equation: ln(1e-6) * -scale height.

Which is from the KSP wiki's "Atmosphere" page, here: 4791c594e9e599b0b813125e8a001569.png

To be honest, I've never seen this form of scale height/atmosphere height equation anywhere else...

Okay, so if I make Sarnus' scale height 22km, the OPM wikia puts the atmosphere height at 303.941km, which is close to the in-game data, which puts the actual atmospheric height at 304km.

Okay, so there's problem one. I can't get a scale height that gives an atmospheric height of 304km even. Problem two:

I took that equation and tried to apply it / check it with the KSP wikia's data for the planets, and my numbers are way off. For example - Kerbin's scale height is listed at 5.6km, and the atmosphere height, we all know is 70km. But that equation gives an atmospheric height of ~77km, which is wrong. With Jool, it's even worse. Scale height is listed as 31km, atmospheric height we know (from the game itself) is 200km. The equation says ~428km.

So now, I don't even know how to come up with a reliable way to calculate scale height.

If you use the real world equation, which is (1.38e-23 * Average Temperature in Kelvin) / (Average mass of molecule in kg * surface gravity), you get numbers that are wayyyy off the listed numbers on the wikia pages. Part of that is because I don't know how to take the wiki's data of Kerbin having a molar mass of 28.9644 g/mol into straight kg. I tried using the "Avogadro Constant" to break it down to kilograms for use in the equation, but even then, I ended up with a scale height of 8.07km, which is closer to Earth's scale height than Kerbin's.

So what crazy voodoo am I missing here? Is there some KSP specific unit or formula I'm missing? Is there a different way to calculate scale height, such as with density, temperature and atmospheric height? Am I totally botching up the math involved? Are the wiki pages TOTALLY outdated or wrong? Or is this a case of, simply, real-world principals that cannot be transferred to KSP? Which I find hard to imagine.

Link to comment
Share on other sites

i haven't tried it (didn't bring my calculator on vacation) but something you wrote bugged me : the equation you copy-pasted uses the neperian logarithm (ln) along with decimal powers (10^x) and you wrote it yourself using the neperian logarithm and the exponential (e^x) function. Maybe you messed up here ? just an idea

Link to comment
Share on other sites

Given altitude h, and surface pressure P0, pressure P(h) at altitude is given by the following.

P(h) = P0 exp(-h/H)

That's from definition of scale height. Now, KSP cuts off atmosphere where P(h) = P0 / 1,000,000. It's just a thing KSP does. Once pressure is lower than 10-6 of surface pressure, it's considered negligible, and KSP computes things as if it's total vacuum. In other words, altitude cuts off when:

P0 exp(-h/H) = 10-6 P0

Solving it for h trivially yields h = -ln(10-6) H = ln(106) H = 6 ln(10) H.

For example, pre 1.1, KSP scale height was 5,000m. 6 ln(10) = 13.82. That puts h at 69km. Which is where atmosphere used to end.

After the aerodynamics update, these things changed a bit, but it's still pretty close.

Link to comment
Share on other sites

For example, pre 1.1, KSP scale height was 5,000m. 6 ln(10) = 13.82. That puts h at 69km. Which is where atmosphere used to end.

Okay, but that equation does not work for other bodies -

Eve - Atmospheric height is 90km. Wiki lists the Scale Height at 7.3km. The equation's results are: 100.853km.

Dun - Atmospheric height is 50km. Wiki lists the Scale Height at 6km. The equation's results are: 82.893km

Laythe - Atmospheric height is 50km . Wiki lists the Scale Height at 8km. The equation's results are: 110.524km

Jool - Atmospheric height is 200km. Wiki lists the Scale Height at 31km. The equation's results are: 428.280km

So even though Kerbin comes out correct with that equations, none of the other bodies do. Am I missing something?

6 * ln ( 10 ) = 13.82

13.82 * Scale Height = Atmospheric Height

So am I wrong? Or is the Wiki wrong? And where the heck did they get those numbers on the Wiki page?

Link to comment
Share on other sites

Okay, I have a question regarding KSP, scale heights, and the KSP wiki pages.

I came into this problem because I've been adding to the Outer Planets Mod's wikia page, and it uses an Infobox/Body template that calculates atmosphere height by scale height.

So here's my issue - the OPM wikia's template takes the scale height and does this equation: ln(1e-6) * -scale height.

Which is from the KSP wiki's "Atmosphere" page, here: http://wiki.kerbalspaceprogram.com/images/math/4/7/9/4791c594e9e599b0b813125e8a001569.png

To be honest, I've never seen this form of scale height/atmosphere height equation anywhere else...

Okay, so if I make Sarnus' scale height 22km, the OPM wikia puts the atmosphere height at 303.941km, which is close to the in-game data, which puts the actual atmospheric height at 304km.

Okay, so there's problem one. I can't get a scale height that gives an atmospheric height of 304km even. Problem two:

I took that equation and tried to apply it / check it with the KSP wikia's data for the planets, and my numbers are way off. For example - Kerbin's scale height is listed at 5.6km, and the atmosphere height, we all know is 70km. But that equation gives an atmospheric height of ~77km, which is wrong. With Jool, it's even worse. Scale height is listed as 31km, atmospheric height we know (from the game itself) is 200km. The equation says ~428km.

So now, I don't even know how to come up with a reliable way to calculate scale height.

If you use the real world equation, which is (1.38e-23 * Average Temperature in Kelvin) / (Average mass of molecule in kg * surface gravity), you get numbers that are wayyyy off the listed numbers on the wikia pages. Part of that is because I don't know how to take the wiki's data of Kerbin having a molar mass of 28.9644 g/mol into straight kg. I tried using the "Avogadro Constant" to break it down to kilograms for use in the equation, but even then, I ended up with a scale height of 8.07km, which is closer to Earth's scale height than Kerbin's.

So what crazy voodoo am I missing here? Is there some KSP specific unit or formula I'm missing? Is there a different way to calculate scale height, such as with density, temperature and atmospheric height? Am I totally botching up the math involved? Are the wiki pages TOTALLY outdated or wrong? Or is this a case of, simply, real-world principals that cannot be transferred to KSP? Which I find hard to imagine.

I thought Kerbin's scale height is 5k alt. I have been using the equation that Kerbins atmosphere recedes at 8 fold reduction per 10,000 meters.

In the real world scale height type calculation are only valid in a range. PV = nRT and this is a function of the molecular weight of the gas and its density. The heavier gases tend to settle in the lower atmosphere and the lighter gases (hydrogen and helium) are found in LEO. Also temperature falls to about -100 and then begins to rise. Finally, there is a density of gas inside the earths magnetosphere, and most recent articles (I posted here about 1 month ago) show that the gas and associated temperatures exist in tendrils that spiral around earth. Finally you exit the magnetosphere and you encounter the solar wind. In KSPs model gravity is contained in spherical SOI in which the graviational isoquants are also spherical, and pressure terminates at a fixed altitude. The earth is also spinning and there is a perturbative interaction of Coriolis effect, Earth-moon interactions, etc. To get an idea of what these are like compare real aircraft data for GPS altitude and altimeter data from aircraft. Commericial aircraft set the MSL pressure to a fixed value at 18k feet and ride waves of pressure under an assumption of atmospheric pressure-elevation above. This can often vary in any location by 1000s of meters depending on pressure, and these perturbations increase in flux at higher altitudes. You really don't want KSP doing real world pressure, given it takes massively paralleled supercomputers to model real world atmospheric conditions, the only way the could model real world variation would be to create a model Kerbin with a supercomputer devoted to generating pressure and use something like flight simulators real-world downloads to update everyones machine, and of course it would have to be done everytime you entered and exited warp, queriing their server with a new time-stamp.

So, no, we are not in the real world; back to the original problem, how to verify the formula. . . . .is it really that important to get the calculation down to a relative variation of 0.001%?

Edited by PB666
Link to comment
Share on other sites

At this point, I would like a formula that gives consistently correct answers with all the atmospheric bodies in the game.

As I stated, the formula works fine for Kerbin, but then is massively off - anywhere from 10-50% depending on the planet/moon.

Link to comment
Share on other sites

Okay, but that equation does not work for other bodies -

Eve - Atmospheric height is 90km. Wiki lists the Scale Height at 7.3km. The equation's results are: 100.853km.

Dun - Atmospheric height is 50km. Wiki lists the Scale Height at 6km. The equation's results are: 82.893km

Laythe - Atmospheric height is 50km . Wiki lists the Scale Height at 8km. The equation's results are: 110.524km

Jool - Atmospheric height is 200km. Wiki lists the Scale Height at 31km. The equation's results are: 428.280km

So even though Kerbin comes out correct with that equations, none of the other bodies do. Am I missing something?

6 * ln ( 10 ) = 13.82

13.82 * Scale Height = Atmospheric Height

So am I wrong? Or is the Wiki wrong? And where the heck did they get those numbers on the Wiki page?

These results tally with what some people have been talking about - that bodies other than Kerbin have their atmospheres "chopped off" too low, making aerobraking needlessly hard. It may be that the edge of the atmosphere is now coded in the game as a definite value, regardless of surface pressure.
Link to comment
Share on other sites

Okay, that's starting to make sense to me now. It's a shame that it throws off any scale height calculations, and thus any calculations that require the use of scale height.

Link to comment
Share on other sites

A LOT of this is outdated as of aerodynamics update. KSP's game code has had an ability to handle planets with pressure-altitude relation defined by control curves for a while now. I wouldn't be surprised if that's being used now.

Has anyone done actual pressure measurements at a bunch of altitudes to test this recently?

Link to comment
Share on other sites

  • 2 weeks later...

@Everybody

I have found the correct values for scale height! I'll add those to the wiki.

Kerbol: 43429.45m (result: 600000.03m)

Eve: 6514.42m (result: 90000.01m)

Kerbin: 5066.77m (result: 70000.01m)

Duna: 3619.12m (result: 49999.99m)

Jool: 14476.48m (result: 199999.96m)

Laythe: 3619.12m (result: 49999.99m)

@-ctn-

Here are the values for the OPM planets, I added them already to my wiki

Sarnus: 22004.25m (result: 303999.95m)

Tekto: 7274.43m (result: 100499.96m)

Neidon: 8034.45m (result: 111000.03m)

Urlum: 9047.80m (result: 124999.98m)

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