KiCAD Stops Simulation on First Failed Run

While running a parameter sweep, the KiCAD simulator stops at the first failed run, where standalone ngspice continues to run through all the parameters. Is this a setting I can change while using the shared library version of ngspice, or is this something going on with KiCAD?

Here is the general netlist:

.title KiCad schematic
.include
V1 Vin 0 DC 1
R2 out Vin 1000
R1 open 0 5e12
XQ1 0 out open
.NODESET v(out)=0
*.IC v(out)=0
.NODESET v(open)=0
*.IC v(open)=0
*.options rshunt=1e12
.tran 1e-6 90e-6
.control
let start_V = -10
let stop_V = 10
let delta_V = .5
let v_act = {start_V}
while v_act le stop_V
alter V1 = {v_act}
*tran 1e-6 90e-6
run
let V_ratio=v(out)/v(Vin)
let Vg=v(Vin)
set wr_singlescale
set wr_vecnames
option numdgt =7
wrdata all
set appendwrite
let v_act = {v_act + delta_V}
end
unset appendwrite
.endc
.end

What does this mean? This netlist will not run in ngspice.

What is the subcircuit ‘open’? ‘Open’ is another node name. What is the subcircuit name? Without its definition the netlist cannot be run. So it is difficult to figure out what is happening.

What is the error message when Eeschema/ngspice stops? What is the error message with standard ngspice?

I did not notice that it removed what I had in there. I have in there as I cannot share the model that I am using currently. If it would be helpful I can try to recreate the error using a different subcircuit and put that into a netlist here.

Similar to above, the at the end got removed. There are actually 3 ports on the subcircuit that are being used. open is indeed a node and not a subcircuit name.

Eeschema/ngspice fails with a gmin error (possibly something with capacitances inside the subcircuit). Standalone ngspice also gives a gmin error, but continues to run the subsequent parameter (voltage) sweep value where eventually at a certain voltage the circuit does run fine.

You probably cannot run this type of script in Eeschema/ngspice. Eeschema sends the netlist to shared ngspice and then issues its own ‘run’ command. Simulation is thus started in a second thread. In parallel your script is run in the main thread. It contains a run command which is in conflict to the already (internal) running internal ‘run’ command and so probably it is ignored. Your loop does not work.

Two (potential) solutions:

Run standard ngspice from Eeschema ‘Generate netlist’ (details depend on your KiCad version, see for example http://ngspice.sourceforge.net/ngspice-eeschema.html#external). Eeschema sends the netlist ‘as is’ to ngspice.

Try adding the command

set controlswait

to your control section. This will delay subsequent commands until the internally started simulation has finished (see http://ngspice.sourceforge.net/ngspice-eeschema.html#external2).

1 Like