Spice is a powerful tool for circuit analysis. But it often surprises users with
. holes in its abilities and strange definitions
. lack of industry-wide standards
. the need for the user to model the physics of their circuit, not just draw the schematic

I hope this blog will educate users and promote discussion in these areas.

Setting the Transient max time step (TMAX)

(and why it matters)

In Transient simulation, Spice calculates a length for the time interval between simulated data points. This is called the Transient "time step" and Spice varies it automatically, often by orders of magnitude during a single simulation.

In theory the time step size should relate to how fast the circuit waveforms are changing. But Spice is biased towards using large time steps to speed up simulation, and it is not sophisticated in choosing its time step size. It doesn't know where the circuit waveform is going, only where it has been.

This can cause problems in simulation, where you need to intervene.

but first let's review the

TRTOL parameter

This is a Spice tolerance that affects the size of the automatic time step Spice calculates. Spice originally defaulted to TRTOL = 7 which results in simulated sine waves looking like they are crudely built from straight lines.

A number of Spice programs, including 5Spice, now default TRTOL to 1 (in 5Spice this is the "fine" setting in Transient analysis). This gives more simulated points per cycle of a sine wave > smoother graph. However there is still some roughness.

Remember that a Transient simulation is a series of simulated data points in time. A graph joins the points with straight line segments to approximate the waveform.

Max Time Step (TMAX)

This is an optional parameter of Transient simulation.

It specifies the largest time step that Spice can use in the simulation. It is the key to solving the problems that result from Spice taking too large time steps. (Command line Spice: ignore what the original Spice user manual says about TSTEP, TSTEP is only a suggestion to Spice. set TMAX.)

Rule of thumb for Max Time Step
When you feel the simulation is giving correct data, run it again with a max time step of half the previous value. If the waveform changes, the max time step size is affecting your results. Keep halving the size until results do not change significantly.

[Note: If you do not enter a max time step value, Spice uses 1/50 of the simulation run time. This is very coarse.]

Max Time Step affects these issues

Sine waves
It takes at least ten data points per cycle to display a reasonable looking sinewave. If TRTOL=1 and/or you want a better looking sine wave, set the max time step.

Graph accuracy/interpolation
Most graphs linearly interpolate between data points. For plots with curvature, if you try to measure a precise number at an interpolated point, you may get significant error. Halve the max time step to check.

Circuits with a dominant pole or zero
Start by setting the max time step to be less than half the period of the highest dominant pole/zero frequency in the circuit’s transfer function. Think of the Nyquist limit since Spice is using sampled data.

Oscillation on waveform (default Trapezoidal integration method)
If there is an oscillation in the data that switches direction at each time step interval (numerical oscillation), try shortening the max time step by a factor of 100 or more.

If this does not solve the problem, use the Gear integration method to avoid numerical oscillation. Note that Gear has its own issues.

Switch-mode Power Supply and clock driven analog circuits
Start with setting the time step to the circuit's (clock period) /20. This is slow but probably accurate enough for many applications. You need at least two simulation points in the shorter portion of the waveform's duty cycle. More if you need accuracy in inductor currents there.

5Spice has a convergence option to optimize SMPS simulation for better speed.

Narrow Pulses
From another source: "For circuits which use short pulses, TMAX should be no more than about 50 times the shortest feature of interest."
I believe this is not an issue when the pulse is created using a source's Pulse waveform. However Spice may skip over such a pulse that is generated by the circuitry. See similar problem in Controlled Switches below.

Controlled Switches & B Source (NonLinear Source) clipping functions
Spice has a timing problem with these when the circuit's waveform is not switched synchronously with a source that uses the Pulse waveform. [Spice takes special care and uses a smaller time step when simulating near the Pulse waveform edges.]

In Spice the controlled switches and the B source (5Spice's NonLinear source) clipping functions do not notify the time step control algorithm when they are about to switch or unclamp.

If a large time step is being used, there will often be a corresponding lag in circuit response immediately after the controlled switch switches or the clipping function releases. Very noticeable and frustrating.

The brute force solution is to set the max time step to force smaller time steps at every point in the simulation.

5Spice 2.0 improvements
Controlled switches and logic gates notify Spice when they are approaching their switching threshold. Spice shortens the time step to precisely find the switching time, so there is no significant lag in switching, or skipping over. These problems are still present with the NonLinear Source clipping functions or narrow pulses created by the circuitry.


  1. > [Spice takes special care and uses a smaller time step when simulating near the Pulse waveform edges.]

    Is this really the case with standard 3f5 SPICE?

    1. Yes. It happens at the time points where the Pulse waveform changes slope.

  2. Thanks! Ngspice-24 did not have it, but newer ones do. I upgraded.