Air mass: Difference between revisions

2,469 bytes added ,  11 months ago
no edit summary
(RPL: add section)
No edit summary
Line 477:
90 34.32981136 34.36666557
</pre>
 
=={{header|Delphi}}==
{{works with|Delphi|6.0}}
{{trans|GO}}
{{libheader|SysUtils,StdCtrls}}
 
<syntaxhighlight lang="Delphi">
 
const RE = 6371000; { radius of earth in meters}
const DD = 0.001; { integrate in this fraction of the distance already covered}
const FIN = 1e7; { integrate only to a height of 10000km, effectively infinity}
 
function rho(a: double): double;
{ The density of air as a function of height above sea level.}
begin
Result:=Exp(-a / 8500);
end;
 
function Radians(degrees: double): double;
{ Converts degrees to radians}
begin
Result:= degrees * Pi / 180
end;
 
function Height(A, Z, D: double): double;
{ a = altitude of observer}
{ z = zenith angle (in degrees)}
{ d = distance along line of sight}
var AA,HH: double;
begin
AA := RE + A;
HH := Sqrt(AA*AA + D*D - 2*D*AA*Cos(Radians(180-z)));
Result:= HH - RE;
end;
 
function ColumnDensity(A, Z: double): double;
{ Integrates density along the line of sight.}
var Sum,D,Delta: double;
begin
Sum := 0.0;
D := 0.0;
while D < FIN do
begin
delta := Max(DD, DD*D); { adaptive step size to avoid it taking forever}
Sum:=Sum + Rho(Height(A, Z, D+0.5*Delta)) * Delta;
D:=D + delta;
end;
Result:= Sum;
end;
 
 
function AirMass(A, Z: double): double;
begin
Result:= ColumnDensity(A, Z) / ColumnDensity(a, 0);
end;
 
procedure ShowAirMass(Memo: TMemo);
var Z: integer;
begin
Memo.Lines.Add('Angle 0 m 13700 m');
Memo.Lines.Add('------------------------------------');
Z:=0;
while Z<=90 do
begin
Memo.Lines.Add(Format('%2d %11.8f %11.8f', [z, airmass(0, Z), airmass(13700, Z)]));
Z:=Z+5;
end;
end;
 
 
 
</syntaxhighlight>
{{out}}
<pre>
Angle 0 m 13700 m
------------------------------------
0 1.00000000 1.00000000
5 1.00380963 1.00380965
10 1.01538466 1.01538475
15 1.03517744 1.03517765
20 1.06399053 1.06399093
25 1.10305937 1.10306005
30 1.15418974 1.15419083
35 1.21998076 1.21998246
40 1.30418931 1.30419190
45 1.41234169 1.41234567
50 1.55280404 1.55281025
55 1.73875921 1.73876915
60 1.99212000 1.99213665
65 2.35199740 2.35202722
70 2.89531368 2.89537287
75 3.79582352 3.79596149
80 5.53885809 5.53928113
85 10.07896219 10.08115981
90 34.32981136 34.36666557
 
Elapsed Time: 189.304 ms.
 
</pre>
 
 
=={{header|Factor}}==
465

edits