How to convert Simscape (Hydraulic) blocks to discrete time to reduce computational time?

My model currently has a high computation time because half of it is using continueous time hydraulic blocks from the Simscape Hydraulics package. As I do not need continueous time signals, (in real life these measurements are taken every 1 sec) I want to switch the whole model to discrete time. Is this possible, and if so, how?
Explicitly, I'm modeling a centrifugal pump with a tank and some other blocks such as pipes and a flow rate source from the isothermal liquid (IL) library. These blocks do not clearly offer the option to switch to discrete time.

 Accepted Answer

If you want to run a Simscape model in discrete model, you can attach a Solver Configuration block to your system and use a local solver with your sample time.
I tried it out on the example model for Simscape Hydraulic and I was able to get a discrete output
Note: I also had to change the sample time of blocks (not any Simscape block in this case) to match the sample time of solver configuration.

4 Comments

Thanks for this, this greatly increases computation speed! Two questions:
  • What is the physical interpretation of this?
  • Doesn't the system (or its blocks) adjust to the highest set sampling time? E.g.if one block has 1e-5, and I set the solver to 1e-3, won't this first block change to 1e-3?
Usually the sample time of blocks is inherited (-1), in my case it was manually set to something else. It should give you an error if you do not have the same sample time throughout.
Which physical interpretation do you mean?
@Nikhil Baishkiyar is it correct that in continuous solvers the integral is used and the trapezoidal rule is just an approximation?
All simulink solvers employ numerical integration to find out answers. You can see which method they use in the Configuration parameters. Trapezoidal Rule is an approximation but that is the best you can get with limited data points. Continuous solvers usually employ a variable time step to improve accuracy but discrete solvers do not.

Sign in to comment.

More Answers (0)

Products

Release

R2022b

Community Treasure Hunt

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

Start Hunting!