[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: differential equation
From: |
Liam Groener |
Subject: |
Re: differential equation |
Date: |
Mon, 16 May 2011 22:04:30 -0700 |
Sent from my iPad
On May 16, 2011, at 8:41 PM, Thomas Shores <address@hidden> wrote:
> On 05/16/2011 04:52 PM, Liam Groener wrote:
>> On May 16, 2011, at 9:35 AM, CdeMills wrote:
>>
>>> Hello,
>>>
>>> I'm trying to simulate an electrical circuit whose time-domain differential
>>> equation is
>>> V" + k1 V' +k2 V = a1 I' + a2 I
>>> Vs(t) - Rs I = V
>>> where V and I are the device voltage and current, respectively, and the rest
>>> are constants. Vs is the time-varying voltage source, and Rs its internal
>>> resistance. Starting from equilibrium, all values and their derivatives are
>>> set to zero.
>>>
>>> I don't see how to formulate the problem, in particular adding the source
>>> equation into the picture.
>>>
>>> LSODE: let's say x1 = V, x2 = I, x3 = V'; so we have
>>> x1' = x3
>>> x2' = ??? => I' depends on Vs'(t) ???
>>> x3' = a1 * ??? + a2 x2 - k1 x3 - k2 x1
>>> How to fill the "???"
>>>
>>> DASSL: same variables
>>> res1 = x1'-x3
>>> res2 = ...
>>> res3 = x3' - a1 x2' - a2 x2 - k1 x3 - k2 x1
>>> In all cases, I need a relationship around I', and would like Vs(t) to be a
>>> step source, in this case Vs'(t) would become infinite ???
>>>
>>> Any hints ?
>>
>> I would substitute I = (Vs-V)/Rs into your first equation and use lsode.
>> You would then have 2 d.e.'s:
>> x'(1) = x(2)
>> x'(2) = aVs - k1 x(2) - b x(1)
>> where:
>> a = a1/Rs and b = k2+a1/Rs
>>
>> The initial conditions would be:
>> x(1)=0, x(2)=0
>> Don't worry about the infinite derivative, the imbalance in the initial
>> voltage should take care of that.
>>
>> _______________________________________________
>> Help-octave mailing list
>> address@hidden
>> https://mailman.cae.wisc.edu/listinfo/help-octave
> Interesting. This works. In any case, the three variable cannot possibly
> work, since lsode is based on methods (ABM, BDF) that assume continuous
> solutions, and this is all they will generate. However, the formula Vs =
> V+Rs*I guarantees that one of V or I cannot possibly be continuous at any
> jump discontinuity of Vs. Thus the 3-variable approach cannot possibly work
> in any formulation since it would mandate that V, V' and I be continuous
> initially and at every interior point. In that regard, the conditions that I
> and I' vanish initially make the system inconsistent if they are meant to be
> used as part of an initial value problem. Your approach ignore those
> constraints and banished the potential discontinuities due to the step
> source on the right hand side of the first order ode as simple jump
> discontinuities, so the problem remains well posed. Here's a script that
> illustrates these points with an impulse function.
>
> Thomas Shores
>
> % DEtest.m
>
> clear
> global k = [1,2] # [k1,k2]
> global a = [2,2] # [a1,a2]
> global Rs = 0.5
>
> function retval = heaviside(t)
> retval = (t==0)*0.5 + (t>0);
> end
>
> function retval = Vs(t)
> retval = heaviside(t-0.5)-heaviside(t-1);
> end
>
> function retval = Vsp(t)
> retval = zeros(size(t)); # ignore any dirac delta function
> end
>
> function retval = fcn(x,t)
> # here x = [V; Vp]
> global k;
> global a;
> global Rs;
>
> retval = [0;0];
> retval(1) = x(2);
> retval(2) = a(1)*(Vsp(t)-x(2))/Rs + a(2)*(Vs(t)-x(1))/Rs - k(1)*x(2) -
> k(2)*x(1);
> end
>
> % main: give it a spin
> x0 = [0;0];
> t = linspace(0,4,800);
> x = lsode(@fcn,x0,t);
> clf
> plot(t',x(:,1),"-1;V(t);")
> hold on, grid
> plot(t',x(:,2),"-2;V'(t);")
> plot(t',(Vs(t)'-x(:,1))/Rs,"-3;I(t);")
> plot(t,Vs(t),"-4;Vs(t);")
>
Actually, I see that I forgot the I' part of the original d.e., so back to the
drawing boards.