Main Content

Troubleshooting Fluids Simulations

Simscape™ blocks have complex interactions, and incorrectly designing or parameterizing a model can result in simulations that stop before completion with one or more error messages, or fully run but deliver unexpected results. To address these problems, you can troubleshoot the block or the fluids network. For general Simscape troubleshooting techniques, see Troubleshooting Simulation Errors.

It is good practice to build and test models incrementally. Start with simulating an idealized, simplified system and verify that it works as expected. Then, change the default settings and add complexity incrementally. You can use subsystems to capture the model hierarchy and test these subsystems separately before testing the entire model.

Baseline Troubleshooting Steps

These steps can help identify basic problems in your model. For more advanced troubleshooting, see Issues with Specific Model Blocks or Issues in the Fluid Network.

  • Solver Configuration Block — Check that each topologically distinct fluid network has exactly one Solver Configuration block connected to it.

  • Units — Be aware of units when converting between Simulink and Simscape signals. Change the Output signal unit and Input signal unit parameters in PS-Simulink Converter and Simulink-PS Converter blocks from inherit and 1, respectively, to specific values. If you specify the unit, Simscape performs the unit conversion on any input or output signals. For more information, see How to Work with Physical Units.

  • Network Domain — See Select the Working Fluid to verify that your network fluid is appropriate for your application.

  • Fluid Properties Block — Check that each topologically distinct fluid network has no more than one fluid properties block connected to it. For more information, see Select the Working Fluid.

  • Variables — Use the Variable Viewer to inspect variable values, units, and initialization status.

  • Absolute Variables — Check that absolute variables, such as pressure or temperature, are positive values. There are no restrictions on the sign of the change in pressure or the change in temperature.

  • Affine Units — When specifying temperature, which can be relative or absolute, you may need to apply an affine conversion. For more information about affine conversions, see How to Apply Affine Conversion.

  • Model Fidelity — Use only as much fidelity as necessary for the model goals.

Issues with Specific Model Blocks

If your model returns an error message that identifies specific model blocks, inspect these blocks for wrong connections or unintended use. For individual blocks, check:

  • Valve and Orifice Leakage Area — For blocks with a Leakage Area parameter, ensure the parameter is large enough to prevent numerical issues. Parts of the system may become isolated if a small amount of fluid is not present in all components of the network throughout the simulation. Choose a value for the Leakage Area parameter that is small enough to be negligible when compared to the maximum valve area, but not as small as possible.

  • Dynamic Compressibility — Fluid dynamic compressibility may be relevant for components with internal volumes if the component time constant of the pressure dynamics is slower than inputs to the system. The blocks in the Isothermal Liquid library model dynamic compressibility by default for blocks that support it.

  • Scope and Senor Measurements — Sensors and scopes take measurements at the block ports. In components with an internal fluid volume, the results at the ports may not agree with the expected response. You can use the Results Explorer to inspect all logged values of a block, including the properties of the internal fluid volume. For more information, see Simscape Results Explorer. You can also use a Probe block to probe for the logged values of a block and display the signal on a Scope.

  • Block Use — Read the assumptions and limitations in the block documentation for the blocks in your model and ensure your design considers these limitations. For example, an Ideal Pressure Source block can simulate a pump only when the pressure is constant.

  • Block Connections — Verify that the model makes sense as a system. For example, look for:

    • Actuators connected against each other, which causes motion in opposite directions.

    • Volume blocks, such as chambers, tanks, or accumulators, that are connected directly together. Place some kind of flow resistance between them, such as a flow resistance, pipe, or orifice block.

    Connections between blocks do not represent physical volumes and values pass along these connections instantaneously.

Issues in the Fluid Network

If your model returns an error message that does not identify specific blocks, you may need to troubleshoot the fluid network.

  • Solver Choice — Verify that you are using the best solver for your model. In fluid systems, equations are typically stiff and nonlinear. Using the ssc_new function automatically creates a new model with the recommended solver settings:

    • For the solver selection, set Type to Variable-step and Solver to auto (Automatic solver selection).

    • Set Relative tolerance and Absolute tolerance to 1e-3.

    • Clear the Auto scale absolute tolerance check box.

    • Set Max step size, Min step size, and Initial step size to auto.

  • Algebraic Loops — Do not use Memory or Unit Delay blocks, which are intended for discrete systems, to break an algebraic loop in a Simscape model. Instead, use a Transfer Fcn block to break algebraic loops in continuous systems. For more information, see Why you should never break a continuous algebraic loop with a Memory block.

  • Discrete Controller — If your model uses a discrete controller to drive a continuous Simscape plant, insert a First Order Hold block between the controller and the Simscape model. The First Order Hold block interpolates the discrete controller signal into a continuous signal for the plant. For more information, see A New First Order Hold.

  • Dry Nodes — If you have too many quasi-steady components clustered in your network, such as valves, and the calculations occur only at the block ports, your model may be at higher risk for dry nodes, which may slow or stop your simulation. You can improve simulation convergence in these scenarios by adding blocks with internal volumes, which add dynamic components that can respond to dynamic shifts in the network.

  • Loop Elevation — If you specify elevation change in one component, such as a pipe, you must ensure that the rest of the system is consistent with this elevation change, including the inlet heights in tank blocks. If you have a fluid loop, the net elevation change must sum to zero after a full circle around the loop.

  • Grounding Rules — Every fluid network must contain at least one block that models fluid volume, such as a pipe with compressibility, a chamber, or a reservoir. Internal nodes inside these blocks represent the fluid volume, which serves as a reference point for the Across variables in the network. If the loop only contains quasi-steady components, such as valves and pumps, the solver fails.

Related Topics