Main Content

Choose Blocks to Model Electrical Systems

Simscape™ software provides a set of block libraries and simulation features for modeling physical systems in the Simulink® environment. With Simscape you build physical component models based on physical connections that directly integrate with Simulink block diagrams. Simscape Electrical™ software is a Simscape add-on product that provides more complex components and analysis capabilities for electrical systems. You can use the Simscape Electrical block libraries to model electronic, mechatronic, and electrical power systems, and power electronics. You can integrate electrical, mechanical, thermal, and other physical systems into your model using components from the Simscape family of products. You can design controllers or develop signal processing algorithms for your electrical system and protect your models, when you want to share them with a third party without revealing intellectual property, using Simulink. You can also automate designs or analyze and visualize data using MATLAB®.

Build Electrical Networks using Simscape and Simscape Electrical

You build electrical networks using Simscape blocks. A Simscape block is any block developed using Simscape language, a dedicated textual language for modeling physical systems. This includes most blocks belonging to the libraries you get with Simscape, Simscape Electrical, or the other Simscape add-on products:

  • Simscape Battery™

  • Simscape Driveline™

  • Simscape Fluids™

  • Simscape Multibody™

Simscape blocks represent physical components by defining mathematical relationships between two or more physical variables. Connections between these blocks represent physical connections, like idealized wires in a circuit. The blocks have conserving ports that belong to a specific physical domain. To model electrical networks, you can use blocks with ports in the electrical domain and the three-phase electrical domain. In these domains, the physical variables are current and voltage. You add the blocks to the canvas and connect them to assemble the components as you would in a circuit diagram. You do not have to specify flow directions when connecting Simscape blocks, just as you do not have to specify this information when you connect real physical components. Simscape calculates the value of the current and voltage simultaneously at each time step. The three-phase electrical domain simplifies block diagrams by representing three-phase connections with a single physical connection line that is equivalent to three physical connection lines in the electrical domain. You can also model each phase individually, for example, to inject a single-line-to-ground fault into your circuit, by expanding the three-phase ports on these blocks into three separate single-phase electrical ports.

To model simple electrical networks, you can use blocks in the Simscape Foundation Library that belongs to the Simscape product. It contains basic physical elements and building blocks organized into sublibraries according to the technical discipline and function. To build electrical networks, you use blocks in the Simscape > Foundation Library > Electrical library.

The block libraries available with Simscape Electrical extend the electrical and three-phase electrical domains. The library has many of the same fundamental components available in the Simscape Foundation Library but with more customization options. It also has additional components not available with Simscape. To display this library in the Simulink Library Browser, scroll to the Simscape node. If you have installed any of the Simscape add-on products, you can see the corresponding libraries under Simscape library. Expand the Simscape node and then the Electrical node. Alternatively, at the MATLAB command window, enter this command.

ee_lib

To explore the blocks in the top-level Simscape Electrical libraries, further expand the nodes.

Blocks from all twelve libraries except Control and Specialized Power Systems, are Simscape blocks. You can use these blocks, along with other blocks from the Simscape family of products, to build electrical networks and networks in other physical domains.

Choose Blocks to Build Electrical Networks

If more than one block can model the same type of device, choose the simplest block that gives you enough detail to meet your design goals. This makes the model easier to parameterize and increases simulation speed. The block parameters, mask description, and documentation can help you decide which blocks to use. Blocks with a larger number of parameters are usually more complex.

To understand how to choose blocks for your electrical network with the right level of complexity, consider the Model Triangle Wave Generator Using Operational Amplifiers example. To open the model, at the MATLAB Command Window, enter this command.

openExample('simscapeelectrical/TriangleWaveGeneratorExample')

The first stage of the circuit represents a comparator constructed from an op-amp. Two Diode blocks model the Zener diodes that limit the output of the comparator to plus or minus 5 V. These limits result in a square wave. The second stage of the circuit is an integrator. Integrating the square wave creates a triangle wave.

