Modeling and Simulation of Fluid Networks
Simscape™ Fluids™ blocks and connections represent one-dimensional flow paths. This means that internal component dynamics, such as the pressure variation along a pump blade, are not modeled in detail.
As with electric circuits, all network components have an associated Across and Through variable. Unlike an electric circuit, some Simscape Fluids domains have more than one Across and Through variable. For example, in the thermal liquid domain, mass flow rate and energy flow rate are block Through variables, and pressure and temperature are block Across variables. Blocks in the gas, moist air, and two-phase domains also have multiple Through and Across variables. For more information on block connections, ports, and variable types, see Basic Principles of Modeling Physical Networks.
In Fluids networks, flow is supported in either direction along connection lines. Many Simscape Fluids blocks also support reversed flows. Additionally, pressure and temperature are always absolute values. Regardless of flow direction, the variable values remain positive.
It is essential that your network is grounded. Simscape Fluids blocks with internal volumes, called dynamic components, can act as a network ground due to their internally-defined states. Furthermore, dynamic components within the network set the model initial conditions from the specified block parameters.
Due to these internal volumes, fluid variables are calculated at internal nodes as part of the momentum balance over the block. You may observe different values if you choose to measure a variable at an internal node or at a port.
Parameterizing a Block
Some blocks can be parameterized by different methods. You can parameterize these blocks by:
An analytical formulation
Data from a data sheet
Data from measurements
Data tables may be 2-D or 3-D and are composed of independent vectors, such as from a test matrix. For example, in the Variable-Displacement Pump (IL) block, the Volumetric loss table, q_loss(dp,w,D) parameter is populated with the volumetric losses at each test point for pressure loss, shaft speed, and displacement volume, over the range of each parameter.
Start and Simulate Your Model
The Simscape Fluids software provides multiple ways to simulate and analyze multidomain fluid networks in the Simulink® environment.
To open the Simscape model template, enter
ssc_newat the MATLAB® command line. You can view the Simscape Fluids block library by entering
SimscapeFluids_libon the MATLAB command line. Drag blocks from the Simscape Library Browser to the Simulink Editor to construct your model.
To view and inspect your network variables before, during, and after simulation, use the Variable Viewer. To learn more about initializing models and setting variable priorities, see Block-Level Variable Initialization. Initial conditions for Simscape Fluids models are domain-dependent:
In the isothermal liquid domain, the initial pressure must be provided.
In the thermal liquid domain, the initial pressure and temperature must be provided.
In the gas domain, the initial pressure, and either the density or temperature must be provided.
In the moist air domain, the initial pressure, temperature, humidity quality, and trace gas amount must be provided.
In the two-phase domain, the initial pressure and either the phase quality, temperature, enthalpy, or internal energy must be provided.
You can view the results of a simulation by attaching a Scope block to a sensor, or by enabling data logging and viewing the results in the Results Explorer. Exporting data from the Results Explorer to the Data Inspector allows you to compare data between simulations. For more information, see About the Simscape Results Explorer and Simulation Data Inspector.
Scope blocks plot Simulink signals. Convert a Simscape physical signal with a PS-Simulink Converter block to connect a physical signal to a Scope block. See Connecting Simscape Diagrams to Simulink Sources and Scopes for more information.
To turn on data logging, from the Simulink toolstrip, select Modeling > Model Settings > Model Settings. In Configuration Parameters, select Simscape. In the Simscape pane, under Data Logging, set Log simulation data to
Alland select Open viewer after simulation.
To learn more about selecting and configuring the right solver for your system, see Setting Up Solvers for Physical Models. The variable-step solvers
ode15sare versatile solvers that are suitable for a range of dynamics. To use Simulink Coder™ to generate code from your model, use the
ode1besolvers. For more information about code generation, see Code Generation.
See Essential Steps for Constructing a Physical Model for a detailed overview of a Simscape modeling workflow.
You can modify parameter values during simulation if they are run-time configurable. To learn more about configurable parameters and settings, see About Simscape Run-Time Parameters.
Balancing Accuracy, Speed, and Efficiency in Your Model
To change the accuracy, speed, and efficiency of your simulation, you can adjust one or more of the following parameters in Configuration Parameters:
Max step size
You can also adjust the Constraint Residual Tolerance in the Solver Configuration block property inspector.
In most cases, the default tolerance values will produce a good balance between the
accuracy and speed of your model. However, in some cases you may wish to adjust the
Max step size from its default setting of
which is calculated based on the simulation duration and not on the simulation dynamics. If
you are concerned that the solver may be missing significant behavior, you can change this
value to a smaller value.
For more information about the solver parameters, see:
See Solver Configuration to learn more about when to adjust the Constraint Residual Tolerance parameter value.