Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.

Prev Next

Electrical Circuit Simulation Example

For this example, we walk through the creation of a SysML Parametric model for a simple electrical circuit, and then use a parametric simulation to predict and chart the behavior of that circuit.

Circuit Diagram

The electrical circuit we are going to model, shown here, uses a standard electrical circuit notation.

The circuit includes an AC power source, an earth and a resistor, connected to each other by electrical wire.

Create SysML Model

This table shows how we can build up a complete SysML model to represent the circuit, starting at the lowest level types and building up the model one step at a time.




Define Value Types for the Voltage, Current and Resistance. Unit and quantity kind are not important for the purposes of simulation, but would be set if defining a complete SysML model. These types will be generalized from the primitive type 'Real'. In other models, you can choose to map a Value Type to a corresponding simulation type separate from the model.

Value Type Blocks in SysML System Simulation in Sparx Systems Enterprise Architect

Additionally, define a composite type (Block) called ChargePort, which includes properties for both Current and Voltage. This type allows us to represent the electrical energy at the connectors between components.


In SysML, the circuit and each of the components will be represented as Blocks.

In a Block Definition Diagram (BDD), create a Circuit Block. The circuit has three parts: a source, a ground, and a resistor. These parts are of different types, with different behaviors.

Create a Block for each of the part types. The three parts of the Circuit Block are connected through Ports, which represent electrical pins. The source and resistor have a positive and a negative pin. The ground has only one pin, which is positive. Electricity (electric charge) is transmitted through the pins. Create an abstract block 'TwoPinComponent' with two Ports (pins). The two Ports are named 'p' (positive) and 'n' (negative), and they are of type ChargePort.

This figure shows the BDD, with the Blocks Circuit, Ground, TwoPinComponent, Source and Resistor.

Internal Structure

Create an Internal Block Diagram (IBD) for Circuit. Add properties for the Source, Resistor and Ground, typed by the corresponding Blocks. Connect the Ports with connectors. The positive pin of the Source is connected to the negative pin of the Resistor. The positive pin of the Resistor is connected to the negative pin of the Source. The Ground is also connected to the negative pin of the Source.

Notice that this follows the same structure as the original circuit diagram, but the symbols for each component have been replaced with properties typed by the Blocks we have defined.


Equations define mathematical relationships between numeric properties. In SysML, equations are represented as constraints in ConstraintBlocks. Parameters of ConstraintBlocks correspond to PhSVariables and PhSConstants of Blocks ('i', 'v', 'r' in this example), as well as to PhSVariables present in the type of the Ports ('pv', 'pi', 'nv', 'ni' in this example).

Create a ConstraintBlock 'TwoPinComponentConstraint' to define parameters and equations common to sources and resistors. The equations should state that the voltage of the component is equal to the difference between the voltages at the positive and negative pins. The current of the component is equal to the current going through the positive pin. The sum of the currents going through the two pins must add up to zero (one is the negative of the other). The Ground constraint states that the voltage at the Ground pin is zero. The Source constraint defines the voltage as a sine wave with the current simulation time as a parameter. This figure shows how these constraints are rendered in a BDD.



The values of Constraint parameters are equated to variable and constant values with binding connectors. Create Constraint properties on each Block (properties typed by ConstraintBlocks) and bind the Block variables and constants to the Constraint parameters to apply the Constraint to the Block. These figures show the bindings for the Ground, the Source and the Resistor respectively.

For the Ground constraint, bind gc.pv to p.v.

For the Source constraint, bind:

  • sc.pi to p.i
  • sc.pv to p.v
  • sc.v to v
  • sc.i to i
  • to n.i and
  • sc.nv to n.v

For the Resistor constraint, bind:

  • rc.pi to p.i
  • rc.pv to p.v
  • rc.v to v
  • rc.i to i
  • to n.i
  • rc.nv to n.v and
  • rc.r to r

Configure Simulation Behavior

This table shows the detailed steps of the configuration of SysMLSim.



SysMLSimConfiguration Artifact

  • Select 'Simulate > System Behavior > Modelica/Simulink >  SysMLSim Configuration Manager'
  • From the first toolbar icon drop-down, select 'Create Artifact' and create the Artifact element
  • Select the Package that owns this SysML model

Create Root elements in Configuration Manager

  • ValueType
  • Block
  • constraintBlock

ValueType Substitution

Expand ValueType and for each of Current, Resistance and Voltage select 'SysMLSimReal' from the 'Value' combo box.

Set property as flow

  • Expand 'block' to ChargePort | FlowProperty | i : Current and select 'SimVariable' from the 'Value' combo box
  • For 'SysMLSimConfiguration' click on the Browse. button to open the 'Element Configurations' dialog
  • Set 'isConserved' to 'True'


This is the model we want to simulate: set the Block 'Circuit' to be 'SysMLSimModel'.

Run Simulation

In the 'Simulation' page, select the checkboxes against 'resistor.n' and 'resistor.p' for plotting and click on the Solve button.

The two legends 'resistor.n' and 'resistor.p' are plotted, as shown.