This example uses blocks from the Simscape Foundation and Simscape Electrical libraries. Both libraries contain a Capacitor block. The mask descriptions tell you that the block in the Simscape Foundation Library models a linear capacitor and the block in the Simscape Electrical Library models a capacitor with optional tolerance, operational limits, and fault behavior. Without the customization options the two blocks are identical so you can choose either block. Both libraries also contain a Diode block. If you look at the block parameters or documentation for the two blocks, you see that only the block in the Simscape Electrical Library can model a Zener diode, so choose the more detailed block from the Simscape Electrical Library. You also use the Band-Limited Op-Amp block from the Simscape Electrical Library. This is a more advanced block that is not available in the Simscape Foundation Library.

Generate Signals, Design Controllers, and Visualize Data using Simulink Blocks

Simulink blocks represent mathematical operations. You connect the output port of one block to the input port of another. Simulink computes the value of the signal sequentially as information passes through the diagram, from one block to the next, at each time step. You can interface these blocks with your physical networks to:

  • Generate and process signals

  • Perform mathematical transformations

  • Develop control algorithms

  • Visualize data

In the Model Triangle Wave Generator Using Operational Amplifiers example, the Sine Wave block generates a signal that governs the resistance of the Variable Resistor block. The Scope block allows you to visualize the output voltage within the Simulink environment.

The Control library in Simscape Electrical contains Simulink blocks you can use to develop control systems for single- and multi-phase electrical power systems.

This table summarizes the main features of Simulink and Simscape blocks.

 Simulink BlocksSimscape Blocks
PurposeModeling dynamic systemsModeling physical systems and interactions across different physical domains
Common uses in electrical models
  • Signal generation

  • Signal processing

  • Mathematical transformations

  • Control algorithms

  • Data visualization

Representing physical components in electronic, mechatronic, and electrical power systems
Mathematical relationships Between inputs and outputsBetween two or more physical variables like current and voltage
Block ports Simulink input and output portsPhysical signal ports and conserving ports
Connections Simulink signal lines

Physical signal lines and physical connection lines

Dynamic behavior Simulink computes the value of the signals sequentially as they pass from one block to the next, at each time step.Simscape calculates physical variables simultaneously at each time step.
Custom blocksCreate custom Simulink blocks using MATLAB, C/C++, and Fortran code.Create custom Simscape blocks using Simscape Language.

Connect Blocks via Compatible Ports

In addition to conserving ports, some Simscape blocks have physical signal ports. These ports are directional ports that transfer signals like Simulink block ports. Simscape uses physical signal input ports instead of Simulink input and output ports to increase computation speed and avoid issues with algebraic loops. Physical signals can also have units associated with them.

You connect blocks together via compatible ports. These rules define the compatibility conditions:

  • You can only connect Simulink output ports to Simulink input ports.

  • You can only connect Simscape physical signal output ports to Simscape physical signal input ports.

  • You can only connect Simscape conserving ports to other conserving ports of the same domain.

  • You can connect Simulink block diagrams to Simscape networks or connect Simscape networks in different domains using blocks that have more than one port type.

This table summarizes the behavior of the different port types.

Feature

Simulink Input and Output PortsSimscape Physical Signal PortsSimscape Conserving Ports
Connection linesSimulink signal lines that represent data flowPhysical signal lines that represent data flowPhysical connection lines that represent physical connections like idealized wires in a circuit
Connection rulesYou can only connect Simulink output ports to Simulink input ports.You can only connect Simscape physical signal output ports to Simscape physical signal input ports. You can only connect Simscape conserving ports to other conserving ports of the same domain.
DirectionDirectional. Arrows indicate the direction of information flow from the Simulink output port of one block to the Simulink input port of another.Directional. Arrows indicate the direction of information flow from the Simscape output port of one block to the Simscape input port of another.No inherent directionality. Through variables like current can flow in either direction.
Splitting connectionsSplitting a Simulink signal line creates multiple paths for the same signal.Splitting a physical signal line creates multiple paths for the same signal. The signal represents a physical variable.Splitting a physical connection line creates a physical junction and separate branches in the system. This branching divides the through variables like current among connected components. Branching also applies the same across variable like voltage at each connected component.

