数値計算プログラム

放物形方程式 クランク・ニコルソン法


input h;
input r;
k:=r*h+h;
input m;
input n;
dim a(n),u(n,m);

input x0;
input a$;
label l1;
input x1;

if (x1-x0)<>h*(n-1) then print"error";goto l1;
input b$;

input t0;
input c$;

c1:=2+2/r;
c2:=2-2/r;
a(2):=c1;
n1:=n-1;

for i:=3 to n1;
a(i):=c1-1/a(i-1);
next i;
for i:=1 to n;
t:=t0;
x:=(i-1)*h+x0;
u(i-1):=val$(c$);
next i;
for j:=1 to m;
x:=x0;
t:=t0+(j-1)*k;
u(1,j):=val$(a$);
x:=x1;
u(n,j):=val(b$);
next j;
for j:=2 to m;
for i:=2 to n1;
u(i,j):=u(i-1,j-1)-c2*u(i,j-1)+u(i+1,j-1);
next i;
u(2,j):=u(2,j)+u(1,j);
for i:=3 to n1;
u(i,j):=u(i,j)+u(i-1,j)/a(i-1);
next i;
for i:=n1 to 2 step -1;
u(i,j):=(u(i,j)+u(i+1,j))/a(i);
next i;
next j;

for j:=1 to m;
print"T=";t0+(j-1)*k;
for i:=1 to n;
print" x=";x0+(i-1)*h;"u=";u(i,j);
next i;
print;
next j;
end;


トラックバック

このエントリーのトラックバックURL:
http://allable.sakura.ne.jp/mt/mt-tb.cgi/4150

当サイトでは、第三者配信事業者によるサービスを使用して広告を表示しています。 これらの第三者配信事業者は、ユーザーの興味に応じた商品やサービスの広告を表示する目的で、 当サイトや他のサイトへのアクセスに関する情報を使用することがあります (氏名、住所、メール アドレス、電話番号は含まれません)。 このプロセスの詳細や、第三者配信事業者にこれらの情報が使用されないようにする方法については、 ここをクリックしてください。