偏微分方程数值解实验报告

2020-06-03 11:07

偏微分方程数值解实验报告

一、题目:

1、用有限元方法求下列边值问题的数值解:

??2?x-y''+y=2sin(),0

其中其精确解为y=4?2sin(?x2),取h=0.1

要求:(1)将精确解与用有限元得到的数值解画在同一图中 (2)u?uh

2、用线性元求解下列问题的数值解:

??u=-2,-1

u?uhL2、0?x?1maxu-uh

精确到小数点后第六位,并画出解曲面。

3、用Crank-Nicolson差分法求解Burger方程

?vt+vvx=?vxx,??0,x?(0,1),t?(0,5),?1];v???t?=v(1,t)=0.?v(x,0)=sin2?x,x?[0,

其中取??1 要求画出解曲面。迭代格式如下:

Vjn?1?Vjn?n2n2n?12n?121???Vj?1???Vj??Vj?1???Vj???????4?hh???nn?1nn?1n?1n?11??Vj?1?2Vj?Vj?1Vj?1?2Vj?Vj?1??????222?hh???

二、代码: 1、

%Ritz Galerkin方法求解方程 function u1=Ritz(x) %定义步长 h=1/100; x=0:h:1; n=1/h;

a=zeros(n-1,1); b=zeros(n,1); c=zeros(n-1,1); d=zeros(n,1);

%求解Ritz方法中内点系数矩阵 for i=1:1:n-1

b(i)=(1/h+h*pi*pi/12)*2;

d(i)=h*pi*pi/2*sin(pi/2*(x(i)+h))/2+h*pi*pi/2*sin(pi/2*x(i+1))/2; end

%右侧导数条件边界点的计算 b(n)=(1/h+h*pi*pi/12);

d(n)=h*pi*pi/2*sin(pi/2*(x(i)+h))/2; for i=1:1:n-1

a(i)=-1/h+h*pi*pi/24; c(i)=-1/h+h*pi*pi/24; end

%调用追赶法 u=yy(a,b,c,d) %得到数值解向量 u1=[0,u] %对分段区间做图 plot(x,u1) %得到解析解

y1=sin(pi/2*x); hold on plot(x,y1,'o')

legend('数值解','解析解') function x=yy(a,b,c,d) n=length(b); q=zeros(n,1); p=zeros(n,1); q(1)=b(1); p(1)=d(1); for i=2:1:n

q(i)=b(i)-a(i-1)*c(i-1)/q(i-1); p(i)=d(i)-p(i-1)*c(i-1)/q(i-1); end

x(n)=p(n)/q(n); for j=n-1:-1:1

x(j)=(p(j)-a(j)*x(j+1))/q(j); end x

x =

Columns 1 through 11

0.0157 0.0314 0.0471 0.0628 0.0785 0.0941 0.1097 0.1409 0.1564 0.1719

Columns 12 through 22

0.1874 0.2028 0.2181 0.2335 0.2487 0.2639 0.2790 0.3090 0.3239 0.3387

Columns 23 through 33

0.3535 0.3681 0.3827 0.3972 0.4115 0.4258 0.4400 0.4679 0.4818 0.4955

0.1253 0.2940 0.4540 Columns 34 through 44

0.5091 0.5225 0.5358 0.5490 0.5621 0.5750 0.5878 0.6004 0.6129 0.6253 0.6374

Columns 45 through 55

0.6495 0.6613 0.6730 0.6846 0.6959 0.7071 0.7181 0.7290 0.7397 0.7501 0.7604

Columns 56 through 66

0.7705 0.7805 0.7902 0.8444 0.8527 0.8608

Columns 67 through 77

0.8687 0.8763 0.8838 0.9239 0.9298 0.9355

Columns 78 through 88

0.9409 0.9461 0.9511 0.9759 0.9793 0.9823

Columns 89 through 99

0.9851 0.9877 0.9901 0.9989 0.9995 0.9999

Column 100

1.0000 u =

Columns 1 through 11

0.0157 0.0314 0.0471 0.1409 0.1564 0.1719

Columns 12 through 22

0.7997 0.8090 0.8910 0.8981 0.9558 0.9603 0.9921 0.9940 0.0628 0.0785 0.8182 0.8271 0.9049 0.9114 0.9646 0.9686 0.9956 0.9969 0.0941 0.1097 0.8358 0.9178 0.9724 0.9981 0.1253


偏微分方程数值解实验报告.doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2013年下半年“三基”考试题库(1)(1)

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: