]> git.mxchange.org Git - flightgear.git/blob - src/WeatherCM/air-pressure-explanation.txt
Update from JSBSim
[flightgear.git] / src / WeatherCM / air-pressure-explanation.txt
1 The formula p(x) for calculating the air pressure at a given altitude
2 ---------------------------------------------------------------------
3
4 Well known is the baromertic(?) formula
5
6                    rho0
7                   ------ * g * x
8                     p0
9     p(x) = p0 * e
10
11 with p0 being the airpressure and rho0 being the air density at an altitude of
12 0 metres above sea level and g being the gravity constant of 9.81 m/sq. sec
13
14 This formula can easily be derivated when you know, that:
15
16  * the pressure difference is
17
18     dp = - rho * g * dx
19
20  * Boyle-Mariotte says:
21
22     p0 : p = rho0 : rho
23
24 Combinig the terms and changing them around I get:
25
26     dp                 [  rho0         ]
27         -- = - rho * g = - [ ------ * p(x) ] * g
28         dx                 [   p0          ]
29
30                rho0
31         p'(x) = - ------ * p(x) * g
32                     p0
33
34 Solving that differential equation and knowing that p(0) = p0 I get:
35
36                      rho0
37                   - ------ * g * x
38                       p0
39     p(x) = p0 * e
40
41 q.e.d.
42
43 -------------------------------------------------------------------------------
44
45 The problem with that equation is that it doesn't take different temperatures
46 at different altitudes into account. And the inaccuracies due to it are huge.
47 That's why this formula is only used in very low altitudes.
48
49 So to get a usefull formula for FlightGear I need to extend it. And as I'm
50 already 'recreating' that formula I'm taking the change in g into account, too.
51 This doesn't make such a dramatic difference to the result as the inclusion of
52 temperature change does, but it doesn't complicate the final formula too much.
53
54 So I get three formulas that I'm combining in the end:
55
56  * the change of g with the altitude:
57
58                G * m
59      g(x) = -----------
60              (x + r)^2
61     G is the universal gravity constant(?) and is 6.673e-11 m^3 kg^-1 s^-2
62         m is the mass of the earth and is             5.977e24 kg
63         r is the radius of the earth and is           6368 km
64
65  * The pressure difference stays the same:
66
67     dp = - rho * g(x) * dx
68
69  * If I combine Boyle-Mariotte with Gay-Lussac I get:
70
71            rho0 * T0     p
72     rho = ----------- * ---
73                p0        T
74
75 Combining the terms again I get this time:
76
77     dp                    [  rho0 * T0     p(x)  ]
78         -- = - rho * g(x) = - [ ----------- * ------ ] * g(x)
79         dx                    [      p0        T(x)  ]
80
81                rho0 * T0     p(x) * g(x)
82         p'(x) = - ----------- * -------------
83                        p0           T(x)
84
85 This DE isn't that easy to solve as the one above, it by looking into the right
86 books you'll see the general solution for:
87
88     y' + f(x)*y = 0
89
90 is
91                  x
92                  /\
93               -  |  f(x) dx
94                 \/
95                  n
96     y = m * e 
97
98 and P(m,n) will be a point on the graph.
99
100 For q = n = 0 metres altitude we get y = m. As y is p(x) we know that m has to
101 be p0.
102
103 So our final formuala is
104
105               ho0 * T0     g(x)
106         f1(x) = ----------- * ------
107                      p0        T(x)
108
109
110                      x                     x
111                      /\                    /\
112                   -  |  f1(x) dx           |  f(x) dx
113                     \/                    \/
114                      0                     0                   F(x) - F(0)
115     p(x) = p0 * e                = p0 * e             = p0 * e
116
117 The only disturbing thing we've got left is the integral. Luckily there is a
118 great service at http://integrals.wolfram.com/ that helps me doing it :-)
119
120 But the f(x) is still too general so I'm substituting:
121
122                 rho0 * T0 * G * m
123         f(x) = - -----------------------
124                   p0 * (x + r)^2 * T(x)
125
126 but even that isn't good enough. But as I'm linearily interpolating between
127 two different temperatures I can say that T(x) = a*x + b for the x inbetween 
128 two different stored temperatures. So I just need to integrate every pice
129 independandly. But anyway, I get:
130    
131                     rho0 * T0 * G * m
132         f(x) = - ------------------------------
133                   p0 * (x + r)^2 * (a * x + b)
134
135 Integrating that I get:
136
137               rho0 * T0 * G * m    [            1
138     F(x) = - ------------------- * [ ------------------------ -
139                           p0           [  (-b + a * r) * (r + x) 
140
141
142                                            a * log|r + x|     a * log|b + a * x|  ]
143                                           ---------------- + -------------------- ]
144                                            (b - a * r)^2        (b - a * r)^2     ]
145
146 To lower the computional cost I can transfere the equation.
147
148  * I'm defining
149
150                 rho0 * T0 * G * m    
151     factor = - ------------------- 
152                             p0 
153                1
154         c = --------------
155              (-b + a * r)
156
157  * now I can write
158
159                     [     c                                                 ]
160         F(x) = factor * [ --------- - a * c * c * [log|r + x| + log|b + a * x|] ]
161                         [  (r + x)                                              ]
162
163  * and simplyfy it to
164
165                         [     1                                          ]
166         F(x) = factor * c * [ --------- - a * c * log|(r + x) * (b + a * x)| ]
167                             [  (r + x)                                       ]
168
169 -------------------------------------------------------------------------------
170 The following table shows quite nicely how accurate my formula is:
171
172  Altitude[m] | Airpressure [hPa]             | Error [%]
173              |    Official   |   My formula  |
174  ------------+---------------+---------------+---------------
175       -200   | 1037.51       | 1037.24       |  0.0260     
176       -100   | 1025.32       | 1025.19       |  0.0127    
177          0   | 1013.25       | 1013.25       |  0.0   
178        500   |  954.59       |  955.224      |  0.0664     
179       1000   |  898.70       |  899.912      |  0.1349     
180       2000   |  794.88       |  797.042      |  0.2720     
181       3000   |  700.99       |  703.885      |  0.4130     
182       4000   |  616.28       |  619.727      |  0.5593     
183       5000   |  540.07       |  543.89       |  0.7073    
184       6000   |  471.67       |  475.731      |  0.8610     
185       7000   |  410.46       |  414.643      |  1.0191     
186       8000   |  355.84       |  360.054      |  1.1842     
187       9000   |  307.27       |  311.422      |  1.3513     
188      10000   |  264.21       |  268.238      |  1.5245     
189      20000   |   54.670/55.3 |   55.7971     |  2.0616/0.8989      
190      30000   |   11.8        |   11.3149     |  1.5441      
191      40000   |    3.0        |    2.74665    | 18.9703       
192      50000   |    0.88       |    0.753043   | 41.9183
193      60000   |    0.257      |    0.221907   | 57.9802
194      70000   |    0.0602     |    0.0530785  | 61.9153
195      80000   |    0.0101     |    0.00905461 | 51.5725
196     100000   |    2.14e-4    |    2.03984e-4 |  5.5131
197
198 The official values are from the CINA atmosphere which assumes a air pressure
199 of 1013.25 hPa and a temperature of 15 degC at sea level and a temperature
200 gradient of -6.5 deg/km. The CINA atmosphere gives only values for altiudes 
201 up to 20 km. The values for 20 km and above are from the 1959 ARDC atmosphere.
202 That's why I've got two values at 20000 metres.
203 The temperature changes dramtically in the altitudes over 20 km which I didn't
204 take care of in my calculations which explains the huge errors at that altitude
205 range. But you can see nicely that the values are at least quite close to the
206 official values.
207 Using a better temperature model for the altitudes above 20 km should
208 dramatically increase the accuracy there.
209
210
211
212