Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
DAE in matlab

Subject: DAE in matlab

From: Michal Lukac

Date: 6 Feb, 2012 17:41:10

Message: 1 of 6

Hello,
Copuld anybody help solving these equations in matlab?

http://sites.google.com/site/plsanek/test

thanks
michal

Subject: DAE in matlab

From: Roger Stafford

Date: 6 Feb, 2012 18:58:10

Message: 2 of 6

"Michal Lukac" <michal.lukac@fstroj.uniza.sk> wrote in message <jgp3bm$21n$1@newscl01ah.mathworks.com>...
> Hello,
> Copuld anybody help solving these equations in matlab?
>
> http://sites.google.com/site/plsanek/test
>
> thanks
> michal
- - - - - - - -
   I would suggest trying 'ode15i' which is intended for use with implicit differential equations. However your equations have the unusual quality that no derivatives appear in the last two equations. These make two of the variables in x1, x2, and x3 specifically dependent on the third, so that their first and second derivatives are also interrelated. In turn, the derivatives of x4 and x5 are both completely absent and their solution is dependent on their satisfying the first three equations. Very strange!

  A couple of questions: In the notation "x4.b.sin(x1-pi)" I assume the dot indicates multiplication, so why isn't it used in for example "x3cos(x2)"? Also why write "sin(x1-pi)" instead of "-sin(x1)"?

Roger Stafford

Subject: DAE in matlab

From: Michal Lukac

Date: 7 Feb, 2012 10:30:11

Message: 3 of 6


> A couple of questions: In the notation "x4.b.sin(x1-pi)" I assume the dot indicates multiplication, so why isn't it used in for example "x3cos(x2)"? Also why write "sin(x1-pi)" instead of "-sin(x1)"?
>
Yes, You are right the dot are multiplications, I wanted to write the equations more readable.... and hasn't crossed my mind to simplify the expressions.... sorry.
These equations describe motion of a mechanism. I wrote them as I derive them from the drawing of mechanism. The last two eq. are constrains of the mechanism.

 I tried to use ode15i, odebim(I have found here), but unsecesfull. I'm not a mathematician... These equationas are DAE differential equations + algebraic equations.
http://en.wikipedia.org/wiki/Differential_algebraic_equation

I have' found something about index of DAE, but i don't understand well and the solvers solve the equations just of particular index.
May be, I need to modify these euations a bit but I don't know how..
When I tried to use ode15i and odebim I reduced the order of DE by substitutions
d_y1 = dd_x, d_y2 = d_x, ...etc...

thanks.

Subject: DAE in matlab

From: Torsten

Date: 7 Feb, 2012 11:26:58

Message: 4 of 6

On 7 Feb., 11:30, "Michal Lukac" <michal.lu...@fstroj.uniza.sk> wrote:
> >   A couple of questions:  In the notation "x4.b.sin(x1-pi)" I assume the dot indicates multiplication, so why isn't it used in for example "x3cos(x2)"?  Also why write "sin(x1-pi)" instead of "-sin(x1)"?
>
> Yes, You are right the dot are multiplications, I wanted to write the equations more readable.... and hasn't crossed my mind to simplify the expressions.... sorry.
> These equations describe motion of a mechanism. I wrote them as I derive them from the drawing of mechanism. The last two eq. are constrains of the mechanism.
>
>  I tried to use ode15i, odebim(I have found here), but unsecesfull.  I'm not a mathematician... These equationas are DAE differential equations + algebraic equations.http://en.wikipedia.org/wiki/Differential_algebraic_equation
>
> I have' found something about index of DAE, but i don't understand well and the solvers solve the equations just of particular index.
> May be, I need to modify these euations a bit but I don't know how..
> When I tried to use ode15i and odebim I reduced the order of DE by substitutions
> d_y1 = dd_x,  d_y2 = d_x, ...etc...
>
> thanks.

There are specialized codes for the simulation of constraint
mechanical systems.
Take a look at the 'Mechanical Systems' section under
http://www.unige.ch/~hairer/software.html
I doubt that MATLAB's ode15i can handle index-2 systems as it is
required for your set of equations.

