მთავარი » სტატიები » Математика » Методы Рунге Кутты |
Программа
PROGRAM smith_04;USES crt; VAR i,n:integer; sum,k1,k2,k3,k4,p,dp,eps,Xn,Xk,X,dX:real; rSR,C,dC,r1,r2,r3,r4,cPR:array[1..3] of real; f1,f2:text; PROCEDURE Difur; BEGIN dC[1]:=C[3]*k2+C[2]*k4-C[1]*k1-C[1]*k3; {dcA} dC[2]:=C[1]*k3-C[2]*k4; {dcB} dC[3]:=C[1]*k1-C[3]*k2; {dcC} END; PROCEDURE RK_4; BEGIN Difur; FOR i:=1 TO n DO BEGIN r1[i]:=dC[i]; C[i]:=cPR[i]+r1[i]*(dX/2); END; Difur; FOR i:=1 TO n DO BEGIN r2[i]:=dC[i]; C[i]:=cPr[i]+r2[i]*(dX/2); END; Difur; FOR i:=1 TO n DO BEGIN r3[i]:=dC[i]; C[i]:=cPR[I]+r3[i]*dX; END; Difur; FOR i:=1 TO n DO r4[i]:=dC[i]; FOR i:=1 TO n DO rSR[i]:=((r1[i]+r2[i])*(r2[i]+r3[i])*(r3[i]+r4[i]))/6; END; PROCEDURE STROKA; BEGIN WRITE(f2,'|',x:4:1,'|',c[1]:7:3,'|',c[2]:7:3,'|',c[3]:7:3,'|'); WRITE(f2,sum:3:0,'|',dc[1]:7:3,'|',dc[2]:7:3,'|',dc[3]:7:3,'|'); WRITELN(f2); END; PROCEDURE RUN; BEGIN WRITE('Step 3: Calculating data and writting results to file : out.rez'); X:=Xn; dX:=0.05; REPEAT IF (ABS(x-p)<eps) THEN BEGIN Difur; sum:=C[1]+C[2]+C[3]; STROKA; p:=p+dp; END; FOR i:=1 TO n DO Cpr[i]:=C[i]; RK_4; X:=X+dX; UNTIL(X>Xk); WRITELN(' - done.'); END; PROCEDURE INIT; BEGIN ClrScr; WRITELN('Smith-04: v1.0 (c) 1998 by Mike Smith smith01@home.bar.ru '); WRITELN; WRITELN; WRITE('Step 1: Read data from file : in.dat'); ASSIGN(f1,'in.dat'); RESET(f1); READLN(f1,C[1],C[2],C[3]); READLN(f1,k1,k2,k3,k4); READLN(f1,Xn,Xk,dp,n,eps,p); WRITELN(' - done.'); ASSIGN(f2,'out.rez'); REWRITE(f2); WRITE('Step 2: Write header to file : out.rez'); WRITELN(f2,''); WRITELN(f2,'| t,c| Ca,% | Cb,%| Cc,% | SUM | dCa | dCb | dCc |'); WRITELN(f2,'='); WRITELN(' - done.'); END;
PROCEDURE DONE; BEGIN WRITELN('Step 4: Close all files and exiting...'); CLOSE(f1); WRITELN(f2,'='); CLOSE(f2); WRITELN; END; BEGIN INIT; RUN; DONE; END. | |
ნანახია: 373 | |
სულ კომენტარები: 0 | |
შესვლის ფორმა |
---|
ძებნა |
---|
მინი-ჩეთი |
---|
საიტის მეგობრები |
---|
სტატისტიკა |
---|