Electrical
Electrical realizations shared by the engineering packages.
They are circuit components that join the nodes of a circuit.
BranchInteraction(label, *, a, b)
Bases: Interaction
Component between the nodes a and b whose current flows from a to b.
Every node holds its potential v, and the currents of the components that join a node add into its balance,
which is zero, as Kirchhoff's current law says. A subclass returns its current from _get_current, or its own laws
from _get_branch_laws when the current is a value of its own. A resistor, a diode, and a source in a circuit are
such components, as a pipe between two tanks or a road between two towns would be.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the components of its system. |
required |
a
|
Role
|
The path of the node the current leaves. |
required |
b
|
Role
|
The path of the node the current enters. |
required |
Examples:
>>> from skcomplex.systems.engineering.common.electrical import ResistorInteraction
>>> ResistorInteraction('load', a='top', b='bottom', R=2.0).b
'bottom'
Source code in src/skcomplex/systems/engineering/common/electrical/_components.py
48 49 50 51 | |
CapacitorInteraction(label, *, a, b, branch, C=1.0)
Bases: BranchInteraction
Capacitor whose voltage u and current i live on the element branch.
It has C u' = i and u = a.v - b.v.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the components of its system. |
required |
a
|
Role
|
The path of the node the current leaves. |
required |
b
|
Role
|
The path of the node the current enters. |
required |
branch
|
Role
|
The path of the element that holds the voltage |
required |
C
|
Annotated[float, POSITIVE]
|
The capacitance. |
1.0
|
Examples:
>>> from skcomplex.core.components.elements import Element
>>> from skcomplex.core.systems import System
>>> from skcomplex.systems.engineering.common.electrical import (
... CapacitorInteraction,
... GroundInteraction,
... ResistorInteraction,
... )
>>> nodes = [Element(name, values={'v': 0.0}) for name in ('top', 'bottom')]
>>> branches = [Element('tank', values={'u': 1.0, 'i': 0.0}), Element('earth', values={'i': 0.0})]
>>> interactions = [
... CapacitorInteraction('capacitor', a='top', b='bottom', branch='tank', C=0.5),
... ResistorInteraction('load', a='top', b='bottom', R=2.0),
... GroundInteraction('ground', node='bottom', branch='earth'),
... ]
>>> system = System(elements=nodes + branches, interactions=interactions).prepare()
>>> round(float(system.simulate(until=1.0, dt=1.0).get_values('tank.u')[-1]), 4)
0.3679
Source code in src/skcomplex/systems/engineering/common/electrical/_components.py
147 148 149 150 151 152 153 154 155 156 157 158 | |
ChuaDiodeInteraction(label, *, a, b, m0=-8 / 7, m1=-5 / 7)
Bases: BranchInteraction
Nonlinear resistor of Chua's circuit.
At the voltage u = a.v - b.v it has the current m1 u + (m0 - m1) (|u + 1| - |u - 1|) / 2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the components of its system. |
required |
a
|
Role
|
The path of the node the current leaves. |
required |
b
|
Role
|
The path of the node the current enters. |
required |
m0
|
float
|
The slope of the characteristic inside the breakpoints. |
-8 / 7
|
m1
|
float
|
The slope of the characteristic outside the breakpoints. |
-5 / 7
|
Examples:
>>> from skcomplex.systems.engineering.common.electrical import ChuaDiodeInteraction
>>> round(ChuaDiodeInteraction('diode', a='top', b='bottom').m0, 3)
-1.143
Source code in src/skcomplex/systems/engineering/common/electrical/_components.py
407 408 409 410 | |
CurrentSourceInteraction(label, *, a, b, current=1.0)
Bases: BranchInteraction
Ideal source that drives the constant current current from b through the source to a.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the components of its system. |
required |
a
|
Role
|
The path of the node the source drives the current into. |
required |
b
|
Role
|
The path of the node the source draws the current from. |
required |
current
|
float
|
The current the source drives into |
1.0
|
Examples:
>>> from skcomplex.systems.engineering.common.electrical import CurrentSourceInteraction
>>> CurrentSourceInteraction('source', a='top', b='bottom', current=0.5).current
0.5
Source code in src/skcomplex/systems/engineering/common/electrical/_components.py
283 284 285 | |
DiodeInteraction(label, *, a, b, Is=1e-06, Vt=0.025)
Bases: BranchInteraction
Exponential diode, with the current Is (exp((a.v - b.v) / Vt) - 1).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the components of its system. |
required |
a
|
Role
|
The path of the anode. |
required |
b
|
Role
|
The path of the cathode. |
required |
Is
|
Annotated[float, POSITIVE]
|
The saturation current. |
1e-06
|
Vt
|
Annotated[float, POSITIVE]
|
The thermal voltage. |
0.025
|
Examples:
>>> from skcomplex.systems.engineering.common.electrical import DiodeInteraction
>>> DiodeInteraction('diode', a='anode', b='cathode').Vt
0.025
Source code in src/skcomplex/systems/engineering/common/electrical/_components.py
361 362 363 364 365 366 367 368 369 370 371 372 | |
GroundInteraction(label, *, node, branch)
Bases: Interaction
Reference that holds the potential of a node at zero.
The current that the ground feeds into the node, i of the element branch, balances the node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the components of its system. |
required |
node
|
Role
|
The path of the node held at zero potential. |
required |
branch
|
Role
|
The path of the element that holds the current |
required |
Examples:
>>> from skcomplex.systems.engineering.common.electrical import GroundInteraction
>>> GroundInteraction('ground', node='bottom', branch='earth').node
'bottom'
Source code in src/skcomplex/systems/engineering/common/electrical/_components.py
316 317 318 319 | |
InductorInteraction(label, *, a, b, branch, L=1.0)
Bases: BranchInteraction
Inductor whose current i lives on the element branch, with L i' = a.v - b.v.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the components of its system. |
required |
a
|
Role
|
The path of the node the current leaves. |
required |
b
|
Role
|
The path of the node the current enters. |
required |
branch
|
Role
|
The path of the element that holds the current |
required |
L
|
Annotated[float, POSITIVE]
|
The inductance. |
1.0
|
Examples:
>>> from skcomplex.systems.engineering.common.electrical import InductorInteraction
>>> InductorInteraction('coil', a='top', b='bottom', branch='coil', L=0.5).L
0.5
Source code in src/skcomplex/systems/engineering/common/electrical/_components.py
196 197 198 199 200 201 202 203 204 205 206 207 | |
OperationalAmplifierInteraction(label, *, p, n, out, branch)
Bases: Interaction
Ideal operational amplifier.
Its inputs p and n draw no current, and its output drives the node out with the current i of the element
branch that holds both inputs at equal potentials. The output current returns through the supply of the
amplifier, so no balance takes it back.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the components of its system. |
required |
p
|
Role
|
The path of the noninverting input node. |
required |
n
|
Role
|
The path of the inverting input node. |
required |
out
|
Role
|
The path of the output node. |
required |
branch
|
Role
|
The path of the element that holds the output current |
required |
Examples:
>>> from skcomplex.systems.engineering.common.electrical import OperationalAmplifierInteraction
>>> OperationalAmplifierInteraction('amplifier', p='ground', n='sum', out='output', branch='drive').out
'output'
Source code in src/skcomplex/systems/engineering/common/electrical/_components.py
450 451 452 453 454 455 | |
ResistorInteraction(label, *, a, b, R=1.0)
Bases: BranchInteraction
Resistor that obeys Ohm's law, with the current (a.v - b.v) / R.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the components of its system. |
required |
a
|
Role
|
The path of the node the current leaves. |
required |
b
|
Role
|
The path of the node the current enters. |
required |
R
|
Annotated[float, POSITIVE]
|
The resistance. |
1.0
|
Examples:
>>> from skcomplex.systems.engineering.common.electrical import ResistorInteraction
>>> ResistorInteraction('load', a='top', b='bottom', R=2.0).R
2.0
Source code in src/skcomplex/systems/engineering/common/electrical/_components.py
96 97 98 | |
VoltageSourceInteraction(label, *, a, b, branch, V=1.0)
Bases: BranchInteraction
Ideal source that holds the node a at the voltage V above the node b.
Its current i, from a through the source to b, lives on the element branch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the components of its system. |
required |
a
|
Role
|
The path of the positive node. |
required |
b
|
Role
|
The path of the negative node. |
required |
branch
|
Role
|
The path of the element that holds the current |
required |
V
|
float
|
The voltage. |
1.0
|
Examples:
>>> from skcomplex.systems.engineering.common.electrical import VoltageSourceInteraction
>>> VoltageSourceInteraction('battery', a='plus', b='minus', branch='cell', V=9.0).V
9.0
Source code in src/skcomplex/systems/engineering/common/electrical/_components.py
246 247 248 249 | |