LTspice refuses to find spice model - Page 1
Forum section: electronics / beginners

author: implor
author_rank: Regular Contributor
timestamp: July 07, 2025, 12:09:31 pm
content: I have a spice model for the MMBT3904 npn transistor.What ever I do LTspice refuses to find it.I have used .libsearchpath/MMBT3904.lib spice directive.I have tested using all different npn generic models (and change Value field to MMBT3904).In this simulation I do have other thing using .lib for including libs in the project and it works fine.So my question is if someone can try and see if it works for you?I have struggled with this for the last 90min and it's not productive any more..(File name is now .txt, you can't upload .lib to eevblog).

author: Ian.M
author_rank: Super Contributor
timestamp: July 07, 2025, 01:03:12 pm
content: That's because that is a subcircuit model not a SPICE3 compatible transistor model.Place the model file (MMBT3904.lib)in the same folderas your simulation's .asc file and use the directive.lib MMBT3904.libon your schematic to load it.To actually use it you need a NPN transistor symbol that expects a subcircuit model not a SPICE3.model....NPN(....)model statement. You can get one by placing a NPN then Ctrl-Right_clicking it and changing the Prefix fromQCtoXand the Value toMMBT3904

author: stretchyman
author_rank: Regular Contributor
timestamp: July 07, 2025, 01:06:33 pm
content: Or...Just use the 2N(3904)J.

author: implor
author_rank: Regular Contributor
timestamp: July 07, 2025, 01:47:39 pm
content: Quote from: Ian.M on July 07, 2025, 01:03:12 pmThank you, I got it to find the transistor now. How ever it's super slowHow do you identify it's a subcircuit model and not spice3?i'm looking at the MMBT3904 and another component I could use .lib and import and they look very similar.

author: Ian.M
author_rank: Super Contributor
timestamp: July 07, 2025, 01:52:00 pm
content: Open the model file and look for a line starting.SUBCKTmodel_name!

author: implor
author_rank: Regular Contributor
timestamp: July 07, 2025, 02:00:46 pm
content: Quote from: Ian.M on July 07, 2025, 01:52:00 pmYes that make sens but the attached file I have loaded in with .libfilepath/tlv9102.libI only change Value to TLV9102 and used the OPA2 model.Is it only transistors that needs to change to Prefix X?EDIT: The OPA2 model has Prefix X as default!I really hate LTspice... And yes, It's a skill issue...Anyway, Big thanks for the help!

author: Ian.M
author_rank: Super Contributor
timestamp: July 07, 2025, 02:12:38 pm
content: See LTspice help for the .model directive to see what devices it is applicable to (mostly different types of transistors). Any IC will almost invariably be a .subckt model. A subcircuit inserts a 'block' of components into your sim, increasing its complexity, thus slowing it down. If a .model transistor model is accurate enough its preferable . . .

author: mtwieg
author_rank: Frequent Contributor
timestamp: July 07, 2025, 02:32:17 pm
content: A couple of points:1. The extension of the files is basically meaningless. It's just a part of the file name. You can put subcircuits and/or models in .txt, .lib, .butts, whatever.2. You can use .inc or .lib directives to refer to any of these files. But these two directives do have a subtle difference, explainedhere.3. All the name of all subcircuit instances must start with "X". All model instances must start with the character for that component type ("D" for diodes, "Q" for BJTs, etc).

