Sundials Solver in MATLAB/Simulink

12 views (last 30 days)
I noticed that the Sundials solver is implemented and and used someplaces in Simulink and MATLAB. I often run into problem formation that is Differential Algebraic Equations rather than Ordinary Differential Equations. I would like to experiment with the Sundials solvers however I can only find access to Sundials in SimBiology. Is there any chance that this solver will be available generally in Simulink and Matlab sometime in the future?
  3 Comments
Arthur Goldsipe
Arthur Goldsipe on 23 Feb 2017
Hi Sam, please see the answer I just posted below.
Jason Nicholson
Jason Nicholson on 23 Feb 2017
Edited: Jason Nicholson on 21 Mar 2018
Sam N. No I have not. I think the lack of answer is my answer: No, no support for Sundials in Simulink.
An old interface to Sundials has been written and is linked below. https://searchworks.stanford.edu/view/11143449
I don't plan on trying to connect into Sundials anytime soon. I think it is bit beyond my understanding. My key issues have to do with speed and complexity of models for large scale modeling. Large to me means building system on top of system on top of system. Where each level introduces 10-30 states of very stiff, often DAE, numerical ill-posed problems. My various states may be of the size 0.001 and then another state is 1e8 at the same time step. This state "size" combined with zero crossings, DAE's, absolute tolerances, inherent numerical stiffness, and non-smoothness seem to cause the simulations to be slow. I have work to better pose the problem. That is where I will focus rather than focusing on implementing an interface to Sundials.

Sign in to comment.

Accepted Answer

Jason Nicholson
Jason Nicholson on 21 Mar 2018
Edited: Jason Nicholson on 9 Apr 2018
Support for Sundials is limited in SimBiology. There is no hint that this will be more broadly available anytime soon.
Hint and tips:
  • Use the Simscape modeling language to define DAE's of problems in a way that MATLAB/Simulink can better understand and reformulate the DAE for solving. For instance, SimMechanics is optimized to deal with Index 3 DAE's that arise in rigid motion of multiple bodies moving together. There is no need to algebraically remove the constraints.
  • If you must work in Simulink, then add states with known dynamics in places that have the algebraic states. For instance, replace an algebraic state with a first order transfer function with 10-1000 times faster dynamics than the rest of the model. This adds stiffness to the ODE system but the DAE already added stiffness in the first place. Choosing the dynamics so they are just faster than the rest of the system will allow the model to run reasonably while minimizing solver performance penalties because of added stiffness.

More Answers (2)

Arthur Goldsipe
Arthur Goldsipe on 23 Feb 2017
If your goal is to solve differential algebraic equations, you can already do that using the ODE solvers provided with MATLAB. Here's an example.
  1 Comment
Jason Nicholson
Jason Nicholson on 23 Feb 2017
Edited: Jason Nicholson on 23 Feb 2017
I am aware of this. it does not answer my question.
Notes: You can solve explicit form index 1 DAE's in MATLAB/Simulink.

Sign in to comment.


mona aljeagdaf
mona aljeagdaf on 7 Oct 2018
I have a problem choosing the type of solver in Simulink. Whenever I want to run the model does not work and ask me to change the type and variables of solver or ode and I have other frequently without reaching the solution please help
  2 Comments
Jason Nicholson
Jason Nicholson on 8 Oct 2018
Edited: Jason Nicholson on 8 Oct 2018
Mona, I would call Mathworks about your question. I think your post here off topic and resurrecting this without further information.
Thanks.
-Jason
mona aljeagdaf
mona aljeagdaf on 10 Oct 2018
I'm very sorry ... I thought it was possible for you to answer

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!