Simulations: PSpice, Ngspice and LTspice

I have several questions about using the ngspice simulator. Can somebody please help?

Here are some of them:

  1. How should encrypted models be used in KiCAD? Can they be deciphered by the simulator (or the plugin)?

  2. Do all PSPice models work with ngspice? What I infer from the web is that PSpice models are for the PSpice simulators while ngspice is based on Spice3.

  3. Can I take an LTSpice model from the LTSpice libraries and rename it (from .sub to .lib) and use it as a Spice model for a vendor provided component?

  4. Why does the Generate NetList dialog have a Plugin button?

  5. Again in the Generate Netlist window, there is a simulation command. How can that be used?

  6. Can I simulate in LTSpice and bring the netlist to PCBNew? That way, I can ensure fewer errors in the PCB design.

Requesting clarifications so that I can get over this job of having to find very specific Spice Models. The web is replete with PSpice models but Spice Models need more effort to search and include in the schematics.

1 Like

An answer to some of your questions (sombody else may care for the others)

  • How should encrypted models be used in KiCAD? Can they be deciphered by the simulator (or the plugin)?

Unfortunately this is not possible with ngspice.

  • Do all PSPice models work with ngspice? What I infer from the web is that PSpice models are for the PSpice simulators while ngspice is based on Spice3.

Yes. If not this would be a bug, and I would care for it. ngspice-30 has to be used and a compitibility switch set (see

  • Again in the Generate Netlist window, there is a simulation command. How can that be used?

Please see my post Multiline directives with an example how to use this button.


Spice simulation as an area seems too fragmented between several simulators each with its own limitations and several of them being limited to Windows unfortunately. Add to this, most vendors also seem good with creating PSpice models, rather than SPICE models creating even more confusion

Given those factors, thank you for the reply. At least to some extent, ngspice’s ability to be able to simulate ALL PSpice models on ngspice is a huge reprieve. Wishful thinking but can the LTSpice models also be used on NgSpice?

Or alternatively, can I simulate on LTSim and get the netlist to PcbNew? I am close to trying but any info before hand would be wonderful

Thanks again.

LTSPICE *.sub models today are encrypted binary files. ngspice cannot read them.

The SPICE circuit simulation program originated in the early 1970’s. (I believe the first PUBLIC release was in 1972 or '73.) That makes it almost half a century old! I won’t go into all the ways computing has changed over those five decades, but it’s a tribute to the program’s original authors that it remains a viable piece of software today.

Numerous commercial versions of SPICE have been developed and released (and, in some cases, abandoned) over that time span. Most of these included some kind of “improvements”, “supplements”, “additions”, or “extensions” of the original SPICE program. SPICE models that exploit such alterations may, or may not, be compatible with SPICE versions published by other companies. Fortunately, a true SPICE model file, or netlist file, is (like KiCAD’s files) human-readable. After a little study of the original SPICE syntax, most of the SPICE model files intended for a particular version of SPICE can be converted to other versions. If you can open a SPICE model file with a standard text editor (such as "Notepad++) then it can probably be used directly, or readily converted, for any SPICE-based simulator. Sometimes no conversion is necessary. I believe, for example, that LTSpice can read and process model files that use the PSPICE extensions. From the LTSpice “Help” file:

LTspice can, however, run PSpice semiconductor and behavioral models and is generally a much higher performance simulator, so you might move your PSpice simulations to LTspice.

The exceptions are the encrypted files provided by some publishers. Encryption is used to protect some perceived commercial advantage of a particular SPICE version. This might be a feature or capability added to the original SPICE program, or it might be some discovery or insight into modeling a device.In any case, encrypted files can only be used by the SPICE version they were intended for. Linear Technology, for example, publishes encrypted models for simulating their switching regulators with LTSpice. These model files are not usable with other SPICE simulators. As the LTSpice “Help” file says,

The LTspice SMPS macromodels are implemented in a combination of new proprietary native LTspice devices and/or a proprietary hardware description language. While it is possible, in principle, to develop generic SPICE or PSpice macromodels, the resultant simulation speed would not be viable.

LTSpice is deliberately insensitive to the file extensions of SPICE model files. “*.sub”, " *.lib", " *.mod", " *.mdl", " *.sp3", etc, are all equally acceptable to LTSpice. Don’t assume that an LTSpice model is encrypted just because it has the " *.sub" file extension!

LTSpice can produce netlists that are supposedly compatible with several commercial circuit simulators. You must tell LTSpice whose netlist you want to export, and the last time I looked KiCAD was NOT one of the choices.

For questions concerning LTSpice (and some questions about circuit simulation in general) the Yahoo LTSpice user’s group at LTSpice User’s Group is an excellent resource.



Even though most of these have been answered above, I’ll take a stab at all of them at once for ease of reference.

You cannot use encrypted models. I did want to mention, although I’ve never tried myself, I’ve heard from many sources that contacting certain manufacturers directly for unencrypted versions of models can result in them providing them if you sign an NDA. After all, if you’re going to buy a significant quantity, they want to provide an easier design path for you. For other situations such as TI only providing a TINA model, I have spent the time to develop my own behavioral models for certain parts that I use frequently (the THS video amplifier series in particular). Although, it’s time consuming, you do come out with the added benefit of you understanding the part’s functions more thoroughly than you would have before. This can result in better designs in the real world.

Yes, if you set the compatibility switch (set ngbehavior=ps) in the newer versions.

For basic semiconductor models, yes. You can either copy the entire files found in \LIB\CMP or copy/paste the “.model” statements within those files for parts you want to split off into your own .LIB file. Even VDMOS is now supported by ngspice, which used to previously only been supported by LTspice. For subcircuits, you can open up the *.LIB or *.SUB files in the \LIB\SUB directory for LTspice and see that many of these libraries are unencrypted. However, several of them use LT’s proprietary A-devices to construct these subcircuits. So, I don’t believe you’ll be able to easily port those (without significant redesigning) into another SPICE software that doesn’t implement the A-devices exactly like LTspice does. I don’t really understand how ngspice’s XSPICE plays into this, so someone please correct me if I’m wrong. For models which don’t use A-devices, you can try them out and see if you’re successful. I did get the LT1083.lib to work in KiCad by using it as a model for an LM7805 symbol, as shown below.

Not sure. I never noticed it until you mentioned it.

I’ve used it to launch LTspice using KiCad. It passes the netlist generated by KiCad and runs it within LTspice, using LTspice’s GUI. There’s obviously no backannotation, so you can’t probe anything and have to add in plots/traces manually. I think this is the best way for doing simple DC operating point analysis (.op command) since it’s not supported in KiCad directly.

With certain command-line parameters, you can also have it output the RAW data to a text file for analysis later. I’m using the Windows KiCad version, and it’s very picky on having spaces in your path and it doesn’t respect quotes either. I can only get it to work using DOS style paths.

I have never tried this, and I’m not equipped to answer this question well. My gut tells me that you have it backwards and you would be ensuring more errors. Netlist orders in LTspice symbols are completely shuffled around compared to KiCad symbols.

Holy grail! A million thanks

Just one question. Since KiCAD is precompiled on Ubuntu, does adding the ngbehavior=ps flag work if I add it to the .spiceinit/spice.rc file?

As an alternate, can I merely set/export it in my .profile or .bashrc?

Yes. You have to add
set ngbehavior=ps

And you will need ngspice-30.

No, that is not possible.