-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconversions.pas
212 lines (191 loc) · 6.39 KB
/
conversions.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
unit Conversions;
{$mode ObjFPC}{$H+}
interface
uses
Classes, SysUtils, Math;
function CH2O (t, rh : real) : real; // Temperature °C, relative Humidity in %,
// -> water mass concentration g/m³
function H2Opsat (t : real) : real; // Temperature °C
// - > saturation water vapor pressure hPa
function H2Oppart (t, rh : real) : real; // Temperature °C, relative Humidity in %,
// -> partial water vapor Pressure hPa
function Dewpoint (t, ppartw : real) : real; // Temperature °C, partial water vapor Pressure hPa,
// -> dew point temperature in °C
function SeaLevelReduction(t, rh, e, p : real) : real; // Temperature °C, relative Humidity %, Elevation m, air Pressure absolute hPa
// -> air pressure sea level hPa
implementation
function SeaLevelReduction(t, rh, e, p : real) : real;
{
QFF
"Atmospheric pressure at a place, reduced to MSL using
the actual temperature at the time of observation as
the mean temperature."
calculation per
DWD, Vorschriften und Betriebsunterlagen 3, BEOBACHTERHANDBUCH, Page 6-11
VuB 3 BHB - Dezember 2015
}
const
g = 9.80665; // gravitation constant standard value
R = 287.05; // gas constant dry air (= R/M)
alpha = 0.0065; // vertical temperature gradient
Ch = 0.12; // factor for E
Var
ph : real; // absolute air pressure at barometer elevation (in hPa, 0.1 hPa accuracy)
P0 : real; // sea level reduced air pressure (in hPa)
h : real; // barometer elevation (in m, 0.1 m accuracy)
ThK : real; // barometer ambient temperature (in K, where as T(h) = t(h) + 273,15)
ThC : real; // barometer ambient temperature (in °C)
Hum : real; // rel. humidity (in %)
Pp : real; // partial water vapor pressure (in hPa)
x : real; // exponent for expression
begin
h := e; // adapt to local value
ThC := t;
Hum := rh;
ph := p; // in hPa
Pp := H2Oppart(ThC, Hum); // artial water vapor pressure
ThK := ThC + 273.15; // Temperature in K
x := g/(R*(ThK + Ch*Pp+alpha*h/2))*h;
P0 := ph * exp(x);
result:=P0;
end{ sealevelreduction };
function dewpoint (T, ppartw : real) : real; // dew point calculation
var
td : real;
begin
td:=T;
while H2Opsat(td) >= ppartw do td:=td-0.01;
result:=td;
end;
function H2Oppart (t, rh : real) : real; // partial vapor pressure
begin
result:=rh/100*H2Opsat(T);
end;
function CH2O (t, rh : real) : real; // water mass concentration
const
//Temperature range -50°C to +50°C
//over water Coefficients
a0 = 6.107799961;
a1 = 4.436518521E-1;
a2 = 1.428945805E-2;
a3 = 2.650648471E-4;
a4 = 3.031240396E-6;
a5 = 2.034080948E-8;
a6 = 6.136820929E-11;
//over ice Coefficients
b0 = 6.109177956;
b1 = 5.034698970E-1;
b2 = 1.886013408E-2;
b3 = 4.176223716E-4;
b4 = 5.824720280E-6;
b5 = 4.838803174E-8;
b6 = 1.838826904E-10;
//Temperature range -100°C to -50°C
//over water Coefficients
c0 = 4.866786841;
c1 = 3.152625546E-1;
c2 = 8.640188586E-3;
c3 = 1.279669658E-4;
c4 = 1.077955914E-6;
c5 = 4.886796102E-9;
c6 = 9.296508850E-12;
//over ice Coefficients
d0 = 3.927659727;
d1 = 2.643578680E-1;
d2 = 7.505070860E-3;
d3 = 1.147668232E-4;
d4 = 9.948650743E-7;
d5 = 4.626362556E-9;
d6 = 9.001382935E-12;
R = 8.31446261815324; // Universal gas constant
M = 18.01528; // molar mass of water
var
sat_vap_press,
sat_vap_press_w,
sat_vap_press_i,
Mass_conc_H2O : real;
begin
if (t>50) or (t<-100) then
begin
result:=-1;
exit;
end;
if t>-50 then begin
sat_vap_press_w :=a0 + T*(a1 + T*(a2 + T*(a3 + T*(a4 + T*(a5 + T*a6)))));
sat_vap_press_i :=b0 + T*(b1 + T*(b2 + T*(b3 + T*(b4 + T*(b5 + T*b6)))));
end else
begin
sat_vap_press_w :=c0 + T*(c1 + T*(c2 + T*(c3 + T*(c4 + T*(c5 + T*c6)))));
sat_vap_press_i :=d0 + T*(d1 + T*(d2 + T*(d3 + T*(d4 + T*(d5 + T*d6)))));
end;
sat_vap_press:=min(sat_vap_press_w, sat_vap_press_i); // in hPa
Mass_conc_H2O := rh * sat_vap_press * M / (R * (T + 273.15)); //
result:= Mass_conc_H2O;
end;
function H2Opsat (t : real) : real; //saturation water vapor pressure
//
// The Computation of Saturation Vapor Pressure
// Paul R. Lowe, et al
// Environmental Prediction Research Facility (Navy)
// Monterey, California
// March 1974
//
// https://apps.dtic.mil/sti/citations/AD0778316
//
const
//Temperature range -50°C to +50°C
//over water Coefficients
a0 = 6.107799961;
a1 = 4.436518521E-1;
a2 = 1.428945805E-2;
a3 = 2.650648471E-4;
a4 = 3.031240396E-6;
a5 = 2.034080948E-8;
a6 = 6.136820929E-11;
//over ice Coefficients
b0 = 6.109177956;
b1 = 5.034698970E-1;
b2 = 1.886013408E-2;
b3 = 4.176223716E-4;
b4 = 5.824720280E-6;
b5 = 4.838803174E-8;
b6 = 1.838826904E-10;
//Temperature range -100°C to -50°C
//over water Coefficients
c0 = 4.866786841;
c1 = 3.152625546E-1;
c2 = 8.640188586E-3;
c3 = 1.279669658E-4;
c4 = 1.077955914E-6;
c5 = 4.886796102E-9;
c6 = 9.296508850E-12;
//over ice Coefficients
d0 = 3.927659727;
d1 = 2.643578680E-1;
d2 = 7.505070860E-3;
d3 = 1.147668232E-4;
d4 = 9.948650743E-7;
d5 = 4.626362556E-9;
d6 = 9.001382935E-12;
var
sat_vap_press,
sat_vap_press_w,
sat_vap_press_i : real;
begin
if (t>50) or (t<-100) then
begin
result:=-1;
exit;
end;
if t>-50 then begin
sat_vap_press_w :=a0 + T*(a1 + T*(a2 + T*(a3 + T*(a4 + T*(a5 + T*a6)))));
sat_vap_press_i :=b0 + T*(b1 + T*(b2 + T*(b3 + T*(b4 + T*(b5 + T*b6)))));
end else
begin
sat_vap_press_w :=c0 + T*(c1 + T*(c2 + T*(c3 + T*(c4 + T*(c5 + T*c6)))));
sat_vap_press_i :=d0 + T*(d1 + T*(d2 + T*(d3 + T*(d4 + T*(d5 + T*d6)))));
end;
sat_vap_press:=min(sat_vap_press_w, sat_vap_press_i); // in hPa
result:= sat_vap_press;
end;
end.