收藏 分销(赏)

一维偏微分方程的pdepe(matlab)函数解法.doc

上传人:xrp****65 文档编号:6868036 上传时间:2024-12-22 格式:DOC 页数:8 大小:132.50KB
下载 相关 举报
一维偏微分方程的pdepe(matlab)函数解法.doc_第1页
第1页 / 共8页
一维偏微分方程的pdepe(matlab)函数解法.doc_第2页
第2页 / 共8页
一维偏微分方程的pdepe(matlab)函数解法.doc_第3页
第3页 / 共8页
一维偏微分方程的pdepe(matlab)函数解法.doc_第4页
第4页 / 共8页
一维偏微分方程的pdepe(matlab)函数解法.doc_第5页
第5页 / 共8页
点击查看更多>>
资源描述

1、本文根据matlab帮助进行加工,根据matlab帮助上的例子,帮助更好的理解一维偏微分方程的pdepe函数解法,主要加工在于程序的注释上。ExamplesExample 1. This example illustrates the straightforward formulation, computation, and plotting of the solution of a single PDE.This equation holds on an interval for times .The PDE satisfies the initial conditionand bounda

2、ry conditionsIt is convenient to use subfunctions to place all the functions required by pdepe in a single function.function pdex1 m = 0;x = linspace(0,1,20);%linspace(x1,x2,N)linspace是Matlab中的一个指令,用于产生x1,x2之间的N点行矢量。%其中x1、x2、N分别为起始值、终止值、元素个数。若缺省N,默认点数为100t = linspace(0,2,5); sol = pdepe(m,pdex1pde,p

3、dex1ic,pdex1bc,x,t);% Extract the first solution component as u.u = sol(:,:,1); % A surface plot is often a good way to study a solution.surf(x,t,u) title(Numerical solution computed with 20 mesh points.)xlabel(Distance x)ylabel(Time t) % A solution profile can also be illuminating.figureplot(x,u(en

4、d,:)title(Solution at t = 2)xlabel(Distance x)ylabel(u(x,2)% -function c,f,s = pdex1pde(x,t,u,DuDx)c = pi2;f = DuDx;s = 0;% -function u0 = pdex1ic(x)u0 = sin(pi*x);% -function pl,ql,pr,qr = pdex1bc(xl,ul,xr,ur,t)pl = ul;ql = 0;pr = pi * exp(-t);qr = 1;In this example, the PDE, initial condition, and

5、 boundary conditions are coded in subfunctions pdex1pde, pdex1ic, and pdex1bc.The surface plot shows the behavior of the solution.The following plot shows the solution profile at the final value of t (i.e., t = 2).我们再将该问题复杂化,比如在原方程右边加一项,对于标准形式,其余条件不变function pdex1 m = 0;x = linspace(0,1,20);%linspac

6、e(x1,x2,N)linspace是Matlab中的一个指令,用于产生x1,x2之间的N点行矢量。%其中x1、x2、N分别为起始值、终止值、元素个数。若缺省N,默认点数为100t = linspace(0,2,5); sol = pdepe(m,pdex1pde,pdex1ic,pdex1bc,x,t);% Extract the first solution component as u.u = sol(:,:,1); % A surface plot is often a good way to study a solution.surf(x,t,u) title(Numerical s

7、olution computed with 20 mesh points.)xlabel(Distance x)ylabel(Time t) % A solution profile can also be illuminating.figureplot(x,u(end,:)title(Solution at t = 2)xlabel(Distance x)ylabel(u(x,2)% -function c,f,s = pdex1pde(x,t,u,DuDx)c = pi2;f = DuDx;s = u2;% -function u0 = pdex1ic(x)u0 = sin(pi*x);%

8、 -function pl,ql,pr,qr = pdex1bc(xl,ul,xr,ur,t)pl = ul;ql = 0;pr = pi * exp(-t);qr = 1;对比结果有差异,表示可行Example 2. This example illustrates the solution of a system of PDEs. The problem has boundary layers at both ends of the interval. The solution changes rapidly for small .The PDEs arewhere .This equat

9、ion holds on an interval for times .The PDE satisfies the initial conditionsand boundary conditionsIn the form expected by pdepe, the equations areThe boundary conditions on the partial derivatives of have to be written in terms of the flux. In the form expected by pdepe, the left boundary condition

10、 isand the right boundary condition isThe solution changes rapidly for small . The program selects the step size in time to resolve this sharp change, but to see this behavior in the plots, the example must select the output times accordingly. There are boundary layers in the solution at both ends o

11、f 0,1, so the example places mesh points near 0 and 1 to resolve these sharp changes. Often some experimentation is needed to select a mesh that reveals the behavior of the solution.程序在pdex4.m中function pdex4 %pdex4为文件名clcm = 0;x = 0 0.005 0.01 0.05 0.1 0.2 0.5 0.7 0.9 0.95 0.99 0.995 1;t = 0 0.005 0

12、.01 0.05 0.1 0.5 1 1.5 2; sol = pdepe(m,pdex4pde,pdex4ic,pdex4bc,x,t);%pdepe函数,用于直接求解偏微分方程,其形式为sol = pdepe(m,pdefun,icfun,bcfun,xmesh,tspan)%下面为作图步骤u1 = sol(:,:,1);% ui = sol(:,:,i) is an approximation to the ith component of the solution vector u .u2 = sol(:,:,2); figuresurf(x,t,u1)title(u1(x,t)xla

13、bel(Distance x)ylabel(Time t) figuresurf(x,t,u2)title(u2(x,t)xlabel(Distance x)ylabel(Time t)% -function c,f,s = pdex4pde(x,t,u,DuDx)%被调用的函数,其作用是描述偏微分方程c = 1; 1; f = 0.024; 0.17 .* DuDx; y = u(1) - u(2);F = exp(5.73*y)-exp(-11.47*y);s = -F; F; % -function u0 = pdex4ic(x);%此函数是用来描述初值u0 = 1; 0; % -function pl,ql,pr,qr = pdex4bc(xl,ul,xr,ur,t)%此函数用来描述边界条件pl = 0; ul(2); ql = 1; 0; pr = ur(1)-1; 0; qr = 0; 1; In this example, the PDEs, initial conditions, and boundary conditions are coded in subfunctions pdex4pde, pdex4ic, and pdex4bc.The surface plots show the behavior of the solution components.

展开阅读全文
部分上传会员的收益排行 01、路***(¥15400+),02、曲****(¥15300+),
03、wei****016(¥13200+),04、大***流(¥12600+),
05、Fis****915(¥4200+),06、h****i(¥4100+),
07、Q**(¥3400+),08、自******点(¥2400+),
09、h*****x(¥1400+),10、c****e(¥1100+),
11、be*****ha(¥800+),12、13********8(¥800+)。
相似文档                                   自信AI助手自信AI助手
搜索标签

当前位置:首页 > 百科休闲 > 其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服