Main Content

Describe Component Behavior Using Simscape

A physical subsystem is a Simulink® subsystem with Simscape™ connections. A physical subsystem with Simscape connections uses a physical network approach suited for simulating systems with real physical components and represents a mathematical model.

Using Simscape behaviors for components in System Composer™ improves model simulation and design for systems with physical components. This functionality requires a Simscape license. For more information, see Basic Principles of Modeling Physical Networks (Simscape).

To describe component behavior in Simscape for a System Composer architecture model, follow these steps:

Open this model to interact with a System Composer architecture model named Fan with Simscape behavior on a component DC Motor. The steps in this tutorial will produce this model.

Architecture Model with Simscape Behavior for a DC Motor

This example shows a DC motor in an architecture model of a fan. The DC motor is modeled using a Simscape behavior within a Simulink subsystem component.

Define Physical Ports on a Component

A physical port represents a Simscape physical modeling connector port called a Connection Port (Simscape). Use physical ports to connect components in an architecture model or to enable physical systems in a Simulink subsystem.

Create a new System Composer architecture model. Add a component to the canvas called DC Motor. To add physical ports to a component, pause on the boundary of the component until a port outline appears. Click the port outline and, from the options, select Physical.

The DC motor component with 4 physical ports

Physical ports can be later used to connect to Simscape blocks.

Specify Physical Interfaces on the Ports

You can specify physical interfaces on the physical ports.

A physical interface defines the kind of information that flows through a physical port. The same interface can be assigned to multiple ports. A physical interface is a composite interface equivalent to a Simulink.ConnectionBus object that specifies at least one Simulink.ConnectionElement object. A physical interface is equivalent to a Simulink.ConnectionBus object that specifies at least one Simulink.ConnectionElement object. Use a physical interface to bundle physical elements to describe a physical model using at least one physical domain.

A physical element describes the decomposition of a physical interface. A physical element is equivalent to a Simulink.ConnectionElement object. Define the Type of a physical element as a physical domain to enable use of that domain in a physical model.

  1. To open the Interface Editor, navigate to Modeling > Design > Interface Editor. The Interface Editor will open at the bottom of the canvas.

  2. To add a new physical interface definition, click the list next to the add data interface icon and select Physical Interface. Name the physical interface ElectricalInterface.

  3. To add a physical element to the physical interface, click the add data element icon. Physical interface and physical element names must be valid MATLAB® variable names. Create the physical elements Positive and Negative.

  4. In the Type column, define the Simscape domain to which these physical elements belong. In this case, both belong to foundation.electrical.electrical.

    Physical interfaces and elements with domains for the fan model

  5. Select the E port on the DC Motor component. Right-click the ElectricalInterface physical interface on the Interface Editor and click Assign to Selected Port(s).

Create a Simulink Subsystem Component

You can create a Simulink subsystem in System Composer to enable direct Simscape integration. For more information, see Create Simulink Behavior Using Simulink Subsystem.

Select the DC Motor component. Navigate to Modeling > Component > Create Simulink Behavior, or use the right-click menu on the component.

Create Simulink behavior with Type Subsystem for DC Motor

Click OK.

Subsystem component DC Motor

Describe Component Behavior Using Simscape

Double-click the subsystem component to describe component behavior using Simscape. For the DC motor this example is based on, see Evaluating Performance of a DC Motor (Simscape).

The physical interface can be decomposed into physical elements using a Simscape bus. Each physical element represents a conserving connection associated with a domain in Simscape. Simscape buses bundle conserving connections. For more information, see Simscape Bus (Simscape).

Add a Simscape Bus block next to the E physical port. Double-click the Simscape Bus and select the connection type Bus: ElectricalInterface. Connect the E physical port to the Simscape Bus block. The domain foundation.electrical.electrical defined under the Type of the Positive and Negative physical elements are used for any connections from these ports.

Simscape Bus blocks with physical elements inside

You can also use owned interfaces defined locally on ports to enable domain-specific lines on a Simscape behavior model in System Composer. Edit the port interface through the Property Inspector. Navigate to Modeling > Design > Property Inspector. In this case, Simscape Bus blocks are not needed, and the port can connect directly to the physical connection of the specified domain. Add an owned physical interface to the physical port R with Type as a foundation.mechanical.rotational.rotational domain. Selecting edit to Open in Interface Editor enters the Port Interface View in the Interface Editor. For more information, see Define Owned Interfaces Local to Ports.

Owned interface for V+ physical port

Using the Library Browser, retrieve the following Simscape blocks and construct the DC Motor model with electrical and rotational mechanical domain-specific connectors.

A physical connector can represent a nondirectional conserving connection of a specific physical domain. Connectors can also represent physical signals. Use physical connectors to connect physical components that represent features of a system to simulate mathematically. For more information, see Domain-Specific Line Styles (Simscape).

Simscape model for DC motor

Physical modeling uses the network approach and is therefore different from regular Simulink modeling. For more information, see Modeling Best Practices (Simscape) and Troubleshooting Simulation Errors (Simscape).

See Also

| | | | |

Related Topics