author: Zero999
author_rank: Super Contributor
timestamp: July 07, 2025, 06:49:54 pm
content: Quote from: implor on July 07, 2025, 02:00:46 pmThis is not unique to LTSpice. It's SPICE in general.SPICE doesn't use schematics, but a net list, which like a wiring schedule which tells it what components are connected to what. Most modern SPICE implementations enable you to enter the circuit as a schematic, which is internally converted to a net list, before being processed by the SPICE engine. The net list can be seen by clicking on view, SPICE net list. This can be useful for diagnosing faults and making sub circuits which can be used as models.SPICE has a built-in BJT transistor model, which just needs a list of parameters to create a user-defined model, rather than having to enter in equations, or a circuit. The component in the net list has to begin with the letter Q, to tell the SPICE engine to use the BJT model. The model you're using doesn't use the SPICE transistor model. It is defined as a subcircuit. To use a sub circuit, the component in the net list has to begin with the letter X.When you ask LTSpice to use X for the prefix, it will add a X§ to the component start of the component name, so instead of Q1, you'll see X§Q1 on the net list, even thought it won't appear on the schematic or results. The § letter tells LTSpice to hide the prefix, to safe confusion when displaying the results, but internally the SPICE engine sees the full X§Q1.By default BJT symbols will use Q as the pre-fix, because that's what's normally used for BJT models. The op-amp symbol uses X, because op-amps are composed of a large number of components which require a sub circuit.For example, entering the following schematic, with one of the BJTs as a sub circuit and the other as a BJT model, generates the following net list.astable subckt.asc(3.28 kB - downloaded 18 times.)* C:\users\usr\Documents\SPICE\astable subckt.asc* Generated by LTspice 24.1.8 for Windows.Q1 _out b1 0 0 2N3904TX§Q2 out b2 0 MMBT3904V1 supply 0 5VR1 supply b2 100kR2 supply b1 100kR3 supply _out 1kR4 supply out 1kC1 b2 _out 10n ic=0C2 out b1 10n.model NPN NPN.model PNP PNP.lib C:\users\usr\AppData\Local\LTspice\lib\cmp\standard.bjt* Package: SOT 23** Package Pin 1: Base* Package Pin 2: Emitter* Package Pin 3: Collector*** Extraction date (week/year): 11/2024* Spicemodel includes temperature dependency************************************************************#* Please note: Diode D1, Transistor Q2 and Resistor RQ* are dedicated to improve modeling of quasi* saturation area and reverse mode operation* and do not reflect physical devices.*.SUBCKT MMBT3904 1 2 3Q1 1 2 3 MAIN 0.8878Q2 11 2 3 MAIN 0.1122RQ 1 11 140.8D1 2 1 DIODE*.MODEL MAIN NPN+ IS = 5.781E-15+ NF = 1.016+ ISE = 2.291E-15+ NE = 1.421+ BF = 192+ IKF = 0.05304+ VAF = 22.03+ NR = 1.009+ ISC = 3.177E-16+ NC = 1.094+ BR = 1.5+ IKR = 0.5298+ VAR = 100+ RB = 35+ IRB = 0.00035+ RBM = 8.7+ RE = 0.01879+ RC = 0.8705+ XTB = 1.935+ EG = 1.11+ XTI = 4.633+ CJE = 6.407E-12+ VJE = 0.681+ MJE = 0.2929+ TF = 3.55E-10+ XTF = 10+ VTF = 2+ ITF = 0.2+ PTF = 0+ CJC = 2.51E-12+ VJC = 0.4054+ MJC = 0.2622+ XCJC = 1+ TR = 1.25E-07+ CJS = 0+ VJS = 0.75+ MJS = 0.333+ FC = 0.78.MODEL DIODE D+ IS = 7.413E-11+ N = 1.5+ BV = 1000+ IBV = 0.001+ RS = 1150+ CJO = 0+ VJ = 1+ M = 0.5+ FC = 0+ TT = 0+ EG = 1.11+ XTI = 3.ENDS*.tran 10m.MODEL 2n3904T NPN(IS=4.1799f BF=215.38 VAF=79.874 IKF=.88689 ISE=4.2698f NE=1.9988 BR=4.8050 VAR=100 IKR=.54262 ISC=2.5346p NC=1.4324 NK=1.3890 RB=14.616 RC=.53092 CJE=9.4850p MJE=.33333 CJC=7.6517p MJC=.33333 TF=481.51p XTF=10 VTF=10 ITF=1 TR=124.93n Vceo=40 Icrating=600m mfg=Philips).backanno.end

author: implor
author_rank: Regular Contributor
timestamp: July 08, 2025, 06:00:17 am
content: Quote from: Zero999 on July 07, 2025, 06:49:54 pmMy problem is not how spice works but usability (rant incoming). For example the program should pe-validate (or offer it). Example if I try to add a subcircuit when it expect a spice model. If the program checks all included files/libs and creates a list of what subcircuits exist and models it could easy check and say "Hey, there is not a model with that name, however there is a subcircuit, want to use that instead?".Or if a simulation runs really slow, offer options to speed it up.I just feel that it is a area where massive innovation could be done. Just something like a Wizard to set up simulations could be a amazing improvement.And it's not a really a LTspice only problem. Ti-Tina is not much better.Anyway. Big thanks for the help!

author: Zero999
author_rank: Super Contributor
timestamp: July 08, 2025, 12:41:25 pm
content: Quote from: implor on July 08, 2025, 06:00:17 amBut how does it know the sub circuit is supposed to be a BJT, rather than any other three pin component such as a TRIAC, SCR or shunt regulator TL431, LM7805, which are modeled using a sub circuit, because SPICE doesn't have built-in models for them? Remember, when SPICE sees .subckt, it just sees a load of parts and/or mathematical formulas. It could be anything. In this case you know it's a BJT due to the part number and where you got it from, but if I gave you a random sub circuit, with the part number randomised, would you be able to tell me what it's model of?QuoteIt already does that. Tools > Settings, Hacks or SPICE tabs. The problem is, it doesn't know why the simulation is being slow. The user has to look at the circuit and models to figure that one out. Yes, it's a pain, but it's because the simulator is just an advanced calculator program. It doesn't know what the circuit is supposed to do.QuoteYes, it's a SPICE problem.It's true, the user interface could be improved, but I doubt a wizard is the answer. It would just add another layer between the user and the SPICE engine. I suspect you wouldn't have had this issue if you had to manually enter in the net list and the model into a text file and run a SPICE program from the command line, because you would immediately see it's a sub circuit, rather than the default SPICE BJT model. Don't get me wrong, that would take much longer and I'm not suggesting anyone you do that, but it illustrates my point that insulating the user from the SPICE engine has its downsides.