Скачиваний:
43
Добавлен:
10.05.2014
Размер:
111.27 Кб
Скачать

Узлы пространственной сетки,

Численное решение задачи в узлах сетки в момент времени

Точное решение задачи в узлах сетки,

Модуль разности между точным и приближенным решением в узлах сетки,

Аппроксимация 1 порядка

Аппроксимация 2 порядка

Аппроксимация 1 порядка

Аппроксимация 2 порядка

0.0

0.05

0.10

0.15

0.20

0.25

0.30

0.35

0.40

0.45

0.50

0.55

0.60

0.65

0.70

0.75

0.80

0.85

0.90

0.95

1.00

-2.3946

-2.3842

-2.3721

-2.3587

-2.3438

-2.3270

-2.3078

-2.2866

-2.2642

-2.2405

-2.2154

-2.1885

-2.1593

-2.1274

-2.0924

-2.0546

-2.0140

-1.9708

-1.9246

-1.8752

-1.8227

-2.40989

-2.40062

-2.39038

-2.37915

-2.36676

-2.35316

-2.33819

-2.32178

-2.30379

-2.28410

-2.26252

-2.23893

-2.21315

-2.18501

-2.15434

-2.12090

-2.08446

-2.04481

-2.00172

-1.95507

-1.90461

-2.41007

-2.40080

-2.39059

-2.37936

-2.36702

-2.35344

-2.33852

-2.32214

-2.30417

-2.28446

-2.26287

-2.23923

-2.21338

-2.18513

-2.15431

-2.12071

-2.08414

-2.04439

-2.00125

-1.95452

-1.90399

1.55E-02

1.66E-02

1.85E-02

2.07E-02

2.32E-02

2.65E-02

3.07E-02

3.56E-02

4.00E-02

4.40E-02

4.75E-02

5.07E-02

5.41E-02

5.77E-02

6.19E-02

6.61E-02

7.02E-02

7.36E-02

7.66E-02

7.93E-02

8.13E-02

1.75E-04

1.83E-04

2.13E-04

2.17E-04

2.55E-04

2.83E-04

3.37E-04

3.61E-04

3.84E-04

3.66E-04

3.48E-04

2.99E-04

2.24E-04

1.27E-04

2.92E-05

1.90E-04

3.22E-04

4.23E-04

4.74E-04

5.50E-04

6.21E-04

Максимальный модуль разности

при t = 2.0

8.13e-2

6.21e-4

4. Полулогарифмический график зависимости максимальной по­греш­ности от времени:

Код с 1 и 2 порядком аппроксимации начальных и граничных условий, шаблон-крест

uses crt, math;

Function f(x,t:real):real;

begin

f:=2.5*tanh(t-x)/cosh(t-x)/cosh(t-x);

end;

Function phi1(x:real):real;

begin

phi1:=2.5*tanh(x);

end;

Function dphi1(x:real):real;

begin

dphi1:=-5*tanh(x)/cosh(x)/cosh(x);

end;

Function phi2(x:real):real;

begin

phi2:=-2.5/cosh(x)/cosh(x);

end;

Function psi1(t:real):real;

begin

psi1:=-5*tanh(t)-2.5/cosh(t)/cosh(t);

end;

Function psi2(t:real):real;

begin

psi2:=2.5/cosh(1-t)/cosh(1-t);

end;

Function U0(x,t:real):real;

begin

U0:=2.5*tanh(x-t);

end;

var

j,k,nx,nt:integer;

hx,ht,xmax,tmax,aa,sr,m:real;

x,t:array[0..500] of real;

u1,u2: array [0..500,0..500] of real;

Output:text;

begin

clrscr;

Assign(output,'out4.txt');

Rewrite(output);

aa:=1/2;

hx:=0.05;

ht:=0.05;

xmax:=1;

Write('T max = '); Readln(tmax);

nx:=round(xmax/hx);

nt:=round(tmax/ht);

x[0]:=0;

t[0]:=0;

For j:=1 to nx do

x[j]:=x[j-1]+hx;

For k:=1 to nt do

t[k]:=t[k-1]+ht;

{1 poryadok approks.}

For j:=0 to nx do

begin

U1[j,0]:=phi1(x[j]);

U1[j,1]:=U1[j,0]+ht*phi2(x[j]);

end;

For k:=1 to nt-1 do

begin

For j:=1 to nx-1 do

U1[j,k+1]:=2*U1[j,k]-U1[j,k-1]+aa*ht*ht/(hx*hx)*(U1[j+1,k]-2*U1[j,k]+U1[j-1,k])+f(x[j],t[k])*ht*ht;

U1[0,k+1]:=(U1[1,k+1]+hx*psi1(t[k+1])) / (1+2*hx);

U1[nx,k+1]:=(U1[nx-1,k+1]+hx*psi2(t[k+1]));

end;

{2 poryadok approks.}

For j:=0 to nx do

begin

U2[j,0]:=phi1(x[j]);

U2[j,1]:=phi1(x[j])+ht*phi2(x[j])+ht*ht/2*(aa*dphi1(x[j])+f(x[j],0));

end;

For k:=1 to nt-1 do

begin

For j:=1 to nx-1 do

U2[j,k+1]:=2*U2[j,k]-U2[j,k-1]+aa*ht*ht/(hx*hx)*(U2[j+1,k]-2*U2[j,k]+U2[j-1,k])+f(x[j],t[k])*ht*ht;

U2[0,k+1]:=2*aa*ht*ht/(hx*hx)*(U2[1,k]-(1+2*hx)*U2[0,k]+hx*psi1(t[k]))+2*U2[0,k]-U2[0,k-1]+ht*ht*f(0,t[k]);

U2[nx,k+1]:=2*aa*ht*ht/(hx*hx)*(U2[nx-1,k]-U2[nx,k]+hx*psi2(t[k]))+2*U2[nx,k]-U2[nx,k-1]+ht*ht*f(x[nx],t[k]);

end;

k:=nt;

Writeln(output,'T= ',t[k]);

Writeln(output,'Tochnoe reshenie');

For j:=0 to nx do

Writeln(output,U0(x[j],t[k]));

Writeln(output);

Writeln(output,'Shislennoe 1-go poryadka');

For j:=0 to nx do

Writeln(output,U1[j,k]);

Writeln(output);

Writeln(output,'Raznost 1-go poryadka s tochnim');

For j:=0 to nx do

Writeln(output,abs(u1[j,k]-U0(x[j],t[k])));

Writeln(output);

Writeln(output,'Shislennoe 2-go poryadka');

For j:=0 to nx do

Writeln(output,U2[j,k]);

Writeln(output);

Writeln(output,'Raznost 2-go poryadka s tochnim');

For j:=0 to nx do

Writeln(output,abs(u2[j,k]-U0(x[j],t[k])));

Writeln(output);

Writeln(output,'-------');

Writeln(output);

{1}

Writeln(output,'maximaln. modul raznosti dlya 1-go poryadka');

k:=nt;

m:=0;

For j:=0 to nx do

begin

sr:=abs(u1[j,k]-U0(x[j],t[k]));

If m<sr

then m:=sr;

end;

Writeln(output,m);

{2}

Writeln(output,'maximaln. modul raznosti dlya 2-go poryadka');

k:=nt;

m:=0;

For j:=0 to nx do

begin

sr:=abs(u2[j,k]-U0(x[j],t[k])) ;

If m<sr

then m:=sr;

end;

Writeln(output,m);

Close(output);

Readln;

end.

Соседние файлы в папке 4. Волновое уравнение. Шаблон-крест