|On this page…|
You might find this brief overview helpful for constructing models and understanding errors. For more information, see How Simscape Models Represent Physical Systems.
Simscape™ software gives you multiple ways to simulate and analyze physical systems in the Simulink® environment. Running a physical model simulation is similar to simulating any Simulink model. It entails setting various simulation options, starting the simulation, and viewing the simulation results. This topic describes various aspects of simulation specific to Simscape models. For specifics of simulating and analyzing with individual Simscape add-on products, refer to the documentation for those individual add-on products.
This flow chart presents the Simscape simulation sequence.
The flow chart consists of the following major phases:
The Simscape solver first validates the model configuration and checks your data entries from the block dialog boxes.
All Simscape blocks in a diagram must be connected into one or more physical networks. Unconnected Conserving ports are not allowed.
Each topologically distinct physical network in a diagram requires exactly one Solver Configuration block.
If your model contains hydraulic elements, each topologically distinct hydraulic circuit in a diagram must connect to a Custom Hydraulic Fluid block (or Hydraulic Fluid block, available with SimHydraulics® block libraries). These blocks define the fluid properties that act as global parameters for all the blocks that connect to the hydraulic circuit. If no hydraulic fluid block is attached to a loop, the hydraulic blocks in this loop use the default fluid. However, more than one hydraulic fluid block in a loop generates an error.
Similarly, if your model contains pneumatic elements, default gas properties for a pneumatic network are for dry air and ambient conditions of 101325 Pa and 20 degrees Celsius. If you attach a Gas Properties block to a pneumatic circuit, you can change gas properties and ambient conditions for all the blocks connected to the circuit. However, more than one Gas Properties block in a pneumatic circuit generates an error.
Signal units specified in a Simulink-PS Converter block must match the input type expected by the Simscape block connected to it. For example, when you provide the input signal for an Ideal Angular Velocity Source block, specify angular velocity units, such as rad/s or rpm, in the Simulink-PS Converter block, or leave it unitless. Similarly, units specified in a PS-Simulink Converter block must match the type of physical signal provided by the Simscape block outport.
After validating the model, the Simscape solver constructs the physical network based on the following principles:
Two directly connected Conserving ports have the same values for all their Across variables (such as voltage or angular velocity).
Any Through variable (such as current or torque) transferred along the Physical connection line is divided among the multiple components connected by the branches. For each Through variable, the sum of all its values flowing into a branch point equals the sum of all its values flowing out.
Based on the network configuration, the parameter values in the block dialog boxes, and the global parameters defined by the fluid properties, if applicable, the Simscape solver constructs the system of equations for the model.
These equations contain system variables of the following types:
Dynamic — Time derivatives of these variables appear in equations. Dynamic variables are the independent states for simulation.
Algebraic — Time derivatives of these variables do not appear in equations. The states of algebraic variables are always dependent, on dynamic variables, other algebraic variables, or inputs.
The Simscape solver computes the initial conditions only once, in the beginning of simulation (t=0). In the Solver block dialog box, the default is that the Start simulation from steady state check box is not selected.
The solver computes the initial conditions by setting all dynamic variables to 0, except those corresponding to blocks that have an initial condition field in their block dialog boxes, and solving for all the system variables. The blocks with initial conditions have their dynamic variables set according to the user-provided value in the block dialog. Initial conditions can be set only on dynamic variables, because dynamic variables are the independent states for simulation. For example, the Translational Spring block has the Initial deformation parameter, so the corresponding spring position state is set to the initial offset specified in the block dialog box. To find which blocks have initial conditions specified through their dialog boxes, refer to the block reference documentation.
The initial conditions for dependent dynamic states must be set consistently. For example, the initial voltages on two parallel, ideal capacitors must be equal. When the solver detects dependent dynamic variables, it performs a check and issues an error if the initial conditions on dynamic states are not set consistently.
When you select the Start simulation from steady state check box, the solver attempts to find the steady state that would result if the inputs to the system were held constant for a long enough time, starting from the initial state obtained from the initial conditions computation just described. If the steady-state solve succeeds, the state found is some steady state (within tolerance), but not necessarily the state expected from the given initial conditions. Steady state means that the system variables are no longer changing with time. Simulation then starts from this steady state.
After computing the initial conditions, or after a subsequent event (such as a discontinuity resulting, for example, from a valve opening, or from a hard stop), the Simscape solver performs transient initialization. Transient initialization fixes all dynamic variables and solves for algebraic variables and derivatives of dynamic variables. The goal of transient initialization is to provide a consistent set of initial conditions for the next phase, transient solve.
Finally, the Simscape solver performs transient solve of the system of equations. In transient solve, continuous differential equations are integrated in time to compute all the variables as a function of time.
The solver continues to perform the simulation according to the results of the transient solve until the solver encounters an event, such as a zero crossing or discontinuity. The event may be within the physical network or elsewhere in the Simulink model. If the solver encounters an event, the solver returns to the phase of transient initialization, and then back to transient solve. This cycle continues until the end of simulation.