用显式格式求解二维抛物型偏微分方程

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

用显式格式求解二维抛物型偏微分方程2010-05-1410:41functionvarargout=liu(varargin)T=1;a=1;h=1/32;dt=1/200;[X,T,Z]=chfenmethed(h,dt,a,T);mesh(X,T,Z(:,:,3));shadingflat;%xlabel('X','FontSize',14);%ylabel('t','FontSize',14);%zlabel('error','FontSize',14);%title('误差图');function[X,Y,Z]=chfenmethed(h,dt,a,T);%求解下问题%u_t-a*(u_xx+u_yy)=f(x,y,t)0x,y1,0tT%u(0,y,t)=g0,u(1,y,t)=g1,%u(x,y,0)=d%h离散xy方向的步长%dt离散t方向的步长x=0:h:1;y=x;t=0:dt:T;m=length(x);n=length(t);r=a*dt/h^2;[X,Y]=meshgrid(x,y);Z=zeros(m,m,n);U=zeros(m,m,n);fori=1:mforj=1:mU(i,j,1)=d(x(i),y(j));endendforj=2:nfork=1:mU(1,k,j)=g0(y(k),t(j));U(m,k,j)=g1(y(k),t(j));U(k,1,j)=h0(x(k),t(j));U(k,m,j)=h1(x(k),t(j));endendfork=2:nfori=2:m-1forj=2:m-1U(i,j,k)=U(i,j,k-1)+r*a*(U(i+1,j,k-1)+U(i-1,j,k-1)+U(i,j+1,k-1)...+U(i,j-1,k-1)-4*U(i,j,k-1))+f(x(i),y(j),t(k-1));Z(i,j,k)=abs(U(i,j,k)-Uu(x(i),y(j),t(k)));endendendfunctionz=Uu(x,y,t)%精确解函数z=exp(-2*t)*sin(x+y);functionz=g0(y,t)z=Uu(0,y,t);functionz=g1(y,t)z=Uu(1,y,t);functionz=h0(x,t)z=Uu(x,0,t);functionz=h1(x,t)z=Uu(x,1,t);functionz=d(x,y)z=Uu(x,y,0);functionz=f(x,y,t)z=0;

1 / 3
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功