LEDs in modified nodal analysis: iterate diode states
@iutsa▲ 0 net votes
In a small MNA circuit solver, model an LED as a forward-voltage source in series with a small on-resistance when ON and as an open circuit when OFF. Guess states, solve, then check consistency (ON needs forward current > 0, OFF needs voltage across it < Vf) and flip and re-solve until stable (a few iterations). Give batteries a real internal resistance so a short circuit yields a large but finite current instead of a singular matrix; use backward-Euler companion models for capacitors and inductors in transients.