Skip to content

Electrical

Electrical realizations shared by the engineering packages: the connector of a pin and circuit components.

CapacitorElement(label, visual=None, *, p_v=0.0, p_i=0.0, n_v=0.0, n_i=0.0, u=0.0, C=1.0)

Bases: TwoPinElement

Capacitor of voltage u, with C u' = p_i and u = p_v - n_v.

Parameters:

Name Type Description Default
label str

The label of the element, unique among the parts of its system.

required
visual VisualSpec | None

How the element is drawn, or None for default_visual_.

None
p_v object

The potential of the positive pin.

0.0
p_i object

The current into the positive pin.

0.0
n_v object

The potential of the negative pin.

0.0
n_i object

The current into the negative pin.

0.0
u Annotated[object, StateSpec()]

The initial voltage.

0.0
C Annotated[object, ParameterSpec(domain=POSITIVE)]

The capacitance.

1.0

Examples:

>>> from skcomplex.systems.engineering.common.electrical import CapacitorElement
>>> CapacitorElement('tank', u=1.0).u
1.0
Source code in src/skcomplex/systems/engineering/common/electrical/_components.py
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
def __init__(
    self,
    label: str,
    visual: VisualSpec | None = None,
    *,
    p_v: object = 0.0,
    p_i: object = 0.0,
    n_v: object = 0.0,
    n_i: object = 0.0,
    u: Annotated[object, StateSpec()] = 0.0,
    C: Annotated[object, ParameterSpec(domain=POSITIVE)] = 1.0,
) -> None:
    super().__init__(label, visual, p_v=p_v, p_i=p_i, n_v=n_v, n_i=n_i)
    self.u = u
    self.C = C

ChuaDiodeElement(label, visual=None, *, p_v=0.0, p_i=0.0, n_v=0.0, n_i=0.0, m0=-8 / 7, m1=-5 / 7)

Bases: TwoPinElement

Nonlinear resistor of Chua's circuit, with the current m1 u + (m0 - m1) (|u + 1| - |u - 1|) / 2 at voltage u.

Parameters:

Name Type Description Default
label str

The label of the element, unique among the parts of its system.

required
visual VisualSpec | None

How the element is drawn, or None for default_visual_.

None
p_v object

The potential of the positive pin.

0.0
p_i object

The current into the positive pin.

0.0
n_v object

The potential of the negative pin.

0.0
n_i object

The current into the negative pin.

0.0
m0 Annotated[object, ParameterSpec()]

The slope of the characteristic inside the breakpoints.

-8 / 7
m1 Annotated[object, ParameterSpec()]

The slope of the characteristic outside the breakpoints.

-5 / 7

Examples:

>>> from skcomplex.systems.engineering.common.electrical import ChuaDiodeElement
>>> round(ChuaDiodeElement('diode').m0, 3)
-1.143
Source code in src/skcomplex/systems/engineering/common/electrical/_components.py
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
def __init__(
    self,
    label: str,
    visual: VisualSpec | None = None,
    *,
    p_v: object = 0.0,
    p_i: object = 0.0,
    n_v: object = 0.0,
    n_i: object = 0.0,
    m0: Annotated[object, ParameterSpec()] = -8 / 7,
    m1: Annotated[object, ParameterSpec()] = -5 / 7,
) -> None:
    super().__init__(label, visual, p_v=p_v, p_i=p_i, n_v=n_v, n_i=n_i)
    self.m0 = m0
    self.m1 = m1

CurrentSourceElement(label, visual=None, *, p_v=0.0, p_i=0.0, n_v=0.0, n_i=0.0, current=1.0)

Bases: TwoPinElement

Ideal source that drives a constant current from n through the source to p, so p_i = -current.

Parameters:

Name Type Description Default
label str

The label of the element, unique among the parts of its system.

required
visual VisualSpec | None

How the element is drawn, or None for default_visual_.

None
p_v object

The potential of the positive pin.

0.0
p_i object

The current into the positive pin.

0.0
n_v object

