Eight patches against pre-master-47 (ngspice-47 development branch),
answering feature requests #52, #53, #84, #94, #40, #102 and #34, plus one
unrelated pre-existing bug fix found while working on #102.
Apply with:
git am --keep-cr 0001*.patch 0002*.patch 0003*.patch 0004*.patch \
0005*.patch 0006*.patch 0007*.patch 0008*.patch
--keep-cr is required: src/frontend/com_wr_ic.c and its header are CRLF in
the repository, and patch 0002 touches them. Verified: every patch applies
in sequence, the tree builds after each one, and make check passes with
the same 4 pre-existing lib-processing failures as an unmodified checkout
(see BUG-REPORT-lib-processing.md, attached separately, unrelated to this
series).
The patches are independent except 0008, which needs 0007. 0006 is
unrelated to the rest and can be taken alone (one Makefile.am hunk needs
manual context adjustment if taken without 0001-0005; noted in the patch).
Summary of each patch:
0001 (#52, #53) - .measure/meas may measure an expression, not just a
single vector: .meas tran vd max v(a)-v(b). Existing vectors still take
precedence, so old decks are unaffected.
0002 (#94, #40) - new command wrnodeset, writes the last solution as
.nodeset lines (wrnodev already did this as .ic lines). Both now work after
a finished op/dc/tran, not only a paused transient as the old warning text
claimed.
0003 (#84) - diagnostic only, not a full implementation. .dc <param> now
tells the user why a .param name cannot be swept (it is substituted
textually before the circuit is built) and points at the supported
workaround (alterparam + mc_source). A real sweep would need much
larger changes; see the patch's commit message for why a partial version
would be unsafe.
0004 (#102, part 1) - a .noise analysis no longer aborts when the input
source has no AC value; it computes output noise only (input-referred noise
is exactly 0, both densities and the integral). Also reports when a
zero-impedance voltage source shorts the noise output (correct behaviour,
commonly mistaken for a bug).
0005 (#102, part 2) - .noise i(vsrc) ... measures the noise current
through a voltage source, in addition to the existing node-voltage output.
0006 (unrelated) - fixes a pre-existing bug: every diode's integrated noise
was NaN due to uninitialized sidewall-noise-density stack entries in
DIOnoise(). Root-caused, fixed, regression test added, and cross-checked
against the closed-form value.
0007 (#34) - new .stb analysis: loop gain / stability analysis by the
double-injection method of Tian, Visvanathan, Hantgan and Kundert,
"Striving for Small-Signal Stability" (IEEE Circuits & Devices, Jan 2001).
.stb VPROBE {DEC|OCT|LIN} NP FSTART FSTOP, probe is a 0 V source inserted
into the feedback loop. Produces the complex loopgain vector plus gain
and phase margins. Validated against closed-form loop gains including a
deliberately loaded break point (where naive single-injection measurement
is wrong by 2x), a hand-built double-injection cross-check, and both probe
orientations (proven equivalent by the paper).
0008 - .measure stb ... support on loop-gain plots, e.g.
.meas stb fcross when mag(loopgain)=1.
Known limitations are documented in each patch's commit message and in
COVER-LETTER.md (attached). Draft manual text for each new feature is
included there as well, since the manual is not part of this repository.
Two issues were found during this work that are NOT fixed by this series
and are reported separately: