Modeling a nary node

We have previously created node models that depend on the arity of the ports to be connected. For example, a binary node model and a ternary node model. We now want to create a node model that allows any number of ports to be linked together. We would also like to be able to express the necessary properties on this set of ports.

In order to do this, we can create a new type as a model of list of Ports that we call Plist:

List  Plist() of Port[] End

Now an instance of Plist can be pass as an argument to a new model of Node. We can express glabal properties on the Plist Lp :

  • AllEqual(Lp, V) that means that all the variables V of the elements of Lp must be equal.

  • Sum(Lp, I) = 0 that means that the sum of the variables I of the elements of Lp has to be equal to zero.

Model Node (Lp)
Constants

Variables

Elements
Lp : Plist[];

Properties
AllEqual(Lp, V);
Sum(Lp, I) = 0;

End

And then, the Wheatstone bridge problem can be rewritten as follow :

Problem Wheatstone
Constants
e : Voltage = 50;

Variables

Elements
Res1:Resistor(1);
Res2: Resistor(2, 3);
Res3 : Resistor(3, 6);
Res4 : Resistor(4, 4);
Gen : VSource(e);
Mesure : Dipole(1);

lp1 : Lp() = [Gen.P2, Res1.P2, Res4.P2)];
lp2 : Lp() = [Gen.P1, Res2.P1, Res3.P1];
lp3 : Lp() = [Res2.P2, Res1.P1, Mesure.P1];
lp4 : Lp() = [Res4.P1, Res3.P2, Mesure.P2];

Connexion1 : Node(lp1);
Connexion2 : Node(lp2);
Connexion3 : Node(lp3);
Connexion4 : Node(lp4);

Properties
Mesure.I = 0.0;
Mesure.P1.V = Mesure.P2.V;

End