The potential of the negative pin.

0.0
n_i object

The current into the negative pin.

0.0
current Annotated[object, ParameterSpec()]

The current the source drives out of its positive pin.

1.0

Examples:

>>> from skcomplex.systems.engineering.common.electrical import CurrentSourceElement
>>> CurrentSourceElement('source', current=0.5).current
0.5
Source code in src/skcomplex/systems/engineering/common/electrical/_components.py
362
363
364
365
366
367
368
369
370
371
372
373
374
def __init__(
    self,
    label: str,
    visual: VisualSpec | None = None,
    *,
    p_v: object = 0.0,
    p_i: object = 0.0,
    n_v: object = 0.0,
    n_i: object = 0.0,
    current: Annotated[object, ParameterSpec()] = 1.0,
) -> None:
    super().__init__(label, visual, p_v=p_v, p_i=p_i, n_v=n_v, n_i=n_i)
    self.current = current

DiodeElement(label, visual=None, *, p_v=0.0, p_i=0.0, n_v=0.0, n_i=0.0, Is=1e-06, Vt=0.025)

Bases: TwoPinElement

Exponential diode, with p_i = Is (exp((p_v - n_v) / Vt) - 1).

Parameters:

Name Type Description Default
label str

The label of the element, unique among the parts of its system.

required
visual VisualSpec | None

How the element is drawn, or None for default_visual_.

None
p_v object

The potential of the positive pin.

0.0
p_i object

The current into the positive pin.

0.0
n_v object

The potential of the negative pin.

0.0
n_i object

The current into the negative pin.

0.0
Is Annotated[object, ParameterSpec(domain=POSITIVE)]

The saturation current.

1e-06
Vt Annotated[object, ParameterSpec(domain=POSITIVE)]

The thermal voltage.

0.025

Examples:

>>> from skcomplex.systems.engineering.common.electrical import DiodeElement
>>> DiodeElement('diode').Vt
0.025
Source code in src/skcomplex/systems/engineering/common/electrical/_components.py
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
def __init__(
    self,
    label: str,
    visual: VisualSpec | None = None,
    *,
    p_v: object = 0.0,
    p_i: object = 0.0,
    n_v: object = 0.0,
    n_i: object = 0.0,
    Is: Annotated[object, ParameterSpec(domain=POSITIVE)] = 1e-6,
    Vt: Annotated[object, ParameterSpec(domain=POSITIVE)] = 0.025,
) -> None:
    super().__init__(label, visual, p_v=p_v, p_i=p_i, n_v=n_v, n_i=n_i)
    self.Is = Is
    self.Vt = Vt

GroundElement(label, visual=None, *, p_v=0.0, p_i=0.0)

Bases: Element

Reference of the potentials of a circuit, whose one pin has zero potential.

Parameters:

Name Type Description Default
label str

The label of the element, unique among the parts of its system.

required
visual VisualSpec | None

How the element is drawn, or None for default_visual_.

None
p_v Annotated[object, StateSpec(algebraic=True)]

The potential of the pin.

0.0
p_i Annotated[object, StateSpec(algebraic=True)]

The current into the pin.

0.0

Examples:

>>> from skcomplex.systems.engineering.common.electrical import GroundElement
>>> sorted(GroundElement.ports)
['p']
Source code in src/skcomplex/systems/engineering/common/electrical/_components.py
414
415
416
417
418
419
420
421
422
423
424
def __init__(
    self,
    label: str,
    visual: VisualSpec | None = None,
    *,
    p_v: Annotated[object, StateSpec(algebraic=True)] = 0.0,
    p_i: Annotated[object, StateSpec(algebraic=True)] = 0.0,
) -> None:
    super().__init__(label, visual=visual)
    self.p_v = p_v
    self.p_i = p_i

InductorElement(label, visual=None, *, p_v=0.0, p_i=0.0, n_v=0.0, n_i=0.0, i=0.0, L=1.0)

Bases: TwoPinElement

