Jump to content

Help with Math and atmospheric pressure


Recommended Posts

Hi Everyone,

I wonder if anyone can help me calculate pressure as I am doing it wrong but cannot figure out why?

p = p0 * e * -(alt/scale) ...

p0 = 1 atm at at sea level

e = 2.718281828 base of natural logarithm

alt = 10 km pressure I am trying to find

scale = 5km scale height for kerbin

so..

p = 1 * 2.718281828 * -(10,000 / 5000)

= -5.436563656

I was expecting a value between 1 and 0?

My math isn't great though I am trying!

Any help most appreciated!

Link to comment
Share on other sites

Hi Everyone,

I wonder if anyone can help me calculate pressure as I am doing it wrong but cannot figure out why?

p = p0 * e * -(alt/scale) ...

p0 = 1 atm at at sea level

e = 2.718281828 base of natural logarithm

alt = 10 km pressure I am trying to find

scale = 5km scale height for kerbin

so..

p = 1 * 2.718281828 * -(10,000 / 5000)

= -5.436563656

I was expecting a value between 1 and 0?

My math isn't great though I am trying!

Any help most appreciated!

Looks to me like everything's in order except for one thing: e should be raised to the power of (neg altitude/scale height), not multiplied by it.

e^(-10k/5k)= e^-2 = .135.

Best,

-Slashy

Link to comment
Share on other sites

Well I just smashed the correct formula into a simple python script to check the output up to 70km and now have an error at around 47km...

Alt : 0 1.0

Alt : 1 0.8187307531056343

Alt : 2 0.670320046080919

Alt : 3 0.5488116361496342

Alt : 4 0.44932896417792534

Alt : 5 0.36787944123356736

Alt : 6 0.30119421197323853

Alt : 7 0.24659696399990763

Alt : 8 0.2018965180492073

Alt : 9 0.16529888827183278

Alt : 10 0.13533528328232175

Alt : 11 0.11080315840349961

Alt : 12 0.09071795332618014

Alt : 13 0.07427357824694523

Alt : 14 0.060810062653971736

Alt : 15 0.049787068393087074

Alt : 16 0.04076220400039389

Alt : 17 0.033373269979487995

Alt : 18 0.027323722463903855

Alt : 19 0.022370771870521344

Alt : 20 0.018315638901106275

Alt : 21 0.014995576831113588

Alt : 22 0.012277339912191026

Alt : 23 0.010051835752442027

Alt : 24 0.008229747055690998

Alt : 25 0.006737947004774766

Alt : 26 0.005516564425605095

Alt : 27 0.0045165809467314095

Alt : 28 0.003697863719979968

Alt : 29 0.0030275547483412006

Alt : 30 0.0024787521791779297

Alt : 31 0.002029430638420578

Alt : 32 0.0016615572749697277

Alt : 33 0.0013603680390641114

Alt : 34 0.0011137751491237945

Alt : 35 0.0009118819666324642

Alt : 36 0.0007465858092844442

Alt : 37 0.0006112527618934322

Alt : 38 0.000500451434082909

Alt : 39 0.0004097349795194947

Alt : 40 0.00033546262835571747

Alt : 41 0.00027465357035247226

Alt : 42 0.00022486732449783064

Alt : 43 0.00018410579393495803

Alt : 44 0.00015073307531947874

Alt : 45 0.0001234098042742452

Alt : 46 0.00010103940199407177

Alt : 47 8.272406568794921e-05

Alt : 48 6.772873660065466e-05

Alt : 49 5.545159952394706e-05

Alt : 50 4.539992983915324e-05

Alt : 51 3.717031874815291e-05

Alt : 52 3.0432483061851678e-05

Alt : 53 2.49160097761043e-05

Alt : 54 2.0399503448377194e-05

Alt : 55 1.6701700821270857e-05

Alt : 56 1.3674196091544086e-05

Alt : 57 1.1195484864143998e-05

Alt : 58 9.166087754203352e-06

Alt : 59 7.504557930031233e-06

Alt : 60 6.144212365779335e-06

Alt : 61 5.030455617475469e-06

Alt : 62 4.1185887161601544e-06

Alt : 63 3.372015241314173e-06

Alt : 64 2.760772578004827e-06

Alt : 65 2.260329411943277e-06

Alt : 66 1.8506012017071356e-06

Alt : 67 1.5151441155718734e-06

Alt : 68 1.2404950828057307e-06

Alt : 69 1.015631473369371e-06

Alt : 70 8.315287210694906e-07

Also checked the individual values in the windows calculator and have the errors.

Whether this is a rounding error to do with the precision of the computer or a mathematical error I am unsure...

Link to comment
Share on other sites

- - - Updated - - -

Well I just smashed the correct formula into a simple python script to check the output up to 70km and now have an error at around 47km...

Alt : 0 1.0

Alt : 1 0.8187307531056343

Alt : 2 0.670320046080919

Alt : 3 0.5488116361496342

Alt : 4 0.44932896417792534

Alt : 5 0.36787944123356736

Alt : 6 0.30119421197323853

Alt : 7 0.24659696399990763

Alt : 8 0.2018965180492073

Alt : 9 0.16529888827183278

Alt : 10 0.13533528328232175

Alt : 11 0.11080315840349961

