Author Topic: What's going on with this simulation?  (Read 1918 times)

0 Members and 3 Guests are viewing this topic.

Online SteveThackeryTopic starter

  • Super Contributor
  • ***
  • Posts: 2076
  • Country: gb
  • 50 year novice
What's going on with this simulation?
« on: May 26, 2025, 08:23:26 pm »
This is a spin-off from Chet's thread in Dodgy Technology, and I want to be clear that I absolutely do not want to go over all that stuff again; it's fine being left where it is.

My question is about circuit simulation. I have no knowledge of how circuit simulation is done, and very little experience using simulation - just the odd bit here and there, so forgive me if this is a naive question.

One of the simulations Chet points to is this one:

https://falstad.com/circuit/circuitjs.html?ctz=CQAgjCAMB0l3BWEBOWkwHYwGYeIExgAcEALBiEtpJQKYC0YYAUAMbgBsI22XjXPLqXA0YcCGPRQ2nbkWH85w4WFFoJ66e3odhgkPWQDeIFWvFRNkGTr3yDRpaZGWLkiTbCk9JxhmNCLu6uUtbaXnYKmAL2ZiEabswA7gb4+D586TT61in0aZGppNn21gBORdm+WU40quUguk5g+ES1IvjwMi1t2PY93CbK0BjwY+NwpAxtwbPJ4K2DXGDI+EvSKQN9Kqu1zMQUK2v6R+3UcCITjUiS2MwAbo0ZTyD4CFx1jXWdUL8wCPMmtsXqQwB9Acowa90qYobloZCuAVXu8NgteiYmMcTPCses8W9wZtvCjli1SWjkYTwLtqdYAM4vakE1GfAAuZQArrRmAAVVIw-R+GLCbIXCR-aDIaV8gwRdaGEW-c7gP6WaXIWW2BVQ4Fiz6idUy-m6kxA0rccVqmAa-YkGlrZkkumWurin4wUXQUjMAD2lBeFFI2AQSBu0AlEAw2AwRA4yH8+GQpCIfU64z94GETSDIbDlgghZCcETyGwyYQuDemaQTRooI42ADMAgjoDd39qhe9bBTfDECbay7dyAA

Of course I don't buy his claims for it, but nevertheless it does show some extremely odd behaviour, and I wonder if anyone can explain what is going on. It looks to me like some sort of bug, perhaps.

I urge you to take a look at it. Operate the switch briefly and then just watch it for a minute or so. The circuit appears to behave chaotically, but most interesting is that alternating currents and voltages appear and build up with no power source connected (after the brief operation of the switch).  It is really very interesting.

Chet claims that a physical manifestation of this circuit would show the same behaviour (in fact his entire thesis depends on it), but of course it wouldn't because, as simulated, energy appears to come from nowhere, which isn't possible.

So, with that made clear, does anyone know enough about the algorithms and virtual mechanics of circuit simulation to explain what is going on?
 

Online SteveThackeryTopic starter

  • Super Contributor
  • ***
  • Posts: 2076
  • Country: gb
  • 50 year novice
Re: What's going on with this simulation?
« Reply #1 on: May 26, 2025, 08:37:29 pm »
Just to add: I've edited it to remove the switch and sine wave generator. It takes longer to get going, but the end result is the same if you wait long enough.

In that configuration there is no power source, but there are two power-sapping resistors of 100 ohms and 102k, which I would think should dissipate energy and dampen the whole thing, but it's as if the simulator isn't modelling them.

EDIT: I have reduced the circuit to just the four transformers, the six capacitors, and the 100 ohm resistor (pictured). It behaves the same. Presumably the simulation models the noise in the circuit? And that appears to be what kicks it off. (I might be wrong.) I'm puzzled by the apparent amplification of this noise (if that's what is going on) and especially why the 10 ohm resistor apparently isn't damping the behaviour.
« Last Edit: May 26, 2025, 08:54:13 pm by SteveThackery »
 

Online MK14

  • Super Contributor
  • ***
  • Posts: 5376
  • Country: gb
Re: What's going on with this simulation?
« Reply #2 on: May 26, 2025, 08:49:11 pm »
Disclaimer:
There are and/or have been, people I've seen on here, more experienced and knowledgeable about electronics simulators, especially SPICE based ones, than me.

My understanding, is that they need to show convergence (mathematically), i.e. the freshly calculated (slightly in the future) iteration, needs to be closer to the solution/answer, than the previous 'timeslice/iteration'.  Then it works, reasonably stably/accurately, given all sorts of other limitations and exceptions to that fact.

But that is a result of lots of mathematical work, tuning, debugging and stuff, and is aimed primarily, when sensible/realistic/practicable circuits are constructed.

If you start 'messing' around, and giving it 'dirty' circuits, that are a bit silly in nature.  Those convergences are much less guaranteed or likely.

Hence the 'explosive' chaos you seem to be reporting.

I've given it a quick play through and seen some of the chaos.  But not spent time, analyzing it, to see why.

I suppose real world analogies, would be crashes or compile time errors, because of silliness in the source code.
Unwanted oscillations in circuits, because of poor circuit design.
Etc.
 
The following users thanked this post: splin

Online radiolistener

  • Super Contributor
  • ***
  • Posts: 5387
  • Country: Earth
Re: What's going on with this simulation?
« Reply #3 on: May 26, 2025, 08:53:47 pm »
My question is about circuit simulation. I have no knowledge of how circuit simulation is done, and very little experience using simulation - just the odd bit here and there, so forgive me if this is a naive question.

I didn't read original thread in dodgy technology, so I may didn't notice something. But from what I can see in the circuit, the simulation doesn't account for real-world losses in wires, transformers, or capacitors. As a result, once the circuit is excited by a pulse, the LC oscillations continue indefinitely without any damping. In a real circuit, however, there would always be energy losses - primarily due to resistance in wires, parasitic losses in capacitors, and core/winding losses in transformers, which would cause the oscillations to gradually decay.

Moreover, due to small numerical errors in the simulation engine, and the absence of any dissipative elements, the amplitude of oscillations may even appear to grow over time, which is of course physically incorrect.

To fix this bug, simply add resistors in series with the windings of each transformer. These will simulate the real-world energy losses and stabilize the simulation, preventing the unrealistic amplitude buildup.
« Last Edit: May 26, 2025, 09:07:21 pm by radiolistener »
 

Online SteveThackeryTopic starter

  • Super Contributor
  • ***
  • Posts: 2076
  • Country: gb
  • 50 year novice
Re: What's going on with this simulation?
« Reply #4 on: May 26, 2025, 08:56:53 pm »
What interests me, @radiolistener, is that there are two resistors in the circuit (there is still one in the reduced circuit), but still the oscillations aren't damped. That's the weird bit.
 


Online radiolistener

  • Super Contributor
  • ***
  • Posts: 5387
  • Country: Earth
Re: What's going on with this simulation?
« Reply #6 on: May 26, 2025, 09:08:19 pm »
What interests me, @radiolistener, is that there are two resistors in the circuit (there is still one in the reduced circuit), but still the oscillations aren't damped. That's the weird bit.

Most circuit simulators operate using discrete time steps, and depending on the integration method and step size, certain circuit topologies - particularly high-Q LC networks without losses can exhibit numerical artifacts. Even if a resistive load is present at the end of the LC chain, if there are no losses within the intermediate stages, and the simulation step size isn't well-suited to the circuit dynamics, unrealistic behaviors such as sustained or growing oscillations can occur due to approximations and caclulation errors which is multiplied on LC circuits.

This is pretty common issue with simulators.

Another possible cause of such oscillatory behavior may lie in the limited numerical precision used to represent signal values during simulation. In lossless LC circuits, voltage and current amplitudes can grow significantly under certain conditions. If these values approach or exceed the numerical limits of the simulator's internal data types, overflow or rounding errors can occur. This, in turn, may result in artificial self-oscillations driven by numerical instability rather than actual circuit dynamics. From what I can see at a glance, this may well be the case here, although I haven’t analyzed the simulation in detail.

A similar form of oscillation can be reproduced in C code using just two variables, where you repeatedly add and subtract their values from each other in a loop. This kind of construct effectively demonstrates how numerical feedback without damping can lead to sustained or even unstable oscillations, purely as an artifact of the algorithm/data type, rather than any physical process.
« Last Edit: May 26, 2025, 09:23:01 pm by radiolistener »
 
The following users thanked this post: Someone

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 8108
  • Country: fi
    • My home page and email address
Re: What's going on with this simulation?
« Reply #7 on: May 27, 2025, 05:48:24 am »
I thought I explained it a week ago in that thread already: too-large time steps, and not enough numerical precision.

