FLUID|
begin
comment library A0, A1, A4, A5, A12, A15;
comment Specimen ALGOL program from Appendix 1 of KDF9 ALGOL manual.
This is a program for a practically arising problem.
It illustrates the use of many of the facilities available to the
ALGOL user;
real alpha, lambda, Delta alpha;
integer i, f1, f2, f3, f4, f5;
real procedure erfc (z); value z; real z;
begin comment This procedure evaluates the complementary
error function of z using the trapezoidal rule.
It halves the interval until the required accuracy
is attained, but avoids repeating the evaluation of
ordinates more than once;
real x, h, J0, J1;
integer n, i;
h := 0.1; J0 := 0; n := 0; i := 1;
R: J1 := J0;
for n := n, n + i while n × h × (n × h + 2 × z) < 11.51 do
begin
x := z + n × h;
J0 := J0 + exp(-(x^2)) × (if n = 0 then 0.5 else 1);
end ;
if abs(1 - 2 × J1/J0) > 0.00001 then
begin
i := 2; n := 1; h := h/2;
goto R
end ;
erfc := 1.128379 × J0 × h
end erfc;
open (20);
Delta alpha := read (20); close (20);
comment Delta alpha is the only input data item required by the program;
open (10);
write text (10,
[
Propagation*of*an*Impulse*into*a*Viscous-locking*Medium
[cccc_]
[ssss_]
Delta*alpha*=*
]
);
write (10, format ([d.ddddccc_]), Delta alpha);
write text(10,
[
[ssss_]
alpha
[sssss_]
[sssss_]
[sss_]
lambda
[sssssss_]
[sssssss_]
[ss_]
lambda.sqrt(2alpha)
[s_]
g
[cc_]
[ssss_]
0.0000
[sssss_]
[sssss_]
[sss_]
INFINITY
[sssss_]
[sssss_]
[sss_]
1.00000
[sssss_]
[sssss_]
[sss_]
1.00000
[c_]
]
);
f1 := format ([ssssd.dddd_]);
f2 := format ([12sd.ddddº+nd_]);
f3 := format ([12sd.ddddd_]);
f4 := format ([13sd.dddddcc_]);
f5 := format ([13sd.dddddc_]);
i := 1;
for alpha := Delta alpha step Delta alpha until 1.0 do
begin
real l1, l2;
i := i + 1;
lambda := (1 - alpha)/sqrt (2 × alpha);
if alpha = 1 then goto SKIP;
Repeat:
l1 := lambda;
l2 := sqrt (0.886227 × (1-alpha)/alpha × l1 × erfc (l1) × exp(+l1^2));
lambda := l2 + 0.835 × alpha × (l2-l1);
if abs (1-l2/lambda)>º-5 then goto Repeat;
SKIP:
write (10, f1, alpha);
write (10, f2, lambda);
write (10, f3, lambda × sqrt (2 × alpha));
write (10,
if i - i ÷ 5 × 5 = 0 then f4 else f5,
if lambda > .70710678
then 2 × lambda^2 × alpha × (1-alpha)
else
if lambda ± 0
then alpha × (1 - alpha) × exp (lambda^2) / (lambda × 2.3282180)
else 0.48394
)
end ;
newline(10, 2);
close (10)
end
|
0.1;
|