常微分方程数值解函数Word格式.docx

上传人:b****2 文档编号:1205224 上传时间:2023-04-30 格式:DOCX 页数:16 大小:21.27KB
下载 相关 举报
常微分方程数值解函数Word格式.docx_第1页
第1页 / 共16页
常微分方程数值解函数Word格式.docx_第2页
第2页 / 共16页
常微分方程数值解函数Word格式.docx_第3页
第3页 / 共16页
常微分方程数值解函数Word格式.docx_第4页
第4页 / 共16页
常微分方程数值解函数Word格式.docx_第5页
第5页 / 共16页
常微分方程数值解函数Word格式.docx_第6页
第6页 / 共16页
常微分方程数值解函数Word格式.docx_第7页
第7页 / 共16页
常微分方程数值解函数Word格式.docx_第8页
第8页 / 共16页
常微分方程数值解函数Word格式.docx_第9页
第9页 / 共16页
常微分方程数值解函数Word格式.docx_第10页
第10页 / 共16页
常微分方程数值解函数Word格式.docx_第11页
第11页 / 共16页
常微分方程数值解函数Word格式.docx_第12页
第12页 / 共16页
常微分方程数值解函数Word格式.docx_第13页
第13页 / 共16页
常微分方程数值解函数Word格式.docx_第14页
第14页 / 共16页
常微分方程数值解函数Word格式.docx_第15页
第15页 / 共16页
常微分方程数值解函数Word格式.docx_第16页
第16页 / 共16页
亲,该文档总共16页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

常微分方程数值解函数Word格式.docx

《常微分方程数值解函数Word格式.docx》由会员分享,可在线阅读,更多相关《常微分方程数值解函数Word格式.docx(16页珍藏版)》请在冰点文库上搜索。

常微分方程数值解函数Word格式.docx

odefun

Afunctionhandlethatevaluatestherightsideofthedifferentialequations.SeeFunctionHandlesintheMATLABProgrammingdocumentationformoreinformation.Allsolverssolvesystemsofequationsintheformorproblemsthatinvolveamassmatrix,.Theode23ssolvercansolveonlyequationswithconstantmassmatrices.ode15sandode23tcansolveproblemswithamassmatrixthatissingular,i.e.,differential-algebraicequations(DAEs).

tspan

Avectorspecifyingtheintervalofintegration,[t0,tf].Thesolverimposestheinitialconditionsattspan

(1),andintegratesfromtspan

(1)totspan(end).Toobtainsolutionsatspecifictimes(allincreasingoralldecreasing),usetspan=[t0,t1,...,tf].

Fortspanvectorswithtwoelements[t0tf],thesolverreturnsthesolutionevaluatedateveryintegrationstep.Fortspanvectorswithmorethantwoelements,thesolverreturnssolutionsevaluatedatthegiventimepoints.Thetimevaluesmustbeinorder,eitherincreasingordecreasing.

Specifyingtspanwithmorethantwoelementsdoesnotaffecttheinternaltimestepsthatthesolverusestotraversetheintervalfromtspan

(1)totspan(end).AllsolversintheODEsuiteobtainoutputvaluesbymeansofcontinuousextensionsofthebasicformulas.Althoughasolverdoesnotnecessarilysteppreciselytoatimepointspecifiedintspan,thesolutionsproducedatthespecifiedtimepointsareofthesameorderofaccuracyasthesolutionscomputedattheinternaltimepoints.

Specifyingtspanwithmorethantwoelementshaslittleeffectontheefficiencyofcomputation,butforlargesystems,affectsmemorymanagement.

y0

Avectorofinitialconditions.

options

Structureofoptionalparametersthatchangethedefaultintegrationproperties.Thisisthefourthinputargument.

[t,y]=solver(odefun,tspan,y0,options)

Youcancreateoptionsusingtheodesetfunction.Seeodesetfordetails.

Thefollowingtableliststheoutputargumentsforthesolvers.

T

Columnvectoroftimepoints.

Y

Solutionarray.EachrowinYcorrespondstothesolutionatatimereturnedinthecorrespondingrowofT.

