For this particular desk
.title Pulse
Bsource in 0 v=time^4*exp(-1000*time)
R1 in out 9kOhm
R2 out 0 1kOhm
.options TEMP = 27°C
.options TNOM = 27°C
.ic
.tran 0.001ms 20ms 0s
.end
that plot No. of Data Rows : 20008 in ngspice cli
PySpice https://github.com/FabriceSalvaire/PySpice is know to retrieve correctly plots but for this desk the plot is wrong see https://github.com/FabriceSalvaire/PySpice/issues/172
I checked for data truncation issue since the plot looks like the beginnning of the expected one.
I dumped the C array from ngspice api to check for PySpice issue.
It looks like there an issue with the API.
This is unfortunately not enough information to check for any bug.
What part of the ngspice api are you using to transfer the data to the host program?
shared ngspice simulates correctly. I have succsessfully tranferd the netlist to ngspice.dll (ngspice-32, Windows 10) and retrieved the data back to the caller. Adding a gnuplot command shows the correct output.
What the OP has shown in his 'wrong' plot is not the beginning of the plot, but is the result of a truncated input line
Bsource in 0 v=time^4 ; *exp(-1000*time)Please check if pyspice is sending the complete input line to ngspice. You may check the ngspice input parser by sending a command 'listing' and reading the response. If the line
set ngdebugis put into .spiceinit, then a debug output debug-out.txt is generated to show the input file after parsing in ngepice.
I supect '*' ...
debug-out.txt is
listing is
Just one glimpse, and it is obvious:
ngspice expects something like
-1.0000000000e+03
and it gets
-1,0000000000e+03
The difference is the dot versus the comma.
ngspice does not set locale itself, it expects settings as are obtained by using
setlocale(LC_NUMERIC, "C");
standard ngspice executable does this setting automatically (as all C coded executable without explicit locale settings), shared ngspice does not.
oh, but why we didn't encounter this issue before ? PySpice send the string
time^4*exp(-1000*time)thus something strange happen in ngspiceI got the same result for
bsource in 0 v= time ^ 4,0000000000e+00 ** ** exp ( -1,0000000000e+03 * time )very suspiciousAs a shared library ngspice adopts the locale setting of the calling program. This may have changed, or is even user depending. So it might be advisable to set the locale LC_NUMERIC to "C" directly before calling ngspice. This is what KiCAD is doing right now. One could of course think about other solutions, but this is by no means a short term activity.