Inductor of current i, with L i' = p_v - n_v and i = p_i.

Parameters:

Name Type Description Default
label str

The label of the element, unique among the parts of its system.

required
visual VisualSpec | None

How the element is drawn, or None for default_visual_.

None
p_v object

The potential of the positive pin.

0.0
p_i object

The current into the positive pin.

0.0
n_v object

The potential of the negative pin.

0.0
n_i object

The current into the negative pin.

0.0
i Annotated[object, StateSpec()]

The initial current.

0.0
L Annotated[object, ParameterSpec(domain=POSITIVE)]

The inductance.

1.0

Examples:

>>> from skcomplex.systems.engineering.common.electrical import InductorElement
>>> InductorElement('coil', L=0.5).L
0.5
Source code in src/skcomplex/systems/engineering/common/electrical/_components.py
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
def __init__(
    self,
    label: str,
    visual: VisualSpec | None = None,
    *,
    p_v: object = 0.0,
    p_i: object = 0.0,
    n_v: object = 0.0,
    n_i: object = 0.0,
    i: Annotated[object, StateSpec()] = 0.0,
    L: Annotated[object, ParameterSpec(domain=POSITIVE)] = 1.0,
) -> None:
    super().__init__(label, visual, p_v=p_v, p_i=p_i, n_v=n_v, n_i=n_i)
    self.i = i
    self.L = L

OperationalAmplifierElement(label, visual=None, *, p_v=0.0, p_i=0.0, n_v=0.0, n_i=0.0, out_v=0.0, out_i=0.0)

Bases: Element

Ideal operational amplifier, whose inputs draw no current and whose output holds them at equal potentials.

The output current returns through the supply of the amplifier, so no equation balances it.

Parameters:

Name Type Description Default
label str

The label of the element, unique among the parts of its system.

required
visual VisualSpec | None

How the element is drawn, or None for default_visual_.

None
p_v Annotated[object, StateSpec(algebraic=True)]

The potential of the noninverting input.

0.0
p_i Annotated[object, StateSpec(algebraic=True)]

The current into the noninverting input.

0.0
n_v Annotated[object, StateSpec(algebraic=True)]

The potential of the inverting input.

0.0
n_i Annotated[object, StateSpec(algebraic=True)]

The current into the inverting input.

0.0
out_v Annotated[object, StateSpec(algebraic=True)]

The potential of the output.

0.0
out_i Annotated[object, StateSpec(algebraic=True)]

The current into the output.

0.0

Examples:

>>> from skcomplex.systems.engineering.common.electrical import OperationalAmplifierElement
>>> sorted(OperationalAmplifierElement.ports)
['n', 'out', 'p']
Source code in src/skcomplex/systems/engineering/common/electrical/_components.py
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
def __init__(
    self,
    label: str,
    visual: VisualSpec | None = None,
    *,
    p_v: Annotated[object, StateSpec(algebraic=True)] = 0.0,
    p_i: Annotated[object, StateSpec(algebraic=True)] = 0.0,
    n_v: Annotated[object, StateSpec(algebraic=True)] = 0.0,
    n_i: Annotated[object, StateSpec(algebraic=True)] = 0.0,
    out_v: Annotated[object, StateSpec(algebraic=True)] = 0.0,
    out_i: Annotated[object, StateSpec(algebraic=True)] = 0.0,
) -> None:
    super().__init__(label, visual=visual)
    self.p_v = p_v
    self.p_i = p_i
    self.n_v = n_v
    self.n_i = n_i
    self.out_v = out_v
    self.out_i = out_i

ResistorElement(label, visual=None, *, p_v=0.0, p_i=0.0, n_v=0.0, n_i=0.0, R=1.0)

Bases: TwoPinElement

Resistor that obeys Ohm's law, p_v - n_v = R p_i.

Parameters:

Name Type Description Default
label str

The label of the element, unique among the parts of its system.

required
visual VisualSpec | None

How the element is drawn, or None for default_visual_.

None
p_v object

The potential of the positive pin.