TE

Thetimeatwhichaneventoccurs.

YE

Thesolutionatthetimeoftheevent.

IE

Theindexioftheeventfunctionthatvanishes.

sol

Structuretoevaluatethesolution.

Description

[T,Y]=solver(odefun,tspan,y0)withtspan=[t0tf]integratesthesystemofdifferentialequationsfromtimet0totfwithinitialconditionsy0.odefunisafunctionhandle.SeeFunctionHandlesintheMATLABProgrammingdocumentationformoreinformation.Functionf=odefun(t,y),forascalartandacolumnvectory,mustreturnacolumnvectorfcorrespondingto.EachrowinthesolutionarrayYcorrespondstoatimereturnedincolumnvectorT.Toobtainsolutionsatthespecifictimest0,t1,...,tf(allincreasingoralldecreasing),usetspan=[t0,t1,...,tf].

ParameterizingFunctions,intheMATLABMathematicsdocumentation,explainshowtoprovideadditionalparameterstothefunctionfun,ifnecessary.

[T,Y]=solver(odefun,tspan,y0,options)solvesasabovewithdefaultintegrationparametersreplacedbypropertyvaluesspecifiedinoptions,anargumentcreatedwiththeodesetfunction.CommonlyusedpropertiesincludeascalarrelativeerrortoleranceRelTol(1e-3bydefault)andavectorofabsoluteerrortolerancesAbsTol(allcomponentsare1e-6bydefault).Ifcertaincomponentsofthesolutionmustbenonnegative,usetheodesetfunctiontosettheNonNegativepropertytotheindicesofthesecomponents.Seeodesetfordetails.

[T,Y,TE,YE,IE]=solver(odefun,tspan,y0,options)solvesasabovewhilealsofindingwherefunctionsof,calledeventfunctions,arezero.Foreacheventfunction,youspecifywhethertheintegrationistoterminateatazeroandwhetherthedirectionofthezerocrossingmatters.Dothisbysettingthe'

Events'

propertytoafunction,e.g.,eventsor@events,andcreatingafunction[value,isterminal,direction]=events(t,y).Fortheitheventfunctioninevents,

value(i)isthevalueofthefunction.

isterminal(i)=1,iftheintegrationistoterminateatazeroofthiseventfunctionand0otherwise.

direction(i)=0ifallzerosaretobecomputed(thedefault),+1ifonlythezeroswheretheeventfunctionincreases,and-1ifonlythezeroswheretheeventfunctiondecreases.

CorrespondingentriesinTE,YE,andIEreturn,respectively,thetimeatwhichaneventoccurs,thesolutionatthetimeoftheevent,andtheindexioftheeventfunctionthatvanishes.

sol=solver(odefun,[t0tf],y0...)returnsastructurethatyoucanusewithdevaltoevaluatethesolutionatanypointontheinterval[t0,tf].Youmustpassodefunasafunctionhandle.Thestructuresolalwaysincludesthesefields:

sol.x

Stepschosenbythesolver.

sol.y

Eachcolumnsol.y(:

i)containsthesolutionatsol.x(i).

sol.solver

Solvername.

IfyouspecifytheEventsoptionandeventsaredetected,solalsoincludesthesefields:

sol.xe

Pointsatwhichevents,ifany,occurred.sol.xe(end)containstheexactpointofaterminalevent,ifany.

sol.ye

Solutionsthatcorrespondtoeventsinsol.xe.

sol.ie

IndicesintothevectorreturnedbythefunctionspecifiedintheEventsoption.Thevaluesindicatewhicheventthesolverdetected.

IfyouspecifyanoutputfunctionasthevalueoftheOutputFcnproperty,thesolvercallsitwiththecomputedsolutionaftereachtimestep.Fouroutputfunctionsareprovided:

