Electric circuits
Skill ferret-physics-electric · download all skills · SKILL.md
When to use#
Lamps that surge and burn, fuses and breakers that trip, motors and generators, wiring puzzles.
The model#
A Circuit solves its elements each step (nodes by name, '0' is ground). Parts: VSource, ISource, Battery, Resistor, Lamp (inrush, burnout, T), Heater, Wire (overheat), Fuse (I²t), Breaker (thermal + magnetic), Rcd, Switch, Capacitor, Inductor, Diode, IdealTransformer, DCMachine, InductionMotor, Relay. circuit.phasor(ω) solves in the frequency domain.
Steps#
c.add(new VSource('V', 'a', '0', 230))and the loads; every node needs a path to ground.c.step(dt); sub-step fast circuits withmaxStep; callcircuit.restart()after throwing a switch.- Events:
circuit:short,circuit:blown,lamp:burnt,trip,overheat. - Motors: copy the shaft's
omegato the machine, feed itstorqueto the shaft (ferret-physics-mechanisms). - Link faults to the world:
wireFire,arcFlash(ferret-physics-links). - Commands:
circuit.add|connect|set|state|step,meter.read.
Check afterwards#
A 2.3 kW kettle on 230 V draws 10 A; kettle plus dryer trips a 16 A breaker; rectifier ripple is about I / (2 f C).
What usually goes wrong#
- NaN or huge voltages: a node with no path to ground, or a source across a short.
- A switch makes a spike: no
restart(). - A motor does not turn:
omeganot copied, orksign reversed. - Energy does not close on a resonating circuit: lower
maxStep.
Files#
reference/electric.md— Circuits with batteries, lamps, motors, generators and heaters; fuses, breakers and wires that fail; mains and three-phase.reference/api-physics-electric.md— every export of@ferret/physics-electricwith signature and doc commentreference/commands.md— 7 commands of these packages with their argumentsrecipes/machines-and-circuits.md— Six recipes: a lamp that surges and burns, a rectifier that smooths, a transformer, a wind turbine lighting a lamp through a generator, a winch that cannot run back, a flywheel that evens out a pulsing drive.recipes/flooded-cellar.md— A burst main fills a cellar faster than the sump pump can empty it; the water reaches a socket, the circuit shorts, the breaker trips, the pump stops, and the flood wins.