Ngspice OP DC analysis gotcha with unconnected caps

The SPICE and ngspice “.op” DC analysis is often described as performing an analysis treating inductors as short circuits and capacitors as open circuits. This is not only incorrect, but also may mislead the unwary user into potentially quite wrong simulation results for this seemingly simple analysis type.

Illustration of the problem

and the accompanying console output:
SimNonConverge_good_console

… all looks fine.

Now let’s suppose you have a capacitor (here C4) in the schematic that you’ve temporarily moved aside, perhaps to assess different behavior in one of the AC analyses. What does the OP DC analysis look like now?

Yikes! Why are there currents through the capacitors, and some incorrect voltages? What does the console say? Hmmm, this is what you might well see:
SimNonConverge_bad_console_01

… “something or other finished successfully.” If this wasn’t such a simple example, you might not have noticed the odd voltages and currents, and the cursory glance at the console window makes it look like all is good.

A more complete look earlier in the console window shows:
SimNonConverge_bad_console_02

… a few “warnings” (sounds not too important), and “source stepping failed”, whatever that means. But no clear “ERROR” message.

Now, the messages do actually point out that something is wrong:

a. The simulator does not treat the capacitors as open circuit. Instead, it applies some initial conditions to the circuit, and then iterates some number of times. I’m assuming it tries to iterate until variables converge to some values that change less than some threshold between iterations, or until some max number of iterations. Ie: Allows the capacitors to charge to some stable value.

b. In the pathological case, the simulator iterates to the point where it determines a problem (there’s a node that is not going to converge?) and bails out at that point. Hence “Warning: singular matrix: check node probe_int_unconnected-_c4-pad1__c4_1”, and indeed pin 1 of C4 is not connected.

c. But unhelpfully, in kicad, it goes ahead and draws voltage and current tags onto the schematic, even though these are incorrect.

You can see that iterations were arrested at an intermediate juncture, since the RC circuits with large time constants are further from their ultimate values. Not presently understood by me: why does the simulation bail out apparently before the calculatable nodes converge, which would isolate incorrect results to just the disconnected capacitor nodes?

Discussion

This is no doubt a well-known behavior of SPICE simulations and the .op analysis. However, as implemented in Kicad, it is particularly pernicious:

  1. Kicad eeschema being general purpose schematic-drawing software, we might be familiar with circuits that have not been completed, but wanting to simulate the part that is complete, and ignore other components not yet assembled or temporarily set aside. The not-connected components provoke trouble for the simulation.

  2. After performing the OP simulation, Kicad places voltage and current tags on the schematic in a confidence-inspiring manner, even if the simulation failed. So unlike running ngspice on the command line, the user’s attention is mostly on the schematic, and drawn away from any alerts of a problem.

  3. The type of failure illustrated here is rated by ngspice as a Warning rather than an Error.

  4. The console output appears in a relative small subpanel of the Spice Simulator window, and any warnings appear before the (usually quite lengthy) list of node results.

So in the face of Kicad attaching seemingly plausible tags to the schematic, the user would have to do some considerable scrolling back in the console panel to discover that these results are not legitimate.

All of this to say:

  • Be vigilant for this kind of simulation failure.

  • Bear in mind that other analyses perform a DC analysis before proceeding, so this issue pervades other simulation analyses types too.

  • It would be helpful if the Kicad ngspice window would provide a conspicuous warning light or popup message that the simulation had failed.

  • That popup could offer the choice to not label the schematic with the incompletely-iterated results, or to optionally do so anyway, in case that somehow helps diagnosis.

1 Like

This topic was automatically closed after 90 days. New replies are no longer allowed.