Re: Simplify and then discretize a set of equations with derivatives and integrals
- To: mathgroup at smc.vnet.net
- Subject: [mg126693] Re: Simplify and then discretize a set of equations with derivatives and integrals
- From: Matthieu Brucher <matthieu.brucher at gmail.com>
- Date: Thu, 31 May 2012 02:49:38 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
> > Hi, Matthieu, > > Just to give an idea of what can easily be done. You can slightly rewrite > the system as follows: > > Clear[t]; > f[v_] := a*Exp[b*v + c]; > eqns = {e[t] - i[t]*R - vc[t] - vd[t] == 0, vc'[t] == CC^-1*i[t], > i[t] == f[vd[t]]} > > Here I use CC instead of C, since in Mathematica C is reserved. There are > besides an syntax error in the expression f(v) = a * e^(b * v + c). In > addition the second equation is differential instead of the integral. > You may then eliminate the variable i[t]: > > expr = Eliminate[eqns, i[t]] > > the result is: > > a E^(c + b vd[t]) == CC Derivative[1][vc][t] && > vd[t] == e[t] - vc[t] - CC R Derivative[1][vc][t] && CC != 0 > > Its first and second parts are your desired equations. Indeed > > expr[[1]] > expr[[2]] > > > E^(1 + vd[t]) == Derivative[1][vc][t] > > vd[t] == Sin[t] - vc[t] - Derivative[1][vc][t] > > > This you may solve numerically, if you fix the function e[t] and > parameters to be numeric. You can discretize it, but you need not. > Instead you might better apply the built-in function NDSolve. Have a look > in Menu/Help/NDSolve. To give an idea, I put below all constants equal to > 1, e[t]=Sin[t], and numerically solve the obtained system: > > e[t_] := Sin[t]; > c = 1; b = 1; CC = 1; a = 1; R = 1; > > s = NDSolve[{expr[[1]], expr[[2]], vc[0] == 0}, {vc[t], vd[t]}, {t, 0, > 30}][[1]] // Quiet > > Execute it. The result is expressed in terms of two > InterpolatingFunctions. To have a look what it gives, execute this: > > Plot[Evaluate[{vc[t], vd[t]} /. s], {t, 0, 30}] > > Finally, in this problem it was no need to exclude the variable, just > solve all the three equations at once numerically. > > I have chosen the initial values arbitrarily. Execute this: > > e[t_] := Sin[t]; > c = 1; b = 1; CC = 1; a = 1; R = 1; > > s1 = NDSolve[{eqns, vc[0] == 0, vd[0] == 1, i[0] == 0}, {vc[t], vd[t], > i[t]}, {t, 0, 30}][[1]] // Quiet > > and have a look at the result here: > > Plot[Evaluate[{vc[t], vd[t], i[t]} /. s1], {t, 0, 30}, > PlotStyle -> {Red, Green, Blue}] > > Here red gives vc, green - vd and blue - i. > > Have fun, Alexei > > Alexei BOULBITCH, Dr., habil. > IEE S.A. > ZAE Weiergewan, > 11, rue Edmond Reuter, > L-5326 Contern, LUXEMBOURG > > Office phone : +352-2454-2566 > Office fax: +352-2454-3566 > mobile phone: +49 151 52 40 66 44 > > e-mail: alexei.boulbitch at iee.lu > > > > > Hi Alexei, Thanks for the corrections and the advice. I will try it today. Indeed, the plot can be interesting to validate my final implementation of the problem. At the moment, I need to discretize it so that I can implement the final equation solver in C++. Thanks again, Matthieu -- Information System Engineer, Ph.D. Blog: http://matt.eifelle.com LinkedIn: http://www.linkedin.com/in/matthieubrucher