ConnectSystemModelComponents[{"c1"∈comp1,…},{"c1.a""c2.b",…}]
creates a system model by connecting connector "a" of component "c1" with connector "b" of component "c2" etc.
ConnectSystemModelComponents
ConnectSystemModelComponents[{"c1"∈comp1,…},{"c1.a""c2.b",…}]
creates a system model by connecting connector "a" of component "c1" with connector "b" of component "c2" etc.
Details and Options
- ConnectSystemModelComponents assembles components to create a new system model. These connections communicate values and set conservation laws in the system.
- ConnectSystemModelComponents returns SystemModel[…].
- ConnectSystemModelComponents["NewModel",…] gives the created model the name "NewModel".
- ConnectSystemModelComponents["PackageA.NewModel",…] inserts "NewModel" into "PackageA".
- The compi can be a SystemModel object, a full model name string or a shortened model name accepted by SystemModel.
- In ConnectSystemModelComponents[…,spec], spec is an Association with the following keys:
-
"ParameterValues" {p1val1,…} parameter values "InitialValues" {v1val1,…} initial values "ExtendsModels" {partial1,…} partial models to build on "DiscreteVariables" {v1,v2,…} variables changing only at events "SimulationSettings" {opt1val1,…} model simulation options - With ConnectSystemModelComponents[…,"ExtendsModels"partial], the new model is combined with the existing partial SystemModel defined in Modelica. »
- A model can extend multiple models using "ExtendsModels"{"partial1",…}.
- Partial models to build on are usually defined in an Interfaces package. For example, SystemModels["Modelica.Electrical.Analog.Interfaces.*","model"|"block"] can be used to find partial models for the built-in electrical library.
- "InitialValues" correspond to the start property in the Modelica model.
- Allowed options in "SimulationsSettings"->{opt1val1,…} include
-
"Method" simulation method "StartTime" simulation start time "StopTime" simulation stop time - Available adaptive-step "Method" values include:
-
"DASSL" DASSL DAE solver "CVODES" CVODES ODE solver - Options for adaptive-step methods include:
-
"InterpolationPoints" number of interpolation points "Tolerance" tolerance for adaptive step size - Available fixed-step "Method" values include:
-
"Euler" explicit Euler's method of order 1 "Heun" Heun's method of order 2 "RungeKutta" explicit Runge–Kutta method of order 4 - Options for fixed-step methods include:
-
"StepSize" fixed step size - The layout for the created model diagram can be controlled with the option GraphLayout.
Examples
open all close allBasic Examples (2)
Create a simple electrical circuit:
components = {"L"∈"Modelica.Electrical.Analog.Basic.Inductor", "AC"∈"Modelica.Electrical.Analog.Sources.SineVoltage", "G"∈"Modelica.Electrical.Analog.Basic.Ground"};connections = {"G.p" -> "AC.n", "AC.p" -> "L.n", "L.p" -> "AC.n"};model = ConnectSystemModelComponents[components, connections]Show the current and voltage in the inductor:
SystemModelPlot[model, {"L.i", "L.v"}, 5]Use short naming to refer to the Abs and Sine components in Modelica.Blocks:
comp = {"a"∈"Math.Abs", "sine"∈"Sources.Sine"};conn = {"sine.y" -> "a.u"};model = ConnectSystemModelComponents[comp, conn]SystemModelPlot[model, {"a.y"}, 2]Scope (5)
Create a block example, sampling a sine wave at regular intervals:
comp = {"sine"∈"Modelica.Blocks.Sources.Sine", "sample"∈"Discrete.Sampler"};conn = {"sine.y""sample.u"};model = ConnectSystemModelComponents[comp, conn]Simulate and plot the sampled signal:
SystemModelPlot[model, {"sample.y"}, 2]Give a value to a parameter in a component:
comp = {"inAdd"∈"DocumentationExamples.Basic.InputAdd", "cSource"∈"Modelica.Blocks.Sources.Constant"};conn = {"cSource.y""inAdd.u"};Set the amplitude of the sine to 3:
model = ConnectSystemModelComponents[comp, conn, <|"ParameterValues" -> {"inAdd.sine.amplitude" -> 3}|>]SystemModelPlot[model, {"inAdd.y"}, 2]Connect two masses with heat capacity with a thermal conductor:
comp = {"mass1"∈"HeatCapacitor", "mass2"∈"HeatCapacitor", "conduction"∈"ThermalConductor"};conn = {"mass1.port""conduction.port_a", "conduction.port_b""mass2.port"};model = ConnectSystemModelComponents[comp, conn]Set heat capacities, masses and initial temperatures:
model2 = SystemModel[model, {"conduction.G" -> 10, "mass1.C" -> 15, "mass2.C" -> 40, "mass1.T" -> 373.15, "mass2.T" -> 273.15}];Show that a temperature equilibrium is reached:
SystemModelPlot[model2, {"mass1.T", "mass2.T"}, 5]Create a mass connected to a spring:
comp = {"fixed"∈"Modelica.Mechanics.Translational.Components.Fixed", "spring"∈"Modelica.Mechanics.Translational.Components.Spring", "mass"∈"Modelica.Mechanics.Translational.Components.Mass"};conn = {"fixed.flange""spring.flange_a", "spring.flange_b""mass.flange_a"};Move the initial position of the mass, stretching the spring:
model = ConnectSystemModelComponents[comp, conn, <|"InitialValues" -> {"mass.s" -> 2}|>]Show how the mass position oscillates:
SystemModelPlot[model, {"mass.s"}, 10]comp = {"world"∈"Modelica.Mechanics.MultiBody.World", "rev"∈"Modelica.Mechanics.MultiBody.Joints.Revolute", "damper"∈"Modelica.Mechanics.Rotational.Components.Damper", "body"∈"Modelica.Mechanics.MultiBody.Parts.Body"};conn = {"world.frame_b""rev.frame_a", "damper.flange_b""rev.axis", "rev.support""damper.flange_a", "body.frame_a""rev.frame_b"};model = ConnectSystemModelComponents[comp, conn, <|"ParameterValues" -> {"rev.useAxisFlange" -> True, "body.r_CM" -> {1, 0, 0}, "damper.d" -> 0.1}|>]Simulate and animate the path of the pendulum:
sim = SystemModelSimulate[model, 10];graphics = sim["Graphics3D", t];pendulum[x_ ? NumberQ] := pendulum[x] = Show[graphics /. t -> x, PlotRange -> {{-1.2, 1.2}, {-1.2, 0.1}, {-.2, .2}}, ImageSize -> 300]Animate[Evaluate[pendulum[x]], {x, 0, 10}, AnimationRate -> 0.5, AnimationRunning -> False, SaveDefinitions -> True, TrackedSymbols :> {pendulum, x, graphics}]Generalizations & Extensions (1)
Rule, DirectedEdge and UndirectedEdge can be used for connections:
comp1 = {"sine"∈"Modelica.Blocks.Sources.Sine", "sample"∈"ZeroOrderHold"};Use Rule to specify a connection:
conn1 = {"sine.y" -> "sample.u"};model1 = ConnectSystemModelComponents[comp1, conn1]Use DirectedEdge and UndirectedEdge to specify connections:
comp2 = Append[comp1, "foh"∈"FirstOrderHold"];conn2 = {"sine.y""sample.u", "sample.y""foh.u"};model2 = ConnectSystemModelComponents[comp2, conn2]Simulate and plot the signals:
Column[{SystemModelPlot[model1, {"sample.y"}, 2], SystemModelPlot[model2, {"foh.y"}, 2]}]Options (3)
GraphLayout (3)
GraphLayout can be used to specify the layout of the model diagram:
comp = {"sine"∈"Modelica.Blocks.Sources.Sine", "sample"∈"ZeroOrderHold", "foh"∈"FirstOrderHold"};conn = {"sine.y""sample.u", "sample.y""foh.u"};ConnectSystemModelComponents[comp, conn, GraphLayout -> "LinearEmbedding"]An edge-weighted "SpringElectricalEmbedding" is used by default:
comp = {"sine"∈"Modelica.Blocks.Sources.Sine", "sample"∈"ZeroOrderHold"};conn = {"sine.y" -> "sample.u"};ConnectSystemModelComponents[comp, conn, GraphLayout -> {"SpringElectricalEmbedding", "EdgeWeighted" -> True}]comp = {"sine"∈"Modelica.Blocks.Sources.Sine", "sample"∈"ZeroOrderHold"};conn = {"sine.y" -> "sample.u"};ConnectSystemModelComponents[comp, conn, GraphLayout -> None]Applications (3)
A DC Motor (1)
Create a model of a DC motor by connecting electrical and mechanical components:
components = {"step1"∈"Blocks.Sources.Step", "resistor1"∈"Analog.Basic.Resistor", "inductor1"∈"Analog.Basic.Inductor", "EMF1"∈"RotationalEMF", "ground1"∈"Analog.Basic.Ground", "signalVoltage1"∈"Analog.Sources.SignalVoltage", "inertia1"∈"Rotational.Components.Inertia"};connections = {"resistor1.n""inductor1.p", "inductor1.n""EMF1.p", "step1.y""signalVoltage1.v", "signalVoltage1.p""resistor1.p", "EMF1.n""signalVoltage1.n", "ground1.p""signalVoltage1.n", "EMF1.flange""inertia1.flange_a"};model = ConnectSystemModelComponents[components, connections]Show the angular velocity of the DC motor:
SystemModelPlot[model, "inertia1.w", 10]A Lowpass Filter (1)
Create a digital lowpass filter:
a = LeastSquaresFilterKernel[{"Lowpass", 0.1}, 20];Convert the filter into a transfer function:
h = ListZTransform[a, z];tf = TransferFunctionModel[h, z, SamplingPeriod -> 0.01]//TransferFunctionCancellowPass = CreateSystemModel[tf];Create a signal generating source:
signal = CreateSystemModel["Signal", {y[t] == Abs[Sin[t Cos[2t]]]t}, t, <|"ExtendsModels" -> "Modelica.Blocks.Interfaces.SignalSource"|>];Connect the signal source to the filter:
model = ConnectSystemModelComponents["FilteredSignal", {"signal"∈signal, "filter"∈lowPass}, {"signal.y""filter.u"}]Simulate and plot the signal output and the filtered signal:
sim = SystemModelSimulate[model, 10];SystemModelPlot[sim, {"signal.y", "filter.y"}]An Inerter (1)
Create an inerter, with forces at the terminals proportional to relative acceleration:
inerter = CreateSystemModel["Inerter", {f[t] == b(Subscript[v, rel]'[t])}, t, <|"ExtendsModels" -> "Translational.Interfaces.PartialCompliantWithRelativeStates"|>];Compare how adding an inerter to a damping system influences vibrations:
comp = {"damper"∈"Modelica.Mechanics.Translational.Components.Damper", "mass"∈"Modelica.Mechanics.Translational.Components.Mass", "force"∈"Modelica.Mechanics.Translational.Sources.Force", "vibration"∈"Interfaces.RealInput", "fixed"∈"Modelica.Mechanics.Translational.Components.Fixed", "spring"∈"Modelica.Mechanics.Translational.Components.Spring"};conn = {"fixed.flange" -> "spring.flange_a", "fixed.flange" -> "damper.flange_a", "damper.flange_b" -> "mass.flange_a", "spring.flange_b" -> "mass.flange_a", "force.flange" -> "mass.flange_a", "vibration" -> "force.f"};damping = ConnectSystemModelComponents[comp, conn]inerterDamping = ConnectSystemModelComponents[Append[comp, "inerter"∈inerter], Join[conn, {"inerter.flange_b" -> "mass.flange_a", "inerter.flange_a" -> "fixed.flange"}]]Set parameter values and simulate the system with a sine vibration force:
d = 300;b = 700;c = 275;m = 2000;vibr = Function[t, Sin[10t]];tstop = 50;simInerter = SystemModelSimulate[inerterDamping, tstop, <|"Inputs" -> {"vibration" -> vibr}, "ParameterValues" -> {"inerter.b" -> b, "damper.d" -> d, "spring.c" -> c, "mass.m" -> m}|>];simDamper = SystemModelSimulate[damping, tstop, <|"Inputs" -> {"vibration" -> vibr}, "ParameterValues" -> {"damper.d" -> d, "spring.c" -> c, "mass.m" -> m}|>];Damping effects are of similar magnitude:
SystemModelPlot[{simInerter, simDamper}, {"mass.s"}, PlotLegends -> {"Inerter", "No inerter"}]Forces acting on the damper component are significantly reduced with an inerter:
damperForceInerter = simInerter[{"damper.f"}]//First;damperForce = simDamper[{"damper.f"}]//First;Plot[{Abs[damperForceInerter[t]], Abs[damperForce[t]]}, {t, 0, 10}, PlotLegends -> {"Inerter", "No inerter"}]Properties & Relations (3)
Use CreateSystemModel to create models based on differential equations:
model = CreateSystemModel[{Subscript[y, 1]'[t] == Subscript[y, 1][t] + Subscript[y, 2][t], Subscript[y, 2]'[t] == Subscript[y, 1][t] + Sin[t]}, t];SystemModelPlot[{model, 2.5}, {"y_1", "y_2"}]CreateSystemModel can be used similarly to ConnectSystemModelComponents:
model = CreateSystemModel[{"sine.y""sample.u"}, t, {"sine"∈"Modelica.Blocks.Sources.Sine", "sample"∈"ZeroOrderHold"}];SystemModelPlot[{model, 2}, {"sample.y"}]Hierarchical models based on existing components enable quick creation of larger systems:
components = {"controller"∈"Systems.Components.LQControlSystem", "gear"∈"Systems.Components.GearBox", "motor"∈"Systems.Components.ElectricalMotor", "pendulum"∈"Systems.Components.Pendulum"};connections = {"pendulum.angle""controller.angle", "pendulum.position""controller.xPos", "motor.flange""gear.flange_a", "gear.flange_b""pendulum.flange_a", "motor.u""controller.y"};Build a 3D inverted pendulum model with a controller:
model = ConnectSystemModelComponents[components, connections]A complex multidomain system can be built using few components:
model["Summary"]Neat Examples (1)
Show thermal conductance between vertices in a graph:
g = HararyGraph[4, 13];{vlist, elist} = {VertexList[g], EdgeList[g]};{nv, ne} = Length /@ {vlist, elist};vcomp = Map["v" <> ToString[#]∈"HeatCapacitor"&, vlist];ecomp = Table["e" <> ToString[i]∈"ThermalConductor", {i, ne}];complist = Join[vcomp, ecomp];connlist = Join@@Table[With[{e = ToString /@ elist[[i]], is = ToString[i]}, {"v" <> e[[1]] <> ".port""e" <> is <> ".port_a", "v" <> e[[2]] <> ".port""e" <> is <> ".port_b"}], {i, ne}];Create a model and set initial and parameter values:
m = ConnectSystemModelComponents["ThermalGraph", complist, connlist, GraphLayout -> None];SetSystemModel[m, Join[{"v1.T" -> 320}, Table["e" <> ToString[i] <> ".G" -> 10, {i, ne}], Table["v" <> ToString[i] <> ".C" -> 15, {i, nv}]]];Simulate and animate the model, indicating temperature by color:
sim = SystemModelSimulate[m, 5];temps = Table[i -> ColorData["TemperatureMap"][Rescale[sim["v" <> ToString[i] <> ".T", t], {293, 297}]], {i, nv}];vgraph[x_ ? NumberQ] := vgraph[x] = Graph[vlist, elist, VertexStyle -> (temps /. t -> x), VertexSize -> 0.3]Animate[Evaluate[vgraph[x]], {x, 0, 5}, AnimationRate -> 0.5, SaveDefinitions -> True, AnimationRunning -> False]See Also
Related Guides
Related Links
Text
Wolfram Research (2018), ConnectSystemModelComponents, Wolfram Language function, https://reference.wolfram.com/language/ref/ConnectSystemModelComponents.html (updated 2020).
CMS
Wolfram Language. 2018. "ConnectSystemModelComponents." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/ConnectSystemModelComponents.html.
APA
Wolfram Language. (2018). ConnectSystemModelComponents. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ConnectSystemModelComponents.html
BibTeX
@misc{reference.wolfram_2026_connectsystemmodelcomponents, author="Wolfram Research", title="{ConnectSystemModelComponents}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/ConnectSystemModelComponents.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_connectsystemmodelcomponents, organization={Wolfram Research}, title={ConnectSystemModelComponents}, year={2020}, url={https://reference.wolfram.com/language/ref/ConnectSystemModelComponents.html}, note=[Accessed: 12-June-2026]}