Skip to content
OnePort.md

OnePort ​

A base model for two-terminal electrical components, defining voltage and current relationships.

This partial component serves as a foundational building block for creating various two-pin electrical devices. It establishes a common interface with a positive pin (p) and a negative pin (n). By extending TwoPin, it defines voltage across the component (v) as the potential difference between these pins:

v=p.v−n.v

The current (i) flowing through the component is taken as the current entering the positive pin (p):

i=p.i

Conservation of charge is maintained by enforcing Kirchhoff's Current Law, ensuring that the current entering one pin exits through the other:

p.i+n.i=0

This model is intended to be extended by specific components like resistors, capacitors, etc., which will add their own constitutive equations relating v and i.

This component extends from TwoPin

Usage ​

ElectricalComponents.OnePort()

Connectors ​

  • p - This connector represents an electrical pin with voltage and current as the potential and flow variables, respectively. (Pin)

  • n - This connector represents an electrical pin with voltage and current as the potential and flow variables, respectively. (Pin)

Variables ​

NameDescriptionUnits
vVoltage across the component (between pin p and pin n).V
iCurrent flowing through the component (from pin p to pin n).A

Source ​

dyad
"""
A base model for two-terminal electrical components, defining voltage and current relationships.

This partial component serves as a foundational building block for creating various two-pin electrical devices.
It establishes a common interface with a positive pin (`p`) and a negative pin (`n`).
By extending `TwoPin`, it defines voltage across the component (`v`) as the potential difference between these pins:

math v = p.v - n.v

The current (`i`) flowing through the component is taken as the current entering the positive pin (`p`):

math i = p.i

Conservation of charge is maintained by enforcing Kirchhoff's Current Law,
ensuring that the current entering one pin exits through the other:

math p.i + n.i = 0

This model is intended to be extended by specific components like resistors, capacitors, etc.,
which will add their own constitutive equations relating `v` and `i`.
"""
partial component OnePort
  extends TwoPin
  "Current flowing through the component (from pin p to pin n)."
  variable i::Current
relations
  i = p.i
  p.i + n.i = 0
end
Flattened Source
dyad
"""
A base model for two-terminal electrical components, defining voltage and current relationships.

This partial component serves as a foundational building block for creating various two-pin electrical devices.
It establishes a common interface with a positive pin (`p`) and a negative pin (`n`).
By extending `TwoPin`, it defines voltage across the component (`v`) as the potential difference between these pins:

math v = p.v - n.v

The current (`i`) flowing through the component is taken as the current entering the positive pin (`p`):

math i = p.i

Conservation of charge is maintained by enforcing Kirchhoff's Current Law,
ensuring that the current entering one pin exits through the other:

math p.i + n.i = 0

This model is intended to be extended by specific components like resistors, capacitors, etc.,
which will add their own constitutive equations relating `v` and `i`.
"""
partial component OnePort
  "Positive electrical pin."
  p = Pin() {
    "Dyad": {
      "placement": {"icon": {"iconName": "pos", "x1": -50, "y1": 450, "x2": 50, "y2": 550}}
    }
  }
  "Negative electrical pin."
  n = Pin() {
    "Dyad": {
      "placement": {"icon": {"iconName": "neg", "x1": 950, "y1": 450, "x2": 1050, "y2": 550}}
    }
  }
  "Voltage across the component (between pin p and pin n)."
  variable v::Voltage
  "Current flowing through the component (from pin p to pin n)."
  variable i::Current
relations
  v = p.v - n.v
  i = p.i
  p.i + n.i = 0
metadata {}
end


Test Cases ​

No test cases defined.

  • Examples

  • Experiments

  • Analyses