Can't get .op (operating point analysis) to work


#1

Sorry, total KiCad n00b here. I was asked to help transfer my SPICE knowledge to KiCad and maybe help write a tutorial in the future. Anyway, I’m trying to start simple and get the basic operating point analysis to run in KiCad/ngspice, since I believe that’s the best way to get SPICE beginners off the ground (pun intended). I’ve updated to ngspice-30, added pspice compatibility (set ngbehavior=ps), and enabled the debug output (set ngdebug). This is what the simulator debug window spits out after running my simulation:

? finished after 2682.03 seconds.
max line length 34, max subst. per line 0, number of lines 15
test temperature 0.000000
Circuit: KiCad schematic
? finished after 2682.03 seconds.
? finished after 2682.03 seconds.
? finished after 2682.03 seconds.
? finished after 2682.03 seconds.
? finished after 2682.03 seconds.
? finished after 2682.03 seconds.
? finished after 2682.03 seconds.
? finished after 2682.03 seconds.
? finished after 2682.03 seconds.
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000
? finished after 2682.03 seconds.
? finished after 2682.03 seconds.
 Reference value :  0.00000e+000
No. of Data Rows : 1
Background thread stopped with timeout = 0
Error: no such vector 2
Error: no such vector 1

And below is the netlist for this simulation. It is a basic voltage divider with two 100ohm resistors and a 5V DC voltage source. If I change the analysis type to transient, I don’t get any errors and I’m able to probe nodes and look at device currents on the plot screen.

.title KiCad schematic
R2 Net-_R1-Pad2_ GND 100
V1 Net-_R1-Pad1_ GND dc 5
R1 Net-_R1-Pad1_ Net-_R1-Pad2_ 100
.save @r2[i]
.save @v1[i]
.save @r1[i]
.save V(GND)
.save V(Net-_R1-Pad1_)
.save V(Net-_R1-Pad2_)
.op
.end

Is the simple operating point analysis not supported in KiCad yet? Or am I doing something obviously wrong here? Thanks!


#2

You may reduce the error by not using the GND symbol, but use the 0 (Zero) symbol, or label your ground net with name “0”. ngspice 0 net name as a reference 0 volt (It don’t understand that GND can be use as 0 volt reference).


#3

ngspice automatically translates the GND symbol to 0.

If you don’t want that behaviour, you may set
set no_auto_gnd
to .spiceinit or spice.rc. This flag is available in ngspice-30.


#4

Please have a look at the manual http://docs.kicad-pcb.org/master/en/eeschema.html#simulator, chapt. 16.3.10. Simulation settings on simulations supported, that are

  • AC
  • DC Transfer
  • Transient

A small tutorial may be found here http://ngspice.sourceforge.net/ngspice-eeschema.html.


#5

Hum… I did not experiencing that. May be, I were using ngspice interactive console, and manipulating some pspice net list file make it a difference experience. I will had to adjust my logic about this… Thank you @holger


#6

My simulation settings window shows many more tabs (screenshot attached). I vaguely recall reading elsewhere that showing the unsupported tabs is a bug of some kind? Anyway, I find it strange that .op isn’t supported, since .op is always run during any of the other simulation types as the first step in the simulation. Doing a standalone .op would just be a subset of features that already exist. Having a standalone .op which just spits out all node voltages and device currents in the simulation log window would be very powerful. I know ngspice supports this, so I believe KiCad needs to be set up to call it properly and parse the data. Oh well, sounds like something I need to request as a feature? Can someone point me in that direction? Thanks for the help.