Код программы.
Program My;
uses crt;
var L,as,bs,aa,bb,cc,qq,q:real; Ps,Pi,Ti,k1,Xi,Yi,Ci:array [1..3] of real;
wi,a,b,Fi1,fi2:array [1..3] of real; yy,fug1,fug2,t,t1:real;y1,y2,y3,z,k,z1,sumk:real; i,ii,j:integer;
function sum(z:real):real;
var n,P:real;
begin
p:=0;
while p<20000000 do begin
p:=p+100;
n:=n+((z-1)/p);
end;
sum:=n;
end;
const
P=20000000;
Te=300;
Vc6=343;
Vc5=276;
Vc4=234;
V=0.4;
R=8.31;
begin
clrscr;
wi[1]:=0.121;
wi[2]:=0.164;
wi[3]:=0.202;
Pi[1]:=3200000;
Pi[2]:=3800000;
Pi[3]:=4150000;
Ti[1]:=501;
Ti[2]:=484;
Ti[3]:=435.6;
Ci[1]:=0.3;
Ci[2]:=0.4;
Ci[3]:=0.3;
for i:=1 to 3 do begin
Ps[i]:=Pi[i]*exp(5.37*(1-wi[i])*(1-Ti[i]/Te));
k1[i]:=Ps[i]/P;
end;
repeat
for i:=1 to 3 do begin
Xi[i]:=Ci[i]/(k1[i]*V+1-V);
Yi[i]:=Ci[i]*k1[i]/(k1[i]*V+1-V);
end;
for i:=1 to 3 do begin
a[i]:= 0.46*R*R*Ti[i]*Ti[i]/Pi[i];
end;
as:=0;
for i:=1 to 3 do begin
for j:=1 to 3 do begin
as:=as+Xi[i]*Xi[j]*sqrt(a[i]*a[j]);
end;
end;
for i:=1 to 3 do begin
b[i]:=0.078*R*Ti[i]/Pi[i];
end;
bs:=0;
for i:=1 to 3 do begin
bs:=bs+Xi[i]*b[i];
end;
AA:=bs*P/(R*Te)-1;
BB:=(as/P-3*bs*bs-2*bs*R*Te/P)*P*P/(R*R*Te*Te);
CC:=(bs*bs*bs-bs*bs*R*Te/P+bs*bs/P)*P*P*P/(R*R*R*Te*Te*Te);
k:=BB-AA*AA/3;
q:=2*AA*AA*AA/27-AA*BB/3+CC;
QQ:=k*k*k/27+q*q/4;
If ((QQ<0) and (k<0)) then begin
t:=(-1)*q/(2*exp((3/2)*ln((-1)*k/3)));
t1:=arctan(sqrt(1-sqr(t))/t);
y1:=2*sqrt((-1)*k/3)*cos(t1/3);
y2:=(-2)*sqrt((-1)*k/3)*cos(t1/3+3.14/3);
y3:=(-2)*sqrt((-1)*k/3)*cos(t1/3-3.14/3);
if ((y1>y2) and (y1>y3)) then yy:=y1 else if ((y2>y1) and (y2>y3)) then yy:=y2 else yy:=y3;
end;
if ((QQ>=0) and (k>0)) then begin
t:=(2/q)*exp((3/2)*ln(k/3));
t1:=arctan(t);
if sin(t1/2)/cos(t1/2)<0 then
t:=-exp((1/3)*ln(-sin(t1/2)/cos(t1/2)))
else
t:=exp((1/3)*ln(sin(t1/2)/cos(t1/2)));
t1:=arctan(t);
y1:=(-2)*sqrt(k/3)/(sin(t1*2)/cos(t1*2));
yy:=y1;
end;
if ((QQ>=0) and (k<0)) then begin
t:=(2/q)*exp((3/2)*ln((-1)*k/3));
t1:=arctan(t/(sqrt(1-sqr(t))));
t:=exp((1/3)*ln(sin(t1/2)/cos(t1/2)));
t1:=arctan(t);
y1:=(-2)*sqrt((-1)*k/3)/sin(2*t1);
yy:=y1;
end;
z:=yy-AA/3;
{2 componenta}
for i:=1 to 3 do begin
a[i]:= 0.46*R*R*Ti[i]*Ti[i]/Pi[i];
end;
as:=0;
for i:=1 to 3 do begin
for j:=1 to 3 do begin
as:=as+Yi[i]*Yi[j]*sqrt(a[i]*a[j]);
end;
end;
for i:=1 to 3 do begin
b[i]:=0.078*R*Ti[i]/Pi[i];
end;
bs:=0;
for i:=1 to 3 do begin
bs:=bs+Yi[i]*b[i];
end;
AA:=bs*P/(R*Te)-1;
BB:=(as/P-3*bs*bs-2*bs*R*Te/P)*P*P/(R*R*Te*Te);
CC:=(bs*bs*bs-bs*bs*R*Te/P+bs*bs/P)*P*P*P/(R*R*R*Te*Te*Te);
k:=BB-AA*AA/3;
q:=2*AA*AA*AA/27-AA*BB/3+CC;
QQ:=k*k*k/27+q*q/4;
If ((QQ<0) and (k<0)) then begin
t:=(-1)*q/(2*exp((3/2)*ln((-1)*k/3)));
t1:=arctan(sqrt(1-sqr(t)/t));
y1:=2*sqrt((-1)*k/3)*cos(t1/3);
y2:=(-2)*sqrt((-1)*k/3)*cos(t1/3+3.14/3);
y3:=(-2)*sqrt((-1)*k/3)*cos(t1/3-3.14/3);
if ((y1>y2) and (y1>y3)) then yy:=y1 else if ((y2>y1) and (y2>y3)) then yy:=y2 else yy:=y3;
end;
if ((QQ>=0) and (k>0)) then begin
t:=(2/q)*exp((3/2)*ln(k/3));
t1:=arctan(t);
t:=exp((1/3)*ln(sin(t1/2)/cos(t1/2)));
t1:=arctan(t);
y1:=(-2)*sqrt(k/3)/(sin(t1*2)/cos(t1*2));
yy:=y1;
end;
if ((QQ>=0) and (k<0)) then begin
t:=(2/q)*exp((3/2)*ln((-1)*k/3));
t1:=arctan(t/(sqrt(1-sqr(t))));
if sin(t1/2)/cos(t1/2)<0 then
t:=-exp((1/3)*ln(-sin(t1/2)/cos(t1/2)))
else
t:=exp((1/3)*ln(sin(t1/2)/cos(t1/2)));
t1:=arctan(t);
y1:=(-2)*sqrt((-1)*k/3)/sin(2*t1);
yy:=y1;
end;
z1:=yy-AA/3;
Fug1:=sum(z);
Fug2:=sum(z1);
sumk:=0;
For i:=1 to 3 do begin
Fi1[i]:=Fug1*Ci[i];
Fi2[i]:=Fug2*Ci[i];
k1[i]:=Fi1[i]/Fi2[i];
end;
until (sqr(1-k1[1])+sqr(1-k1[2])+sqr(1-k1[3]))<exp((-12)*ln(10));
for i:=1 to 3 do begin
writeln('jidkosti ',Xi[i]*100:2:2,' gas ',yi[i]*100:2:2);
end;
readkey;
end.