Main Content

Simulating an Electronic, Mechatronic, or Electrical Power System

Selecting a Solver

Simscape™ Electrical™ software supports all of the continuous-time solvers that Simscape supports. For more information, see Setting Up Solvers for Physical Models.

You can select any of the supported solvers for running a simulation of an electronic model. The variable-step solvers, ode23t and ode15s, are recommended for most applications because they run faster and work better for systems with a range of both fast and slow dynamics. The ode23t solver is closest to the solver that SPICE traditionally uses.

To use Simulink® Coder™ software to generate standalone C or C++ code from your model, you must use the ode14x or ode1be solvers. For more information about code generation, see Code Generation.

Specifying Simulation Accuracy/Speed Tradeoff

To trade off accuracy and simulation time, adjust one or more of the following parameters:

  • Relative tolerance in the Simulink Configuration Parameters dialog box

  • Absolute tolerance in the Simulink Configuration Parameters dialog box

  • Max step size in the Simulink Configuration Parameters dialog box

  • Consistency Tolerance in the Solver Configuration block dialog box

In most cases, the default tolerance values produce accurate results without sacrificing unnecessary simulation time. The parameter value that is most likely to be inappropriate for your simulation is Max step size, because the default value, auto, depends on the simulation start and stop times rather than on the amount by which the signals are changing during the simulation. If you are concerned about the solver missing significant behavior, change the parameter to prevent the solver from taking too large a step.

The Simulink documentation describes the following parameters in more detail and provides tips on how to adjust them:

The Solver Configuration block reference page in the Simscape documentation explains when to adjust the Consistency Tolerance parameter value.

Avoiding Simulation Issues

If you experience a simulation issue, first read Troubleshooting Simulation Errors to learn about general troubleshooting techniques.

There are a few techniques you can apply to any Simscape Electrical model to overcome simulation issues:

  • Add parasitic capacitors and/or resistors (specifically, junction capacitance and ohmic resistance) to the circuit to avoid numerical issues. The Astable Oscillator example uses these devices.

  • Adjust the current and voltage sources so they start at zero and ramp up to their final values rather than starting at nonzero values.

To learn about avoiding simulation errors in the presence of specific Simscape Electrical model configurations, see Modeling Instantaneous Events and Using Simulink Blocks to Model Physical Components.

Running a Time-Domain Simulation

When you run a time-domain simulation, Simscape Electrical software uses the Simscape solver to analyze the physical system in the Simulink environment. For more information, see How Simscape Simulation Works.

Running a Small-Signal Frequency-Domain Analysis

You can perform small-signal analysis for Simscape and Simscape Electrical models using linearization capabilities of Simulink software. For more information, see Linearize an Electronic Circuit.

See Also

Related Topics