Ngspice Inconsistency?

I have a large circuit that generates pulses and I measure the pulse width using a .meas statement. Accuracy in this measurement is critical to understanding the circuit.

I am currently using:

.tran 8u 10ms 0

because the first parameter - the timestep - has a large influence on the measurement of the pulse width. For example with this tran statement:

ngspice built into KiCAD 5.1.12: pulse width = 3.277ms

External ngspice 36: pulse width = 3.250ms

That is a difference of 27us in measurements. Why is the difference not 8us in the worse case?

It seems that every time I run the simulation I get exactly the same pulse width as before, so where is the difference between the two versions of ngspice coming from? E.g. the external ngspice always has a shorter pulse width.

If I reduce the timestep to 5us then the simulation breaks. Am I reaching what is possible with ngspice?

Note that I am also using:

.options CHGTOL=1e-25

Thanks!

Without even knowing which ngspice version you are using in KiCad (depending on the OS and version) and without any test project published here it is not possible to analyze your findings. The relative pulse width deviation is less than 1% between (unknown) simulator versions. The deviation from run to run within a single ngspice version is 0.

So why not stick to a single version and then do comparisons of circuit behavior?

Hi Holger thanks for the reply. Because we are comparing the simulation to the real thing running side by side on a test bench and we want the simulation to be as accurate as possible and that 1% is significant for us.

Why do different versions of ngspice give different results? Is the latest version the most accurate?

I am using the Windows version of KiCAD 5.1.12. Where do I find the ngspice version number? I didn’t see it printed in the output.

Add

.op
.control
version
.endc

in a text box on an empty Eeschema window and run the simulation.