odeplot,odephas2,odephas3,odeprint.Whenyoucallthesolverwithnooutputarguments,itcallsthedefaultodeplottoplotthesolutionasitiscomputed.odephas2andodephas3producetwo-andthree-dimensionalphaseplaneplots,respectively.odeprintdisplaysthesolutioncomponentsonthescreen.Bydefault,theODEsolverpassesallcomponentsofthesolutiontotheoutputfunction.YoucanpassonlyspecificcomponentsbyprovidingavectorofindicesasthevalueoftheOutputSelproperty.Forexample,ifyoucallthesolverwithnooutputargumentsandsetthevalueofOutputSelto[1,3],thesolverplotssolutioncomponents1and3astheyarecomputed.

Forthestiffsolversode15s,ode23s,ode23t,andode23tb,theJacobianmatrixiscriticaltoreliabilityandefficiency.UseodesettosetJacobianto@FJACifFJAC(T,Y)returnstheJacobianortothematrixiftheJacobianisconstant.IftheJacobianpropertyisnotset(thedefault),isapproximatedbyfinitedifferences.SettheVectorizedproperty'

on'

iftheODEfunctioniscodedsothatodefun(T,[Y1,Y2...])returns[odefun(T,Y1),odefun(T,Y2)...].Ifisasparsematrix,settheJPatternpropertytothesparsitypatternof,i.e.,asparsematrixSwithS(i,j)=1iftheithcomponentofdependsonthejthcomponentof,and0otherwise.

ThesolversoftheODEsuitecansolveproblemsoftheform,withtime-andstate-dependentmassmatrix.(Theode23ssolvercansolveonlyequationswithconstantmassmatrices.)Ifaproblemhasamassmatrix,createafunctionM=MASS(t,y)thatreturnsthevalueofthemassmatrix,anduseodesettosettheMasspropertyto@MASS.Ifthemassmatrixisconstant,thematrixshouldbeusedasthevalueoftheMassproperty.Problemswithstate-dependentmassmatricesaremoredifficult:

IfthemassmatrixdoesnotdependonthestatevariableandthefunctionMASSistobecalledwithoneinputargument,t,settheMStateDependencepropertyto'

none'

.

Ifthemassmatrixdependsweaklyon,setMStateDependenceto'

weak'

(thedefault);

otherwise,setitto'

strong'

.Ineithercase,thefunctionMASSiscalledwiththetwoarguments(t,y).

Iftherearemanydifferentialequations,itisimportanttoexploitsparsity:

Returnasparse.

SupplythesparsitypatternofusingtheJPatternpropertyorasparseusingtheJacobianproperty.

Forstronglystate-dependent,setMvPatterntoasparsematrixSwithS(i,j)=1ifforanyk,the(i,k)componentofdependsoncomponentjof,and0otherwise.

Ifthemassmatrixissingular,thenisasystemofdifferentialalgebraicequations.DAEshavesolutionsonlywhenisconsistent,thatis,ifthereisavectorsuchthat.Theode15sandode23tsolverscansolveDAEsofindex1providedthaty0issufficientlyclosetobeingconsistent.Ifthereisamassmatrix,youcanuseodesettosettheMassSingularpropertyto'

yes'

'

no'

or'

maybe'

.Thedefaultvalueof'

causesthesolvertotestwhethertheproblemisaDAE.Youcanprovideyp0asthevalueoftheInitialSlopeproperty.Thedefaultisthezerovector.IfaproblemisaDAE,andy0andyp0arenotconsistent,thesolvertreatsthemasguesses,attemptstocomputeconsistentvaluesthatareclosetotheguesses,andcontinuestosolvetheproblem.WhensolvingDAEs,itisveryadvantageoustoformulatetheproblemsothatisadiagonalmatrix(asemi-explicitDAE).

Solver

ProblemType

OrderofAccuracy

WhentoUse

ode45

Nonstiff

Medium

Mostofthetime.Thisshouldbethefirstsolveryoutry.

ode23

Low

Forproblemswithcrudeerrortolerancesorforsolvingmoderatelystiffproblems.

ode113

Lowtohigh

Forproblemswithstringenterrortolerancesorforsolvingcomputationallyintensiveproblems.

ode15s

Stiff

Lowtomedium

Ifode45isslowbecausetheproblemisstiff.

ode23s

Ifusingcrudeerrortolerancestoso

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 法律文书 > 调解书

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2