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
Add voltage compliance to current source (pfalstad#241 redesign)
Adds an optional compliance voltage to CurrentElm. The redesign
addresses both pieces of @pfalstad feedback on PR pfalstad#241:
- No checkbox. Default maxVoltage = 0 means unlimited (ideal current
source); a positive value enables compliance. The dialog field is
labelled "Max Voltage (V, 0=unlimited)".
- Convergence with switches open. The original implementation
hard-stepped between "stamp ideal source" and "stamp open" once
|vd| crossed maxVoltage. Newton-Raphson then ping-ponged between
the two stamps with no fixed point, especially with high-impedance
loads (open switches, large resistors). Replaced with a smooth
tanh-shaped saturation:
i(vd) = currentValue * 0.5 * (1 - tanh((|vd| - maxVoltage)/vt))
with vt = 5% of maxVoltage. The Norton companion model stamps the
exact analytic Jacobian (di/dvd = -currentValue * 0.5 * sech^2(arg)
/ vt * sign(vd)) plus a small gmin so the matrix never goes
singular when sech^2 is near zero.
Result: the source rolls off smoothly to zero current as |vd|
approaches maxVoltage rather than slamming between full-on and
full-off, which is what was killing convergence in the test circuit
@pfalstad shared on pfalstad#241.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
0 commit comments