0.0
p_i object

The current into the positive pin.

0.0
n_v object

The potential of the negative pin.

0.0
n_i object

The current into the negative pin.

0.0
R Annotated[object, ParameterSpec(domain=POSITIVE)]

The resistance.

1.0

Examples:

>>> from skcomplex.systems.engineering.common.electrical import ResistorElement
>>> ResistorElement('load', R=2.0).R
2.0
Source code in src/skcomplex/systems/engineering/common/electrical/_components.py
116
117
118
119
120
121
122
123
124
125
126
127
128
def __init__(
    self,
    label: str,
    visual: VisualSpec | None = None,
    *,
    p_v: object = 0.0,
    p_i: object = 0.0,
    n_v: object = 0.0,
    n_i: object = 0.0,
    R: Annotated[object, ParameterSpec(domain=POSITIVE)] = 1.0,
) -> None:
    super().__init__(label, visual, p_v=p_v, p_i=p_i, n_v=n_v, n_i=n_i)
    self.R = R

TwoPinElement(label, visual=None, *, p_v=0.0, p_i=0.0, n_v=0.0, n_i=0.0)

Bases: Element

Component with a positive pin p and a negative pin n, whose currents balance.

A subclass returns the equations of its branch from _get_branch_laws, in the voltage p_v - n_v and the current p_i from p to n.

Parameters:

Name Type Description Default
label str

The label of the element, unique among the parts of its system.

required
visual VisualSpec | None

How the element is drawn, or None for default_visual_.

None
p_v Annotated[object, StateSpec(algebraic=True)]

The potential of the positive pin.

0.0
p_i Annotated[object, StateSpec(algebraic=True)]

The current into the positive pin.

0.0
n_v Annotated[object, StateSpec(algebraic=True)]

The potential of the negative pin.

0.0
n_i Annotated[object, StateSpec(algebraic=True)]

The current into the negative pin.

0.0
Source code in src/skcomplex/systems/engineering/common/electrical/_components.py
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
def __init__(
    self,
    label: str,
    visual: VisualSpec | None = None,
    *,
    p_v: Annotated[object, StateSpec(algebraic=True)] = 0.0,
    p_i: Annotated[object, StateSpec(algebraic=True)] = 0.0,
    n_v: Annotated[object, StateSpec(algebraic=True)] = 0.0,
    n_i: Annotated[object, StateSpec(algebraic=True)] = 0.0,
) -> None:
    super().__init__(label, visual=visual)
    self.p_v = p_v
    self.p_i = p_i
    self.n_v = n_v
    self.n_i = n_i

VoltageSourceElement(label, visual=None, *, p_v=0.0, p_i=0.0, n_v=0.0, n_i=0.0, V=1.0)

Bases: TwoPinElement

Ideal source of the constant voltage V = p_v - n_v.

Parameters:

Name Type Description Default
label str

The label of the element, unique among the parts of its system.

required
visual VisualSpec | None

How the element is drawn, or None for default_visual_.

None
p_v object

The potential of the positive pin.

0.0
p_i object

The current into the positive pin.

0.0
n_v object

The potential of the negative pin.

0.0
n_i object

The current into the negative pin.

0.0
V Annotated[object, ParameterSpec()]

The voltage.

1.0

Examples:

>>> from skcomplex.systems.engineering.common.electrical import VoltageSourceElement
>>> VoltageSourceElement('battery', V=9.0).V
9.0
Source code in src/skcomplex/systems/engineering/common/electrical/_components.py
303
304
305
306
307
308
309
310
311
312
313
314
315
def __init__(
    self,
    label: str,
    visual: VisualSpec | None = None,
    *,
    p_v: object = 0.0,
    p_i: object = 0.0,
    n_v: object = 0.0,
    n_i: object = 0.0,
    V: Annotated[object, ParameterSpec()] = 1.0,
) -> None:
    super().__init__(label, visual, p_v=p_v, p_i=p_i, n_v=n_v, n_i=n_i)
    self.V = V