Re: Problem with NDSolve
- To: mathgroup at smc.vnet.net
- Subject: [mg37893] Re: Problem with NDSolve
- From: "Edgardo S. Cheb-Terrab" <ecterrab at cecm.sfu.ca>
- Date: Sun, 17 Nov 2002 06:44:41 -0500 (EST)
- References: <200210220847.EAA27452@smc.vnet.net> <ar25in$g4h$1@smc.vnet.net> <ar4o8l$5be$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
"Sergio Rescia" <rescia at bnl.gov> wrote in message news:ar25in$g4h$1 at smc.vnet.net... > > Dear Math expert, > > > > I am trying to use NDSolve to solve a circuit where a component > > changes its value at some time. NDSolve (Mathematica version 4 on an > > IBM PC running Windows 98SE) misses the transient. > > > > The simplest circuit (which can also be solved analythically) which > > shows the problem can be modelled as an RC circuit with a step input. > > At time t0 a capacitor ... ... > > ... > > > > As can be seen in the notebook, NDSolve misses the transient, and > > computes an almost exact rising exponential with the initial time > > constan (R * C). > > ... > ---------------------------------------- "Selwyn Hollis" <hollisse at mail.armstrong.edu> wrote in message news:ar4o8l$5be$1 at smc.vnet.net... > Hi Sergio, > > If you look at your i2[t] expression, you'll see that it has a term > involving DiracDelta[t-.5]. There is no way a numerical algorithm is > going to deal correctly with that. Here's a simple, though not totally > satisfactory, work-around: ... > ... > ---------------------------------------- Hi, Yes, the problem is in the presence of the Dirac function, which cannot be directly handled numerically. There is however a way to treat these problems which use to work with linear ODEs (your case): change variables V(t) -> v(t) g(t), where V(t) is the dependent variable of your ODE and g(t) is some function to be determined such that: neither g(t) nor the resulting ODE in v(t) contain Dirac functions. Finally plotting v(t) g(t) you obtain the plot for your original problem in V(t). Example. (-1 - Dirac(t - 5)) vout UnitStep(t) vout' = ------------------------ + ------------------- 1 + UnitStep(t - 5) 1 + UnitStep(t - 5) where vout(t) is the dependent variable. Searching for vout(t) = v(t) g(t) with g having the properties mentioned, by eye, g(t) = 1/(1 + UnitStep(t - 5)) is a solution, since it does not contain Dirac, and through vout = v g, it leads to an ODE in v also free of Dirac v v' + ------------------- - UnitStep(t) = 0 1 + UnitStep(t - 5) So, noting that vout(0) = v(0) = 0, solve numerically this ODE in v and plot v g to obtain the plot of the solution to your original problem in V. In above one could still object the "guesswork" in finding an appropriate g(t). A manner of avoiding this guesswork is based in the observation that a function g(t), with properties as the one mentioned, typically has its derivative expressed in terms of Dirac (that is why the ODE in the new variable v(t) has no Dirac functions). So formulate the problem for g(t). Example. Change variables vout(t) = v(t) g(t), with g(t) unknown at this point, arriving at v g Dirac(t - 5) ------------------- + v g' (A) 1 + UnitStep(t - 5) (v' UnitStep(t - 5) + v + v') g UnitStep(t) + ------------------------------- - ------------------- = 0 1 + UnitStep(t - 5) 1 + UnitStep(t - 5) Take now the terms in above containing " Dirac and g' " only, equate them to zero and solve for g: v g Dirac(t - 5) -------------------- + v g' = 0 1 + UnitStep(t - 5) g = C[1] Exp(- UnitStep(t - 5)) and there you are, with a generic g(t) solving your problem. Take C[1]=1 for simplicity, and your ODE in v(t) free of Dirac, from (A) above, is (v' UnitStep(t - 5) + v + v') g UnitStep(t) ------------------------------- - ------------------- = 0 1 + UnitStep(t - 5) 1 + UnitStep(t - 5) Again, solve numerically for v and plot v g, representing the plot of the solution to your original problem in V. PS: thanks to Allan Wittkopf who pointed this to me once. Edgardo S. Cheb-Terrab http://lie.uwaterloo.ca/ecterrab Theoretical Physics Department UERJ,Brazil Centre for Experimental and Constructive Mathematics SFU, Canada