Increase LTSpice speed for simple circuit - Page 1
Forum section: electronics / projects

author: matthuszagh
author_rank: Frequent Contributor
timestamp: February 25, 2024, 02:20:46 am
content: I'm simulating an AC/DC power supply in LTSpice. I mostly use ngspice, but I'm using some Linear Technology parts and AD doesn't release spice models for a lot of their partsso I'm using ltspice for this. I'm new to ltspice so I thought I'd run a simple simulation up through the rectifier and filters. This is going extremely slow, though. I'm in the low 10s of ns/s speed range. These sorts of things have always been very fast with ngspice, so I figure I must just be using ltspice incorrectly. Am I (see screenshot)? Would someone mind pointing out my issue. This is running on a modern, fast desktop.

author: moffy
author_rank: Super Contributor
timestamp: February 25, 2024, 03:07:07 am
content: I ran your sim with the generic diodes and ran into the same slow performance when I replaced the diodes with real world diodes (MBR745) the sim was very fast, you might want to replace the generic D diodes.

author: RoGeorge
author_rank: Super Contributor
timestamp: February 25, 2024, 03:14:06 am
content: Try adding a new spice directive, and type in it:.options method=gearhttps://ltwiki.org/LTspiceHelp/LTspiceHelp/_OPTIONS_Set_simulator_options.htmIf not try.options method=trapAlso, attach the .asc file, so others can run the same simulation as you.

author: matthuszagh
author_rank: Frequent Contributor
timestamp: February 25, 2024, 03:16:15 am
content: Quote from: RoGeorge on February 25, 2024, 03:14:06 amMy bad - I had this in mind and then forgot. Anyway, here it is.

author: SiliconWizard
author_rank: Super Contributor
timestamp: February 25, 2024, 04:50:23 am
content: Use the alternate solver (in Settings/Spice). The sim runs nearly instant with this, and very slow with the "normal" solver.I always set it to "alternate" btw. So I didn't notice this was slow, and had to fiddle with options to figure out why.As moffy pointed out, the real "culprit" here is using generic diodes, which model ideal diodes (that will make very severe non-linearities that are hard on the solver). So even if using the alternate solver makes the sim very fast, I'd still recommend assigning "real" diode models. Otherwise, your sim won't be realistic anyway.

author: temperance
author_rank: Super Contributor
timestamp: February 25, 2024, 01:10:10 pm
content: Adding high value resistor in parallel with diodes performing some switching action in a circuit can also speed up the simulation.

author: moffy
author_rank: Super Contributor
timestamp: February 25, 2024, 09:22:34 pm
content: Yeah and as SiliconWizard mentioned, LTSpice and SPICEs don't like discontinuities, they really don't like ideal switches.

author: SiliconWizard
author_rank: Super Contributor
timestamp: February 25, 2024, 09:33:07 pm
content: Note that, if comparing to ngspice as the OP did, the situation is different regarding the diode models: in ngspice, I bet the OP had defined a diode model with at least some basic parameters. And then, of course, the solvers are different and they can make a big difference in how the simulation converges.If you just add a generic diode in LTSpice, and do not assign the symbol any specific model, it gets default values, which are listed in LTSpice's help:https://ltwiki.org/LTspiceHelp/LTspiceHelp/D_Diode.htmAs you can see, this will be an idealized diode. Almost never use an idealized diode in a Spice simulation unless you perfectly know why you are.

author: matthuszagh
author_rank: Frequent Contributor
timestamp: February 25, 2024, 09:35:36 pm
content: Quote from: moffy on February 25, 2024, 09:22:34 pmMakes sense - and I was aware about this with spice. My surprise here was more that the generic diode provides an ideal device. In ngspice, the generic diode is a model of what they deem to be a "typical" diode (it just uses the default model parameters). If you truly wanted an ideal diode you could do such a thing with xspice, which allows you to specify your own transfer functions and that sort of thing, or probably by defining a diode model accordingly. I've found the performance of most xspice models to be fine, but I haven't tried this specific case so I don't know how it would compare.The choice to make the generic diode ideal seems strange to me. But maybe there's something I'm not considering. Anyway, thanks to the help here my sim is now running quickly and for next time I'll know not to use the generic components.

author: Ian.M
author_rank: Super Contributor
timestamp: February 25, 2024, 09:48:25 pm
content: Quote from: SiliconWizard on February 25, 2024, 04:50:23 amIts worth noting that even 0.1pF in parallel with each offending ideal diode makes this sim run at pretty much full speed. It gives somewhere for residual current at the discontinuity to go without infinite dV/dt.A similar result can be achieved in the original sim by adding a tiny capacitance to ground to all nodes with:Code:.opt cshunt=0.1p