Skip to content
TwoPin.md

TwoPin

A base model for two-terminal electrical components, defining voltage relationship.

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). The voltage across the component (v) is defined as the potential difference between these pins:

v=p.vn.v

Usage

TwoPin()

Connectors

Variables

NameDescriptionUnits
vVoltage across the component (between pin p and pin n).V

Source

dyad
# A base model for two-terminal electrical components, defining voltage relationship.
#
# 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`).
# The voltage across the component (`v`) is defined as the potential difference between these pins:
# ```math
# v = p.v - n.v
# ```
partial component TwoPin
  # 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
relations
  v = p.v-n.v
end
Flattened Source
dyad
# A base model for two-terminal electrical components, defining voltage relationship.
#
# 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`).
# The voltage across the component (`v`) is defined as the potential difference between these pins:
# ```math
# v = p.v - n.v
# ```
partial component TwoPin
  # 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
relations
  v = p.v-n.v
metadata {}
end


Test Cases

This is setup code, that must be run before each test case.

julia
using ElectricalComponents
using ModelingToolkit, OrdinaryDiffEqDefault
using Plots
using CSV, DataFrames

snapshotsdir = joinpath(dirname(dirname(pathof(ElectricalComponents))), "test", "snapshots")
"/home/actions-runner-10/.julia/packages/ElectricalComponents/bmmPM/test/snapshots"
  • Examples

  • Experiments

  • Analyses