Alt : 12 0.09071795332618014

Alt : 13 0.07427357824694523

Alt : 14 0.060810062653971736

Alt : 15 0.049787068393087074

Alt : 16 0.04076220400039389

Alt : 17 0.033373269979487995

Alt : 18 0.027323722463903855

Alt : 19 0.022370771870521344

Alt : 20 0.018315638901106275

Alt : 21 0.014995576831113588

Alt : 22 0.012277339912191026

Alt : 23 0.010051835752442027

Alt : 24 0.008229747055690998

Alt : 25 0.006737947004774766

Alt : 26 0.005516564425605095

Alt : 27 0.0045165809467314095

Alt : 28 0.003697863719979968

Alt : 29 0.0030275547483412006

Alt : 30 0.0024787521791779297

Alt : 31 0.002029430638420578

Alt : 32 0.0016615572749697277

Alt : 33 0.0013603680390641114

Alt : 34 0.0011137751491237945

Alt : 35 0.0009118819666324642

Alt : 36 0.0007465858092844442

Alt : 37 0.0006112527618934322

Alt : 38 0.000500451434082909

Alt : 39 0.0004097349795194947

Alt : 40 0.00033546262835571747

Alt : 41 0.00027465357035247226

Alt : 42 0.00022486732449783064

Alt : 43 0.00018410579393495803

Alt : 44 0.00015073307531947874

Alt : 45 0.0001234098042742452

Alt : 46 0.00010103940199407177

Alt : 47 8.272406568794921e-05

Alt : 48 6.772873660065466e-05

Alt : 49 5.545159952394706e-05

Alt : 50 4.539992983915324e-05

Alt : 51 3.717031874815291e-05

Alt : 52 3.0432483061851678e-05

Alt : 53 2.49160097761043e-05

Alt : 54 2.0399503448377194e-05

Alt : 55 1.6701700821270857e-05

Alt : 56 1.3674196091544086e-05

Alt : 57 1.1195484864143998e-05

Alt : 58 9.166087754203352e-06

Alt : 59 7.504557930031233e-06

Alt : 60 6.144212365779335e-06

Alt : 61 5.030455617475469e-06

Alt : 62 4.1185887161601544e-06

Alt : 63 3.372015241314173e-06

Alt : 64 2.760772578004827e-06

Alt : 65 2.260329411943277e-06

Alt : 66 1.8506012017071356e-06

Alt : 67 1.5151441155718734e-06

Alt : 68 1.2404950828057307e-06

Alt : 69 1.015631473369371e-06

Alt : 70 8.315287210694906e-07

Also checked the individual values in the windows calculator and have the errors.

Whether this is a rounding error to do with the precision of the computer or a mathematical error I am unsure...

Pizzaboy,

those aren't actually errors. It's just providing the answer in scientific notation.

the "e-NN" means "x10^-NN"

so for the example at 47km altitude, 8.272e-05 is 8.272x10^-5, which is 0.00008272.

*edit*

Or another way of looking at it: "eNN" means "shift the decimal point this many times this way". Take 8.272 and shift the decimal point -5 places.

Best,

-Slashy

Edited by GoSlash27
Link to comment
Share on other sites

This makes me curious. Isn't the stock atmosphere pressure degradation in KSP linear instad of logarhytmic? (at least before the new aero) While Far applies the natural log ?

QPDO,

Negatory.

Pressure has always been logarithmic in KSP and FAR uses the same atmosphere, it just changes the behavior of the parts themselves. I think the source of this confusion is from people referring to stock aerodynamics as "souposphere" in comparison to FAR, but in reality the atmosphere itself is not altered.

Best,

-Slashy

Link to comment
Share on other sites

FAR does change the atmosphere: it computes density using pressure and temperature, vs. stock .90 where density is a linear function of pressure, ignoring temperature. This means that lift/drag, which are a function of Q (which is a function of density and velocity squared) will vary with temperature as well as pressure.

Link to comment
Share on other sites

FAR does change the atmosphere: it computes density using pressure and temperature, vs. stock .90 where density is a linear function of pressure, ignoring temperature.

The FAR method, as you describe it, isn't correct either. Atmospheric pressure in KSP is computed using a constant scale height, which implies constant temperature. If temperature is going to be varied, then the pressure-height profile should be reformulated. Using the same pressure-height profile as the stock game (i.e. constant scale height) while varying the temperature necessitates the improbably scenario of variable molecular weight. In real life this is not the case. The lower layers of known planetary atmospheres are well-mixed and homogeneous with constant molecular weight (though this begins to change at extreme altitudes).

The stock model is a reasonable simplification that works well for a game. If FAR wants more realism, then it should completely remodel the atmosphere rather than trying to retain some aspects of stock while changing others. All that's needed to formulate a model is the temperature-height profile (typically defined as a series of linear functions of height), the pressure at sea level, and the gas molecular weight (or, alternately, the density at sea level). Rather than using the stock formula to calculate pressure, atmospheric pressure should be computed using different formulas for each segment of the temperature-height profile.

If the FAR method, as I understand it from NathanKell's post, was intended to produce greater realism, then I believe it failed. It simply traded one unrealistic assumption (constant temperature) for a different unrealistic assumption (variable molecular weight).

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