| Simscape™ | ![]() |
| On this page… |
|---|
Simscape™ software gives you multiple ways to simulate and analyze physical systems in the Simulink® environment. Running a physical model simulation is similar to running a simulation of any other Simulink model. It entails setting various simulation options, starting the simulation, and viewing the simulation results. See the Using Simulink documentation for a general discussion of these topics. This chapter focuses on aspects of simulation specific to Simscape and SimHydraulics® models. Refer to the SimMechanics™ and SimDriveline™ documentation for specifics of simulating and analyzing SimMechanics and SimDriveline models.
You might find this brief overview helpful for constructing models and understanding errors.
Simscape simulation sequence is shown in the following flow chart.

It consists of the following major phases:
Simscape solver first validates the model configuration and checks your data entries from the block dialogs. In particular:
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 requires a Custom Hydraulic Fluid block (or Hydraulic Fluid block, available with SimHydraulics block libraries) to be connected to it. These blocks define the fluid properties that act as global parameters for all the blocks connected 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.
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, 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 provided in the block dialogs, and the global parameters defined by the fluid properties, if applicable, Simscape solver constructs the system of equations for the model.
These equations contain variables of the following types:
Dynamic — Time derivative of this variable appears in equations. Dynamic variables are the independent states for simulation.
Algebraic — Time derivative of this variable does not appear in equations. Algebraic variables are always dependent (on dynamic variables, other algebraic variables, or inputs).
Simscape solver computes the initial conditions only once, in the beginning of simulation (t=0).
Initial conditions are computed by setting all dynamic variables to 0, except those corresponding to blocks that have an initial condition field in their block dialogs, 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 only be set on dynamic variables, because these 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. Refer to the block reference documentation to find which blocks have initial conditions specified through their dialogs.
It is required that the initial conditions for dependent dynamic states be set consistently. For example, the initial voltages on two parallel 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.
This concludes the initial conditions computation when the Start simulation from steady state check box in the Solver block dialog box is not selected (this is the default).
When this box is selected, the solver attempts to find the steady state that would result if the inputs to the system were held constant for a sufficiently large time, starting from the initial state obtained from the initial conditions computation, described previously. Although the solver tries to find the particular steady state resulting from the given initial conditions, it is not guaranteed to do so. All that is guaranteed is that if the steady-state solve succeeds, the state found is a steady state (within tolerance). Steady state means that the system variables are no longer changing with time. Simulation then starts from this steady state.
Note If the simulation fails at or near the start time when you use the Start simulation from steady state option, consider clearing the check box and simulating with the plain initial conditions computation only. |
After computing the initial conditions, or after a subsequent event (such as a discontinuity resulting, for example, from a valve opening, or a hard stop hitting the stop), Simscape solver performs transient initialization. This is done by fixing all dynamic variables and solving 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 transient solve phase.
Finally, 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.
Simscape solver continues to perform the simulation according to the results of the transient solve until it 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 an event is encountered, Simscape solver returns to the phase of transient initialization, and then back to transient solve. This cycle continues until the end of simulation.
![]() | Simulating Physical Models | Troubleshooting Simulation Errors | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |