Ngspice exits with error message Internal Error: incomplete CKTunsetup() on netlist from KiCad schematic editor

I get the following error message in ngspice when simulating my op-amp with negative feedback audio signal amplifier circuit drawn in KiCad schematic editor, exported netlist to spice.

Did anyone encounter anything similar, and how did you get around it?

Perhaps @holger has some input?

Thanks in advance!

(By the way, it would be great if ngspice .disto and .noise could be integrated in the KiCad simulation user interface!)


** ngspice-40 : Circuit level simulation program
** The U. C. Berkeley CAD Group
** Copyright 1985-1994, Regents of the University of California.
** Copyright 2001-2023, The ngspice team.
** Please get your ngspice manual from Ngspice, the open source Spice circuit simulator - Documentation: manual and control flow
** Please file your bug-reports at Ngspice circuit simulator - Reporting Bugs
** Creation Date: Sat Apr 1 00:00:00 UTC 2023


Note: Compatibility modes selected: ps lt a

Circuit: KiCad schematic

ngspice 79 → op
Reducing trtol to 1 for xspice ‘A’ devices
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000

No. of Data Rows : 1
ngspice 80 → ac dec 10 10 100k
Reducing trtol to 1 for xspice ‘A’ devices
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000

No. of Data Rows : 41
ngspice 81 → plot vdb(Output)
Warning: Missing charsets in String to FontSet conversion
ngspice 82 → noise v(Output) v1 dec 10 10 100k
Reducing trtol to 1 for xspice ‘A’ devices
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000

Internal Error: incomplete CKTunsetup(), this will cause serious problems, please report this issue !

ERROR: fatal error in ngspice, exit(1)

KiCad version info:

Application: KiCad Schematic Editor x86_64 on x86_64

Version: 7.99.0-1.20230701gitbcfb6e4.fc37, release build

Libraries:
wxWidgets 3.2.1
FreeType 2.12.1
HarfBuzz 5.2.0
FontConfig 2.14.1
libcurl/7.85.0 OpenSSL/3.0.9 zlib/1.2.12 brotli/1.0.9 libidn2/2.3.4 libpsl/0.21.1 (+libidn2/2.3.3) libssh/0.10.5/openssl/zlib nghttp2/1.51.0

Platform: Fedora release 37 (Thirty Seven), 64 bit, Little endian, wxGTK, KDE, wayland

Build Info:
Date: Jul 1 2023 17:17:57
wxWidgets: 3.2.1 (wchar_t,wx containers) GTK+ 3.24
Boost: 1.78.0
OCC: 7.6.3
Curl: 7.85.0
ngspice: 40
Compiler: GCC 12.3.1 with C++ ABI 1017

Build settings:

It seems that the error doesn’t occur if noise is the first and only simulation you run after starting ngspice.
Still, in this case, all noise values will be zero, so there is something not working anyway. At least the circuit has resistors with thermal noise, which should exist at all times at room temperature.
If operating point or ac simulation is run, like in the example I gave above, the error occurs.

I have never encountered anything similar.

Could you post the project here (including all device libs)?

Netlist produced by KiCad:

Ohmega7253.cir (819 Bytes)

Op-amp SPICE model (from Texas Instruments):
RC4558.301 (1.2 KB)

Capacitor spice model (from Würth):
WCAP-ATG8.lib (29.7 KB)

It seems to behave the same even if I take out the capacitor model and replace it with a built in ideal capacitor (ac simulation results differ of course, but noise simulation gives the same error message).
Ohmega7253_b.cir (699 Bytes)

If you add a .control section instead of typing individual commands, the simulation runs to completion. There seems to be a bug, when typing commands manually.

I will have a look at the code.

.control
op
ac dec 10 10 100k
plot vdb(Output)
noise v(Output) v1 dec 10 10 100k
setplot ; show all plots where data are saved.
.endc

If you want to continue typing commands manually, you may add a ‘reset’ before each new simulation command (except for plotting).

1 Like

This way I don’t get the error message, and I even get some kind of data in the noise simulation.

The data seems to be all over the place, though. For example, when I have excluded R1,R2,R3, C1, C2 and instead connected R4 in the feedback loop, just for simplification, I still get between 2 to 5 volts per sqrt Hz, not some tens of _nano_volts like I expect from my hand calculations.
Also, the noise contribution from R5 (470 ohm) is somewhere couple hundred femtovolts per sqrt Hz, not a few (perhaps 3) nanovolts per sqrt Hz like I would expect.

I wonder if I am doing something fundamentally wrong, or is there something broken?
My initial guess is that the op-amp model I use is not working properly in the noise simulation, but it might well be something else…

ac simulation gives a reasonable output of about 40dB gain with -3dB rolloff at a few tens of kHz.