OnePort IconOnePort
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
| Name | Description | Units |
|---|---|---|
v | Voltage across the component (between pin p and pin n). | V |
i | Current flowing through the component (from pin p to pin n). | A |
Source
"""
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`.
"""</span>
<span class="hljs-keyword">partial</span> <span class="hljs-keyword">component</span> OnePort
<span class="hljs-keyword">extends</span> <span class="hljs-link"><a href="https://help.juliahub.com/dyad/dev/stdlib/ElectricalComponents/types/TwoPin.html">TwoPin</a></span>
<span class="hljs-comment">"Current flowing through the component (from pin p to pin n)."</span>
<span class="hljs-keyword">variable</span> <span class="hljs-symbol">i</span>::<span class="hljs-link"><a href="https://help.juliahub.com/dyad/dev/stdlib/Dyad/types/Current.html">Current</a></span>
<span class="hljs-keyword">relations</span>
i = p.i
p.i + n.i = 0
<span class="hljs-keyword">end</span></code></pre>
Flattened Source
"""
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`.
"""</span>
<span class="hljs-keyword">partial</span> <span class="hljs-keyword">component</span> OnePort
<span class="hljs-comment">"Positive electrical pin."</span>
<span class="hljs-symbol">p</span> = <span>Pin</span>() {
"Dyad": {
"placement": {"icon": {"iconName": "pos", "x1": -50, "y1": 450, "x2": 50, "y2": 550}}
}
}
<span class="hljs-comment">"Negative electrical pin."</span>
<span class="hljs-symbol">n</span> = <span>Pin</span>() {
"Dyad": {
"placement": {"icon": {"iconName": "neg", "x1": 950, "y1": 450, "x2": 1050, "y2": 550}}
}
}
<span class="hljs-comment">"Voltage across the component (between pin p and pin n)."</span>
<span class="hljs-keyword">variable</span> <span class="hljs-symbol">v</span>::<span>Voltage</span>
<span class="hljs-comment">"Current flowing through the component (from pin p to pin n)."</span>
<span class="hljs-keyword">variable</span> <span class="hljs-symbol">i</span>::<span>Current</span>
<span class="hljs-keyword">relations</span>
v = p.v - n.v
i = p.i
p.i + n.i = 0
<span class="hljs-keyword">metadata</span> {}
<span class="hljs-keyword">end</span></code></pre>
Test Cases
No test cases defined.
Related
- Examples
- Experiments
- Analyses