Best wishes
Torsten.

Subject: DAE in matlab

From: Torsten

Date: 7 Feb, 2012 12:58:01

Message: 5 of 6

On 7 Feb., 12:26, Torsten <Torsten.Hen...@umsicht.fraunhofer.de>
wrote:
> On 7 Feb., 11:30, "Michal Lukac" <michal.lu...@fstroj.uniza.sk> wrote:
>
> > >   A couple of questions:  In the notation "x4.b.sin(x1-pi)" I assume the dot indicates multiplication, so why isn't it used in for example "x3cos(x2)"?  Also why write "sin(x1-pi)" instead of "-sin(x1)"?
>
> > Yes, You are right the dot are multiplications, I wanted to write the equations more readable.... and hasn't crossed my mind to simplify the expressions.... sorry.
> > These equations describe motion of a mechanism. I wrote them as I derive them from the drawing of mechanism. The last two eq. are constrains of the mechanism.
>
> >  I tried to use ode15i, odebim(I have found here), but unsecesfull.  I'm not a mathematician... These equationas are DAE differential equations + algebraic equations.http://en.wikipedia.org/wiki/Differential_algebraic_equation
>
> > I have' found something about index of DAE, but i don't understand well and the solvers solve the equations just of particular index.
> > May be, I need to modify these euations a bit but I don't know how..
> > When I tried to use ode15i and odebim I reduced the order of DE by substitutions
> > d_y1 = dd_x,  d_y2 = d_x, ...etc...
>
> > thanks.
>
> There are specialized codes for the simulation of constraint
> mechanical systems.
> Take a look at the 'Mechanical Systems' section underhttp://www.unige.ch/~hairer/software.html
> I doubt that MATLAB's ode15i can handle index-2 systems as it is
> required for your set of equations.
>
> Best wishes
> Torsten.

You may try to differentiate the last two algebraic equations twice
with respect to t and
solve the resulting ODE-system using ODE15I.
But since you loose information by the differentiation, the errors in
x1, x2 and x3 may accumulate
such that your algebraic constraints from the last two equations get
violated during the integration.

Best wishes
Torsten.

Subject: DAE in matlab

From: John Hedengren

Date: 20 Mar, 2012 05:20:22

Message: 6 of 6

Below is an implementation of your equations that you can solve with APM MATLAB:

http://www.mathworks.com/matlabcentral/fileexchange/32068-optimization-nonlinear-control-and-estimation-toolbox

If you want to quickly verify that the model is coded correctly, you can try it through the web-interface for steady state models:

http://apmonitor.com/online/view_pass.php

APM MATLAB is designed to solve high-index DAEs in implicit form for simulation, parameter estimation, or optimization applications. It converts the DAEs to an NLP and solves them with large-scale sparse solvers such as APOPT or IPOPT.

! ---Begin model

Constants
  pi = 3.1415
End Constants

Parameters
  a = 1
  b = 2
  c = 3
  d = 4
  e = 5
  f = 6
  g = 7
  h = 8
End Parameters

Variables
  x1
  x2
  x3
  x4
  x5
  v1
  v2
  v3
End Variables

Equations
  v1 = $x1
  v2 = $x2
  v3 = $x3
  -a * $v1 - x4 * b * sin(x1-pi) + x5 * b * cos(x1-pi) = 0
  $v2 * (c+d+e*x3^2) + 2*e*$x2*x3*$x3 + x4*(x3*sin(x2)+f*sin(x2))-x5*(x3*cos(x2))+f*cos(x2)=0
  x3 * sin(x2) + f*sin(x2) + b*sin(x1-pi) - h = 0
End Equations

!----End Model Specifications

-John Hedengren

"Michal Lukac" <michal.lukac@fstroj.uniza.sk> wrote in message <jgp3bm$21n$1@newscl01ah.mathworks.com>...
> Hello,
> Copuld anybody help solving these equations in matlab?
>
> http://sites.google.com/site/plsanek/test
>
> thanks
> michal

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us