ConnectSystemModelComponents[{"c1"∈comp1,…},{"c1.a""c2.b",…}]
通过将元件 "c1" 的接口 "a" 与元件 "c2" 的接口 "b" 等相连接创建一个系统模型.
ConnectSystemModelComponents
ConnectSystemModelComponents[{"c1"∈comp1,…},{"c1.a""c2.b",…}]
通过将元件 "c1" 的接口 "a" 与元件 "c2" 的接口 "b" 等相连接创建一个系统模型.
更多信息和选项
- ConnectSystemModelComponents 组装元件并创建一个新的系统模型. 这些连接传达值并在系统中设置守恒定律.
- ConnectSystemModelComponents 返回 SystemModel[…].
- ConnectSystemModelComponents["NewModel",…] 将创建的模型命名为 "NewModel".
- ConnectSystemModelComponents["PackageA.NewModel",…] 把 "NewModel" 插入到 "PackageA" 中.
- compi 可以是一个 SystemModel对象、SystemModel 接受的完整模型名称字符串或模型简称.
- 在 ConnectSystemModelComponents[…,spec] 中,spec 是一个 Association,其中的键为:
-
"ParameterValues" {p1val1,…} 参数值 "InitialValues" {v1val1,…} 初始值 "ExtendsModels" {partial1,…} 所基于的部分模型 "DiscreteVariables" {v1,v2,…} 仅在事件发生时变化的变量 "SimulationSettings" {opt1val1,…} 模型仿真选项 - 当设置为 ConnectSystemModelComponents[…,"ExtendsModels"partial] 时,会将新模型与 Modelica 中已定义的 partial SystemModel 结合在一起. »
- 通过使用 "ExtendsModels"{"partial1",…} 一个模型可以跨越多个模型.
- 在其上进行构建的部分模通常在 Interfaces 包中被定义. 例如,SystemModels["Modelica.Electrical.Analog.Interfaces.*","model"|"block"] 可用于查找内置电子模型库中的部分模型 (partial models).
- "InitialValues" 对应于 Modelica 模型中的 start 属性.
- 在 "SimulationsSettings"->{opt1val1,…} 中允许的选项包括:
-
"Method" 仿真方法 "StartTime" 仿真开始时间 "StopTime" 仿真停止时间 - 可用的自适应步长 "Method" 值包括:
-
"DASSL" DASSL DAE 求解器 "CVODES" CVODES ODE 求解器 - 自适应步长法的选项包括:
-
"InterpolationPoints" 插值点数 "Tolerance" 自适应步长的公差 - 可用的固定步长"Method"值包括:
-
"Euler" 显式 1 阶欧拉方法 "Heun" 2 阶 Heun 方法 "RungeKutta" 显式四阶 Runge-Kutta 法 - 固定步长法的选项包括:
-
"StepSize" 固定步长 - 可以使用 GraphLayout 选项控制创建的模型图的布局.
范例
打开所有单元 关闭所有单元基本范例 (2)
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]SystemModelPlot[model, {"L.i", "L.v"}, 5]用简写名称指代 Modelica.Blocks 中的 Abs 和 Sine 元件:
comp = {"a"∈"Abs", "sine"∈"Sources.Sine"};conn = {"sine.y" -> "a.u"};model = ConnectSystemModelComponents[comp, conn]SystemModelPlot[model, {"a.y"}, 2]范围 (5)
comp = {"sine"∈"Modelica.Blocks.Sources.Sine", "sample"∈"Discrete.Sampler"};conn = {"sine.y""sample.u"};model = ConnectSystemModelComponents[comp, conn]SystemModelPlot[model, {"sample.y"}, 2]comp = {"inAdd"∈"DocumentationExamples.Basic.InputAdd", "cSource"∈"Modelica.Blocks.Sources.Constant"};conn = {"cSource.y""inAdd.u"};model = ConnectSystemModelComponents[comp, conn, <|"ParameterValues" -> {"inAdd.sine.amplitude" -> 3}|>]SystemModelPlot[model, {"inAdd.y"}, 2]comp = {"mass1"∈"HeatCapacitor", "mass2"∈"HeatCapacitor", "conduction"∈"ThermalConductor"};conn = {"mass1.port""conduction.port_a", "conduction.port_b""mass2.port"};model = ConnectSystemModelComponents[comp, conn]model2 = SystemModel[model, {"conduction.G" -> 10, "mass1.C" -> 15, "mass2.C" -> 40, "mass1.T" -> 373.15, "mass2.T" -> 273.15}];SystemModelPlot[model2, {"mass1.T", "mass2.T"}, 5]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"};model = ConnectSystemModelComponents[comp, conn, <|"InitialValues" -> {"mass.s" -> 2}|>]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}|>]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}]推广和延伸 (1)
Rule、DirectedEdge 和 UndirectedEdge 可被用来建立连接:
comp1 = {"sine"∈"Modelica.Blocks.Sources.Sine", "sample"∈"ZeroOrderHold"};用 Rule 来指定连接:
conn1 = {"sine.y" -> "sample.u"};model1 = ConnectSystemModelComponents[comp1, conn1]用 DirectedEdge 和 UndirectedEdge 来指定连接:
comp2 = Append[comp1, "foh"∈"FirstOrderHold"];conn2 = {"sine.y""sample.u", "sample.y""foh.u"};model2 = ConnectSystemModelComponents[comp2, conn2]Column[{SystemModelPlot[model1, {"sample.y"}, 2], SystemModelPlot[model2, {"foh.y"}, 2]}]选项 (3)
GraphLayout (3)
GraphLayout 可用于指定模型图的布局:
comp = {"sine"∈"Modelica.Blocks.Sources.Sine", "sample"∈"ZeroOrderHold", "foh"∈"FirstOrderHold"};conn = {"sine.y""sample.u", "sample.y""foh.u"};ConnectSystemModelComponents[comp, conn, GraphLayout -> "LinearEmbedding"]默认情况下使用加权为 "SpringElectricalEmbedding" 的边:
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]应用 (3)
A DC Motor (1)
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]SystemModelPlot[model, "inertia1.w", 10]A Lowpass Filter (1)
a = LeastSquaresFilterKernel[{"Lowpass", 0.1}, 20];h = ListZTransform[a, z];tf = TransferFunctionModel[h, z, SamplingPeriod -> 0.01]//TransferFunctionCancellowPass = CreateSystemModel[tf];signal = CreateSystemModel["Signal", {y[t] == Abs[Sin[t Cos[2t]]]t}, t, <|"ExtendsModels" -> "Modelica.Blocks.Interfaces.SignalSource"|>];model = ConnectSystemModelComponents["FilteredSignal", {"signal"∈signal, "filter"∈lowPass}, {"signal.y""filter.u"}]sim = SystemModelSimulate[model, 10];SystemModelPlot[sim, {"signal.y", "filter.y"}]An Inerter (1)
inerter = CreateSystemModel["Inerter", {f[t] == b(Subscript[v, rel]'[t])}, t, <|"ExtendsModels" -> "Translational.Interfaces.PartialCompliantWithRelativeStates"|>];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"}]]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}|>];SystemModelPlot[{simInerter, simDamper}, {"mass.s"}, PlotLegends -> {"Inerter", "No 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"}]属性和关系 (3)
用 CreateSystemModel 基于微分方程创建模型:
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"}]可以与使用 ConnectSystemModelComponents 类似的方式使用 CreateSystemModel:
model = CreateSystemModel[{"sine.y""sample.u"}, t, {"sine"∈"Modelica.Blocks.Sources.Sine", "sample"∈"ZeroOrderHold"}];SystemModelPlot[{model, 2}, {"sample.y"}]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"};model = ConnectSystemModelComponents[components, connections]model["Summary"]Neat 巧妙范例 (1)
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}];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}]]];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]文本
Wolfram Research (2018),ConnectSystemModelComponents,Wolfram 语言函数,https://reference.wolfram.com/language/ref/ConnectSystemModelComponents.html (更新于 2020 年).
CMS
Wolfram 语言. 2018. "ConnectSystemModelComponents." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2020. https://reference.wolfram.com/language/ref/ConnectSystemModelComponents.html.
APA
Wolfram 语言. (2018). ConnectSystemModelComponents. Wolfram 语言与系统参考资料中心. 追溯自 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: 14-September-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: 14-September-2026]}