Jump to content

Atmospheric pressure equation or measurement


schedar

Recommended Posts

Hello All,

I was searching the Internet for equation that will give me exact atmospheric pressure value. Unfortunately I can't find any reliable info. I would be grateful if you could provide me with one that works for KSP. And I would like to have one that can be applied to every planet, not only Kerbin.

I've gone through the equation on wiki:

http://wiki.kerbalspaceprogram.com/wiki/Atmosphere

p=p_{0}\cdot e^{{\frac  {-altitude}{H}}}

 

But results does not correspond with Kerbin pressure table:

http://wiki.kerbalspaceprogram.com/wiki/Kerbin

 

My example results:

Altitude [km] Kerbin pressure
0 1
1 0.8187307531
2 0.670320046
3 0.5488116361
4 0.4493289641
5 0.3678794412
6 0.3011942119

 

What am I doing wrong?

Alternatively I could measure atmospheric pressure when going all the way up but how do I save the data so that I can use it in Excel?

 

Link to comment
Share on other sites

On ‎5‎/‎18‎/‎2016 at 2:21 PM, schedar said:

I've gone through the equation on wiki:

http://wiki.kerbalspaceprogram.com/wiki/Atmosphere

p=p_{0}\cdot e^{{\frac  {-altitude}{H}}}

That equation no longer works in KSP.  Back in the beta version the scale height, H, was a constant for each planet.  However, starting with v1.0 the atmospheres were changed to a more complex and realistic model.  Since H now varies, you can no longer use a simple equation.

Pressure is now computed using a float curve.  Each float curve is made up of a series cubic Hermite splines.  At the bottom of this post you will find the pressure curve data from each atmosphere.  Each set of four numbers are (1) altitude in meters, (2) pressure in kPa, (3) slope in, and (4) slope out.  If you really want to know the math, then study the links provided in this paragraph.  I've already figured all this out and created an Excel spreadsheet in which we can plug in the curve data and it converts everything to simple polynomials.  For me, I find this much easier to use.  We can just use the polynomial equations to compute the pressure at any given altitude.  Below is a link to my spreadsheet:

http://www.braeunig.us/KSP/FloatCurve.xlsx

Enter into the gray fields the curve data as listed below.  Given In the blue fields are the polynomial equations and the range over which each equation is applicable.  (The default example is the base temperature curve for Kerbin.)

Eve
 atmospherePressureCurve
 {
  key = 0 506.625 -0.08693577 -0.08693577
  key = 9723.525 113.4918 -0.0149408 -0.0149408
  key = 20000 29.0968 -0.003046887 -0.003046887
  key = 45000 0.82 -6.321458E-05 -6.321458E-05
  key = 80000 0.0035 -9.886503E-07 -9.886503E-07
  key = 90000 0 0 0
 }

Kerbin
 atmospherePressureCurve
 {
  key = 0 101.325 0 -0.01501631
  key = 1241.025 84.02916 -0.01289846 -0.01289826
  key = 2439.593 69.68138 -0.01107876 -0.01107859
  key = 3597.11 57.78001 -0.009515483 -0.009515338
  key = 4714.942 47.90862 -0.00817254 -0.008172415
  key = 5794.409 39.72148 -0.00701892 -0.007018813
  key = 6836.791 32.93169 -0.006027969 -0.006027877
  key = 7843.328 27.30109 -0.005176778 -0.0051767
  key = 8815.22 22.63206 -0.004445662 -0.004445578
  key = 10786.42 15.3684 -0.003016528 -0.00301646
  key = 12101.4 11.87313 -0.002329273 -0.00232922
  key = 13417.05 9.172798 -0.001798594 -0.001798554
  key = 16678.47 4.842261 -0.0009448537 -0.0009448319
  key = 21143.1 2.050097 -0.0003894095 -0.0003894005
  key = 26977.92 0.6905929 -0.0001252565 -0.0001252534
  key = 33593.82 0.2201734 -3.626878E-05 -3.626788E-05
  key = 42081.87 0.05768469 -9.063159E-06 -9.062975E-06
  key = 49312.13 0.01753794 -3.029397E-06 -3.029335E-06
  key = 56669.95 0.004591824 -8.827175E-07 -8.826996E-07
  key = 62300.84 0.001497072 -3.077091E-07 -3.077031E-07
  key = 70000 0 0 0
 }

Duna
 atmospherePressureCurve
 {
  key = 0 6.755 0 -0.0007
  key = 12000 1.276 -0.000223 -0.000223
  key = 20000 0.241 -4.22E-05 -4.22E-05
  key = 35000 0.015 -2.787075E-06 -2.787075E-06
  key = 50000 0 0 0
 }

Jool
 atmospherePressureCurve
 {
  key = 0 1519.875 0 -0.05753474
  key = 29000 628.0436 -0.01449255 -0.01449255
  key = 123450 22.26 -0.001562163 -0.001562163
  key = 150000 2 -0.0001361465 -0.0001361465
  key = 170000 0.1 -1.001277E-05 -1.001277E-05
  key = 200000 0 0 0
 }

Laythe
 atmospherePressureCurve
 {
  key = 0 60.795 0 -0.005216384
  key = 5250 33.40898 -0.004252711 -0.004252711
  key = 10000 17.78605 -0.002407767 -0.002407767
  key = 17000 7.100577 -0.001092064 -0.001092064
  key = 22000 3.812421 -0.0004677011 -0.0004677011
  key = 31000 1.312482 -0.0001961767 -0.0001961767
  key = 38000 0.5104055 -7.855808E-05 -7.855808E-05
  key = 50000 0 0 0
 }

 

Edited by OhioBob
fixed typo in spreadsheet link
Link to comment
Share on other sites

That is fantastic answer. Thank you very much!
I will read all the math thing but first I just wanted to try out the xls you've attached. I've tried first two polynomials for Kerbis and got following results.
I see that pressure at 0m is strangely similar to ours 1013.25 hPa and transition between two ranges seems fluent. I think it's good. What do you think?

Altitude[m] [Pa]
0 101.325
100 99.832
200 98.358
300 98.358
400 96.901
500 95.461
600 94.039
700 92.635
800 91.247
900 88.522
1000 87.185
1100 85.864
1200 84.560
1300 83.368
1400 82.216
1500 81.032
1600 79.822
1700 78.594
1800 77.356
1900 76.114
2000 74.877
Link to comment
Share on other sites

I get the same as you for the 0-1200 m range, but I get slightly different numbers for the 1300-2000 m range.  I think one of us has probably made a typo somewhere.  I've double and triple checked my numbers and I don't see an error on my end.  Here are my numbers:

1300 83.271
1400 81.999
1500 80.742
1600 79.501
1700 78.276
1800 77.066
1900 75.871
2000 74.692

The fact that Kerbin's sea level pressure is 101.325 kPa is obviously no coincidence.  Kerbin's atmosphere is based on the U.S. Standard Atmosphere of Earth.  However, the height of that model was more than was wanted in the game, so it was squashed down to 80% its original height.  Therefore, for example, the pressure found at an altitude of 10 km on Earth is found at an altitude of 8 km on Kerbin.
 

Edited by OhioBob
Link to comment
Share on other sites

As far as how to do it experimentally goes, just use the barometer and take screenshots (or even write down numbers by hand). Pressure at 0 m is also available in the tracking station. You shouldn't need too many points to get a curve that's good enough for practical purposes, in particular estimating how fast a ship will descend under parachutes on another world when you know how fast it falls on Kerbin.

Link to comment
Share on other sites

13 hours ago, cantab said:

As far as how to do it experimentally goes, just use the barometer and take screenshots (or even write down numbers by hand). Pressure at 0 m is also available in the tracking station. You shouldn't need too many points to get a curve that's good enough for practical purposes, in particular estimating how fast a ship will descend under parachutes on another world when you know how fast it falls on Kerbin.

If real high accuracy isn't needed, then what you suggest will work.  However, if we want an equation to give pressure as a function of altitude, it is be best to plot LN(pressure) vs. altitude.  This will give a relatively straight distribution of points through which it is easy to plot a good trendline and obtain an equation.  Therefore, to get the pressure we would plug altitude into the equation to obtain LN(pressure), and then we take EXP() of that value to get the pressure.

Link to comment
Share on other sites

Yes, typo on my side. Yours is correct. So here you go - the whole plot for Kerbin:

Spoiler

atmo.png

 

And just for the record all the steps in MATLAB (or Octave) to get the plot:

Spoiler

%all altitude ranges that correspond to polynomials
alt1=[0:1241];
alt2=[1242:2440];
alt3=[2441:3597];
alt4=[3598:4715];
alt5=[4716:5794];
alt6=[5795:6837];
alt7=[6838:7843];
alt8=[7844:8815];
alt9=[8816:10786];
alt10=[10787:12101];
alt11=[12102:13417];
alt12=[13418:16678];
alt13=[16679:21143];
alt14=[21144:26978];
alt15=[26979:33594];
alt16=[33595:42082];
alt17=[42083:49312];
alt18=[49313:56670];
alt19=[56671:62301];
alt20=[62302:70000];

%full altitude range
alt0 = [0:70000];

