Modelica: Naming convention: Why does the OnePort family of electrical components have 2 Pins? Where is the "one port"?

Icon class
icon_class
far fa-sticky-note
icon_class_computed
far fa-sticky-note
Note kind
Policy level
SysMLv1.x keywords
Modelica keywords
Keywords

This one can be confusing at first glance, especially if you are also working with Systems Modeling Language v1 (SysML®) and SysML Extension for Physical Interaction and Signal Flow Simulation (SysPhS) where each Modelica Pin is represented by a SysML Port. Also, in microcontroller terminology, Port is often used as a functional description for behaviour controlled by connection to potentially multiple physical Pins.

Here's a typical definition of the Modelica OnePort from Wolfram SystemModeler:


partial model OnePort "Component with two electrical pins p and n and current i from p to n"
  SI.Voltage v "Voltage drop of the two pins (= p.v - n.v)";
  SI.Current i "Current flowing from pin p to pin n";
  PositivePin p "Positive electrical pin";
  NegativePin n "Negative electrical pin";
equation
  v = p.v - n.v;
  0 = p.i + n.i;
  i = p.i;
end OnePort;
Where:

connector PositivePin "Positive pin of an electrical component"
  SI.ElectricPotential v "Potential at the pin";
  flow SI.Current i "Current flowing into the pin";
end PositivePin;
connector NegativePin "Negative pin of an electrical component"
  SI.ElectricPotential v "Potential at the pin";
  flow SI.Current i "Current flowing into the pin";
end NegativePin;
Apart from PositivePin and NegativePin offering the opportunity to carry distinctive icons, there is nothing intrinsically "positive" and "negative" about them, that is just imposed by signs used in equations in a usage context, such as here for "voltage drop":

  v = p.v - n.v;
The counting of "Ports" as used above is related to the number of current balancing equations:

  0 = p.i + n.i;
Thus the simpler Modelica TwoPin has no "Ports":

partial model TwoPin "Component with two electrical pins"
  SI.Voltage v "Voltage drop of the two pins (= p.v - n.v)";
  PositivePin p "Positive electrical pin";
  NegativePin n "Negative electrical pin";
equation
  v = p.v - n.v;
end TwoPin;
And the Modelica TwoPorts has 2 current balancing equations:

partial model TwoPort "Component with two electrical ports, including current"
  SI.Voltage v1 "Voltage drop of port 1 (= p1.v - n1.v)";
  SI.Voltage v2 "Voltage drop of port 2 (= p2.v - n2.v)";
  SI.Current i1 "Current flowing from pos. to neg. pin of port 1";
  SI.Current i2 "Current flowing from pos. to neg. pin of port 2";
  PositivePin p1 "Positive electrical pin of port 1";
  NegativePin n1 "Negative electrical pin of port 1";
  PositivePin p2 "Positive electrical pin of port 2";
  NegativePin n2 "Negative electrical pin of port 2";
equation
  v1 = p1.v - n1.v;
  v2 = p2.v - n2.v;
  0 = p1.i + n1.i;
  0 = p2.i + n2.i;
  i1 = p1.i;
  i2 = p2.i;
end TwoPort;

The use of the name "OnePort" above is at odds with the concept of "physical port" referenced here https://en.wikipedia.org/wiki/Modelica:

Connectors describing physical interaction The interaction of a component to other components is defined by physical ports, called connectors, e.g., an electrical pin is defined as:

connector Pin "Electrical pin"
   Voltage      v "Potential at the pin";
   flow Current i "Current flowing into the component";
end Pin;
When drawing connection lines between ports, the meaning is that corresponding connector variables without the "flow" prefix are identical (here: "v") and that corresponding connector variables with the "flow" prefix (here: "i") are defined by a zero-sum equation (the sum of all corresponding "flow" variables is zero). The motivation is to automatically fulfill the relevant balance equations at the infinitesimally small connection point.
Relates to
Related notes
Related notes (backlinks)
Related snippets (extracts)
Visit also
Visit also (backlinks)
External links