LtSpice - Inconsistent simulation of identical circuits?

Discussion in 'General Electronics Chat' started by Hypatia's Protege, Aug 29, 2016.

  1. Hypatia's Protege

    Thread Starter Distinguished Member

    Mar 1, 2015
    2,781
    1,232
    Kind friends.

    Please note that the PSU circuit represented in the attached schematic and image files is comprised of two identical circuits connected for 'complementary' (i.e. 'split polarity') output.

    My question -- As simulated: |Ek| - |Ea| = 16.887V -- when one would expect |Ek|=|Ea|:confused:
    Granted! 1/30'th of 1% isn't much -- even so, one wishes to understand 'the ways of Spice':cool:

    Perhaps component tolerance is simulated by default?:confused:

    Many advance thanks for any insight/info!:)

    Best regards
    HP:)

    PS -- Re: the attached image -- please note that although the cursors are occulting the traces -- I assure you they are there!:D

    MazPsuSim.png
     
  2. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    5,692
    901
    Interesting. For 3 runs, I got 2.281 V (0.00306%), 1.24 V, and 0.26 V differences. The latter values were -75.58909 kV and 74.589351 kV. I wonder whether the cursor value is reading pixels on my screen versus the result of a mathematical calculation? If it is actually reading the screen, I am surprised it is that good.

    Here is a snippet of the positive voltage with cursor:
    upload_2016-8-29_5-21-35.png

    And of the negative cursor (magnifications are not identical):

    upload_2016-8-29_5-24-21.png

    The fine structure of the curves are very slightly different at the maxima. Although, at the normal viewing size, they appear to be identical. At the same time, one voltage's ripple may be increasing and the other decreasing. Measurement on the ripple might not be identical.

    Do you get similar results with very high enlargements?

    John
     
    Hypatia's Protege likes this.
  3. OBW0549

    Well-Known Member

    Mar 2, 2015
    1,308
    884
    SPICE does mysterious things like this from time to time. It is also not exact. You might try fiddling with the RELTOL option a bit to see if you can improve results.

    No, it does not. SPICE only simulates component tolerances by performing multiple simulation runs, each with different component values according to your tolerance specifications, in a Monte Carlo analysis.
     
    Hypatia's Protege likes this.
  4. Aleph(0)

    Member

    Mar 14, 2015
    343
    325
    HP one thing's for sure that precision is even out of your Keysight probes league so there's no checking up on simulation:eek:!
     
  5. DGElder

    Member

    Apr 3, 2016
    344
    85
    Not identical. D1 D2 / D3 D4 are flipped.
     
    Hypatia's Protege likes this.
  6. dannyf

    Well-Known Member

    Sep 13, 2015
    1,808
    361
    But blaming spice is much easier.
     
  7. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,043
    3,807
    @Hypatia's Protege

    You are looking at a single point in time, 10 mSec after simulation startup. Let it run longer to get to see if the error shrinks. Set starting values of the components instead of letting everything start at 0V. Expecting a stable system in 10 mSec on a 50kV system doesn't happen in real life, why should it happen in a simulation?

    Spice uses Monte Carlo methods for simulation...
    https://en.wikipedia.org/wiki/Monte_Carlo_method

    You should have more precise answers after longer simulation time.
     
    Last edited: Aug 29, 2016
    Hypatia's Protege likes this.
  8. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,797
    1,103
    There's something that looks like random noise in the waveforms. Easiest to see if you add a behavioural voltage source whose output is the sum of the two waveforms.
     
    Hypatia's Protege likes this.
  9. eetech00

    Active Member

    Jun 8, 2013
    650
    112
    Use .meas statement so a consistent measurement is taken.
     
    Hypatia's Protege likes this.
  10. Bordodynov

    Active Member

    May 20, 2015
    638
    188
    Used .opt reltol=1u and solver=Alternate
    With this you greatly increase the accuracy of calculations, but lost in the account of time.

    |Ek| - |Ea|=V(ea)+V(ek)
     
    Hypatia's Protege and OBW0549 like this.
  11. MrAl

    Well-Known Member

    Jun 17, 2014
    2,433
    490
    Hello there,

    It looks like it could be a simple phase delay in the calculation due to the step size.
    For example, if we calculate two RC networks by hand for time increments of 0.1 second each, we have to do one before the other and so RC1 gets calculated at t=1.1 and is logged as a solution while RC2 still has it's value of 1.0, the old value. If it is displayed at t=1.1 the values will not be the same until RC2 is calculated if there is a calculation delay, and it is even possible that each network gets calculated at alternate sub steps, which would mean RC1 gets calculated at t=1.05 and RC2 gets calculated at t=1.10 seconds, then the results displayed for each.
    Try setting the max step size much smaller like 1e-8 and see if there is a lower error.

    It could also be the rounding method used, where they use the alternate random round method for binary values which is believed to produce lower distributed errors over a large number of calculations.
     
    Hypatia's Protege likes this.
  12. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,797
    1,103
    That does the trick. Here's what the sum looks like when max step = 1e-8 :-
    Sum.PNG
    The error is now down at the uV level after a few mS.
     
    Hypatia's Protege likes this.
  13. MrAl

    Well-Known Member

    Jun 17, 2014
    2,433
    490
    Hi,

    Oh yes, very nice :)
    I hope it didnt take too long to run with the smaller step size, that's the drawback although set within reason it gives better results simply because all the derivatives are naturally smoother, and wow, there must be a lot of derivatives in this circuit.

    I would say that it could indicate a flaw in the adaptive step algorithm they use but then again the original accuracy wasnt that bad either...we just got very picky :)
     
    Hypatia's Protege likes this.
  14. kubeek

    AAC Fanatic!

    Sep 20, 2005
    4,670
    804
    Doesn´t ltspice also simulate some noise in the components?
     
    Hypatia's Protege likes this.
  15. MrAl

    Well-Known Member

    Jun 17, 2014
    2,433
    490
    Hi,

    Probably, but dont you have to include a noise generator?
    That's the way it is another simulator i know.
     
    Hypatia's Protege likes this.
  16. OBW0549

    Well-Known Member

    Mar 2, 2015
    1,308
    884
    Apparently, LTSpice now includes built-in noise sources in its device models when doing the .noise simulation. If it does what I think it does, that's a big labor-saver and something new to me.
     
    Hypatia's Protege likes this.
  17. MrAl

    Well-Known Member

    Jun 17, 2014
    2,433
    490
    Hello again,

    Oh that's great, i guess :)

    That might mean we could try to simulate one of those chaotic oscillators. I tried one and it didnt act chaotically but i think it was because the simulator was noiseless and a real circuit always has some noise.

    I ran into a real life problem one time where the noise was very low so the design did not work because it depended on at least a small amount of noise. I had trouble convincing the designer because it looked good on paper.
     
    Hypatia's Protege likes this.
  18. KL7AJ

    AAC Fanatic!

    Nov 4, 2008
    2,040
    287
    I also discovered that LT Spice limits the Q of a simple LC tank circuit to a value of 1000. Not that there's any problem with this....other "manifestations" of SPICE will simply spit out a divide by zero error if you have infinite Q. I haven't been able to identify the limiting factor in LTspice....I presume a fixed finite resistance is incorporated into even "perfect" inductors....though this doesn't seem to show up on any of the library inductor properties.

    Eric
     
    Hypatia's Protege likes this.
  19. OBW0549

    Well-Known Member

    Mar 2, 2015
    1,308
    884
    Those noise sources would only be active during a .noise analysis, which is a special form of .ac analysis; they would not show up during a time-domain .tran analysis.

    Been there, done that. I once worked on a product in which the clock oscillator for a CPU chip was built from a couple of TTL inverter gates, a crystal resonator, a couple of resistors and a capacitor. Crude but effective; it always started up and worked perfectly.

    Until one day when we got a panicked call from Production: CPU cards were all passing their board-level tests, but when assembled into their card racks along with the voltage regulator card and RAM, ROM, ADCs, DACs, etc. they either wouldn't work at all or would mysteriously go several seconds or even minutes after power-up without working, then suddenly start oscillating, after which they worked fine.

    The engineer responsible for the CPU card pulled his hair out for several days before finally tracking down the problem: the regulator card, based on a switching regulator, was too quiet! It seems Purchasing had begun buying filter capacitors for the regulator cards from a different manufacturer, and the new capacitors had a much lower ESR than the old ones, as well as much, MUCH lower equivalent series inductance. As a result, the tiny little voltage spikes that were normally on the regulator output were now about one-tenth the amplitude they had been previously.

    And unbeknownst to the engineer, his oscillator circuit depended on those spikes to initiate oscillation. No spikes ==> dead CPU!
     
    Hypatia's Protege and atferrari like this.
  20. MrAl

    Well-Known Member

    Jun 17, 2014
    2,433
    490
    Hi again,

    Interesting story. It's funny the things that can turn up as time goes by. Time is the greatest tester of them all :)

    It's too bad then that LTS doesnt work in time domain for noise analysis, but maybe they have a separate noise source we can put into the circuit? Or maybe they allow a "rand" function in one of the function sources.
    That's what i used in the past, but not for LT Spice yet.

    LATER:
    Ok rand works but will take a little fussing with to get a decent 'noise' signal.
     
    Last edited: Aug 30, 2016
    Hypatia's Protege likes this.
Loading...