9
\$\begingroup\$

I have the following simple circuit set up in LTspice: LTspice screenshot

Blue is on the output of the transformer and green from the rectifier.

If I don't include a capacitor this works fine and the simulation goes quickly. If I include the capacitor however the simulation becomes incredibly slow after a few milliseconds. The image shows up until it basically stops simulating at reasonable speed. The time at which it becomes slow seems to depend on the value of the capacitor

What is going on here?

NOTE: Solved by selecting 'alternate' solver in SPICE settings

\$\endgroup\$
5
  • 2
    \$\begingroup\$ Hmmm, I've just set the Solver to "alternate" and it now works nicely. Very Strange. \$\endgroup\$ Commented Jan 31, 2013 at 17:57
  • \$\begingroup\$ SPICE doesn't know what you think is interesting about the circuit, so it tries to solve it as accurately as it can. I don't know exactly what's going on, but probably as C1 charges up you start to get some different time constants related to either the resistances of the diodes or an oscillation between the L2 coil and either C1 or one of the diode capacitances. This forces the transient simulator to take much smaller steps and slows down the simulation. Somehow the "alternate" solver knows a way around this, but I can't say how it knows. \$\endgroup\$
    – The Photon
    Commented Jan 31, 2013 at 19:18
  • \$\begingroup\$ I'm simulating a bridge rectifier and running into the same problem. \$\endgroup\$
    – Navin
    Commented Jan 8, 2015 at 16:15
  • \$\begingroup\$ Did you try 'alternate' as the solver? \$\endgroup\$ Commented Jan 9, 2015 at 13:32
  • \$\begingroup\$ How in the world does this simulation run without a path to ground in the primary? Unless you added/deleted it later... \$\endgroup\$ Commented Sep 21, 2016 at 12:11

2 Answers 2

10
\$\begingroup\$

The solver is essentially solving a system of differential equations, and there are various algorithms for doing this, some which work better that others depending on the conditions ("stiffness" of the equation - if you know e.g. Matlab/Scilab/Octave see the various ODE solvers there for different conditions)

Depending on the circuit, the solver may have a hard time coverging, and as the Photon says shortens the time scale until it basically just slows down and stops (sometimes if you leave it long enough it will complete the "difficult" part, but often not).
This often happens when ideal capacitive/inductive elements are present, so it's always a good idea to select a series resistance for an inductor (actually defaults to 1m) and also an ESR for a capacitor. Right click on the component to set these and other values (as you probably know)

One other thing is your voltage source appears to be floating from circuit ground - add a high value resistor across the transformer (e.g. 100Meg) Without a DC path it makes it hard for SPICE to determine the nodes voltage.

The last thing I notice about your circuit is you have not selected a "real" diode - this may cause issues also. Right click and select a diode from the list available, I imagine this combined with setting some reasonable value ESR for the cap (and maybe a little more for the inductors) will make it work for either solver.

The circuit below works fine with either solver (cap has 1m ESR):

Circuit Example

Simulation:

Simulation

\$\endgroup\$
1
  • \$\begingroup\$ +1 for the resistor over transformer trick, sometimes the only thing to keep spice from ever decreasing timesteps (and eventually even stopping) \$\endgroup\$
    – PlasmaHH
    Commented Oct 22, 2014 at 15:05
1
\$\begingroup\$

Simulators in general have a hard time with infinite current spikes from ideal transformers. Computers also do not like to have conditions where the result is divide by zero and results in scripted error recovery mechanisms which may explain some latency in normal simulation.

If you dont know for sure, Guess, and include some realistic Rs values to ideal parts such as Caps, Diodes and transformers unless you are using valid realisitic models.

I know my son-in-law ( PhD EE Prof at U of T) does not like to use simulators that require these tricks unless they tell you specifically to include Rs in ideal parts. I disagree, if you explain when divide by zero can occur from Rs=0 in simulation, then explain that adding realisitic Rs is a good thing to learn and use. ( To me knowing the ESR, ESL and stray capcitance of every critical part is the essence of a good Designer.)

\$\endgroup\$

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.