I try to simulate different MOSFET's for wich a spice model is provided by the manufacturer as a .lib file containing a subcircuit. In my schematic, the subcircuit is included with a .inc <fname> statement and used by changing the Prefix of a NMOS from M to X and setting to value to the name of the subcircuit.

All of this works, however, as I want to compare different MOSFETS, I want to step through a list of different models.

I tried to use the same method as found here:

  1. Define numerical models: .model 1 ako:<FET Type>
  2. Step over the numerical models

However, this does not work. A error "Unknown subcircuit called" is returned.

Is there another way of stepping over different subcurcuits?


1 Answer 1


It's not officially supported, since LTspice flattens the schematics prior to simulation. That is, all subcircuits, hierarchies, are expanded and flattened to fit in the matrix solver, so if, for example, a second circuit that is stepped doesn't coincide element by element and node by node with the first one, then LTspice may have problems expanding the circuit "mid-flight".

A minor proof is using any stepped subcircuit and looking at the extended netlist format, in the log, after the simulation. You'll see that the expanded subcircuit is the first one, repeated over all the steps.

But that doesn't mean it's not impossible, only that, if it fails, you shouldn't complain. First, ako only works with models, which are well-defined internally, while subcircuits can have any topology. For this, rename your subcircuits with numerals, 1, 2, 101, etc, so that they can be used with a .step variable. Then you're set, but, again, don't expect miracles. Here's a quick example:


Alternatively, you can use switches and/or resistors that connect the subcircuits to the rest of the schematic, and step their values between 1m and 1g, for example, but that will make all the subcircuits count towards the matrix solver, even if they won't be used.


I realize I forgot to mention this, it's important: having different topologies in .STEPped subcircuits only works if Control Panel > Save Defaults > Save Subcircuit Node/Device Voltages/Currents are not checked (depending on the topology).

For example, relative to 1 above, 102 has two series R, which means the node count is changed, but the current is the same -- in this case, the subcircuit voltages must not be checked. If the two resistors were in parallel, then the node count would be the same but there would be two currents, so the subcircuit currents must not be checked.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.