# @ferret/physics-electric: API

circuits of sources, wires, lamps, motors, inductors and capacitors solved each step.

48 exports. Generated from the source (`packages/physics-electric/src`), so it matches the code.

## Classes

### Base

*class* · `packages/physics-electric/src/circuit.ts:65`

```ts
abstract class Base implements Element
```

- `extra: number` — extra unknowns this element needs (ideal voltage sources and transformers)
- `k: number` — first extra index, set by the circuit
- `nonlinear: boolean`
- `kind: Element['kind']`
- `power: number` — power the element takes from the circuit now, W (negative = delivers)
- `v: number` — last voltage across it and last current through it
- `i: number`
- `constructor(readonly name: string, readonly a: string, readonly b: string)`
- `abstract stamp(s: Stamper, h: number, t: number): void` — put the element into the matrix for a step of h ending at time t
- `commit(va: number, vb: number, _h: number, _t: number, _c: Circuit): void` — after the step is accepted: voltages across a→b and the current a→b through the element
- `abstract current(va: number, vb: number, x: number[]): number` — current a → b through the element for the solution (to read it)

### Battery

*class* · `packages/physics-electric/src/circuit.ts:198`

```ts
class Battery extends Base
```

A battery: an open-circuit voltage that falls with the state of charge behind an internal resistance; Ah of capacity.

- `kind: "source"`
- `soc: number`
- `heat: number`
- `empty: boolean`
- `drawn: number`
- `constructor(name: string, a: string, b: string, public capacityAh: number, public rInt = 0.05, public vFull = 12.6, public vEmpty = 10.5, public soc0 = 1)`
- `get open()`
- `stamp(s: Stamper)` — put the element into the matrix for a step of h ending at time t
- `current(va: number, vb: number)` — current a → b through the element for the solution (to read it)
- `commit(va: number, vb: number, h: number, t: number, c: Circuit)` — after the step is accepted: voltages across a→b and the current a→b through the element

### Breaker

*class* · `packages/physics-electric/src/circuit.ts:180`

```ts
class Breaker extends Base
```

Thermal–magnetic breaker: θ' = (I²/In² − θ)/τ trips at θ = 1, and a current above `magnetic`·In trips at once.

- `theta: number`
- `tripped: boolean`
- `constructor(name: string, a: string, b: string, public rated: number, public tau = 10, public magnetic = 8, public R = 1e-3)`
- `stamp(s: Stamper)` — put the element into the matrix for a step of h ending at time t
- `current(va: number, vb: number)` — current a → b through the element for the solution (to read it)
- `reset()`
- `commit(va: number, vb: number, h: number, t: number, c: Circuit)` — after the step is accepted: voltages across a→b and the current a→b through the element
- `phasor(s: PhasorStamper)`

### Capacitor

*class* · `packages/physics-electric/src/circuit.ts:80`

```ts
class Capacitor extends Base
```

- `kind: "storage"`
- `constructor(name: string, a: string, b: string, public C: number, v0 = 0, public leak = 0)`
- `stamp(s: Stamper, h: number)` — put the element into the matrix for a step of h ending at time t
- `current(_va: number, _vb: number)` — current a → b through the element for the solution (to read it)
- `commit(va: number, vb: number, h: number, _t: number, c: Circuit)` — after the step is accepted: voltages across a→b and the current a→b through the element
- `stored()`
- `phasor(s: PhasorStamper, w: number)`

### Circuit

*class* · `packages/physics-electric/src/circuit.ts:383`

```ts
class Circuit
```

- `readonly elements: Element[]`
- `readonly byName: Map<string, Element>`
- `time: number`
- `euler: boolean` — the step in hand is a backward-Euler step
- `x: number[]` — extras and node voltages of the last solution
- `voltages: Map<string, number>`
- `events: CircuitEvent[]`
- `onEvent: ((e: CircuitEvent) => void) | null`
- `delivered: number` — cumulative energy given by the sources and taken by the elements, J
- `dissipated: number`
- `add<T extends Element>(e: T): T`
- `get<T extends Element = Element>(name: string): T`
- `transformer(name: string, p1: string, p2: string, s1: string, s2: string, spec: TransformerSpec)` — A real transformer: winding resistances, magnetising inductance and core loss around an ideal one. Returns its parts.
- `restart()` — A discontinuity (a switch thrown) is coming: take the next step with backward Euler so the trapezoid does not ring.
- `emit(type: CircuitEventType, element: string)`
- `get size()`
- `step(h: number)` — Advance h seconds.
- `balance()` — Energy bookkeeping: delivered by sources against dissipated plus stored, J.
- `voltage(node: string)`
- `phasor(w: number): Map<string, [number, number]>` — AC steady state at angular frequency w: complex node voltages (re, im) by node name.