Plus, most electrical simulations do not actually verify that the total energy is conserved in an isolated system.  What is the charge stored in the 10-farad capacitors at the beginning of the simulation?  What is the magnetic field in the transformers at the start of the simulation?

One of my very first self-made simulators simulated Morse copper, i.e. using pairwise Morse potential with constants \$D_e\$, \$a\$, and \$r_0\$ chosen to roughly match real-world copper.  I had a few thousand atoms in a face-centered cubic lattice, modeling solid monocrystalline Morse copper, and a similar number of atoms in random positions but no pair closer than the lattice constant, in a periodic box (infinitely repeated in all directions).  My problem was that I actually placed the second block one lattice constant too close to the solid block, so that in the planar interface, there were atoms extremely close to each other.  After some twenty thousand time steps, it "stabilized", with acoustic vibrations where the entire system vibrated with wavelength about a dozen times longer than the diagonal of the simulated volume.  The initial energy was just so ridiculously high, the simulation became utterly unrealistic.  (I much later found out that after a hundred thousand to a million more time steps, the entire system liquefies as one would expect; the Morse copper will eventually melt.  It's just that to maintain total energy, those initial time steps have to be tiny, in the attosecond class; and the melting only takes on the order of picoseconds.)

Funnily enough, if you use a much too large time step, you get much more believable results initially (with that utterly unrealistic start condition).  It's only if you check the total energy, you see it jumping around randomly, a tell-tale sign that such an isolated constant-volume ("microcanonical ensemble") simulation has gone wrong.

SteveThackery's question is, how to determine exactly how the simulation goes wrong.

That is a difficult question, similar to when someone shows you the original question and the result they got, but not their work, and asks you where they went wrong.  If we knew the exact working, step-by-step, it would be just a matter of walking through it step by step, and seeing where the error is.  Here, the Falstad simulator originates in Java code, with the initial version here, current versions at Github here.  The Java sources for transformers are here, for capacitors here.  If we read circuitjs1/client/CirSim.java, it says "For information about the theory behind this, see Electronic Circuit & System Simulation Methods by Pillage or https://github.com/sharpie7/circuitjs1/blob/master/INTERNALS.md."

The general answer to that question is explained in that github.com/sharpie7/circuitjs1/blob/master/INTERNALS.md file, by the original author of the JavaScript/Java-over-GWT port, showing how the circuits are calculated each timestep.

Note how that file explains how it uses Kirchhoff's current law as its basis?  Now, look at the three isolated center circuits in reply #1.  As both the capacitors and transformers are idealized, these inner circuits have zero resistance.

The solution method here is \$\mathbf{A}\mathbf{x} = \mathbf{b}\$, where each row vector of \$\mathbf{A}\$ describes the current in one node, according to Kirchhoff's current law, with \$\mathbf{x}\$ a column vector corresponding to voltage (with respect to ground) at each node, and \$\mathbf{b}\$ is a column vector corresponding to the net current to each node.  Since we have no current sources in the circuit, \$\mathbf{b}\$ is all zeros.

Mathematically, the solution is \$\mathbf{x} = \mathbf{A}^{-1} \mathbf{b}\$ where \$\mathbf{A}^{-1}\$ is the inverse matrix (or \$\mathbf{x} = \mathbf{A}^{*} \mathbf{b}\$ where \$\mathbf{A}^{*}\$ is the pseudoinverse or Moore–Penrose inverse, useful when \$\mathbf{A}\$ is not a square matrix, yielding the "best" solution in the least squares sense; here, it should be square as both column vectors have the same number of elements, the number of nodes in the circuit).  A lot of the "speed" in simulations is related to how to calculate this inverse fast, and often some numerical precision is sacrificed for maximum speed.

The problem here is that since the resistance in the three inner circuits is zero, the Kirchhoff's current law equations in them, solved for the voltage at each of their nodes, involves a division by zero.  However, because the corresponding result is also zero, those divisions get cancelled out during the matrix construction, similar to as if you had say (x+1)/(x-1)=2/(x-1) and the solver recognized the common divisor and multiplies it out, and telling you the answer is x=1, even though there is no actual solution due to division by zero.  Essentially, the constructed matrix no longer describes the electrical circuit.

That circuit shows exactly what the Falstad simulator cannot simulate correctly: circuits or sub-circuits with zero resistances and nonlinear components.  Hell, the documentation for the simulator explicitly warns against this!

(It is also a reason why some dislike ngspice: it very often reports failure for similar circuits.  I've seen many people comment that they'd just rather have some result instead, instead of fixing their damn circuits to be more realistic.  Yeah, the extra resistors sprinkled in the simulation can be annoying, but that's what you get if you use idealized components in the first place.)

The correct version of said circuit includes series resistors with each transformer coil, matching the approximate resistance of best physically possible coils –– make them out of silver, 15.87·10⁻⁹ Ω·m = 0.00000001587 ohms per meter of wire needed.  I suspect, but have not verified (since it also depends on how the length of time steps is defined in the simulation, and I just cannot be arsed to delve that deep for this), that even adding just one nano-ohm = 0.000000001 Ω resistor per coil will drastically change the simulation behaviour, because of how that affects the matrix representation of that circuit using Kirchhoff's current law.
« Last Edit: May 27, 2025, 05:51:17 am by Nominal Animal »
 
The following users thanked this post: Zero999, Ian.M, MK14, SteveThackery

Online Zero999

  • Super Contributor
  • ***
  • Posts: 21892
  • Country: gb
  • 0999
Re: What's going on with this simulation?
« Reply #8 on: May 27, 2025, 10:27:14 am »
As mentioned above, simulators use floating point numbers, which have limited precision. Values (resistances, voltages or currents) with a huge ratios between them, can introduce rounding errors, leading to nonsensical results.
Here's an example. The voltage source has its internal impedance set to 1fΩ, = 10-15Ω, and R1 is 10k = 104Ω. The massive ratio of 1019, exceeds the dynamic range of the floating point numbers used, so the current through V1 is miscalculated.
« Last Edit: May 27, 2025, 11:08:13 am by Zero999 »
 
The following users thanked this post: tom66, Ian.M, MK14, Nominal Animal, paul cotter

Online SteveThackeryTopic starter

  • Super Contributor
  • ***
  • Posts: 2076
  • Country: gb
  • 50 year novice
Re: What's going on with this simulation?
« Reply #9 on: May 27, 2025, 04:27:57 pm »
I thought I explained it a week ago in that thread already: too-large time steps, and not enough numerical precision.

I'm sorry - there was so much noise in that thread.

I've been experimenting with the Falstad circuit*, varying the timesteps, with and without tapping the switch. For each timestep value I did one run without tapping the switch, and then another run where I tap the switch as soon as possible after starting the run.

Clearly this is a very inexact experiment, but I am satisfied the results will be repeatable, although I would expect to see some variations in the exact timings.

1us
No tap: nothing happens, still running at t = 10s
Tap: current jittering appears at t = 50ms, lamp lights at t = 130ms, simulator freezes at t = 1.11s

2us
No tap: current "jittering" by t = 8ms, builds up, lamp lights at t = 34ms, simulator freezes at t = 220ms
Tap: current jittering immediately, builds up rapidly, lamp lights at t = 28ms, simulator freezes at t = 220ms

5us
No tap: jittering appears at t = 260ms, lamp lights at t = 620ms, simulator freezes at t = 4.3s
Tap: jittering appears at t = 130ms, lamp lights at 380ms, simulator freezes at t = 4.1s

10us
No tap: nothing happens, still running at t = 30s
Tap: jittering starts immediately, slowly reduces to a minimum at t = 7s, still running at t = 30s

20us
No tap: nothing happens, still running at t = 30s
Tap: jittering starts at t = 8s, builds up slowly, lamp lights at t = 25s, still running at t = 30s

Conclusion
My conclusion is in line with the explanations by @Nominal Animal and others: the tendency for the simulator to become chaotic and run away (eventually freezing in most cases) is obviously due to shortcomings in the simulator algorithms. The way that the exact same circuit behaves differently depending on the timestep value underlines that this behaviour is not inherent in the circuit itself, but in the simulation process.

I think we can safely say that this circuit demonstrates a shortcoming in the simulator algorithms, not an undiscovered physics phenomenon.

*The schematic is attached, and the simulation is at:

https://falstad.com/circuit/circuitjs.html?ctz=CQAgjCAMB0l3BWEBOWkwHYwGYeIExgAcEALBiEtpJQKYC0YYAUAMbgBsI22XjXPLqXA0YcCGPRQ2nbkWH85w4WFFoJ66e3odhgkPWQDeIFWvFRNkGTr3yDRpaZGWLkiTbCk9JxhmNCLu6uUtbaXnYKmAL2ZiEabswA7gb4+D586TT61in0aZGppNn21gBORdm+WU40quUguk5g+ES1IvjwMi1t2PY93CbK0BjwY+NwpAxtwbPJ4K2DXGDI+EvSKQN9Kqu1zMQUK2v6R+3UcCITjUiS2MwAbo0ZTyD4CFx1jXWdUL8wCPMmtsXqQwB9Acowa90qYobloZCuAVXu8NgteiYmMcTPCses8W9wZtvCjli1SWjkYTwLtqdYAM4vakE1GfAAuZQArrRmAAVVIw-R+GLCbIXCR-aDIaV8gwRdaGEW-c7gP6WaXIWW2BVQ4Fiz6idUy-m6kxA0rccVqmAa-YkGlrZkkumWurin4wUXQUjMAD2lBeFFI2AQSBu0AlEAw2AwRA4yH8+GQpCIfU64z94GETSDIbDlgghZCcETyGwyYQuDemaQTRooI42ADMAgjoDd39qhe9bBTfDECbay7dyAA

« Last Edit: May 27, 2025, 04:35:14 pm by SteveThackery »
 
The following users thanked this post: Nominal Animal

Online SteveThackeryTopic starter

  • Super Contributor
  • ***
  • Posts: 2076
  • Country: gb
  • 50 year novice
Re: What's going on with this simulation?
« Reply #10 on: May 28, 2025, 01:12:35 pm »
I was looking for the simplest circuit that would show the abberant behaviour. Four capacitors and a transformer is all you need:

2578042-0

You can play with it here:

https://falstad.com/circuit/circuitjs.html?ctz=CQAgjCAMB0l3AWAnC1b0DYQGYAcAmaAdg3wFYCwFsVIMEQEiQydIWBTAWjDACgAxuCzZsWHiLGNw7GHAhzICwcJy4GEtQwZhZsJVH3KhXejilckkrDr3zD9yCtMM8Gq1um6HBxcoAqIC7m4mAi6lBs7AqRMKh8QA

The simulation only goes nuts when the timestep is 2us or 5us. At other timesteps the circuit sits there, inert, as it always should. I think this is perhaps a simple enough example of the abberant behaviour for Mr Falstad and whoever looks after SPICE to fix the bug.

PS: It doesn't count as free energy because there are no lossy components in it, such as a resistor or lamp. But the current appears spontaneously and builds up.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 21892
  • Country: gb
  • 0999
Re: What's going on with this simulation?
« Reply #11 on: May 28, 2025, 01:47:35 pm »
Have you tried using another simulator?

Falstad is not SPICE based. It is intended as an educational tool, rather than serious circuit simulation. Because it's designed to work under Java and in real time, it's optimised for speed, rather than accuracy, so the models are much simpler and don't reflect reality as well as SPICE does.
 
The following users thanked this post: MK14

Offline jmelson

  • Super Contributor
  • ***
  • Posts: 2940
  • Country: us
Re: What's going on with this simulation?
« Reply #12 on: May 28, 2025, 02:22:41 pm »
Disclaimer:
There are and/or have been, people I've seen on here, more experienced and knowledgeable about electronics simulators, especially SPICE based ones, than me.

My understanding, is that they need to show convergence (mathematically), i.e. the freshly calculated (slightly in the future) iteration, needs to be closer to the solution/answer, than the previous 'timeslice/iteration'.  Then it works, reasonably stably/accurately, given all sorts of other limitations and exceptions to that fact.

But that is a result of lots of mathematical work, tuning, debugging and stuff, and is aimed primarily, when sensible/realistic/practicable circuits are constructed.

If you start 'messing' around, and giving it 'dirty' circuits, that are a bit silly in nature.  Those convergences are much less guaranteed or likely.
Yes, a long time ago I was trying to optimize a power phase shifter passive circuit using SPICE, without really understanding what I was doing.  After I got EXACTLY the desired output, I checked the input characteristics.  I was horrified to see that the circuit was drawing several MILLION amps from the "mains" source!  Yes, the simulation was actually realistic, assuming all inductors and capacitors were ideal and the power company wouldn't mind supplying that much current.
Jon
 
The following users thanked this post: MK14

Online SteveThackeryTopic starter

  • Super Contributor
  • ***
  • Posts: 2076
  • Country: gb
  • 50 year novice
Re: What's going on with this simulation?
« Reply #13 on: May 28, 2025, 02:53:19 pm »
I haven't, @Zero999, because this is one of the models and simulators linked to by Chet to demonstrate his free energy claims (he doesn't call it that).

Also, I have no experience with SPICE, and I think it would be better for someone with SPICE* expertise to explore it further, should anyone be interested.

But the main reason is that I wanted to explore for myself - with the help of others - what could be causing the weird behaviour that the model showed. It soon became clear - and now I'm entirely satisfied - that the behaviour arises from the simulation algorithms, not an intrinsic quality of the actual circuit.

@Chet presented us with various ridiculously complicated and nonsensical schematics to support his claims that energy can build up uncontrollably in just the right circumstances. I've demonstrated that the underlying abberant behaviour can be observed with a simple circuit comprising just five components. It doesn't require any of the complications he presented us with. Admittedly when the circuit is that simple there is no way to extract energy from it, but my purpose was to find the simplest model that would display that behaviour.

As far as I'm concerned there is no need to pursue it any further: I'm satisfied there is nothing behind Chet's claims for free energy and exploding circuits. I'm not interested in repeating the whole investigation in SPICE. Perhaps if someone could nail down just what is going on behind the scenes in the simulator to create this abberant behaviour it would be interesting, but I doubt I'd understand the maths anyway.

*@Zero999 correctly points out that Falstad is not SPICE based. However, I wonder: is it possible that Falstad did, in fact, borrow some (or a lot) of the underlying mathematics from SPICE when designing his simulator? After all, why wouldn't you? Why would you ignore something so widely used and tested, and proven to work?  It would seem foolish to discard all that and start over. I might be wrong, but isn't Falstad mostly about simplification, rather than reinvention? Idealised components, fewer parameters, and most important of all, a vastly better UI?

Anyway, just a thought.
« Last Edit: May 28, 2025, 03:01:06 pm by SteveThackery »
 

Online SteveThackeryTopic starter

  • Super Contributor
  • ***
  • Posts: 2076
  • Country: gb
  • 50 year novice
Re: What's going on with this simulation?
« Reply #14 on: May 28, 2025, 02:59:07 pm »
Yes, a long time ago I was trying to optimize a power phase shifter passive circuit using SPICE, without really understanding what I was doing.  After I got EXACTLY the desired output, I checked the input characteristics.  I was horrified to see that the circuit was drawing several MILLION amps from the "mains" source!  Yes, the simulation was actually realistic, assuming all inductors and capacitors were ideal and the power company wouldn't mind supplying that much current.

I thought that one of the strengths of SPICE is that it does not use idealised components (or, at least, you can use non-ideal components if you choose). Is that not right?
« Last Edit: May 28, 2025, 03:01:17 pm by SteveThackery »
 

Offline showman

  • Regular Contributor
  • *
  • Posts: 77
  • Country: 00
Re: What's going on with this simulation?
« Reply #15 on: May 28, 2025, 04:08:23 pm »
The general answer to that question is explained in that github.com/sharpie7/circuitjs1/blob/master/INTERNALS.md file, by the original author of the JavaScript/Java-over-GWT port, showing how the circuits are calculated each timestep.

It says there that
Quote
This is numerical integration, and there are several ways to do it. There's forward Euler which we don't use. There's backward Euler which is more stable than forward Euler. And there is trapezoidal which is more accurate than backward Euler but less stable. You can select either trapezoidal or backward Euler. Trapezoidal will give you better accuracy for something like an LRC circuit or a filter, but backward Euler will give you better stability (much less oscillation) if an inductor is suddenly switched on or off.

The solution to all the instabilities of the circuits in this thread is to change to backward Euler. Right click-Edit the capacitors and transformers and turn off the trapezoidal approximation checkbox. Seemed to work well, although it is not necessarily ultra-stable either.
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17057
  • Country: fr
Re: What's going on with this simulation?
« Reply #16 on: May 28, 2025, 04:33:24 pm »
Either way, one first change to avoid major instabilities and nonsense results is to add some parasitics to the capacitors and inductors. I think LTSpice adds default parasitics to these even if you don't specify them, but original Spice does not. I don't know about Falstad but I suspect it does not either.

A mere LC circuit with no parastic resistance at all can oscillate forever. That only happens in a simulator with "ideal" models, of course.

Some key points to understand Spice-like transient circuit analysis:

https://www.ecircuitcenter.com/SpiceTopics/Transient%20Analysis/Transient%20Analysis.htm
« Last Edit: May 28, 2025, 04:40:23 pm by SiliconWizard »
 
The following users thanked this post: Someone

Offline jmelson

  • Super Contributor
  • ***
  • Posts: 2940
  • Country: us
Re: What's going on with this simulation?
« Reply #17 on: May 28, 2025, 07:37:34 pm »
Yes, a long time ago I was trying to optimize a power phase shifter passive circuit using SPICE, without really understanding what I was doing.  After I got EXACTLY the desired output, I checked the input characteristics.  I was horrified to see that the circuit was drawing several MILLION amps from the "mains" source!  Yes, the simulation was actually realistic, assuming all inductors and capacitors were ideal and the power company wouldn't mind supplying that much current.

I thought that one of the strengths of SPICE is that it does not use idealised components (or, at least, you can use non-ideal components if you choose). Is that not right?
not correct.  If you specify a resistor, inductor or capacitor, you get a totally mathematical ideal component.  There are libraries of more rational components, ie. capacitors with series and parallel resistances, etc.  But, of you put a 1 Ohm resistor across a 1 million Volt voltage source, the current will be 1 million amps, exactly as the math would require.
Jon
 
The following users thanked this post: SteveThackery

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 8108
  • Country: fi
    • My home page and email address
Re: What's going on with this simulation?
« Reply #18 on: May 29, 2025, 03:09:44 am »
It really is interesting/funny/weird how simulations can fail in so many weird and wonderful ways, I think.  I've definitely explored those in my own work!

To me, an argument based on erroneous simulation(s), is like arguing whether physical models are reliable or not based on dictionary definitions of the words used in the name of the model.  It is so ridiculous I have no words to describe my bafflement.

And, like I wrote earlier, when using simulators, the first thing you always need to do when you see the results, is to make sure they make sense.  Falstad ignores most errors that other simulators like ngspice (used by e.g. KiCad) will complain about, although normally in a weird way (lack of convergence et cetera).  It would be useful for everyone, especially new users to circuit simulators, to explain the issues with idealized components like capacitors, and that the better simulators do try to not produce garbage results and instead complain about e.g. convergence problems (which basically means the situation is chaotic or outside the expected parameters for such circuits so a reliable solution for that time step just does not exist).  Even the users would be less annoyed by the issues, as they'd know to look at the idealized parameters, sprinkling "parasitic" resistances on the likely problem spots.  Even with more complex models, say MOSFETs, I've found that adding a bit of resistance to the gate to limit the current spike can make a difference.

I don't think it would help with those who are trying to find loopholes around reality to bolster their own misconceptions and unfounded beliefs, though; they typically don't read (or if they do read, ignore) the documentation including the limitations, no matter how big a font one used.
 

Offline showman

  • Regular Contributor
  • *
  • Posts: 77
  • Country: 00
Re: What's going on with this simulation?
« Reply #19 on: May 29, 2025, 03:15:49 am »
Either way, one first change to avoid major instabilities and nonsense results is to add some parasitics to the capacitors and inductors.

There are two different kind of instabilities, numerical and physical. For the latter, yes you typically want to play with the parasitics, but that does not inherently ensure numerical stability.

There can be opposite problems too, for example
Quote
But Gear integration doesn’t just dampen numerical ringing, it dampens all ringing, even physical ringing, making it possible for a circuit that malfunctions in real life, due to an oscillation, to simulate as perfectly stable and functional because the instability was damped out of numerical existence. This has led to disastrous situations where an IC design is simulated in PSpice, laid out, and fabricated only to find that the circuit doesn’t function due to an instability that PSpice’s Gear integration missed. A mask revision cycle—at considerable expense in time and treasure—is required to remove the instability to try to achieve initial functionality.
From https://www.analog.com/en/resources/technical-articles/spice-differentiation.html
 
The following users thanked this post: Someone, Nominal Animal

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 8108
  • Country: fi
    • My home page and email address
Re: What's going on with this simulation?
« Reply #20 on: May 29, 2025, 03:41:40 am »
All predictor–corrector methods have their downsides.  In atomic simulations, Gear5 is relatively common, as it allows somewhat longer timesteps (at a specific magnitude of errors) compared to other methods.

I much prefer variable timesteps myself, but there the problem is that for any given simulation, assuming your stability checks (timestep adjustment methods) are correct, you end up calculating almost 2× the minimum necessary number of time steps.  When speed is an issue, that is almost a 50% reduction right there.  Then again, I much prefer verifiable reliability over speed myself.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf