Hello, I noticed a bug on Ngspice-46 affecting the PULSE voltage source. I did not encounter the same behavior on previous Ngspice versions so I think it's a new bug.
For example, I'd expect V1 to generate a single pulse, because I did not set NP and I'm using "set ng-
behavior=xs".
* test pulse SPICE
V1 net1 0 PULSE(0 2 5u 5u 5u 20u 100u)
R1 net1 net2 2
C1 net2 0 1u
L1 net2 0 1u
.tran 1u 500u
.control
run
plot net1 net2
.endc
.END
Here is the log of this simulation, confirming ng-behavior is set to "xs" :
******
** ngspice-46 : Circuit level simulation program
** Compiled with KLU Direct Linear Solver
** The U. C. Berkeley CAD Group
** Copyright 1985-1994, Regents of the University of California.
** Copyright 2001-2025, The ngspice team.
** Please get your ngspice manual from https://ngspice.sourceforge.io/docs.html
** Please file your bug-reports at http://ngspice.sourceforge.net/bugrep.html
** Creation Date: Sat Jul 4 11:57:40 UTC 2026
******
Note: Compatibility modes selected: xs
Circuit: * test pulse spice
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000
Using SPARSE 1.3 as Direct Linear Solver
Initial Transient Solution
--------------------------
Node Voltage
---- -------
net1 0
net2 0
l1#branch 0
v1#branch 0
No. of Data Rows : 750
But in my case, an infinite number of pulses is generated (see attached picture bug_ngspice_np_ommit).
Afterwards, I tried to specify a number of pulses by setting NP to 2. Again, instead of having two pulses, an infinite number of pulses is generated, except the first one is skipped.
I'm using the latest Ngspice-46 release, compiled from source on Ubuntu 26.04.
Your circuit from above will not produce a single pulse.
For obtaining a single pulse:
You may change the PER parameter to 500u or larger.
You may add the NP parameter 1 (after compiling master branch, see below).
However, a large PER and "set ng-behavior=xs" are compatible only in a very limited range of phase given, as the phase (in degrees) is transformed into a time shift as
PHASE/360*PER, so phase relative to PER. With PER=500u (single pulse) a phase (NP)=-3.6 will yield a shifting of the pulse to the right by 25u.Has already been fixed by commit (ngspice git branches 'master', 'pre-master-47')
864ee815b ("Update VSRC and ISRC pulse sources Enable PW=0, improve 'incomplete' pulse specifications", 2026-04-04)