Troubleshooting Simulation Errors

Troubleshooting Tips and Techniques

Simscape simulations can stop before completion with one or more error messages. This section discusses generic error types and error-fixing strategies. You might find the previous section, How Simscape Simulation Works, useful for identifying and tracing errors.

If a simulation failed:

The 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 friction loss, motor shaft compliance, hard stops, 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.

System Configuration Errors

Missing Solver Configuration Block

Each topologically distinct Simscape block diagram requires exactly one Solver Configuration block to be connected to it. The Solver Configuration block specifies the global environment information and provides parameters for the solver that your model needs before you can begin simulation.

If you get an error message about a missing Solver Configuration block, open the Simscape Utilities library and add the Solver Configuration block anywhere on the circuit.

Extra Fluid Block in a Hydraulic Loop

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.

If you get an error message about too many domain-specific global parameter blocks attached to the network, look for an extra Hydraulic Fluid block or Custom Hydraulic Fluid block and remove it.

Missing Reference Block

Simscape libraries contain domain-specific reference blocks, which represent reference points for the conserving ports of the appropriate type. For example, each topologically distinct electrical circuit must contain at least one Electrical Reference block, which represents connection to ground. Similarly, hydraulic conserving ports of all the blocks that are referenced to atmosphere (for example, suction ports of hydraulic pumps, or return ports of valves, cylinders, pipelines, if they are considered directly connected to atmosphere) must be connected to a Hydraulic Reference block, which represents connection to atmospheric pressure. Mechanical translational ports that are rigidly clamped to the frame (ground) must be connected to a Mechanical Translational Reference block, and so on.

If you get an error message about a missing reference block, or node, check your system configuration and add the appropriate reference block based on the rules described above. For more information and examples of best modeling practices, see Grounding Rules.

Basic Errors in Physical System Representation

Physical systems are represented in the Simscape modeling environment as Physical Networks according to the Kirchhoff's generalized circuit laws. Certain model configurations violate these laws and are therefore illegal. There are two broad violations:

These configurations are impossible in the real world and illegal theoretically. If your model contains such a configuration, upon simulation the solver issues an error followed by a list of blocks, as shown in the following example.

Example.   The model shown in the following illustration contains two Ideal Translational Velocity Sources connected in parallel. This produces two independent velocity loops, and the solver cannot construct a consistent system of equations for the circuit.

When you try to simulate the model, the solver issues the following error messages:

Nonlinear solver: failed to converge, residual norm too large.
Transient initialization, solving for consistent states and modes, failed to converge. 
Warning: equations of one or more components may be dependent or inconsistent. This can 
cause problems in transient initialization. Here is the set of components involved:
'vsloop_diagnostics_example/Ideal Translational Velocity Source1'
'vsloop_diagnostics_example/Ideal Translational Velocity Source'

Initial conditions solve failed to converge.

You can simplify the system by using a single Ideal Translational Velocity Source block, with its control signal supplied by the Sine Wave block. Add the constant value from the second source to the bias of the sine wave.

Numerical Simulation Issues

Numerical simulation issues can be either a result of certain circuit configurations or of parameter discontinuities.

Dependent Dynamic States

Certain circuit configurations can result in dependent dynamic states, or the so-called higher-index differential algebraic equations (DAEs). Simscape solver can handle dependencies among dynamic states that are linear in the states and independent of time and inputs to the system. For example, capacitors connected in parallel or inductors connected in series will not cause any problems. Other circuit configurations with dependent dynamic states, in certain cases, may slow down the simulation or lead to an error when the solver fails to initialize.

In electrical circuits, common examples that can cause this behavior include voltage sources connected in parallel with capacitors, inductors connected in series with current sources, and so on. To address this issue, the Capacitor and Inductor blocks include parasitic terms (parallel conductance and series resistance). For other blocks that do not contain these parasitic terms, you might need to introduce your own parasitic conductance or resistance into the circuit. For more information on best modeling practices, as well as for troubleshooting suggestions, see Avoiding Numerical Simulation Issues.

Examples in other domains include direct connections between a velocity source and a mass, a force source and a spring, a pressure source and a hydraulic accumulator, or a flow rate source and a fluid inertia. If you encounter this error, try to either simplify the circuit or include additional blocks, such as spring-damper combinations or constant orifices, to avoid the direct connection that results in dependent states.

Example.   The model shown in the following illustration contains an Ideal Translational Velocity Source directly connected to a Mass.

When you try to simulate the model, the solver issues the following error messages:

Nonlinear solver: failed to converge, residual norm too large.
Transient initialization, solving for consistent states and modes, failed to converge. 
Warning: problems possible for transient initialization, as well as stepsize control 
for transient solve, due to equations of one or more components:
'mech_model1/Mechanical Translational Reference'
'mech_model1//Ideal Translational Velocity Source'
'mech_model1/Mass'

Initial conditions solve failed to converge.

You can try adding a very stiff spring between the velocity source and the mass. To avoid the possibility of high-frequency oscillations introduced by the spring, connect it in parallel with a damper with a high damping coefficient.

Parameter Discontinuities

Nonlinear parameters, dependent on time or other variables, may also lead to numerical simulation issues as a result of parameter discontinuity. These issues usually manifest themselves at the transient initialization stage (see Transient Simulation Issues).

Initial Conditions Solve Failure

The initial conditions solve, which solves for all system variables (with initial conditions specified on some system variables), may fail. This has several possible causes:

If the Simulation Diagnostics window has other, more specific, error messages, address them first and try rerunning the simulation. See also Troubleshooting Tips and Techniques.

Transient Simulation Issues

Transient initialization happens at the beginning of simulation (after computing the initial conditions) or after a subsequent event, such as a discontinuity (for example, when a hard stop hits the stop). It is performed 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 step.

Transient Initialization Not Converging

Error messages stating that transient initialization failed to converge, or that a set of consistent initial conditions could not be generated, indicate transient initialization issues. They can be a result of parameter discontinuity. Review your model to find the possible sources of discontinuity. See also Troubleshooting Tips and Techniques.

You can also try to decrease the Constraint Residual Tolerance parameter value (that is, tighten the tolerance) in the Solver Configuration block.

Step-Size-Related Errors

A typical step-size-related error message may state that the system is unable to reduce the step size without violating the minimum step size for a certain number of consecutive times. This error message indicates numerical difficulties in solving the Differential Algebraic Equations (DAEs) for the model. This might be caused by dependent dynamic states (higher-index DAEs) or by the high stiffness of the system. You can try the following:

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS