({{, (RefLink[ConnectSystemModelComponents, paclet:ref/ConnectSystemModelComponents])[{"(Subscript[c, 1])"∈"(Subscript[comp, 1])",…},{"(Subscript[c, 1]).a"->"(Subscript[c, 2]).b",…}]
creates a system model by connecting connector "a" of component "(Subscript[c, 1])" with connector "b" of component "c2" etc.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[ConnectSystemModelComponents, paclet:ref/ConnectSystemModelComponents]) returns (RefLink[SystemModel, paclet:ref/SystemModel])[…].

(RefLink[ConnectSystemModelComponents, paclet:ref/ConnectSystemModelComponents])["NewModel",…] gives the created model the name "NewModel".

(RefLink[ConnectSystemModelComponents, paclet:ref/ConnectSystemModelComponents])["PackageA.NewModel",…] inserts "NewModel" into "PackageA".

The comp can be a (RefLink[SystemModel, paclet:ref/SystemModel]) object, a full model name string or a shortened model name accepted by (RefLink[SystemModel, paclet:ref/SystemModel]).

In (RefLink[ConnectSystemModelComponents, paclet:ref/ConnectSystemModelComponents])[…,spec], spec is an (RefLink[Association, paclet:ref/Association]) with the following keys:

With (RefLink[ConnectSystemModelComponents, paclet:ref/ConnectSystemModelComponents])[…,\[LeftAssociation]"Extends"->partial\[RightAssociation]], the new model is combined with the existing partial (RefLink[SystemModel, paclet:ref/SystemModel]) defined in Modelica. »

A model can extend multiple models using "Extends"->{"(Subscript[partial, 1])",…}.

Partial models to build on are usually defined in an "Interfaces" package. For example, (RefLink[SystemModels, paclet:ref/SystemModels])["Modelica.Electrical.Analog.Interfaces.*","model"|"block"] can be used to find partial models for the built-in electrical library.

OpenersPrimaryExamplesSection(Spacer1)Examples  (15)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Create a simple electrical circuit:

components={"R"∈"Modelica.Electrical.Analog.Basic.Resistor","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"->"R.n","R.p"->"AC.n"};

model=ConnectSystemModelComponents[components,connections]

Show the current and voltage in the inductor:

SystemModelPlot[{model,5},{"L.i","L.v"}]

Use short naming to refer to the "Abs" and "Sine" components in "Modelica.Blocks":

comp={"a"∈"Abs","sine"∈"Sine"};

conn={"sine.y"->"a.u"};

model=ConnectSystemModelComponents[comp,conn]

SystemModelPlot[{model,2},{"a.y"}]

OpenersExampleSection1(Spacer1)Scope  (4)

Create a block example, sampling a sine wave at regular intervals:

comp={"sine"∈"Modelica.Blocks.Sources.Sine","sample"∈"Sampler"};

conn={"sine.y"\[UndirectedEdge]"sample.u"};

model=ConnectSystemModelComponents[comp,conn]

Simulate and plot the sampled signal:

SystemModelPlot[{model,2},{"sample.y"}]

Connect two masses with heat capacity with a thermal conductor:

comp={"mass1"∈"HeatCapacitor","mass2"∈"HeatCapacitor","conduction"∈"ThermalConductor"};

conn={"mass1.port"\[UndirectedEdge]"conduction.port_a","conduction.port_b"\[UndirectedEdge]"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,5},{"mass1.T","mass2.T"}]

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"\[UndirectedEdge]"spring.flange_a","spring.flange_b"\[UndirectedEdge]"mass.flange_a"};

model=ConnectSystemModelComponents[comp,conn]

Move the initial position of the mass, stretching the spring:

model2=SystemModel[model,{"mass.s"->2}];

Show how the mass position oscillates:

SystemModelPlot[{model2,10},{"mass.s"}]

Build a damped 3D pendulum:

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"\[UndirectedEdge]"rev.frame_a","damper.flange_b"\[UndirectedEdge]"rev.axis","rev.support"\[UndirectedEdge]"damper.flange_a","body.frame_a"\[UndirectedEdge]"rev.frame_b"};

model=ConnectSystemModelComponents[comp,conn];

Set parameter values:

model2=SystemModel[model,{"rev.useAxisFlange"->True,"body.r_CM"->{1,0,0},"damper.d"->0.1}]

Simulate and animate the path of the pendulum:

sim=SystemModelSimulate[model2,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}]

OpenersExampleSection2(Spacer1)Generalizations & Extensions  (2)

(RefLink[Rule, paclet:ref/Rule]), (RefLink[DirectedEdge, paclet:ref/DirectedEdge]) and (RefLink[UndirectedEdge, paclet:ref/UndirectedEdge]) can be used for connections:

comp1={"sine"∈"Modelica.Blocks.Sources.Sine","sample"∈"ZeroOrderHold"};

Use (RefLink[Rule, paclet:ref/Rule]) to specify a connection:

conn1={"sine.y"->"sample.u"};

model1=ConnectSystemModelComponents[comp1,conn1]

comp2=Append[comp1,"foh"∈"FirstOrderHold"];

Use (RefLink[DirectedEdge, paclet:ref/DirectedEdge]) and (RefLink[UndirectedEdge, paclet:ref/UndirectedEdge]) to specify connections:

conn2={"sine.y"\[DirectedEdge]"sample.u","sample.y"\[UndirectedEdge]"foh.u"};

model2=ConnectSystemModelComponents[comp2,conn2]

Simulate and plot the signals:

{SystemModelPlot[{model1,2},{"sample.y"}],SystemModelPlot[{model2,2},{"foh.y"}]}

Turn off automatic layout:

comp={"sine"∈"Modelica.Blocks.Sources.Sine","sample"∈"ZeroOrderHold"};
conn={"sine.y"->"sample.u"};

ConnectSystemModelComponents[comp,conn,GraphLayout->None]

OpenersExampleSection3(Spacer1)Applications  (3)

Create an inerter, with forces at the terminals proportional to relative acceleration:

inerter=CreateSystemModel["Inerter",{f[t]==b((Subscript[v, rel])'[t])},t,<|"Extends"->"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"∈"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"}]

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"∈"EMF","ground1"∈"Analog.Basic.Ground","signalVoltage1"∈"Analog.Sources.SignalVoltage","inertia1"∈"Rotational.Components.Inertia"};

connections={"resistor1.n"\[UndirectedEdge]"inductor1.p","inductor1.n"\[UndirectedEdge]"EMF1.p","step1.y"\[UndirectedEdge]"signalVoltage1.v","signalVoltage1.p"\[UndirectedEdge]"resistor1.p","EMF1.n"\[UndirectedEdge]"signalVoltage1.n","ground1.p"\[UndirectedEdge]"signalVoltage1.n","EMF1.flange"\[UndirectedEdge]"inertia1.flange_a"};

model=ConnectSystemModelComponents[components,connections]

Show the angular velocity of the DC motor:

SystemModelPlot[{model,10},"inertia1.w"]

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]//TransferFunctionCancel

Create a model of the filter:

lowPass=CreateSystemModel[tf];

Create a signal generating source:

signal=CreateSystemModel["Signal",{y[t]==Abs[Sin[t Cos[2t]]]t},t,<|"Extends"->"Modelica.Blocks.Interfaces.SignalSource"|>];

Connect the signal source to the filter:

model=ConnectSystemModelComponents["FilteredSignal",{"signal"∈signal,"filter"∈lowPass},{"signal.y"\[UndirectedEdge]"filter.u"}]

Simulate and plot the signal output and the filtered signal:

sim=SystemModelSimulate[model,10];
SystemModelPlot[sim,{"signal.y","filter.y"}]

OpenersExampleSection4(Spacer1)Properties & Relations  (3)

Use (RefLink[CreateSystemModel, paclet:ref/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"}]

(RefLink[CreateSystemModel, paclet:ref/CreateSystemModel]) can be used similarly to (RefLink[ConnectSystemModelComponents, paclet:ref/ConnectSystemModelComponents]):

model=CreateSystemModel[{"sine.y"\[UndirectedEdge]"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"\[UndirectedEdge]"controller.angle","pendulum.position"\[UndirectedEdge]"controller.xPos","motor.flange"\[UndirectedEdge]"gear.flange_a","gear.flange_b"\[UndirectedEdge]"pendulum.flange_a","motor.u"\[UndirectedEdge]"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"]

OpenersExampleSection5(Spacer1)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};

Define components:

vcomp=Map["v"<>ToString[#]∈"HeatCapacitor"&,vlist];
ecomp=Table["e"<>ToString[i]∈"ThermalConductor",{i,ne}];
complist=Join[vcomp,ecomp];

Define connections:

connlist=Join@@Table[With[{e=ToString/@elist[[i]],is=ToString[i]},{"v"<>e[[1]]<>".port"\[UndirectedEdge]"e"<>is<>".port_a","v"<>e[[2]]<>".port"\[UndirectedEdge]"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]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[CreateSystemModel, paclet:ref/CreateSystemModel])  ▪  (RefLink[SystemModel, paclet:ref/SystemModel])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[System Model Creation, paclet:guide/SystemModelCreation])}, {▪(RefLinkPlain[System Modeling Overview, paclet:guide/SystemModelingOverview])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(Spacer1)▪(WebLink[(Spacer1)Wolfram SystemModeler Documentation, http://reference.wolfram.com/system-modeler/])}})}})