matlab解偏微分方程

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

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

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

资源描述

12ut=a2uxx2.1(t)u(x;t+¢t)¡u(x;t)¢t¼a2u(x+¢x;t)¡2u(x;t)+u(x¡¢x;t)(¢x)2u(x;t+¢t)¼u(x;t)+¢t(¢x)2a2[u(x+¢x;t)¡2u(x;t)+u(x¡¢x;t)]x=i4x;t=j4t;i;j=0;1;2;¢¢¢n¡1;r=¢t(¢x)2a2,u(i;j+1)=(1¡2r)u(i;j)+r[u(i+1;j)¡2u(i;j)+u(i¡1;j)]¢t·(¢x)22a2,O((¢x)2;¢t).8:ut=a2uxxu(0;t)=0;u(l;t)=0u(x;t=0)='(x)0·x·20;a=10'(x)=(1;(10·x·11)0;(x10;x11),x=0:20;t=0:0.01:1;a2=10;r=a2*0.01;u=zeros(21,101);u(10:11,1)=1;forj=1:100u(2:20,j+1)=(1-2*r)*u(2:20,j)+r*(u(1:19,j)+u(3:21,j));plot(u(:,j));axis([02101]);pause(0.1)endsurf(u)2.2(t+4t)u(x;t+¢t)¡u(x;t)¢t¼a2u(x+¢x;t+¢t)¡2u(x;t+¢t)+u(x¡¢x;t+¢t)(¢x)2,Hui;j+1=a2ui+1;j+1¡2ui;j+1+ui¡1;j+1(¢x)2ui;j+1¡ui;j¢t=Hui;j+1Hui;j=a2ui+1;j¡2ui;j+ui¡1;j(¢x)2ui;j+1¡ui;j¢t=Hui;j,ui;j+1¡ui;j¢t=12Hui;j+12Hui;j+1ui;j+1=1+12H¢t1¡12H¢tui;j.(1),@'@t=i@2'@x2H,'i;j+1=2641+i12H4t1¡i12H4t375'i;j'i;j+1=26421¡i12H4t¡1375'i;j´Â¡'i;jÂ(1¡i12H4t)Â=2'i;j(2i+H4t)Â=4i'i;jMATLAB,Ái;jÂ,ÂA,MATLABÂÁi;j+1.220(Gauss)GaussLorentz'j'j20.18,105115k0=0:6;¾=10,x0401130NPTS=220;sigma=10;k0=0.6;x0=40;time=130;v(NPTS)=0;v(105:115)=+0.18;A=diag(-2+2i+v)+diag(ones(NPTS-1,1),1)+diag(ones(NPTS-1,1),-1);PHI0(1)=0;PHI0(NPTS)=0;forx=2:NPTS-1;PHI0(x)=exp(0.5i*x)*exp(-(x-x0)^2*log10(2)/sigma^2);endPHI(:,1)=PHI0.';fory=2:timeCHI(:,y)=4i*(A\PHI(:,y-1));PHI(:,y)=CHI(:,y)-PHI(:,y-1);endmo=moviein(time);forj=1:timeplot([1:NPTS],abs(PHI(:,j)).^2/norm(PHI(:,j)).^2,[1:NPTS],v/2);mo(:,j)=getframe;endmovie(mo)3utt=a2uxx3.1u(x;t+¢t)¡2u(x;t)+u(x;t¡¢t)(¢t)2=a2u(x+¢x;t)¡2u(x;t)+u(x¡¢x;t)(¢x)2x=i¢x;t=j¢t,@2u@t2=ui;j+1¡2ui;j+ui;j¡1(4t)2@2u@x2=ui+1;j¡2ui;j+ui¡1;j(4x)2ui;j+1=c(ui+1;j+ui¡1;j)+2(1¡c)ui;j¡ui;j¡1c=a2(4t)2(4x)2.c1,c=1c1,O(4x2;4t2),3.2t=0j=1Á(x)Ã(x)Ái=Á(xi)Ãi=Ã(xi).ui1=Ái@ui;1@t=ui;2¡ui;024t=Ãiui;0=ui;2¡2Ãi4t,,ui;2=12[c(ui+1;1+ui¡1;1)+2(1¡c)ui;1+2Ãi4t]3.3,u(x;0)=8:h2=3x;(0·x·2=3)h1¡x1¡2=3;(2=3x·1),c=0:05;l=1;h=0:05..N=4000;c=0.05;x=linspace(0,1,420)';u1(1:420)=0;u2(1:420)=0;u3(1:420)=0;u1(2:280)=0.05/279*(1:279)';u1(281:419)=0.05/(419-281)*(419-(281:419)');u2(2:419)=u1(2:419)+c/2*(u1(3:420)-2*u1(2:419)+u1(1:418));h=plot(x,u1,'linewidth',3);axis([0,1,-0.05,0.05]);set(h,'EraseMode','xor','MarkerSize',18)fork=2:Nset(h,'XData',x,'YData',u2);drawnow;u3(2:419)=2*u2(2:419)-u1(2:419)+c*(u2(3:420)...-2*u2(2:419)+u2(1:418));u1=u2;u2=u3;end4uxx+uyy=04.1uxx+uyy=0u(x+¢x;y)¡2u(x;y)+u(x¡¢x;y)(¢x)2+u(x;y+¢y)¡2u(x;y)+u(x;y¡¢y)(¢y)2=0¢x=¢y=h;x=ih;y=jh;(i;j=0;1;2;¢¢¢;n¡1),u(i;j)=14[u(i+1;j)+u(i¡1;j)+u(i;j+1)+u(i;j¡1)](¢y)2(¢x)2·1.u(i;j+1)¡2u(i;j)+u(i;j¡1)=¡(¢y)2(¢x)2[u(i+1;j+1)¡2u(i;j+1)+u(i¡1;j+1)]O((¢x)2;(¢y)2),.,10,,0.01u=zeros(100,100);u(100,:)=10;uold=u+1;unew=u;fork=1:500ifmax(max(abs(u-uold)))=0.01unew(2:99,2:99)=0.25*(u(3:100,2:99)+u(1:98,2:99)+...u(2:99,3:100)+u(2:99,1:98));uold=u;u=unew;endendsurf(u)4.2,0!2u(i;j)=(1¡!)u(i;j)+!4[u(i+1;j)+u(i¡1;j)+u(i;j+1)+u(i;j¡1)],8:uxx+uyy=0;u(0;y)=0;u(a;y)=¹sin3¼yb;u(x;0)=0;u(x;b)=¹sin3¼xacos¼xa¹=1;a=3;b=2.omega=1.5;x=linspace(0,3,30);y=linspace(0,2,20);phi(:,30)=sin(3*pi/2*y)';phi(20,:)=(sin(pi*x).*cos(pi/3*x));forN=1:100fori=2:19forj=2:29ph=(phi(i+1,j)+phi(i-1,j)+phi(i,j+1)+phi(i,j-1));phi(i,j)=(1-omega)*phi(i,j)+0.25*omega*(ph);endendendcolormap([0.5,0.5,0.5]);figure(2),surfc(phi)

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

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

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

×
保存成功