偏微分方程数值解实验报告内容参考.docx
- 文档编号:298345
- 上传时间:2022-10-08
- 格式:DOCX
- 页数:14
- 大小:212.23KB
偏微分方程数值解实验报告内容参考.docx
《偏微分方程数值解实验报告内容参考.docx》由会员分享,可在线阅读,更多相关《偏微分方程数值解实验报告内容参考.docx(14页珍藏版)》请在冰豆网上搜索。
偏微分方程数值解实验报告内容参考
偏微分方程数值解实验报告
一、题目:
1、用有限元方法求下列边值问题的数值解:
其中其精确解为
,取h=0.1
要求:
(1)将精确解与用有限元得到的数值解画在同一图中
(2)
、
、
2、用线性元求解下列问题的数值解:
精确到小数点后第六位,并画出解曲面。
3、用Crank-Nicolson差分法求解Burger方程
其中取
要求画出解曲面。
迭代格式如下:
二、代码:
1、
%RitzGalerkin方法求解方程
functionu1=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方法中内点系数矩阵
fori=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;
fori=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);
holdon
plot(x,y1,'o')
legend('数值解','解析解')
functionx=yy(a,b,c,d)
n=length(b);
q=zeros(n,1);
p=zeros(n,1);
q
(1)=b
(1);
p
(1)=d
(1);
fori=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);
forj=n-1:
-1:
1
x(j)=(p(j)-a(j)*x(j+1))/q(j);
end
x
x=
Columns1through11
0.01570.03140.04710.06280.07850.09410.10970.12530.14090.15640.1719
Columns12through22
0.18740.20280.21810.23350.24870.26390.27900.29400.30900.32390.3387
Columns23through33
0.35350.36810.38270.39720.41150.42580.44000.45400.46790.48180.4955
Columns34through44
0.50910.52250.53580.54900.56210.57500.58780.60040.61290.62530.6374
Columns45through55
0.64950.66130.67300.68460.69590.70710.71810.72900.73970.75010.7604
Columns56through66
0.77050.78050.79020.79970.80900.81820.82710.83580.84440.85270.8608
Columns67through77
0.86870.87630.88380.89100.89810.90490.91140.91780.92390.92980.9355
Columns78through88
0.94090.94610.95110.95580.96030.96460.96860.97240.97590.97930.9823
Columns89through99
0.98510.98770.99010.99210.99400.99560.99690.99810.99890.99950.9999
Column100
1.0000
u=
Columns1through11
0.01570.03140.04710.06280.07850.09410.10970.12530.14090.15640.1719
Columns12through22
0.18740.20280.21810.23350.24870.26390.27900.29400.30900.32390.3387
Columns23through33
0.35350.36810.38270.39720.41150.42580.44000.45400.46790.48180.4955
Columns34through44
0.50910.52250.53580.54900.56210.57500.58780.60040.61290.62530.6374
Columns45through55
0.64950.66130.67300.68460.69590.70710.71810.72900.73970.75010.7604
Columns56through66
0.77050.78050.79020.79970.80900.81820.82710.83580.84440.85270.8608
Columns67through77
0.86870.87630.88380.89100.89810.90490.91140.91780.92390.92980.9355
Columns78through88
0.94090.94610.95110.95580.96030.96460.96860.97240.97590.97930.9823
Columns89through99
0.98510.98770.99010.99210.99400.99560.99690.99810.99890.99950.9999
Column100
1.0000
u1=
Columns1through11
00.01570.03140.04710.06280.07850.09410.10970.12530.14090.1564
Columns12through22
0.17190.18740.20280.21810.23350.24870.26390.27900.29400.30900.3239
Columns23through33
0.33870.35350.36810.38270.39720.41150.42580.44000.45400.46790.4818
Columns34through44
0.49550.50910.52250.53580.54900.56210.57500.58780.60040.61290.6253
Columns45through55
0.63740.64950.66130.67300.68460.69590.70710.71810.72900.73970.7501
Columns56through66
0.76040.77050.78050.79020.79970.80900.81820.82710.83580.84440.8527
Columns67through77
0.86080.86870.87630.88380.89100.89810.90490.91140.91780.92390.9298
Columns78through88
0.93550.94090.94610.95110.95580.96030.96460.96860.97240.97590.9793
Columns89through99
0.98230.98510.98770.99010.99210.99400.99560.99690.99810.99890.9995
Columns100through101
0.99991.0000
ans=
Columns1through10
00.01570.03140.04710.06280.07850.09410.10970.12530.1409
Columns11through20
0.15640.17190.18740.20280.21810.23350.24870.26390.27900.2940
Columns21through30
0.30900.32390.33870.35350.36810.38270.39720.41150.42580.4400
Columns31through40
0.45400.46790.48180.49550.50910.52250.53580.54900.56210.5750
Columns41through50
0.58780.60040.61290.62530.63740.64950.66130.67300.68460.6959
Columns51through60
0.70710.71810.72900.73970.75010.76040.77050.78050.79020.7997
Columns61through70
0.80900.81820.82710.83580.84440.85270.86080.86870.87630.8838
Columns71through80
0.89100.89810.90490.91140.91780.92390.92980.93550.94090.9461
Columns81through90
0.95110.95580.96030.96460.96860.97240.97590.97930.98230.9851
Columns91through100
0.98770.99010.99210.99400.99560.99690.99810.99890.99950.9999
Column101
1.0000
2、function[u]=Q_2(P)
formatlong
ifnargin<1
P=16;
end
f=2;beta
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 微分方程 数值 实验 报告 内容 参考