药物计算分析导论章.pptx
《药物计算分析导论章.pptx》由会员分享,可在线阅读,更多相关《药物计算分析导论章.pptx(46页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、会计学1药物计算分析导论章药物计算分析导论章2003年This LectureThis Lecturen nMore accurate schemesMore accurate schemesn nMore complicated ODEsMore complicated ODEsn nVariable time step and embedded methods used to make sure Variable time step and embedded methods used to make sure errors are within a tolerance.errors are
2、 within a tolerance.第1页/共46页2003年Adams-Bashforth SchemesAdams-Bashforth Schemesn nIn the forward Euler scheme we only used the value of the right hand side at the In the forward Euler scheme we only used the value of the right hand side at the previous time step.previous time step.n ni.e.we only use
3、d a linear approximation to the time derivativei.e.we only used a linear approximation to the time derivative第2页/共46页2003年AB SchemesAB Schemesn nIdea:we set Idea:we set n nwhere If interpolates fwhere If interpolates fn n,f,fn-1n-1,f,fn-2n-2,.,f,.,fn+1-Nstagesn+1-Nstages n ni.e.:i.e.:第3页/共46页2003年f0
4、f1f2f3We interpolate the function through thefirst 4 points.Then we integrate under the curve between t=3 and t=4.第4页/共46页2003年AB SchemesAB Schemes Essentially we use Essentially we use interpolation and a interpolation and a Newton-Cotes quadrature Newton-Cotes quadrature formula to formulate:formu
5、la to formulate:第5页/共46页2003年Runge-Kutta SchemesRunge-Kutta Schemesn nSee van Loan for derivation of Runge-Kutta2 and Runge-See van Loan for derivation of Runge-Kutta2 and Runge-Kutta4.Kutta4.n nThe following(simple)scheme due to Jameson,Schmidt The following(simple)scheme due to Jameson,Schmidt and
6、 Turkel(1981):and Turkel(1981):第6页/共46页2003年Runge-Kutta SchemesRunge-Kutta Schemesn nBeware,it only works when Beware,it only works when f f is a function of is a function of y y and and notnot t tn nhere here s s is the order of the scheme.is the order of the scheme.第7页/共46页2003年Error EstimateError
7、 Estimaten nMatlab has a number of time integrators built in.Matlab has a number of time integrators built in.n node23ode23n node45ode45n nand others.and others.第8页/共46页2003年ode23ode23n nFor n=1:#timestepsFor n=1:#timestepsn node23 uses two estimates for yode23 uses two estimates for yn+1n+1.n nA 2A
8、 2ndnd order RK scheme and a 3 order RK scheme and a 3rdrd order RK scheme are used to build two order RK scheme are used to build two guesses for yguesses for yn+1n+1.n nIf the difference between these two estimates are within a tolerance ode23 If the difference between these two estimates are with
9、in a tolerance ode23 progresses on to calculating yprogresses on to calculating yn+2n+2n nIf the difference is greater than the specified tolerance,ode23 reduces the dt If the difference is greater than the specified tolerance,ode23 reduces the dt and tries again.It repeats until the difference is l
10、ower than the tolerance.and tries again.It repeats until the difference is lower than the tolerance.n nEndEnd第9页/共46页2003年T,Y=ode23(odefun,tspan,yT,Y=ode23(odefun,tspan,y0 0)nwith tspan=t0 tf integrates the system of differential equations from time t0 to tf with initial conditions y0.nY0 A vector o
11、f initial conditions.nOdefun A function that evaluates the right-hand side of the differential equations.第10页/共46页2003年Planets Example Using ode23Planets Example Using ode23n nIdea:replace our home grown Euler Forward scheme with MatlabIdea:replace our home grown Euler Forward scheme with Matlab s o
12、de23 s ode23 scheme in the scheme in the planets1.mplanets1.m script.script.第11页/共46页2003年Parameters forthe planets asbefore第12页/共46页2003年Initial velocitiesGatherX,Y,VX,VYinto one vector第13页/共46页2003年 T,CoordVel=ode23(forcing,TimeLimits,CoordVel(:);Call to Matlab ode23 functionfunction whichcalculat
13、es f(y)0 FinalTime Vector holdsX,Y,VX,VYWorks in Matlab v6.1.0 at least第14页/共46页2003年Call to ode23Find out the time at each time stepExtract final coordinates and velocitiesPlot planet orbitsd=size(X)returns the sizes of each dimension of array X in a vector d with ndims(X)elements.第15页/共46页2003年The
14、 routine whichcalculates the forcing function.第16页/共46页2003年Team ExerciseTeam Exercisen nGrab Grab planets2.mplanets2.m and and forcing.mforcing.mn nRun the scriptRun the scriptn nUse the Tsteps vector to find out the time step for each Use the Tsteps vector to find out the time step for each integr
15、ation stage.Plot a graph showing the time step(dt)integration stage.Plot a graph showing the time step(dt)at each time step.at each time step.n nUse Use helphelp to find out how to change the tolerance used by to find out how to change the tolerance used by ode23ode23 (hint you will need to use (hin
16、t you will need to use odesetodeset)n nRerun the simulation with a tolerance of 0.1 Rerun the simulation with a tolerance of 0.1 第17页/共46页2003年第18页/共46页2003年Application:One-Dimensional Electrostatic Application:One-Dimensional Electrostatic MotionMotion第19页/共46页2003年Charge RepulsionCharge Repulsionn
17、 nNow we will consider the case of charged particles with the same sign Now we will consider the case of charged particles with the same sign chargechargen nInstead of attracting each other,the charges repel each other.Instead of attracting each other,the charges repel each other.第20页/共46页2003年Parti
18、cle AccelerationsParticle Accelerationsa1a2Each particle has a vector accelerationdirectly away from the other particle第21页/共46页2003年Team ProjectTeam ProjectQ1)Modify the Q1)Modify the planets2.mplanets2.m and and forcing.mforcing.m to simulate the following:to simulate the following:n nThere are N
19、electrically charged particles There are N electrically charged particles confined to move in the x-confined to move in the x-direction onlydirection onlyn nDistribute the charges initially at equispaced points in-1,1Distribute the charges initially at equispaced points in-1,1n nThe equations of mot
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 药物 计算 分析 导论
限制150内