%polynomials and their coefficients
y1=[-0.0000000000268120844372701 0.000000903178153766644 -0.01501631 101.325];
y2=[-0.0000000000246999565686753 0.000000895397433845737 -0.0150065568012969 101.320842429958];
y3=[-0.0000000000227285651065375 0.000000881006686570721 -0.0149713705517731 101.292026825343];
y4=[-0.0000000000209739058166392 0.000000862130326936606 -0.0149035365320712 101.210597011028];
y5=[-0.000000000019290742126495 0.000000838388914636763 -0.0147917863784581 101.035066124462];
y6=[-0.0000000000177913844672599 0.000000812368539810303 -0.0146411575806572 100.744202434623];
y7=[-0.0000000000163765649174991 0.000000783400632255324 -0.0144433637816262 100.293812719104];
y8=[-0.0000000000150722087070571 0.000000752711810021787 -0.0142026041346256 99.6640070881201];
y9=[-0.0000000000237596247475928 0.00000106107366057429 -0.0176138273607363 111.723477518828];
y10=[-0.0000000000171481727631151 0.000000850018244016114 -0.0153683595924193 103.761405478354];
y11=[-0.0000000000132149603591211 0.000000707497213645447 -0.0136468832776064 96.8301203523764];
y12=[-0.00000000000825368303661786 0.000000503476944708841 -0.0108514891919671 84.0683679209407];
y13=[-0.00000000000418646062975494 0.000000299710282383075 -0.00744858944658638 65.1254891451002];
y14=[-0.00000000000142928163807707 0.000000125802880994498 -0.00379232806881419 39.5029402529266];
y15=[-0.000000000000441246324335998 0.0000000468156442657168 -0.00168780277526971 20.8149543781124];
y16=[-0.0000000000000977775034730904 0.0000000127016007381843 -0.000558619595473097 8.35896812652954];
y17=[-0.0000000000000188835649357046 0.00000000300601168529362 -0.000161738364205585 2.94788309823452];
y18=[-7.26010197351513E-015 0.00000000130003426246205 -0.000078281383530526 1.58705499119165];
y19=[-2.87645148397864E-015 0.000000000564377362687773 -0.0000371361463152683 0.82010556219898];
y20=[1.36965612496281E-015 -0.00000000025182708303356 0.000015121846587745 -0.294368605139953];

%evaluation of pressure at each altitude range
pre1=polyval(y1,alt1);
pre2=polyval(y2,alt2);
pre3=polyval(y3,alt3);
pre4=polyval(y4,alt4);
pre5=polyval(y5,alt5);
pre6=polyval(y6,alt6);
pre7=polyval(y7,alt7);
pre8=polyval(y8,alt8);
pre9=polyval(y9,alt9);
pre10=polyval(y10,alt10);
pre11=polyval(y11,alt11);
pre12=polyval(y12,alt12);
pre13=polyval(y13,alt13);
pre14=polyval(y14,alt14);
pre15=polyval(y15,alt15);
pre16=polyval(y16,alt16);
pre17=polyval(y17,alt17);
pre18=polyval(y18,alt18);
pre19=polyval(y19,alt19);
pre20=polyval(y20,alt20);

%pressure at full altutude range
pre0 = [pre1 pre2 pre3 pre4 pre5 pre6 pre7 pre8 pre9 pre10 pre11 pre12 pre13 pre14 pre15 pre16 pre17 pre18 pre19 pre20];


%visualising all sub-plots together
plot(alt0,pre0), xlabel('
Altitude[m]'), ylabel(' Pressure[Pa]'), grid on
plot(pre1,alt1,pre2,alt2,pre3,alt3,pre4,alt4,pre5,alt5,pre6,alt6,pre7,alt7,pre8,alt8,pre9,alt9,pre10,alt10,pre11,alt11,pre12,alt12,pre13,alt13,pre14,alt14,pre15,alt15,pre16,alt16,pre17,alt17,pre18,alt18,pre19,alt19,pre20,alt20), xlabel('Pressure[Pa]'), ylabel('Altitude[m]'), grid on

 

By the way I'm struggling with cubic Hermite splines article because there's no polish translation. Could you tell me which equation have you used?

 

 

 

Edited by schedar
Link to comment
Share on other sites

  • 2 weeks later...
On ‎5‎/‎19‎/‎2016 at 0:32 PM, schedar said:

By the way I'm struggling with cubic Hermite splines article because there's no polish translation. Could you tell me which equation have you used?

Sorry for taking so long to respond, I just now saw your post.  The equation that I use is the very first one under the heading Unit interval (0, 1).

It is a pain in the neck to work with, so it's no surprise that you're struggling.  As you can see from the article, the equations works over the interval of t=0 to t=1.  The means the that for each interval, the altitude must be normalized to a number between 0 and 1.  This can probably best be explained with an example.  Let's take Duna and use the interval between the second and third keys, i.e. the altitude range 12000-20000 m.  Here we have,

po = 1.276
p1 = 0.241

The variable t represents the altitude, but we can't enter the altitude directly.  It must be entered as a number between 0 and 1.  Therefore, if we want the pressure at 12000 m, we enter t=0.  For the pressure at 20000 m, we enter t=1.  For the pressure at 15000 m, we enter

t = (15000-12000)/(20000-12000) = 0.375

Because the value of t ranges from 0-1 instead of 12000-20000, we must change the slope accordingly.  The in and out slopes are,

mo = -0.000223*(20000-12000) = -1.784
m1 = -4.22E-05*(20000-12000) = -0.3376

We now plug these numbers into the equation and we should get our answer.

c67f2482bc328d3c50769b8d860b9488c936af63

 

Edited by OhioBob
fixed typo
Link to comment
Share on other sites

  • 2 weeks later...
  • 1 year later...
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...