3 XCSoar Glide Computer - http://www.xcsoar.org/
4 Copyright (C) 2000-2013 The XCSoar Project
5 A detailed list of copyright holders can be found in the file "AUTHORS".
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include "test_debug.hpp"
25 #include "Atmosphere/AirDensity.hpp"
26 #include "Atmosphere/Pressure.hpp"
31 AtmosphericPressure sp
= AtmosphericPressure::Standard().QNHAltitudeToStaticPressure(fixed(100));
32 AtmosphericPressure pres
=
33 AtmosphericPressure::FindQNHFromPressure(sp
, fixed(100));
34 return fabs(pres
.GetHectoPascal() - fixed(1013.25)) < fixed(0.01);
40 AtmosphericPressure sp
= AtmosphericPressure::Standard().QNHAltitudeToStaticPressure(fixed(100));
41 AtmosphericPressure pres
=
42 AtmosphericPressure::FindQNHFromPressure(sp
, fixed(120));
44 printf("%g\n",FIXED_DOUBLE(pres
.GetHectoPascal()));
46 return fabs(pres
.GetHectoPascal() - fixed(1015.6)) < fixed(0.1);
47 // example, QNH=1014, ps=100203
56 AtmosphericPressure pres
= AtmosphericPressure::Standard();
57 fixed p0
= pres
.QNHAltitudeToStaticPressure(fixed(0)).GetPascal();
59 printf("%g\n",FIXED_DOUBLE(p0
));
61 return fabs(p0
-fixed(101325))<fixed(0.1);
67 AtmosphericPressure sp
= AtmosphericPressure::Standard().QNHAltitudeToStaticPressure(fixed(100));
68 AtmosphericPressure pres
=
69 AtmosphericPressure::FindQNHFromPressure(sp
, fixed(120));
70 fixed h0
= pres
.PressureAltitudeToQNHAltitude(fixed(100));
72 printf("%g\n",FIXED_DOUBLE(h0
));
74 return fabs(h0
-fixed(120))<fixed(1);
80 AtmosphericPressure sp
= AtmosphericPressure::Standard().QNHAltitudeToStaticPressure(fixed(100));
81 AtmosphericPressure pres
=
82 AtmosphericPressure::FindQNHFromPressure(sp
, fixed(120));
83 fixed h0
= pres
.StaticPressureToQNHAltitude(pres
);
85 printf("%g %g\n", FIXED_DOUBLE(pres
.GetPascal()), FIXED_DOUBLE(h0
));
87 return fabs(h0
)<fixed(1);
91 test_isa_pressure(const fixed alt
, const fixed prat
)
93 const AtmosphericPressure pres
= AtmosphericPressure::Standard();
94 fixed p0
= pres
.QNHAltitudeToStaticPressure(alt
).GetPascal();
96 printf("%g\n",FIXED_DOUBLE(p0
));
98 return fabs(p0
/fixed(101325)-prat
)<fixed(0.001);
102 test_isa_density(const fixed alt
, const fixed prat
)
104 fixed p0
= AirDensity(alt
);
106 printf("%g\n",FIXED_DOUBLE(p0
));
108 return fabs(p0
/fixed(1.225)-prat
)<fixed(0.001);
111 int main(int argc
, char** argv
)
114 if (!ParseArgs(argc
,argv
)) {
120 ok(test_find_qnh(),"find qnh 0-0",0);
121 ok(test_find_qnh2(),"find qnh 100-120",0);
123 ok(test_qnh_to_static(),"qnh to static",0);
124 ok(test_qnh_round(),"qnh round trip",0);
126 ok(test_qnh_round2(),"qnh round 2",0);
128 ok(test_isa_pressure(fixed(1524), fixed(0.8320)), "isa pressure at 1524m",0);
129 ok(test_isa_pressure(fixed(6096), fixed(0.4594)), "isa pressure at 6096m",0);
131 ok(test_isa_density(fixed(1524), fixed(0.8617)), "isa density at 1524m",0);
132 ok(test_isa_density(fixed(6096), fixed(0.5328)), "isa density at 6096m",0);
134 return exit_status();