Apparent Kirchhoff’s law violation 2

I noticed an inconsistency in the diode current in a power factor corrector simulation I was doing and have simplified all the way down to a couple of components. The current through V1=R1=R2 (all shows as expected in red) but is not the same as D1 (unexpected in green):


  • Updated today to latest QSpice build (behaves differently, but with higher unexpected currents in the diode in a previous build)
  • Setting a low MaxTimeStep and/or reducing simulation time helps (but doesn’t completely solve)
  • Choosing a specific diode or an ideal diode seems to fix it so it seems to be related to the default diode only
  • the first post regarding this subject was due to trapezoidal ringing but this appears to be different as it doesn’t oscillate around the expected current and .options trtol=1 or .options method=Gear doesn’t seem change the plots so this explanation seems unlikely
  • perhaps it is related to the current reporting referenced right at the end of (Apparent Kirchhoff’s law violation) ?

This happens because the current in the diode is modeled in Norton equivalent instead of Thévenin. The solver solves for the voltages about the Norton and the currents in the Thévenins. Because it is useful, the GUI reports the current through Nortons via a forensic analysis of the final matrix, but, depending on the method used to get to that matrix in dealing solving for the circuit’s nonlinear elements, the current can be off when a non-physical model of a diode is used.

Any of these methods can reduce the error:

  1. Use a realistic model for a diode. Right click menu=>
    Selection Guide and pick one. This will eliminate the
  2. Demand that the solution is solved for more accurately
    by adding “.options reltol=1u”
  3. Stipulate a smaller maximum timestep by changing the
    .tran command to “.TRAN 0 20m 0 20n”


1 Like

Thank you so much for your fast reply and explanation @Engelhardt. I didn’t know about reltol and in this example it seems to fix the issue without blowing the processing time out (when compared to the smaller maximum timestep or picking a realistic diode model methods). An ideal diode model also processes fast but deciding on the best method obviously depends on the purpose of each simulation so thanks for outlining multiple methods.

Really enjoying QSpice and keep up the great work!

Hi Mike
I am new in SPICE, could you please help to understand for Tolerance as in ABSTOL, RELTOL, VLTOL, what does those tolerance means? what is it comparing to?

Maybe I need book on SPICE in general…