In the Model Triangle Wave Generator Using Operational Amplifiers example, you use blocks in the Simscape Utilities Library to connect the electrical network to Simscape blocks.

  • You use a Simulink-PS Converter block to convert the Simulink signal from the Sine Wave block into a physical signal that you can pass to the Variable Resistor block. This signal sets the resistance of the Variable Resistor block.

  • You use a PS-Simulink Converter block to convert a physical signal from the Voltage Sensor block into a Simulink signal that you can pass to Scope block. This signal allows you to see the voltage across the circuit through the Scope block.

The Solver Configuration block has a conserving port which is untyped. You can connect this untyped port to conserving ports of any domain. The Solver Configuration block specifies the solver parameters that your model needs before you can begin simulation. You must connect this block to each topologically distinct Simscape network.

The Model Triangle Wave Generator Using Operational Amplifiers example only has one Simscape network. The network is in the electrical domain. You can connect two or more networks via blocks that have ports in more than one domain. Color coding of ports, blocks, and physical connection lines can help you identify the domain.

Many of the blocks in the Simscape Electrical libraries have ports in the thermal, magnetic, mechanical translational, and mechanical rotational domains as well as the electrical and three-phase electrical domains. You can use optional thermal ports to model the heat you generate from electrical losses in a thermal network. You can use blocks in the Electromechanical library to develop models of mechatronic systems. You can also connect blocks, via conserving ports of the same domain, to blocks from the Simscape family of products to build models of multidomain systems.

You can search for blocks by double-clicking on the canvas and typing part of the name of the block you want to search for. If you want to search only for blocks that have a port that is compatible with a specific port of another block:

  1. Click on the port and drag it to create a node

  2. Click on the node

  3. Type to search for a block

Only blocks that have at least one compatible port appear in the search.

Generate C Code, Speed up Simulations, and Plot Logged Simulation Data using Simscape

Simscape blocks in the Simscape Electrical libraries are compatible with features in Simscape. You can:

  • Generate standalone C or C++ code from your physical networks models for rapid prototyping and hard-ware-in-the-loop applications — Simscape blocks support this functionality. You also need a Simulink Coder™ license.

  • Generate an HDL implementation model, generate HDL code for the implementation model, and deploy the code onto FPGA platforms using the Simscape HDL Workflow Advisor.

  • Use the Solver Configuration block to:

    • Choose between continuous and discrete state representations.

    • Perform phasor analysis and speed up simulation of systems with a single nominal frequency by running simulations in frequency-and-time mode.

    • Start simulations from a chosen state using operating points.

    • Increase simulation speed using the Partitioning Solver.

  • Navigate and plot logged simulation data using the Simscape Results Explorer.

  • Output Simscape variables or intermediates as Simulink signals using the Probe block.

  • Model faults using blocks that support fault modeling — You can save your fault triggers and faulted parameter values in a separate file and keep your original model without faults.

Design Systems and Components using Simscape Electrical

The Simscape Electrical Library includes blocks that implement low-fidelity, piecewise linear, mathematical models of power electronic devices. The library also includes blocks that implement high-fidelity, nonlinear, mathematical models of the same devices. The low-fidelity models are easier to parameterize and simulate faster. The high-fidelity models give you more detailed simulation results. Start by developing a model using low-fidelity blocks for system-level design and then move toward more detailed component-level design using high-fidelity blocks.

Explore Examples

The Simscape Electrical documentation contains hundreds of example models that you can learn from and adapt to match your simulation goals. Explore the examples in the Applications category to find a model close to your application. You can also search for models by using the modelfinder function.

See Also

Tools

Related Examples

More About