No BSD License  

Highlights from
Several methods for Solving DAE cases using Simulink and S-fucntion

Be the first to rate this file! 11 Downloads (last 30 days) File Size: 39.9 KB File ID: #23869

Several methods for Solving DAE cases using Simulink and S-fucntion

by

 

Try to solve DAE case using Simulink and S-function, compared the results and CPU time.

| Watch this File

File Information
Description

Try to solve DAE( Differential-Algebraic Equation) using Simulink and s-function.

Use a simple case as example:

der(x1)=-0.2*x1+x2*x3+0.3*x1*x2;
der(x2)=2*x1*x2-5*x2*x3-2*x2^2;
-1+x1+x2+x3=0;
(of course, this example can be translated to ODE form if we let x3=1-x1-x2, but for more complicated cases, this might be impossible, here we just keep this form).

1).Build this case in Simulink only. Use the block ‘Simulink/Math Operations/Algebraic Constraint’. See the attached file ‘DAEcase_simulink.mdl’.

2). Use level-1 S-function and ‘Simulink/Signal Attributes/IC’ block to initialize x3. See the attached file ‘DAEexamp1.m’(S-function file) and ‘DAEcase_1st.mdl’(Simulink file).

3). Try to use iteration (fsolve) in Derivative block of level-1 s-function to get the value of x3. See the attached file ‘DAEexamp2.m’(S-function file) and ‘DAEcase_2nd.mdl’(Simulink file).

4). Use level-1 S-function and ‘Simulink/Math Operations/Algebraic Constraint’ block to initialize x3. See the attached file ‘DAEexamp3.m’(S-function file) and ‘DAEcase_3rd.mdl’(Simulink file).

The simulation results are the same, but CPU time costs are different [1):0.121079s 2):0.160547s 3):0.513035s 4):0.167822s]. It seems the first method is the fastest, but for more complicated case, method 1 is impossible. In these 3 cases using S-function, Method 3 is much slower, but when I compare the CPU time cost using a more complicated case , it shows this method is faster than 2) and 4).

What I want to ask is: are all these methods correct? Which one is the best? Has any other method to solve DAE case? What’s more, I compared the solvers of Matlab(ode15s: for DAE and stiff case, it’s the fastest in Simulink) and Dassl, Dassl is almost more than 10X faster than ode15s, does anyone know how to accelerate Simulink simulation speed?

You are welcome to send me your comments and questions. Thanks.

Required Products Simulink
MATLAB release MATLAB 7.8 (R2009a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (1)
17 May 2011 Francisco-Ronay Lopez-Estrada

What happend when we have 2 algebraic equations. Given the nex dae system:

dx1/dt=2x2u
dx3/dt=x1
-x1+x4=0
x2+x3+x4+input=0
when input should be a sine or step input

Contact us