You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Simulator evaluates parallel branches independently, over-reporting current by 100% or more #8
circuit3d/js/simulate.js:375 states the assumption in a comment:
// Each path is an independent parallel branch — evaluate separately.
Parallel branches are not independent when they share an element. The engine enumerates every path from battery+ to battery- (findAllPaths, :173-212), then for each path sums series resistance and forward voltages and computes I = (V - sum(Vf)) / sum(R) (:380-401). Kirchhoff's current law is never applied.
Worked example. One 220R feeding two parallel LEDs from 9V:
reported: 31.8 mA through EACH LED
-> implies 63.6 mA through a resistor that can pass at most 31.8 mA at 9V
-> implies 0.891 W in a 1/4 W part
correct: 31.8 mA through the resistor, 15.9 mA per LED, 0.223 W
The error scales with branch count: eight LEDs behind one resistor reports 254 mA total. The wrong number is formatted identically to a right one, so a learner has no way to detect it.
Should be
This needs a solver, not a patch. Two candidates, and this issue exists to record the decision:
A. SPICE in WebAssembly. ngspice compiled to WASM (release 47, 2026-08-11). Existing browser builds: tscircuit/ngspice, eelab-dev/EEcircuit, ngspiceX. Gives real DC operating point, transient and AC analysis, and real device models including a proper Shockley diode. Cost: a WASM payload and less control over error messages.
B. Modified Nodal Analysis in JavaScript. Roughly 400 lines: per-component stamping, matrix assembly, LU with partial pivoting, Newton-Raphson for the diodes. Full control over the error messages, which matters for a teaching tool, and no bundle cost. Less capable long term.
Either way, the existing node-graph extraction is kept.simulate.js:1-340 correctly resolves breadboard connectivity, rails and wire merging into nodes. That is the hard part and it already works. The change is to stop solving and start emitting a netlist.
Blocked on a decision. Write golden-file tests against current behavior first so the fix produces a visible diff.
Found in the 2026-08-16 audit (30-agent sweep, 481 findings). Every line reference was verified against main at the time of filing.
Activity