Simscape™ Fluids™ software gives you multiple ways to simulate and analyze hydraulic power and control systems in the Simulink® environment. Running a hydraulic simulation is similar to running a simulation of any other Simscape model. See Desktop Simulation in the Simscape documentation for a discussion of the following topics:
Explanation of how Simscape Fluids software validates and simulates a model
Specifics of using Simulink linearization commands in Simscape Fluids models
Generating code for Simscape Fluids models
Restrictions and limitations on using Simulink tools in Simscape Fluids models
All these aspects of simulating Simscape Fluids models are exactly the same as for Simscape models.
Simscape Fluids software supports all of the continuous-time solvers that Simscape supports. For more information, see Setting Up Solvers for Physical Models in the Simscape documentation.
You can select any of the supported solvers for running a Simscape Fluids simulation.
The variable-step solvers,
are recommended for most applications because they run faster and
work better for systems with a range of both fast and slow dynamics.
To use Simulink Coder™ software to generate standalone
C or C++ code from your model, you must use the
For more information about code generation, see Code Generation in
the Simscape documentation.
To trade off accuracy and simulation time, adjust one or more of the following parameters:
Relative tolerance (in the Configuration Parameters dialog box)
Absolute tolerance (in the Configuration Parameters dialog box)
Max step size (in the Configuration Parameters dialog box)
Constraint Residual Tolerance (in the Solver Configuration block dialog box)
In most cases, the default tolerance values produce accurate
results without sacrificing unnecessary simulation time. The parameter
value that is most likely to be inappropriate for your simulation
is Max step size, because the default value,
depends on the simulation start and stop times rather than on the
amount by which the signals are changing during the simulation. If
you are concerned about the solver missing significant behavior, change
the parameter to prevent the solver from taking too large a step.
The Simulink documentation describes the following parameters in more detail and provides tips on how to adjust them:
The Solver Configuration block reference page in the Simscape documentation explains when to adjust the Constraint Residual Tolerance parameter value.
Sometimes Simscape Fluids models may display physically unattainable values during simulation because of an irregularity within the model. In general, simulation does not stop if one or more variables assume nonphysical values, such as gauge pressures below –1 bar, negative value of fluid volume in the reservoir, and so on. The rationale is that, at the end of simulation, the user knows the extent of the irregularity rather than just the fact that the reservoir is short of fluid or there is a pressure drop below vaporization level.
If you see that your model displays physically unattainable values during simulation, you must analyze your model and iteratively modify your design to smooth out the irregularities.
You can set your models to either warn or stop simulating with an error when absolute pressure in a hydraulic chamber falls below absolute zero. The default behavior is to stop simulation with an error. You can change this by using the Hydraulic Fluid block or the Custom Hydraulic Fluid block connected to the loop, and have the simulation continue with a warning. See the block reference pages for details.
Simscape Fluids simulations can stop before completion with one or more error messages. For a discussion of generic error types and error-fixing strategies, see Troubleshooting Simulation Errors in the Simscape documentation. The following troubleshooting techniques are specific to hydraulic models:
Review the model configuration. If your error message contains a list of blocks, look at these blocks first. Also look for:
Wrong connections — Verify that the model makes sense as a hydraulic system. For example, look for accumulators connected to the pump outlet without check valves; cylinders connected against each other, so that they try to move in opposite directions; directional valves bypassed by a huge orifice, and so on.
Wrong use of hydraulic elements — Simscape Fluids blocks model their respective hydraulic units within certain limits. For example, an Ideal Pressure Source block can simulate a pump only when the pressure remains constant (see Modeling Power Units). Similarly, the Pressure Relief Valve block is a steady-state representation of a real valve. A block may exhibit wrong behavior if it is placed in the wrong environment. Always check the validity of the model for a particular environment and the simulation objectives.
Avoid portions of the system getting isolated from the main system. An isolated or "hanging" part of the system could affect computational efficiency and even cause failure of computation. Use the Leakage Area parameter, introduced specifically for this purpose, to maintain numerical integrity of the circuit. This parameter is present in all the directional valve blocks, pressure control and flow control valve blocks, and most of the variable orifices.
Avoid "dry" nodes in a hydraulic system. By adding a hydraulic chamber to a node, you can considerably improve the convergence and computational efficiency of a model. Adding a chamber adds a degree of freedom. By adding a chamber, you replace a complex algebraic constraint (the dry node) by a dynamic constraint. In the mechanical domain, this is like replacing an ideal gearbox with a gearbox that includes compliance (spring and damper). The hydraulic chamber is represented by the Constant Volume Hydraulic Chamber block in the Simscape Hydraulic Elements library.
MathWorks recommends that you build, simulate, and test your model incrementally. Start with an idealized, simplified model of your system, simulate it, verify that it works the way you expected. Then incrementally make your model more realistic, factoring in effects such as fluid compressibility, fluid inertia, and the other things that describe real-world phenomena. Simulate and test your model at every incremental step. Use subsystems to capture the model hierarchy, and simulate and test your subsystems separately before testing the whole model configuration. This approach helps you keep your models well organized and makes it easier to troubleshoot them.