Dietmar Warning - 2026-10-28

Thanks for the detailed report and for the patch.

Confirmed on pre-master-48. Your repro deck stops at about 112 µs without the patch and runs to the end with it, giving vhigh = 4.4115 V here, matching your number. With the real ST BD140 model (QCO = 0.214 nC) the unpatched run dies at the first switching edge; depending on the options it either aborts or completes with a several-hundred-volt artefact on a 5 V supply, which is worse than the abort.

What I checked against the patch:

DC results unchanged, the sweep output is identical byte for byte.
AC changes only at operating points with vrci <= 0, where the epi capacitance was missing altogether. At Vbe = 0.9 V, Vce = -0.2 V the base current used to be flat over frequency and now rises as it should.
ctest passes including your new test.

On the charge form: the offset you chose, Q = QCO*(K - 1 - GAMMA/2), is what both the PSpice and the Spectre manuals document, so I would keep it rather than the VBIC-style QCOK. It is also the faster of the two here: with the ST BD140 the patched run needs 257k timepoints for 4 µs against 373k for the plain QCOK form, at identical results.

Two follow-ups that came out of reviewing this, which I will handle separately:

The epi charge and the epi resistance carry no area factor in ngspice, while PSpice (areaQCO, areaIepi). A device with area=2 did not match the same device with m=2 once RCO was given.
ngspice divides by VO without a guard, so a model card carrying VO=0 cannot reach an usable operating point at all.

On the difference you left open, the plain ohmic branch for vrci <= 0. That is a model change rather than a bug fix, so it deserves its own discussion.

BTW, unrelated to this report, just for information: the ST BD139/BD140 subcircuits wrap the transistor in 1 µΩ terminal resistors, which is less than a bond wire and an order of magnitude below the 57 mΩ RB of the model itself. In a transient that starts from the quiescent state this drives the timestep into the sub-picosecond range. For a 4 µs run I get 257k timepoints, 99.9 % of them in the idle window before the first switching edge, median step 0.39 ps. Raising those resistors to 1e-5 Ω gives 432 timepoints and the same result to six digits.

A 1 µΩ resistor in a passive network is fine, and the same transistor is fine once the circuit has been excited, so it takes the combination of a BJT, a near-zero terminal resistance and a transient starting at rest. I have not chased it further.