### Coil

*class* · `packages/physics-electric/src/elements.ts:11`

```ts
class Coil extends Base
```

An electromagnet as a circuit element: a coil of N turns on a core with a pole area A and an air gap, so its inductance follows the gap,
L = L_leak + μ0 N² A / (gaps · g), and falls off as the iron saturates (B = B_sat tanh(B_lin / B_sat)). The state is the flux linkage λ, integrated
by the trapezoid rule, so moving the armature (changing `gap`) makes a motional EMF by itself: v = R i + dλ/dt. `force` is the pull on the armature,
gaps · B² A / (2 μ0), and `work` the mechanical work done on it while the gap closed.

- `kind: "storage"`
- `gap: number` — air gap per pole, m; set by whoever moves the armature
- `lambda: number` — flux linkage, Wb
- `work: number`
- `constructor( name: string, a: string, b: string, public turns: number, public area: number, gap: number, public Rw = 0, public gaps = 2, public Bsat = 1.6, public leakage = 0, )`
- `L(i = this.i): number` — the secant inductance at the present current (the unsaturated one at zero), H
- `get B()` — flux density in the gap, T
- `get force()` — pull on the armature toward the core, N
- `stamp(s: Stamper, h: number)` — put the element into the matrix for a step of h ending at time t
- `current(_va: number, _vb: number)` — current a → b through the element for the solution (to read it)
- `commit(va: number, vb: number, h: number, _t: number, c: Circuit)` — after the step is accepted: voltages across a→b and the current a→b through the element
- `stored()`

### DCMachine

*class* · `packages/physics-electric/src/circuit.ts:336`

```ts
class DCMachine extends Base
```

A DC machine: V = E + R·i + L·di/dt with E = k·ω from the shaft, and the torque on the shaft T = k·i. Run as a motor (current into
the a terminal) it drives the shaft; turned by the shaft it makes E, delivers current and loads the shaft with k·i < 0.

- `kind: "machine"`
- `omega: number` — shaft speed, rad/s, set by whoever owns the shaft (the capability, or a test)
- `field: number` — field excitation 0..1 for a wound-field machine (k scales with it)
- `electrical: number` — electrical work taken, mechanical work given (motor) or taken (generator), J
- `mechanical: number`
- `copper: number`
- `constructor(name: string, a: string, b: string, public k_: number, public Ra: number, public La = 0)`
- `get kEff()`
- `get torque()` — torque on the shaft, N·m (positive drives it)
- `stamp(s: Stamper, h: number)` — put the element into the matrix for a step of h ending at time t
- `current(_va: number, _vb: number)` — current a → b through the element for the solution (to read it)
- `commit(va: number, vb: number, h: number, _t: number, c: Circuit)` — after the step is accepted: voltages across a→b and the current a→b through the element
- `stored()`

### Diode

*class* · `packages/physics-electric/src/circuit.ts:147`

```ts
class Diode extends Base
```

A diode with a forward drop and an on-resistance (piecewise linear) or the exponential law; an LED is a diode with a larger drop.

- `nonlinear: boolean`
- `constructor(name: string, a: string, b: string, public Vf = 0.7, public Ron = 0.05, public exponential = false, public Is = 1e-12, public n = 1.8)`
- `stamp(s: Stamper)` — put the element into the matrix for a step of h ending at time t
- `current(va: number, vb: number)` — current a → b through the element for the solution (to read it)

### Fuse

*class* · `packages/physics-electric/src/circuit.ts:167`

```ts
class Fuse extends Base
```

The element melts when ∫I²dt passes its limit (A²·s).

- `integral: number`
- `blown: boolean`
- `constructor(name: string, a: string, b: string, public i2t: number, public R = 1e-3)`
- `stamp(s: Stamper)` — put the element into the matrix for a step of h ending at time t
- `current(va: number, vb: number)` — current a → b through the element for the solution (to read it)
- `commit(va: number, vb: number, h: number, t: number, c: Circuit)` — after the step is accepted: voltages across a→b and the current a→b through the element
- `phasor(s: PhasorStamper)`

### Heater

*class* · `packages/physics-electric/src/circuit.ts:269`

```ts
class Heater extends Resistor
```

A heater: a resistor whose heat is handed to a part; its resistance follows the temperature coefficient.

- `joules: number`
- `constructor(name: string, a: string, b: string, R: number, public alpha = 0, public temperature = 293.15, public T0 = 293.15)`
- `get cold()`
- `stamp(s: Stamper)` — put the element into the matrix for a step of h ending at time t
- `current(va: number, vb: number)` — current a → b through the element for the solution (to read it)
- `commit(va: number, vb: number, h: number, t: number, c: Circuit)` — after the step is accepted: voltages across a→b and the current a→b through the element

### IdealTransformer

*class* · `packages/physics-electric/src/circuit.ts:305`

```ts
class IdealTransformer extends Base
```

An ideal transformer between two ports through one extra unknown (the secondary current). V1 = n·V2 and I1 = I2/n, n = N1/N2.

- `extra: number` — extra unknowns this element needs (ideal voltage sources and transformers)
- `kind: "other"`
- `constructor(name: string, public p1: string, public p2: string, public s1: string, public s2: string, public n: number)`
- `stamp(s: Stamper)` — put the element into the matrix for a step of h ending at time t
- `current(_va: number, _vb: number, x: number[])` — current a → b through the element for the solution (to read it)
- `commit(va: number, vb: number, _h: number, _t: number, c: Circuit)` — after the step is accepted: voltages across a→b and the current a→b through the element
- `phasor(s: PhasorStamper)`

### InductionMotor

*class* · `packages/physics-electric/src/elements.ts:96`

```ts
class InductionMotor extends Base
```

A three-phase induction motor, one phase of its equivalent circuit (wye, so the phase voltage is across a→b): the stator R1 + L1 in series with the
magnetising Lm across the rest, then the rotor L2 and R2/s. The slip s comes from the shaft speed and the supply frequency, so the load resistor
R2/s follows the shaft; the air-gap power of the phases over the synchronous speed is the torque, negative above that speed (a generator).
`omega` is set by whoever owns the shaft. `install` adds the parts and the motor to a circuit.

- `kind: "machine"`
- `omega: number`
- `torque: number` — torque on the shaft, N·m (averaged over a few supply cycles)
- `mechanical: number`
- `readonly parts: { r1: Resistor; l1: Inductor; lm: Inductor; l2: Inductor; rr: Resistor }`
- `constructor( name: string, a: string, b: string, public spec: { r1: number; x1: number; xm: number; r2: number; x2: number; hz: number; poles: number; phases?: number }, )`
- `get ws()` — synchronous speed, rad/s
- `get slip()`
- `stamp(_s: Stamper)` — put the element into the matrix for a step of h ending at time t
- `current()` — current a → b through the element for the solution (to read it)
- `commit(_va: number, _vb: number, h: number, _t: number, _c: Circuit)` — after the step is accepted: voltages across a→b and the current a→b through the element
- `install(c: Circuit)`

### Inductor

*class* · `packages/physics-electric/src/circuit.ts:95`

```ts
class Inductor extends Base
```

- `kind: "storage"`
- `constructor(name: string, a: string, b: string, public L: number, public Rw = 0, i0 = 0)`
- `stamp(s: Stamper, h: number)` — put the element into the matrix for a step of h ending at time t
- `current(_va: number, _vb: number)` — current a → b through the element for the solution (to read it)
- `commit(va: number, vb: number, h: number, _t: number, c: Circuit)` — after the step is accepted: voltages across a→b and the current a→b through the element
- `stored()`
- `phasor(s: PhasorStamper, w: number)`

### ISource

