《时间步长与空间步长对稳定性影响》由会员分享,可在线阅读,更多相关《时间步长与空间步长对稳定性影响(6页珍藏版)》请在金锄头文库上搜索。
1、对下面的一阶对流扩散方程(1.1)对求解区间Matlab程序function u = yingfeng(a,dt,n,minx,maxx,M)%方程中的常数:a%时间步长:dt%空间节点个数:n%求解区间的左端:minx%求解区间的右端:naxx%时间步的个数:M%求解区间上的数值解:uformat long;h = (maxx-minx)/(n-1);if a0 for j=1:(n+M) u0(j) = IniU(minx+(j-M-1)*h); endelse for j=1:(n+M) u0(j) = IniU(minx+(j-1)*h); endend u1 = u0; for k=
2、1:M if a0 for i=(k+1):n+M u1(i) = -dt*a*(u0(i)-u0(i-1)/h+u0(i); end else for i=1:n+M-k u1(i) = -dt*a*(u0(i+1)-u0(i)/h+u0(i); end end u0 = u1;endif a0 u = u1(M+1):M+n);else u = u1(1:n);endformat long;function ux=IniU(x)format long;if x=-0.1 ux=10*(x+0.1); else ux=0; endelse if x plot(u)u=yingfeng(1,0
3、.005,101,0,1,100);plot(u) u=yingfeng(1,0.006,101,0,1,100); plot(u) u=yingfeng(1,0.007,101,0,1,100); plot(u) u=yingfeng(1,0.008,101,0,1,100); plot(u)u=yingfeng(1,0.009,101,0,1,100);plot(u) u=yingfeng(1,0.01,101,0,1,100); plot(u) u=yingfeng(1,0.011,101,0,1,100); plot(u) u=yingfeng(1,0.012,101,0,1,100); plot(u) u=yingfeng(1,0.013,101,0,1,100); plot(u) u=yingfeng(1,0.014,101,0,1,100); plot(u) u=yingfeng(1,0.017,101,0,1,100); plot(u) u=yingfeng(1,0.020,101,0,1,100); plot(u) u=yingfeng(1,1,101,0,1,100); plot(u)由以上得到的图像我们可以知道当,既时波是稳定的,且随着时间的增长向右传播;时,波开始不稳定,且向左不断的扩散。 特别的当方程的解不是平滑的曲线