Connecting the components together
So far, we have created and used node models to link ports together. But it can be useful to have node models that allow components to be connected directly to each other. We’re going to see how the combined use of model overloading and inheritance will allow us to have generic node models between components, while still being able to connect ports to each other.
Let’s start by creating a node model between two components:
Model Node (C1,C2)
Constants
Variables
Elements
C1 : Dipole[DipoleIndex];
C2 : Dipole[DipoleIndex];
Properties
C1.Pin.V = C2.Pout.V;
C1.Pin.I+C2.Pout.I=0;
End
This model can be simplified by using a node model betwwen two ports:
Model Node (C1,C2)
Constants
Variables
Elements
C1 : Dipole[DipoleIndex];
C2 : Dipole[DipoleIndex];
Connect : Node(C1.Pin, C2.Pout);
Properties
End
Therefore the TwoSerialAndNode problem can be rewritten as follow:
Problem TwoSerialAndNode
Constants
e : Voltage = 10;
Variables
Elements
Res1 : Resistor(1) ;
Res2 : Resistor(2, 10) ;
Connection : Node(Res1, Res2) ;
Properties
Res1.P2.V = 0 ;
Res2.P1.V = e ;
Res1.I = 0.1;
End
We can see that the node model with the Node[Dipole[DipoleIndex], Dipole[DipoleIndex]] signature can still be used with two resistors as arguments, as long as the resistor model is a model derived from Dipole (extends).