药物计算分析导论章.pptx

上传人:莉*** 文档编号:74452036 上传时间:2023-02-26 格式:PPTX 页数:46 大小:480.80KB
返回 下载 相关 举报
药物计算分析导论章.pptx_第1页
第1页 / 共46页
药物计算分析导论章.pptx_第2页
第2页 / 共46页
点击查看更多>>
资源描述

《药物计算分析导论章.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

20、ion of the charges are:The equations of motion of the charges are:第22页/共46页2003年Team ProjectTeam ProjectQ1cont)Include the following in one project write up per team:Q1cont)Include the following in one project write up per team:n nA scatter plot,with x as the horizontal axis and t as the vertical ax

21、is,showing A scatter plot,with x as the horizontal axis and t as the vertical axis,showing the paths of all the charged particles using ode23the paths of all the charged particles using ode23n nReplace ode23 with ode45 and rerunReplace ode23 with ode45 and rerunn nPlot the ode23 and ode45(t,x)paths

22、on the same graph.Plot the ode23 and ode45(t,x)paths on the same graph.n nPlot the ode23 and ode45 time step sizes on the same graphPlot the ode23 and ode45 time step sizes on the same graphn nNames of team membersNames of team members第23页/共46页2003年Chap.12 Chap.12 Electrostatics-Colliding Disks Proj

23、ectElectrostatics-Colliding Disks Project第24页/共46页2003年Big Team ProjectBig Team Projectn nOk Ok we have been warming up with some small projects we have been warming up with some small projectsn nNow for something a little more involvedNow for something a little more involved第25页/共46页2003年The Physic

24、sThe Physicsn nThe domain of interest is a two-dimensional periodic The domain of interest is a two-dimensional periodic box of side length Lbox of side length Ln nIt is populated with N circles of mass M each and It is populated with N circles of mass M each and radius Rradius R第26页/共46页2003年xyx=0y

25、=0 x=Ly=LDomain第27页/共46页2003年xyx=0y=0 x=Ly=LParticlesR第28页/共46页2003年Defining A Set of Motion RulesDefining A Set of Motion RulesRule 1Rule 1The disks are initially randomly distributedThe disks have random initial velocity(with the absolute value of each component of velocity bounded by 1)Rule 2Rule

26、 2Effectively Newtons first:all particles do not accelerate until they collide第29页/共46页2003年Particles CollideParticles Collide21Before21After第30页/共46页2003年Rule 4Rule 4n nMomentum(Momentum(动量动量)is conserved in a collision)is conserved in a collisionRule 5Rule 5Angular momentum(动量矩)is conserved in the

27、 collisionRule 6Rule 6Total kinetic energy(动能)is conserved The total kinetic energy of the particles is the same before and after the collision.第31页/共46页2003年Model SimplificationModel Simplificationn nWe are going to use Rules 4,5,and 6 to determine the change in We are going to use Rules 4,5,and 6

28、to determine the change in velocity of two disks when they collide.velocity of two disks when they collide.n nWe can simplify this problem by considering a coordinate frame We can simplify this problem by considering a coordinate frame which is:which is:n n co-moving with the center of one of the di

29、sks(say disk1)at co-moving with the center of one of the disks(say disk1)at its originits originn n with x-axis aligned in direction of the segment connecting the with x-axis aligned in direction of the segment connecting the two disk centerstwo disk centers第32页/共46页2003年In Co-Moving FrameIn Co-Movi

30、ng Frame21Before第33页/共46页2003年Math Version of 4Math Version of 4(in co-moving frame)(in co-moving frame)n nConservation of Conservation of linear momentumlinear momentum:n nWhich reduces to:Which reduces to:第34页/共46页2003年Math Version of 5Math Version of 5(in co-moving frame)(in co-moving frame)n nCo

31、nservation of Conservation of angular angular momentum:momentum:n nAnd since the center of two can not be at the origin And since the center of two can not be at the origin this implies:this implies:第35页/共46页2003年Math Version of 6Math Version of 6(in co-moving frame)(in co-moving frame)n nConservati

32、on of Conservation of kinetic energykinetic energy:n nReduces to:Reduces to:第36页/共46页2003年Summary of 4,5,6Summary of 4,5,6456第37页/共46页2003年SolutionsSolutionsCollisionNo collision第38页/共46页2003年In Co-Moving FrameIn Co-Moving Frame21Before21After第39页/共46页2003年Reverting To Non-moving FrameReverting To N

33、on-moving Frame The rules essentially say that if two equal The rules essentially say that if two equalmass disks collide then:mass disks collide then:1)1)they exchange velocity in their center-to-center vector they exchange velocity in their center-to-center vector 2)2)they retain their own velocit

34、y in the direction of the tangent to they retain their own velocity in the direction of the tangent to their center-to-center vectortheir center-to-center vector第40页/共46页2003年General FormulaGeneral Formula*第41页/共46页2003年Summary of Collision FormulaSummary of Collision Formulan nGiven the relative po

35、sition of two disks before the collision and their velocities we can determine the post-collision velocities第42页/共46页2003年Change invelocity ofdisk 1Exchange of linear andangular momentum第43页/共46页2003年Project DescriptionProject Descriptionn nUsing Euler forward as time steppingUsing Euler forward as

36、time steppingn nInitiate the random initial positions and velocities of the disksInitiate the random initial positions and velocities of the disksn nMove the particles with time step dtMove the particles with time step dtn nEach time step check to see if any disk intersects any other diskEach time s

37、tep check to see if any disk intersects any other diskn nif two disks intersect use the collision formula to determine their new velocitiesif two disks intersect use the collision formula to determine their new velocitiesn nIncrement(Increment(增大增大)the disk positions with dt multiplying their veloci

38、tiesthe disk positions with dt multiplying their velocities第44页/共46页2003年Project Description contProject Description cont Use mod on the updated positions to make sure that the disks stay within the box Repeat until quite a few collisions show up Plot the locations of the particles in a two-dimensional plot use hold so that the time history of the disks shows upmod(x,y)is X X mod Y Y 第45页/共46页

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 应用文书 > PPT文档

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com