我写建模程序作为文凭的一部分,我寻找Modelica作为输入语言。如何将某个模型用作不同模型的一部分?
但在标准规范我无法找到如何实现该功能:
例如,我有一些模型:
model circuit1
Resistor R1(R=10);
Capacitor C(C=0.01);
Resistor R2(R=100);
Inductor L(L=0.1);
VsourceAC AC;
Ground G;
equation
connect (AC.p, R1.p);
connect (R1.n, C.p);
connect (C.n, AC.n);
connect (R1.p, R2.p);
connect (R2.n, L.p);
connect (L.n, C.n);
connect (AC.n, G.p);
end circuit1
如何使用这个模型作为不同模型的一部分?
就像是:
model circuit2
Resistor R1(R=10);
circuit1 circ(); // ! Define some circuit1
Resistor R2(R=100);
Inductor L(L=0.1);
VsourceAC AC;
Ground G;
equation
connect (AC.p, R1.p);
connect (R1.n, C.p);
connect (circ.somePin1, AC.n); // ! Connect circuit1 pins
connect (R1.p, R2.p);
connect (R2.n, L.p);
connect (L.n, circ.somePin2); // ! Connect circuit1 pins
connect (AC.n, G.p);
end circuit2
编辑
model circuit1
extends somePin1; //
extends somePin2; //
Resistor R1(R=10);
Capacitor C(C=0.01);
Resistor R2(R=100);
Inductor L(L=0.1);
VsourceAC AC;
Ground G;
equation
connect (AC.p, R1.p);
connect (R1.n, C.p);
connect (C.n, AC.n);
connect (R1.p, R2.p);
connect (R2.n, L.p);
connect (L.n, C.n);
connect (AC.n, G.p);
connect (AC.n, somePin1); //
connect (R1.n, somePin2); //
end circuit1
但是如何在circuit1中定义circ.somePin1和circ.somePin2?我找不到一些导出变量功能! –
在model1中,添加:MyPin somePin1; –