(41) Density Altitude accounting for humidity - WrongWay - 12-14-2020 09:56 PM
This program takes the inputs of Latitude, Station Elevation, Sea Level Pressure (QNH) inHg, Temperature (c), Dewpoint (c), and, outputs the density altitude of the location. Density Altitude is the equivalent ISA altitude for an elevation under non ISA conditions. The programs uses the WGS84 spheroid to calculate radius for geopotential altitude.
Suggestions for optimization are appreciated, for instance, on line 64 I have to rerun RADIUS in order for GEOPOT to output sensible numbers but im not sure why, eliminating that would speed this up greatly.
size: 542 bytes [021E]
Step - Instructions - INPUT - Function - Display
1) Begin the program - XEQ DALT
2) Input Station Latitude - L - R/S - LATITUDE DMS?
a)input format is in DD.MMSS
3) Input Station Elevation - A - R/s - ELEVATION FEET?
4) Input Temperature degrees C - T_c - R/S - TEMP C?
5) Input Dewpoint degrees C - T_d - R/S - DEW C?
6) Input Station QNH (sea level pressure) - P_s - R/S - QNH IN?
Commented code at the bottom
Code:
LBL "DALT"
"LATITUDE DMS?"
PROMPT
HR
STO 90
"ELEVATION FT?"
PROMPT
3.2808
/
STO 01
XEQ "RADIUS"
XEQ "GEOPOT"
"TEMP C?"
PROMPT
STO 02
273.15
+
STO 03
"DEW C?"
PROMPT
STO 04
273.15
+
STO 05
XEQ "VP"
"QNH IN?"
PROMPT
33.8639
*
0.190263
Y^X
RCL 91
8.417286 E-05
*
-
0.190263
1/X
Y^X
RCL 92
-
100
*
287.05
RCL 03
*
/
RCL 92
100
*
RCL 03
461.495
*
/
+
0.234969
Y^X
-42.2665
*
44.3308
+
1000
*
STO 01
XEQ "RADIUS"
XEQ "GEOPOT"
3.2808
*
FIX 0
"D.ALT: "
ARCL X
AVIEW
FIX 4
STOP
LBL "RADIUS"
RCL 90
ENTER
COS
6378137
X^2
*
X^2
X<>Y
SIN
6356752.314
X^2
*
X^2
+
RCL 90
ENTER
COS
6378137
*
X^2
X<>Y
SIN
6356752.314
*
X^2
+
/
STO 90
RTN
LBL "GEOPOT"
RCL 90
ENTER
RCL 01
*
X<>Y
RCL 01
+
/
STO 91
RTN
LBL "VP"
RCL 04
ENTER
ENTER
ENTER
-0.30994571 E-19
*
0.11112018 E-16
+
*
-0.17892321 E-14
+
*
0.21874425 E-12
+
*
-0.29883885 E-10
+
*
0.43884187 E-08
+
*
-0.61117958 E-06
+
*
0.787736169 E-04
+
*
-0.90826951 E-02
+
*
0.99999683
+
8
Y^X
6.1078
X<>Y
/
STO 92
RTN
END
COMMENTED CODE
Code:
LBL "DALT"
"LATITUDE DMS?"
PROMPT
HR
STO 90 ;LATITUDE HRS
"ELEVATION FT?"
PROMPT
3.2808
/
STO 01 ;ELEVATION METERS
XEQ "RADIUS"
XEQ "GEOPOT"
"TEMP C?"
PROMPT
STO 02 ;TEMPC
273.15
+
STO 03 ;TEMPK
"DEW C?"
PROMPT
STO 04
273.15
+
STO 05
XEQ "VP" ;RESULT IN REGISTER 92
"QNH IN?"
PROMPT
33.8639
*
STO 08 ;SEA LEVEL PRESSURE MILLIBAR
0.190263
Y^X
RCL 91
8.417286 E-05
*
-
0.190263
1/X
Y^X ;ABSOLUTE PRESSURE IN MILLIBAR
RCL 92
- ;DRY AIR PRESSURE P_D
100
*
287.05
RCL 03
*
/
RCL 92
100
*
RCL 03
461.495
*
/
+ ;AIR DENSITY RHO
0.234969
Y^X
-42.2665
*
44.3308
+
1000
* ;ISA GEOPOTENTIAL HEIGHT AS A FUNCTION OF NON STD DENISTY
STO 01 ;USING THE ABOVE AS THE NEW ELEVATION FOR THE GEOMETRIC ALTITUDE CALCULATION
XEQ "RADIUS" ;NOT SURE WHY THIS HAS TO BE RERUN TO PUT THE STACK IN THE CORRECT ORDER
XEQ "GEOPOT"
3.2808
*
FIX 0
"D.ALT: "
ARCL X
AVIEW
FIX 4
STOP
LBL "RADIUS" ;REQUIRES LATITUDE IN HRS IN REGISTER 90
RCL 90
ENTER
COS
6378137 ;WGS84_a
X^2
*
X^2
X<>Y
SIN
6356752.314 ;WGS84_b
X^2
*
X^2
+
RCL 90
ENTER
COS
6378137
*
X^2
X<>Y
SIN
6356752.314
*
X^2
+
/
STO 90 ;STORES RADIUS IN METERS IN REGISTER AS LAT IS NO LONGER REQUIRED
RTN
LBL "GEOPOT"
RCL 90 ;RECALL RADIUS METERS
ENTER
RCL 01 ;RECALL ELEVATION METERS
*
X<>Y
RCL 01
+
/
STO 91 ;GEOPOTENTIAL ALTITUDE (H)
RTN
LBL "VP" ;THIS IS ONLY RUN ONCE USING DEWPOINT TEMPERATURE
RCL 04
ENTER
ENTER
ENTER
-0.30994571 E-19 ;C9
*
0.11112018 E-16 ;C8
+
*
-0.17892321 E-14 ;C7
+
*
0.21874425 E-12 ;C6
+
*
-0.29883885 E-10 ;C5
+
*
0.43884187 E-08 ;C4
+
*
-0.61117958 E-06 ;C3
+
*
0.787736169 E-04 ;C2
+
*
-0.90826951 E-02 ;C1
+
*
0.99999683 ;c0
+
8
Y^X
6.1078
X<>Y
/
STO 92 ;P_V ACTUAL VAPOR PRESSURE
RTN
END
|