Pwrs() function in SPICE model gives an error

I have set ngbehavior=ps in a .spiceinit file in my user profile directory. I also put it in a file called spice.rc as was suggested in a doc I found. It still gives me an error about pwrs() not being found. This makes me suspect .spiceinit is not being read properly for some reason.

C:\>cd %USERPROFILE%
C:\Users\Dave>type .spiceinit
* user provided init file
set ngbehavior=ps
C:\Users\Dave>type spice.rc
* user provided init file
set ngbehavior=ps

Per @holger 's comment above, you need set ngbehavior=psa (note the ‘a’).

Thwarted by an ‘a’! Arrgh, I can’t believe I missed that in the reply. The ‘a’ was the solution.

In my defense, however, I had been following the instructions at: http://ngspice.sourceforge.net/ngspice-eeschema.html that say:

If you want to make use of PSPICE device models (often provided by the semicondctor companies), put a text file named .spiceinit into your user or home directory (For Windows: C:\users’your name’, found also in environmental variable USERPROFILE, for Linux: home/username directory, found also in environmental variable HOME, for macOS it is users/‘your name’). Add the two lines

* user provided init file
set ngbehavior=ps

to .spiceinit. If the file name .spiceinit does not work for you, use the alternative file name spice.rc . Then start or restart KiCad. And that’s it!

Is there any way to update the doc so that the required ‘a’ is included in those instructions? I imagine it might avoid situations like this in the future.

Thanks to everyone who helped get me to this solution. I appreciate your time and dedication.

‘ps’ is sufficient if you add the model to the symbol (Edit Symbol, Edit Spice Model).

‘psa’ is needed if you include the model in a text box in the schematic. In this case your pspice model gets dumped into the raw netlist, so the entire netlist needs to be interpreted in pspice compatibility mode. The ‘a’ applies the compatibility mode to the entire netlist. Without the ‘a’, the pspice compatibility mode is only applied to spice models that are .include'd into the netlist, which you have not done for the model in question.

Note that this is just my paraphrase of @holger’s comment above, he did all the hard work!

Thank you both: for the paraphrase, and for the hard work. I’ve learned a lot in the process.

1 Like

Don’t worry, I was just thwarted by the same “a” problem myself yesterday. And I’m supposed to be the veteran here… Epic fail.

Well, I’m definitely on the noob side of the scale. I think the last time I simulated a circuit was on a student version of MicroCap back in the 90s. 25 years later, I’ve got this crazy idea to start building tube amps for guitars. KiCAD with ngspice has been a tremendous help with that. A quick simulation of a guitar pickup coupled to my input stage gave me insights that would have taken significantly longer with swapping components on the breadboard.

Kudos and sincere appreciation to everyone who works to make these programs the top-notch tools they are.

1 Like