Author Topic: Increase LTSpice speed for simple circuit  (Read 526 times)

0 Members and 1 Guest are viewing this topic.

Offline matthuszaghTopic starter

  • Frequent Contributor
  • **
  • Posts: 373
  • Country: us
Increase LTSpice speed for simple circuit
« on: February 25, 2024, 02:20:46 am »
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 parts  >:( so 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.
 

Online moffy

  • Super Contributor
  • ***
  • Posts: 1749
  • Country: au
Re: Increase LTSpice speed for simple circuit
« Reply #1 on: February 25, 2024, 03:07:07 am »
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.
 
The following users thanked this post: Ian.M, matthuszagh

Offline RoGeorge

  • Super Contributor
  • ***
  • Posts: 6204
  • Country: ro
Re: Increase LTSpice speed for simple circuit
« Reply #2 on: February 25, 2024, 03:14:06 am »
Try adding a new spice directive, and type in it:
.options method=gear
https://ltwiki.org/LTspiceHelp/LTspiceHelp/_OPTIONS_Set_simulator_options.htm
If not try .options method=trap

Also, attach the .asc file, so others can run the same simulation as you.

Offline matthuszaghTopic starter

  • Frequent Contributor
  • **
  • Posts: 373
  • Country: us
Re: Increase LTSpice speed for simple circuit
« Reply #3 on: February 25, 2024, 03:16:15 am »
Also, attach the .asc file, so others can run the same simulation as you.

My bad - I had this in mind and then forgot. Anyway, here it is.
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14488
  • Country: fr
Re: Increase LTSpice speed for simple circuit
« Reply #4 on: February 25, 2024, 04:50:23 am »
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.
 
The following users thanked this post: moffy, tooki, matthuszagh

Offline temperance

  • Frequent Contributor
  • **
  • Posts: 452
  • Country: 00
Re: Increase LTSpice speed for simple circuit
« Reply #5 on: February 25, 2024, 01:10:10 pm »
Adding high value resistor in parallel with diodes performing some switching action in a circuit can also speed up the simulation.
Some species start the day by screaming their lungs out. Something which doesn't make sense at first. But as you get older it all starts to make sense.
 
The following users thanked this post: moffy

Online moffy

  • Super Contributor
  • ***
  • Posts: 1749
  • Country: au
Re: Increase LTSpice speed for simple circuit
« Reply #6 on: February 25, 2024, 09:22:34 pm »
Yeah and as SiliconWizard mentioned, LTSpice and SPICEs don't like discontinuities, they really don't like ideal switches.
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14488
  • Country: fr
Re: Increase LTSpice speed for simple circuit
« Reply #7 on: February 25, 2024, 09:33:07 pm »
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.htm
As 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.
 

Offline matthuszaghTopic starter

  • Frequent Contributor
  • **
  • Posts: 373
  • Country: us
Re: Increase LTSpice speed for simple circuit
« Reply #8 on: February 25, 2024, 09:35:36 pm »
Yeah and as SiliconWizard mentioned, LTSpice and SPICEs don't like discontinuities, they really don't like ideal switches.

Makes 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.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12864
Re: Increase LTSpice speed for simple circuit
« Reply #9 on: February 25, 2024, 09:48:25 pm »
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.
Its 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: [Select]
.opt cshunt=0.1p
« Last Edit: February 25, 2024, 09:52:38 pm by Ian.M »
 
The following users thanked this post: moffy, tooki


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf