0
votes

I have a model which calls a library for thermodynamic properties computation (CoolProp) from an S-Function. This library raises an error and suddenly stops the simulation if its inputs are not meaningful, which sometimes happens when Simulink perturbs the states, and especially when a Step block is present in the model, even if its output is floating! I think this is an attempt to foresee system state changes, and I noticed that reducing the step size reduces the problem, but I can't run a simulation of 20'000 s at 10 us (yes, microseconds!) time steps when it already takes 15 minutes with 5 s step size!

Is there a way to catch that error (raised by a call to error(), I suppose) and tell Simulink "Ehy, the step size you're using is too big"?

EDIT: I'm using ode45 solver, but nothing changes even with ode23tb or ode15s, apart from simulation time which increases dramatically.

1

1 Answers

0
votes

I am assuming you are using a fixed-step solver, you probably want to look into using a variable-step solver instead, which will adjust the step size dynamically based on what the model is doing. If you have a numerically stiff system (which appears to be the case), you probably want to use ode15s or ode23t. You can constrain the solver step size to be between a minimum and maximum step size. See Choosing a solver in the documentation for more details