I recently noticed while using Ngspice that the solution converges to a deviated value if the number of iterations per unit period for a square wave is less than 100, i.e. if I am using a square wave of time period 10 μs, and if my step size is 0.1 μ s then solution converges to a value which is less than 10% off from right value, If I increase step size to 1 μs, the value may get off by 100%. My code is :
RC_Transient Analysis *Resistance and Capacitance parameters r 1 2 1k c 2 0 1u *Input is a square wave v 1 0 pulse(-5 5 0 0 0 6us 10us) .tran 0.04us 10000us .control run plot v(2) .endc .end
Is there any optimal number of iterations per time period which might ensure error less than 5% for most of the problems? Also please tell about the order of ODE solver used by Ngspice.
My try was to plot error vs step size used in iteration : What I get is a linear plot, does that mean global error is O(h)?