Re: NDSolve and hybrid dynamics (Differential Algebraic Equation DAE)
- To: mathgroup at smc.vnet.net
- Subject: [mg113569] Re: NDSolve and hybrid dynamics (Differential Algebraic Equation DAE)
- From: schochet123 <schochet123 at gmail.com>
- Date: Wed, 3 Nov 2010 02:53:52 -0500 (EST)
- References: <iaongc$jf2$1@smc.vnet.net>
Even when a system has binary states it is common to approximate those
states numerically by a smoothed function. Consider, for example the
simple continuous approximation
cpw[x_]=Piecewise[{{1, x < 1/10 - eps}, {1 + (x - (1/10 - eps))/(2
eps),
1/10 - eps <= x <= 1/10 + eps}}, 2]
Taking, for example,
eps=1/1000;
substituting this into the original DAE, i.e., solving the problem
appreqns = {x'[t] == y[t] + Sin[t], y[t] == cpw[x[t]],
x[-Pi] == 1/2};
apprsol = {x[t], y[t]} /. NDSolve[appreqns, {x[t], y[t]}, {t, -5, 5}]
yields a solution which differs from that obtained by using the true
binary state by no more than about 10^(-4). If that is not good
enough, then take a smaller eps and/or a smoother approximation.
One reason for using the smoothed function is that it is not always
easy/possible to solve the algebraic equation for the slaved variable.
Consider for example
alteqns = {x'[t] == y[t] + Sin[t],
y[t]^3 - (2 x[t] + 100) y[t] == cpw[x[t]], x[-Pi] == 1/2,
y[-Pi] == Chop[N[y /. ysubs[[1]], 50]]};
altsol = {x[t], y[t]} /. NDSolve[alteqns2, {x[t], y[t]}, {t, -5, 5}]
where
ysubs = Solve[y^3 - 101 y == 2];
In this example it is possible to omit the initial condition for y and
then NDSolve picks one of the three possible values.
Steve
On Nov 2, 12:00 pm, Ravi Balasubramanian
<ravi.balasubraman... at yale.edu> wrote:
> Hello Oliver,
>
> Thanks for your suggestion.
>
> Unfortunately, a smoothing function would not be useful, since the
> system has binary states.
>
> I figured a way to do this is to include the f[x] function into the
> x'[t] equation such as
>
> x'[t] == f[x[t]] + Sin[t]
>
> (f[x] has only two states and no smoothing)
>
> and use NDSolve to solve for x[t]. This works. And then I can evalu=
ate
> f[x[t]] using the NDSolve solution.
>
> Just to summarize this discussion: NDSolve does not support binary
> variables as part of the state?
>
> Ravi
>
> Oliver Ruebenkoenig wrote:
>
> > Ravi,
>
> > would a smoothing function be useful?
>
> > f[x_] := Which[
> > x <= -1, 0,
> > -1 < x < 1, 1/2 + x (15/16 - x^2 (5/8 - 3/16 x^2)),
> > x >= 1, 1] + 1
>
> > Plot[f[(x - 0.1)/0.001], {x, -0.2, 0.2}]
>
> > eqns = {x'[t] == y[t] + Sin[t], y[t] == f[t], x[-\[Pi]] ==
= 1/2};
> > sol = NDSolve[eqns, {x[t], y[t]}, {t, -5, 5}]
>
> > Hope this helps,
>
> > Oliver
>
> > On Mon, 1 Nov 2010, Ravi Balasubramanian wrote:
>
> >> Friends,
>
> >> I am trying to solve a hybrid dynamics problem using NDSolve.
>
> >> I am aware that I could use the event locator methods in NDSolve and
> >> manually take care of the transitions (set initial conditions etc). =
But
> >> my system is complicated, and I would have to do a lot of book-keeping=