




已阅读5页,还剩4页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
本文根据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 boundary 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,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 solution 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 = 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 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);%linspace(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 solution 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);% -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 equation 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 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 of 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.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)xlabel(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. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年旅游地产项目可持续发展与旅游市场拓展策略报告
- 2025年绿色建材研发中心项目环保合规性分析报告
- 2025年纺织服装智能化生产环境监测与安全报告
- 现场交叉作业安全管理
- 现场临电知识培训内容课件
- 2026届黑龙江省七台河市化学高二第一学期期中监测试题含解析
- 2025年公务员考试行测数量关系高频考点专项训练及解析
- 2025年Python二级考试押题试卷 深度剖析版
- 星巴克广告策划案(定稿)
- 民法典护理课件
- 带病工作免责协议书
- 《创新大学英语综合教程 学生用书3》电子教案-综合教程第三册教案Unit2
- 保密警示教育典型泄密案例教育学习
- 东欧与北亚高二下学期 地理 区域地理复习课件
- 宠物食品基础知识培训课件
- 学校采购煤炭合同协议
- 图解6S管理课件
- 保安值班室管理制度
- 特种设备质量安全风险日管控-周排查-月调度管理制度
- 初中英语动词过去式不规则变化-过去分词-听写表格
- 2025劳动合同官方下载
评论
0/150
提交评论