Now that Fedora has the requisite libraries, I’m trying to get ngspice working. It compiled fine, but when I try to run the first example from http://ngspice.sourceforge.net/ngspice-eeschema.html, I get the following:
push: stackp: 0 -> 1
Circuit: KiCad schematic
pop: stackp: 1 -> 0
calling getcommand run
Initial parse : [ run ]
After history substitution : [ run ]
After alias substitution : [ run ]
Returning : [ run ]
getcommand run
docommand run
After variable substitution : [ run ]
After backquote substitution : [ run ]
After globbing : [ run ]
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000
Reference value : 1.00000e+00
No. of Data Rows : 51
Warning - approaching max data size: current size = 612.805 MB, limit = 292.078 MB
I have created the .spiceinit file, and it contains:
* user provided init file
set ngbehavior=ps
set debug
Does anyone know how to increase the data size limit? Or is there perhaps something else wrong?
BTW, I also tried the example from the demo directory “demos/simulation/pspice” but it gave the same error.
When I run this circuit in stand-alone ngspice, it works without producing any warnings or errors. Interestingly, ngspice does a lot of overprinting, apparently to indicate the run-time of the job. Here is a small example of the character stream, where there are tons of backspaces as part of the overprinting:
You are receiving a lot of debug output. Don’t use set debug
in .spiceinit. This has been for developers only to hunt bugs. I never use this (because there are no more bugs ). Sometimes it may be o.k. to use set ngdebug
instead.
I took the debug line out completely. So now I just have:
$ cat .spiceinit
* user provided init file
set ngbehavior=ps
However, I still get all of the “percent complete” status printed in the lower half of the ngspice window, and KiCad still crashes if I try to select that text.
The library is apparently sending over 1 megabyte of “percent complete” status to KiCad, including tons of backspaces. I think this should be suppressed, or KiCad should be made more tolerant of all this data.
Also, it looks really bad, as you can see near the bottom of this screen shot:
Unfortunately there is no switch in ngspice to simply suppress the output. The code is supposed to send a ref value approximately every 250ms realtime. The caller (eeschema) has to handle this string. The string ends with a \r that allows to overprint the previous value in a console output. Multiple \b are strange, not yet any idea.
The memory warning stems from a different piece of code. The simple circuit should not use up 612 MB.
Could you post your eeschema file, and somebody with KiCad on another Linux help us by running the same simulation example, just to check if this is a Fedora specific issue? I am not using KiCad on Linux, so cannot act immediately.
I will do a test on Linux with your netlist and the ngspice library on Linux over the weekend.
Seems to be a Fedora ngspice problem. ngspice has been built with outdated or risky configure flags. Here the flag --enable-ndev is the problem. The ngspice manual explicitely states that this one belongs to the risky, outdated flags.
I have placed the KiCad project that shows the problem here:
I guess someone on the KiCad team will have to change the --enable-ndev flag.
If I understand correctly, your patch .option norefvalue will be in the ngspice library, so we will have to wait for that library to be updated in Fedora. Is that correct? Should I contact the Fedora maintainer of ngspice and ask that the library be updated?
This is an ngspice flag. Thus this the task of the Fedora ngspice maintainer. I have already contacted him and submitted my request.
This will be available only in the next ngspice release (no fixed date available, probably mid of 2019). If this is too late, one has to download and compile ngspice himself. The tarball of the pre-master branch is available at https://sourceforge.net/p/ngspice/ngspice/ci/pre-master/tree/, button ‘Download snapshot’, compile instructions are given in the ngspice manual, chapt. 32.
Got it. So we can probably expect the --enable-ndev flag to be removed in a few weeks, and that should fix the excessive memory use problem.
But the “ref value” suppression probably won’t be available for roughly 6 months or so, unless the Fedora maintainer is willing to apply your patch sooner.
removing the --enable-ndev is necessary for several reasons.
It will disable the strange ndev status output. It will also disable some code that has not been used for 10 years or so and may have led to other crashes in the past, and is not maintained any more. This is a must!
Whwn done so, we still have the ‘reference value’ output that is a short string sent out every 0.25 seconds or so to show the simulation status. This has been with shared ngspice since its beginning. In a short example this would mean that only a few strings are sent via printf over the ngspice interface. This has never been a problem up to now.
Setting norefvalue will disable the strange ndev status output (if --enable-ndev is still there) and also the ‘reference value’ output. But I guess that this is not really required for the current problem.
In addition there is a fresh bug report that the memory check (issuing the memory warning) has a bug. I have just tested it with Cygwin, and there it is o.k.
Is the fresh bug report about the memory check the same one I reported above, or is it a separate bug report? If it is separate, can I read about it somewhere?
I guess I misunderstood you earlier, because I thought you were saying that removing --enable-ndev would correct the “Warning - approaching max data size” message that I had reported. If that is not the case, then we still need to correct the maxdata warning.
Not sure what the error message means.
This is my first time running ngspice on linux, so maybe I forgot something. Will have another look at this tomorrow.
Does the warning at the bottom look familiar?
I simply will remove this warning from the shared ngspice library. It stems from the old times when you sat in front of the console, typing commands, and reaching the memory limit of your machine. In an automated system, in a dll this is more or less useless. The caller has to take care of watching the memory. It seems to be too complex to figure out how to always get the correct numbers under all use cases and OSs.
Ok, now it makes sense. We can tell people to ignore the memory warning, perhaps by mentioning it in the next set of release notes. And once a new ngspice library is integrated, with @holger’s change, then the memory warning will disappear.
That just leaves the ref string issue, which causes a KiCad crash if you try to select that text. While that issue would be fixed by removing the --enable-ndev flag and/or by adding the .option norefvalue flag, I wonder if we could fix it sooner, by adding some filtering in KiCad to discard the ref string.
@nickoe - do you know if KiCad could filter the text in the lower half of the simulation window? If so, we could discard the huge (megabyte+) ref string by filtering out any string containing % signs and backspaces. That should solve the crash problem.