双曲型差分(二维)数值例子

双曲型差分(二维)数值例子
 
双曲型差分(二维)数值例子_第1张图片

双曲型差分(二维)数值例子_第2张图片

双曲型差分(二维)数值例子_第3张图片

图片

双曲型差分(二维)数值例子_第4张图片

双曲型差分(二维)数值例子_第5张图片
数值解:
 
双曲型差分(二维)数值例子_第6张图片
精确解:
双曲型差分(二维)数值例子_第7张图片
 

// scilab code
 //精确解
t =linspace(0,1,100);
t = t';
x = linspace(0,1,100);
z = cos( 4 * 3.14159 * t ) * sin( 4 * 3.14159 * x) + ( sin( 8 * 3.14159 * t) * sin( 8 * 3.14159 * x) / 8 / 3.14159);
plot3d(t,x,z);

figure

//模拟解
pi_ = 3.14159265;
count =100;
t = linspace(0, 1, 2 * count);
x = linspace(0, 1, count);
h = x(2) - x(1);
tao = t(2) - t(1);
r = tao / h;
u_n_0 = sin( 4 * pi_ * x);
u_n_1 = sin( 4 * pi_ * x) + tao * sin( 8 * pi_ * x);


A = zeros(2 * count, count);
for i = 1: 2 * count 
    if i == 1 then
        A(i,:) = u_n_0;
    elseif i == 2 then
        A(i,:) = u_n_1;
    else 
        A(i,[2 : count - 1 ]) = r * r * ( u_n_1(1:count - 2) + u_n_1(3:count)) + 2 * ( 1 - r * r) * u_n_1(2:count - 1)- u_n_0(2:count - 1);
        A(i,1) = 0;
        A(i, count) = 0;
        u_n_0 = A(i-1,:);
        u_n_1 = A(i,:);
    end   
end
plot3d(t,x,A);


你可能感兴趣的:(双曲型差分(二维)数值例子)