http://www.mathworks.com/matlabcentral/newsreader/view_thread/316628
MATLAB Central Newsreader  DAE in matlab
Feed for thread: DAE in matlab
enus
©19942014 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Mon, 06 Feb 2012 17:41:10 +0000
DAE in matlab
http://www.mathworks.com/matlabcentral/newsreader/view_thread/316628#865907
Michal Lukac
Hello,<br>
Copuld anybody help solving these equations in matlab?<br>
<br>
<a href="http://sites.google.com/site/plsanek/test">http://sites.google.com/site/plsanek/test</a><br>
<br>
thanks<br>
michal

Mon, 06 Feb 2012 18:58:10 +0000
Re: DAE in matlab
http://www.mathworks.com/matlabcentral/newsreader/view_thread/316628#865918
Roger Stafford
"Michal Lukac" <michal.lukac@fstroj.uniza.sk> wrote in message <jgp3bm$21n$1@newscl01ah.mathworks.com>...<br>
> Hello,<br>
> Copuld anybody help solving these equations in matlab?<br>
> <br>
> <a href="http://sites.google.com/site/plsanek/test">http://sites.google.com/site/plsanek/test</a><br>
> <br>
> thanks<br>
> michal<br>
       <br>
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!<br>
<br>
A couple of questions: In the notation "x4.b.sin(x1pi)" I assume the dot indicates multiplication, so why isn't it used in for example "x3cos(x2)"? Also why write "sin(x1pi)" instead of "sin(x1)"?<br>
<br>
Roger Stafford

Tue, 07 Feb 2012 10:30:11 +0000
Re: DAE in matlab
http://www.mathworks.com/matlabcentral/newsreader/view_thread/316628#866025
Michal Lukac
<br>
> A couple of questions: In the notation "x4.b.sin(x1pi)" I assume the dot indicates multiplication, so why isn't it used in for example "x3cos(x2)"? Also why write "sin(x1pi)" instead of "sin(x1)"?<br>
> <br>
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. <br>
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.<br>
<br>
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.<br>
<a href="http://en.wikipedia.org/wiki/Differential_algebraic_equation">http://en.wikipedia.org/wiki/Differential_algebraic_equation</a><br>
<br>
I have' found something about index of DAE, but i don't understand well and the solvers solve the equations just of particular index. <br>
May be, I need to modify these euations a bit but I don't know how..<br>
When I tried to use ode15i and odebim I reduced the order of DE by substitutions<br>
d_y1 = dd_x, d_y2 = d_x, ...etc...<br>
<br>
thanks.

Tue, 07 Feb 2012 11:26:58 +0000
Re: DAE in matlab
http://www.mathworks.com/matlabcentral/newsreader/view_thread/316628#866027
Torsten
On 7 Feb., 11:30, "Michal Lukac" <michal.lu...@fstroj.uniza.sk> wrote:<br>
> > A couple of questions: In the notation "x4.b.sin(x1pi)" I assume the dot indicates multiplication, so why isn't it used in for example "x3cos(x2)"? Also why write "sin(x1pi)" instead of "sin(x1)"?<br>
><br>
> 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.<br>
> 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.<br>
><br>
> 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.<a href="http://en.wikipedia.org/wiki/Differential_algebraic_equation">http://en.wikipedia.org/wiki/Differential_algebraic_equation</a><br>
><br>
> I have' found something about index of DAE, but i don't understand well and the solvers solve the equations just of particular index.<br>
> May be, I need to modify these euations a bit but I don't know how..<br>
> When I tried to use ode15i and odebim I reduced the order of DE by substitutions<br>
> d_y1 = dd_x, d_y2 = d_x, ...etc...<br>
><br>
> thanks.<br>
<br>
There are specialized codes for the simulation of constraint<br>
mechanical systems.<br>
Take a look at the 'Mechanical Systems' section under<br>
<a href="http://www.unige.ch/~hairer/software.html">http://www.unige.ch/~hairer/software.html</a><br>
I doubt that MATLAB's ode15i can handle index2 systems as it is<br>
required for your set of equations.<br>
<br>
Best wishes<br>
Torsten.

Tue, 07 Feb 2012 12:58:01 +0000
Re: DAE in matlab
http://www.mathworks.com/matlabcentral/newsreader/view_thread/316628#866029
Torsten
On 7 Feb., 12:26, Torsten <Torsten.Hen...@umsicht.fraunhofer.de><br>
wrote:<br>
> On 7 Feb., 11:30, "Michal Lukac" <michal.lu...@fstroj.uniza.sk> wrote:<br>
><br>
> > > A couple of questions: In the notation "x4.b.sin(x1pi)" I assume the dot indicates multiplication, so why isn't it used in for example "x3cos(x2)"? Also why write "sin(x1pi)" instead of "sin(x1)"?<br>
><br>
> > 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.<br>
> > 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.<br>
><br>
> > 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.<a href="http://en.wikipedia.org/wiki/Differential_algebraic_equation">http://en.wikipedia.org/wiki/Differential_algebraic_equation</a><br>
><br>
> > I have' found something about index of DAE, but i don't understand well and the solvers solve the equations just of particular index.<br>
> > May be, I need to modify these euations a bit but I don't know how..<br>
> > When I tried to use ode15i and odebim I reduced the order of DE by substitutions<br>
> > d_y1 = dd_x, d_y2 = d_x, ...etc...<br>
><br>
> > thanks.<br>
><br>
> There are specialized codes for the simulation of constraint<br>
> mechanical systems.<br>
> Take a look at the 'Mechanical Systems' section under<a href="http://www.unige.ch/~hairer/software.html">http://www.unige.ch/~hairer/software.html</a><br>
> I doubt that MATLAB's ode15i can handle index2 systems as it is<br>
> required for your set of equations.<br>
><br>
> Best wishes<br>
> Torsten.<br>
<br>
You may try to differentiate the last two algebraic equations twice<br>
with respect to t and<br>
solve the resulting ODEsystem using ODE15I.<br>
But since you loose information by the differentiation, the errors in<br>
x1, x2 and x3 may accumulate<br>
such that your algebraic constraints from the last two equations get<br>
violated during the integration.<br>
<br>
Best wishes<br>
Torsten.

Tue, 20 Mar 2012 05:20:22 +0000
Re: DAE in matlab
http://www.mathworks.com/matlabcentral/newsreader/view_thread/316628#870554
John Hedengren
Below is an implementation of your equations that you can solve with APM MATLAB:<br>
<br>
<a href="http://www.mathworks.com/matlabcentral/fileexchange/32068optimizationnonlinearcontrolandestimationtoolbox">http://www.mathworks.com/matlabcentral/fileexchange/32068optimizationnonlinearcontrolandestimationtoolbox</a><br>
<br>
If you want to quickly verify that the model is coded correctly, you can try it through the webinterface for steady state models:<br>
<br>
<a href="http://apmonitor.com/online/view_pass.php">http://apmonitor.com/online/view_pass.php</a><br>
<br>
APM MATLAB is designed to solve highindex DAEs in implicit form for simulation, parameter estimation, or optimization applications. It converts the DAEs to an NLP and solves them with largescale sparse solvers such as APOPT or IPOPT.<br>
<br>
! Begin model<br>
<br>
Constants<br>
pi = 3.1415<br>
End Constants<br>
<br>
Parameters<br>
a = 1<br>
b = 2<br>
c = 3<br>
d = 4<br>
e = 5<br>
f = 6<br>
g = 7<br>
h = 8<br>
End Parameters<br>
<br>
Variables<br>
x1<br>
x2<br>
x3<br>
x4<br>
x5<br>
v1<br>
v2<br>
v3<br>
End Variables<br>
<br>
Equations<br>
v1 = $x1<br>
v2 = $x2<br>
v3 = $x3<br>
a * $v1  x4 * b * sin(x1pi) + x5 * b * cos(x1pi) = 0<br>
$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<br>
x3 * sin(x2) + f*sin(x2) + b*sin(x1pi)  h = 0<br>
End Equations<br>
<br>
!End Model Specifications<br>
<br>
John Hedengren<br>
<br>
"Michal Lukac" <michal.lukac@fstroj.uniza.sk> wrote in message <jgp3bm$21n$1@newscl01ah.mathworks.com>...<br>
> Hello,<br>
> Copuld anybody help solving these equations in matlab?<br>
> <br>
> <a href="http://sites.google.com/site/plsanek/test">http://sites.google.com/site/plsanek/test</a><br>
> <br>
> thanks<br>
> michal