MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: NDSolve and hybrid dynamics (Differential Algebraic Equation DAE)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113553] Re: NDSolve and hybrid dynamics (Differential Algebraic Equation DAE)
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Tue, 2 Nov 2010 05:02:17 -0500 (EST)

If is a programming construct not a mathematical function. Use Piecewise

eqns = {x'[t] == y[t] + Sin[t],
   y[t] == Piecewise[{{1, t < 1/10}}, 2],
   x[-Pi] == 1/2};

sol = {x[t], y[t]} /. DSolve[eqns, {x[t], y[t]}, t][[1]]

{(1/2)*(-1 + 2*Pi + 2*Piecewise[{{t - Cos[t], t <= 1/10}}, 
            -(1/10) + 2*t - Cos[t]]), Piecewise[{{1, t < 1/10}}, 2]}

Plot[sol, {t, -5, 1},
 Frame -> True,
 Axes -> False,
 Exclusions -> 1/10,
 ExclusionsStyle -> Red]

For NDSolve break the problem into two regions


Bob Hanlon

---- Ravi Balasubramanian <ravi.balasubramanian at yale.edu> 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.

The following represents a simplified version of the problem.

eqns = {x'[t] == y[t] + Sin[t], y[t] == If[t < 0.1, 1, 2],
    x[-Pi] == 1/2};
sol = NDSolve[eqns, {x[t], y[t]}, {t, -5, 5}]

It is a first order differential equation in x[t], but it includes a 
y[t] variable that is discontinuous.  There should be solution for this 
problem, but I get the following error message from NDSolve.

LinearSolve::"nosol" : "Linear equation encountered that has no solution.

The error is probably arising from the "If" condition.

FYI, in my real system the y[t] variable is a Lagrange multiplier that 
is enforcing a constraint.  Under certain conditions, that constraint is 
broken and the system transitions into another state.  It will be great 
if this problem can be solved with NDSolve keeping track of the y[t] 
variable for me.  Any suggestions greatly appreciated.

Thanks!

Ravi Balasubramanian
Yale University




  • Prev by Date: Re: Assertions in Mathematica?
  • Next by Date: Re: NDSolve and hybrid dynamics (Differential Algebraic Equation DAE)
  • Previous by thread: NDSolve and hybrid dynamics (Differential Algebraic Equation DAE)
  • Next by thread: Re: NDSolve and hybrid dynamics (Differential Algebraic Equation DAE)