Menu ▾ ▴

#887 Transient stops with "Timestep too small" where several PWL sources share a corner

v1.0 (example)
open-fixed
None
5
2026-11-01
2026-10-30
No

A transient analysis stops with Timestep too small at an instant where several PWL sources have a corner at the same time. Whether it happens depends on the absolute time. Tighter tolerances and method=gear make no difference.

Version: ngspice-47+, pre-master-48 at 059066b53 (2026-10-05), built from source with the default configure options (XSPICE enabled) plus --without-x --disable-openmp --disable-debug, on macOS 26.5.2, arm64, Apple clang 21.

For example, this deck fails with "Timestep too small" (see attached pwl_corner.cir).

V0 a0 0 PWL(0 0 0.000999992 0 0.001 0 0.001000001 1)
V1 a1 0 PWL(0 0 0.000999993 0 0.001 0 0.001000001 1)
V2 a2 0 PWL(0 0 0.000999996 0 0.001 0 0.001000001 1)
V3 a3 0 PWL(0 0 0.000999997 0 0.001 0 0.001000001 1)
R0 a0 out 1k
R1 a1 out 1k
R2 a2 out 1k
R3 a3 out 1k
C1 out 0 1n
.tran 2n 0.001002 0.000999 4n
.control
run
print vecmax(time)
quit
.endc
.end

Furthermore, the attached pwl_corner_early.cir shows that this behavior is dependent on absolute time.

Writing every time on an exact binary grid doesn't avoid it, because ngspice's number parser isn't correctly rounded. The attached ROOT_CAUSE.md traces both through the code and suggests fixes.

Workaround: .option minbreak=1e-15, with the transient on a .tran line started by run (see attached pwl_corner_workaround.cir). A tran command ignores the option (this bug is reported separately).

1 Attachments

Discussion

  • Holger Vogt

    Holger Vogt - 2026-10-31

    What about simulating with
    .tran 2n 0.001002 0.000999 ; 4n
    ?

     
    • Andrew Sterian

      Andrew Sterian - 2026-11-01

      The particular deck in the original bug report does work by commenting out the tmax (4n). But I've attached another deck which fails due to the same bug, but doesn't require specifying tmax.

       
  • Holger Vogt

    Holger Vogt - 2026-11-01

    The whole issue seems to vanish when a suitable default for minbreak (e.g. 1e-15) is set.

     
  • Holger Vogt

    Holger Vogt - 2026-11-01
    • status: open --> open-fixed
    • assigned_to: Holger Vogt
     
  • Holger Vogt

    Holger Vogt - 2026-11-01

    Fixed by commit to git branch pre-master-48.

     

Log in to post a comment.