*class* · `packages/physics-electric/src/circuit.ts:130`

```ts
class ISource extends Base
```

- `kind: "source"`
- `constructor(name: string, a: string, b: string, public I: number | ((t: number) => number))`
- `stamp(s: Stamper, _h: number, t: number)` — put the element into the matrix for a step of h ending at time t
- `current(_va: number, _vb: number)` — current a → b through the element for the solution (to read it)
- `commit(va: number, vb: number, _h: number, t: number)` — after the step is accepted: voltages across a→b and the current a→b through the element
- `phasor(s: PhasorStamper)`

### Lamp

*class* · `packages/physics-electric/src/circuit.ts:218`

```ts
class Lamp extends Base
```

Incandescent lamp: the filament's resistance follows its temperature, which follows the power in and the radiation out.

- `nonlinear: boolean`
- `T: number`
- `burnt: boolean`
- `constructor( name: string, a: string, b: string, /** cold resistance at T0, ohms */ public R0: number, /** heat capacity of the filament, J/K and its radiating area, m² (emissivity included) */ public C = 2e-3, public area = 6e-5, /** temperature coefficient of resistance, 1/K (tungsten ~4.5e-3 near room temperature, falling hot: R ∝ T^1.2 above) */ public alpha = 4.5e-3, public T0 = 293.15, public Tmelt = 3695, public ambient = 293.15, )`
- `resistance(T: number)`
- `stamp(s: Stamper, h: number)` — put the element into the matrix for a step of h ending at time t
- `current(va: number, vb: number)` — current a → b through the element for the solution (to read it)
- `commit(va: number, vb: number, h: number, t: number, c: Circuit)` — after the step is accepted: voltages across a→b and the current a→b through the element
- `get radiated()` — radiated power now, W

### Potentiometer

*class* · `packages/physics-electric/src/elements.ts:175`

```ts
class Potentiometer
```

A potentiometer: a track of total resistance R from a to b with the wiper at w, position 0..1 from a. Add with `addPotentiometer`.

- `constructor(readonly top: Resistor, readonly bottom: Resistor, readonly total: number, private circuit: Circuit, position: number)`
- `get position()`
- `set position(p: number)`

### Rcd

*class* · `packages/physics-electric/src/elements.ts:213`

```ts
class Rcd extends Switch
```

A residual-current device (earth-leakage trip): a switch in the line that opens when the current out and the current back differ by more than
`threshold` for `delay` seconds. `sense` gives that difference, A (the circuit's own element currents: live − neutral).

- `tripped: boolean`
- `constructor(name: string, a: string, b: string, public sense: () => number, public threshold = 0.03, public delay = 0.03)`
- `reset()`
- `commit(va: number, vb: number, h: number, t: number, c: Circuit)` — after the step is accepted: voltages across a→b and the current a→b through the element

### Relay

*class* · `packages/physics-electric/src/elements.ts:63`

```ts
class Relay extends Coil
```

A relay: a coil that pulls a contact closed when its current passes `pullIn` and lets it go below `dropOut`, after the armature's travel time.
The contact is a Switch the circuit holds (`addRelay` adds both).

- `closed: boolean`
- `readonly contact: Switch`
- `constructor(name: string, a: string, b: string, ca: string, cb: string, public pullIn: number, public dropOut: number, public travel = 5e-3, coil = { turns: 2000, area: 1e-4, gap: 2e-3, Rw: 100 })`
- `commit(va: number, vb: number, h: number, t: number, c: Circuit)` — after the step is accepted: voltages across a→b and the current a→b through the element

### Resistor

*class* · `packages/physics-electric/src/circuit.ts:73`

```ts
class Resistor extends Base
```

- `constructor(name: string, a: string, b: string, public R: number)`
- `stamp(s: Stamper)` — put the element into the matrix for a step of h ending at time t
- `current(va: number, vb: number)` — current a → b through the element for the solution (to read it)
- `phasor(s: PhasorStamper)`

### SolarCell

*class* · `packages/physics-electric/src/elements.ts:193`

```ts
class SolarCell extends Base
```

A solar cell: the photocurrent Isc · irradiance / 1000 against the diode I0 (exp(V/(n Vt)) − 1), nonlinear. Wire its series resistance as a
Resistor. The cell delivers when the current through it a→b is negative.

- `nonlinear: boolean`
- `irradiance: number` — W/m²
- `constructor(name: string, a: string, b: string, public Isc = 3, public I0 = 1e-10, public n = 1.3, public cells = 1)`
- `stamp(s: Stamper)` — put the element into the matrix for a step of h ending at time t
- `current(va: number, vb: number)` — current a → b through the element for the solution (to read it)
- `get Voc()` — open-circuit voltage, V

### Switch

*class* · `packages/physics-electric/src/circuit.ts:139`

```ts
class Switch extends Base
```

- `constructor(name: string, a: string, b: string, public closed = false, public Ron = 1e-3, public Roff = 1e9)`
- `stamp(s: Stamper)` — put the element into the matrix for a step of h ending at time t
- `current(va: number, vb: number)` — current a → b through the element for the solution (to read it)
- `phasor(s: PhasorStamper)`

### Thermistor

*class* · `packages/physics-electric/src/elements.ts:157`

```ts
class Thermistor extends Base
```

A thermistor: NTC R = R0 exp(B (1/T − 1/T0)) or PTC R = R0 (1 + α (T − T0)) (`ptc` = α), with its own temperature from self-heating,
C dT/dt = P − (T − T_amb)/Rth. It is stamped at the temperature of the start of the step.

- `T: number`
- `R: number`
- `constructor(name: string, a: string, b: string, public R0: number, public B = 3950, public T0 = 298.15, public ambient = 298.15, public Rth = 50, public heatCapacity = 0.05, public ptc = 0)`
- `resistance(T: number)`
- `stamp(s: Stamper)` — put the element into the matrix for a step of h ending at time t
- `current(va: number, vb: number)` — current a → b through the element for the solution (to read it)
- `phasor(s: PhasorStamper)`
- `commit(va: number, vb: number, h: number, t: number, c: Circuit)` — after the step is accepted: voltages across a→b and the current a→b through the element

### VSource

*class* · `packages/physics-electric/src/circuit.ts:115`

```ts
class VSource extends Base
```

- `kind: "source"`
- `extra: number` — extra unknowns this element needs (ideal voltage sources and transformers)
- `constructor(name: string, a: string, b: string, public V: number | ((t: number) => number), public phasorValue: [number, number] = [0, 0])`
- `value(t: number)`
- `stamp(s: Stamper, _h: number, t: number)` — put the element into the matrix for a step of h ending at time t
- `current(_va: number, _vb: number, x: number[])` — current a → b through the element for the solution (to read it)
- `commit(va: number, vb: number, _h: number, _t: number, c: Circuit)` — after the step is accepted: voltages across a→b and the current a→b through the element
- `phasor(s: PhasorStamper)`

### Wire

*class* · `packages/physics-electric/src/circuit.ts:285`

```ts
class Wire extends Base
```

A wire: resistance from its length, a heat capacity, and a thermal resistance to the air chosen so that the ampacity gives the rated rise.

- `T: number`
- `over: boolean`
- `joules: number`
- `readonly R: number`
- `readonly Rth: number`
- `constructor( name: string, a: string, b: string, resistancePerM: number, public length: number, public ampacity: number, public heatCapacity: number, public insulation = 343.15, public ambient = 293.15, public ratedRise = 40, )`
- `stamp(s: Stamper)` — put the element into the matrix for a step of h ending at time t
- `current(va: number, vb: number)` — current a → b through the element for the solution (to read it)
- `commit(va: number, vb: number, h: number, t: number, c: Circuit)` — after the step is accepted: voltages across a→b and the current a→b through the element
- `phasor(s: PhasorStamper)`

### Zener

*class* · `packages/physics-electric/src/elements.ts:141`

```ts
class Zener extends Base
```

A Zener diode: forward like a diode, and in reverse it holds the voltage at Vz with a slope resistance Rz.

- `nonlinear: boolean`
- `constructor(name: string, a: string, b: string, public Vz = 5.1, public Rz = 2, public Vf = 0.7, public Ron = 0.05)`
- `stamp(s: Stamper)` — put the element into the matrix for a step of h ending at time t
- `current(va: number, vb: number)` — current a → b through the element for the solution (to read it)

## Functions

### addPotentiometer

*function* · `packages/physics-electric/src/elements.ts:185`

```ts
function addPotentiometer(c: Circuit, name: string, a: string, w: string, b: string, R: number, position = 0.5)
```

### addRelay

*function* · `packages/physics-electric/src/elements.ts:84`

```ts
function addRelay(c: Circuit, name: string, a: string, b: string, ca: string, cb: string, pullIn: number, dropOut: number, travel?: number)
```

Add a relay and its contact to a circuit.

### electric

*function* · `packages/physics-electric/src/index.ts:42`

```ts
function electric(): ElectricCapability
```

### gauss

*function* · `packages/physics-electric/src/circuit.ts:537`

```ts
function gauss(A: number[][], b: number[]): number[] | null
```

Gaussian elimination with partial pivoting; null when singular.

### inductionTorque

*function* · `packages/physics-electric/src/circuit.ts:367`

```ts
function inductionTorque(o: { tMax: number; slipMax: number; hz: number; poles: number; omega: number; voltage?: number }): number
```

Reduced induction motor: Kloss torque against slip at the line frequency and voltage.

### magnetForce

*function* · `packages/physics-electric/src/circuit.ts:375`

```ts
function magnetForce(N: number, I: number, area: number, gap: number, gaps = 1): number
```

Force of a magnet with a coil of N turns, current I, pole area A over an air gap g (two gaps for a C-core): B²A/(2μ0) per gap.

### mains

*function* · `packages/physics-electric/src/circuit.ts:127`

```ts
function mains: (name: string, a: string, b: string, peak: number, hz: number, phase?: number) => VSource
```

Mains: a sinusoidal source.

### phasePeak

*function* · `packages/physics-electric/src/elements.ts:236`

```ts
function phasePeak: (lineRms: number) => number
```

The phase peak of a balanced three-phase supply of a given line-to-line RMS voltage, V.

### railForce

*function* · `packages/physics-electric/src/circuit.ts:380`

```ts
function railForce: (gradient: number, I: number) => number
```

Force of a rail gun carrying I, with inductance gradient L' (H/m): ½·L'·I².

### synchronousSpeed

*function* · `packages/physics-electric/src/circuit.ts:372`

```ts
function synchronousSpeed: (hz: number, poles: number) => number
```

### threePhase

*function* · `packages/physics-electric/src/elements.ts:231`

```ts
function threePhase(c: Circuit, name: string, p: [string, string, string], peak: number, hz: number, n = '0')
```

Three-phase mains: three sources of the same peak 120° apart from the nodes `p` to a neutral `n` (default ground). The phasor form works as
for a single phase. Returns the sources.

## Interfaces

### CircuitEntry

*interface* · `packages/physics-electric/src/index.ts:29`

```ts
interface CircuitEntry
```

- `circuit: Circuit`
- `machines: MachineBinding[]`
- `induction: InductionBinding[]`
- `heaters: HeaterBinding[]`
- `shorted: boolean`

### CircuitEvent

*interface* · `packages/physics-electric/src/circuit.ts:11`

```ts
interface CircuitEvent
```

- `type: CircuitEventType`
- `element: string`
- `time: number`

### ElectricCapability

*interface* · `packages/physics-electric/src/index.ts:31`

```ts
interface ElectricCapability extends Capability
```

- `readonly circuits: Map<string, CircuitEntry>`
- `addCircuit(name: string): Circuit`
- `bindMachine(circuit: string, machine: string, drivetrain: Drivetrain, shaft: Shaft): void` — The machine turns the shaft with its torque and takes its speed from it.
- `bindInduction(circuit: string, motor: string, drivetrain: Drivetrain, shaft: Shaft): void` — An induction motor turns the shaft with its torque (negative above synchronous speed: a generator) and takes its speed from it.
- `bindHeater(circuit: string, heater: string, entity: Entity): void` — The heater's power goes into the part of the entity, and the part's temperature sets its resistance.

### Element

*interface* · `packages/physics-electric/src/circuit.ts:31`

```ts
interface Element
```

- `readonly name: string`
- `readonly a: string`
- `readonly b: string`
- `extra: number` — extra unknowns this element needs (ideal voltage sources and transformers)
- `k: number` — first extra index, set by the circuit
- `nonlinear: boolean`
- `kind: 'resistive' | 'storage' | 'source' | 'machine' | 'other'`
- `stamp(s: Stamper, h: number, t: number): void` — put the element into the matrix for a step of h ending at time t
- `commit(va: number, vb: number, h: number, t: number, c: Circuit): void` — after the step is accepted: voltages across a→b and the current a→b through the element
- `current(va: number, vb: number, x: number[]): number` — current a → b through the element for the solution (to read it)
- `stored?(): number` — energy stored, J
- `phasor?(s: PhasorStamper, w: number): void` — the phasor stamp at angular frequency w (complex admittances)
- `power: number` — power the element takes from the circuit now, W (negative = delivers)
- `v: number` — last voltage across it and last current through it
- `i: number`

### PhasorStamper

*interface* · `packages/physics-electric/src/circuit.ts:58`

```ts
interface PhasorStamper
```

- `y(a: string, b: string, re: number, im: number): void`
- `i(a: string, b: string, re: number, im: number): void`
- `v(a: string, b: string, k: number, re: number, im: number): void`
- `m(row: string, col: string, re: number, im: number): void`

### Stamper

*interface* · `packages/physics-electric/src/circuit.ts:13`

```ts
interface Stamper
```

- `g(a: string, b: string, G: number): void` — conductance between two nodes
- `i(a: string, b: string, I: number): void` — a current I leaving node a through the source into node b
- `v(a: string, b: string, k: number, V: number): void` — a voltage source V = v(a) − v(b) with its current (a → b through the source) as extra unknown number k
- `at(n: string): number` — the node voltage of the last Newton guess
- `x(k: number): number` — the extra current k of the last guess
- `m(row: string, col: string, c: number): void` — add a coefficient to the matrix (row and column are node names or '#k' for the extra unknowns)
- `rhs(row: string, c: number): void`
- `readonly be: boolean` — the step is a backward-Euler one (the first, or after a discontinuity)

### TransformerSpec

*interface* · `packages/physics-electric/src/circuit.ts:323`

```ts
interface TransformerSpec
```

- `ratio: number` — turns ratio N1/N2
- `r1?: number` — winding resistances, ohms
- `r2?: number`
- `lm?: number` — magnetising inductance seen from the primary, H, and the core-loss resistance across it, ohms (Infinity = none)
- `rcore?: number`

## Types

### CircuitEventType

*type* · `packages/physics-electric/src/circuit.ts:10`

```ts
type CircuitEventType = 'blown' | 'trip' | 'battery:empty' | 'lamp:burnt' | 'overheat' | 'short' | 'motor:stall'
```

## Constants

### ELECTRIC_DEFAULTS

*const* · `packages/physics-electric/src/index.ts:24`

```ts
const ELECTRIC_DEFAULTS: { maxStep: number; shortCurrent: number; }
```

electricity. Circuits are stepped with the world; machines turn shafts of M and are turned by them, heaters put their
power into the parts of H, and every protection element reports as an event.

values (each at world / level / zone / entity scope):
  maxStep       longest circuit sub-step, s                       (0.001)
  shortCurrent  a source current above this is a short circuit, A  (1000)

events: `circuit:blown`, `circuit:trip`, `circuit:short`, `circuit:overheat`, `battery:empty`, `lamp:burnt`, `motor:stall`, each { circuit, element }.

### GND

*const* · `packages/physics-electric/src/circuit.ts:6`

```ts
const GND: "0"
```

A circuit network solved by modified nodal analysis. Capacitors and inductors are integrated by the trapezoid rule (second order, no
numerical damping), every element that is not linear is solved by Newton iterations on the whole network, and a replay of the same
circuit with the same step is identical. Node '0' is ground.

### MU0

*const* · `packages/physics-electric/src/circuit.ts:8`

```ts
const MU0: number
```

### SIGMA

*const* · `packages/physics-electric/src/circuit.ts:7`

```ts
const SIGMA: 5.670374419e-8
```

