Skip to content

Instantly share code, notes, and snippets.

Last active October 20, 2023 08:00
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
ltspice options for high precision simulation/data export

ltspice options for high precision simulation/data export

Uses backward Euler integration (maxord=1 option), which can be very slow.

Set maximum iteration counts: DC iteration count limit (itl1, default: 100), DC transfer curve iteration count limit (itl2, default: 50), and transient analysis time point iteration count limit (itl4, default: 10) [ltwiki].

.OPTIONS maxord=1
.OPTIONS itl1=1000
.OPTIONS itl2=1000
.OPTIONS itl4=1000

numdgt and measdgt set the number of digits in the output file. In practice, there are 16 decimal digits for the significand, and 3 for the exponent. (This roughly corresponds to double precision numbers, which store 52 bits for the significand and 11 bits for the exponent. As log2(10) ≈ 3.32 bits, a decimal representation requires at least 16 digits for the first and (strictly speaking) 4 for the latter.) In an ASCII output file, numbers will appear in the form 1.234567812345678e+001.

.OPTIONS numdgt=99
.OPTIONS measdgt=99

Set absolute voltage error tolerance (vntol, default: 1 µV) to be substantially (at least 10⨉) smaller than the smallest voltage difference you want to measure. reltol (default: 1e-3) is an additional convergence criterion. The solver is said to have converged if, for the difference between the last iteration k and the current one k+1, it holds that: |v_{k+1} - v_k| ≤ reltol * max(|v_{k+1}|, |v_k|) + vntol; a similar condition exists for the current [ngspice].

.OPTIONS vntol=1e-12
.OPTIONS reltol=1e-6

gmin is a conductance added to every PN junction to aid convergence (default: 1e-12). abstol is the absolute current error tolerance (default: 1 pA = 1e-12).

.OPTIONS gmin=1e-15
.OPTIONS abstol=1e-15

Disable downsampling ("compression") of the output waveform.

.OPTIONS plotwinsize=0

ltspice uses a variable timestep solver, which under the default settings takes timesteps that are often too big to achieve a high precision on the voltage or current axis. For example, when you want to identify the peak voltage in a waveform, it is crucial that the waveform includes a sample that is as close as possible to the timepoint of the actual peak. If the horizontal (time axis) resolution is too low, the actual maximum might be missed. Maximum timestep can be specified as the fourth argument in the transient analysis command:

.tran <tstep> <tstop> <tstart> <tmax>

Note that smaller tmax may slow down the simulation substantially. To find a good tradeoff between simulation (wall clock) time and precision. begin with a large tmax and gradually lower it until no more changes in the simulation output are observed.

Optionally, restrict output (and output filesize) by saving only certain variables:

.save V(outp) V(outn) I(RL)


[ltwiki] Retrieved 19 June 2017
[ngspice] Retrieved 19 June 2017
[KunCli1993]K.S. Kundert and I.H. Clifford, "Achieving accurate results with a circuit simulator". IEE Colloquium on SPICE: Surviving Problems in Circuit Evalution, 30 June 1993,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment