Closed quetzalcoatl closed 3 years ago
It's a side effect of the approximation. Maybe trapezoidal should be off by default. I could have sworn I tried the LRC circuit with trapezoidal turned off at some point and got very bad results. But I just tried it now and it was fine. I'll have to look into this.
The time constant of this circuit is 47 ns but your timestep is 5 us which is much too long, so it is not possible to simulate the charge of the capacitor accurately. The trapezoidal approximation tends to overcorrect in cases like these which causes the ping-pong you are seeing. If you set the timestep to 5 ns it works fine.
Oh god. sorry about that. I miscalculated it as ~45us not ns, probably I wrote e-6
as capacity scale instead of e-9
. Yeah.. 0.1*470e-9.. vs steps in us.. that makes much sense now.
On: https://www.falstad.com/circuit/ About: Circuit Simulator version 2.4.3js
Circuit:
Sorry about the loose parts laying around, I was in the middle of testing something else.
The odd thing happening is, when the switch is set at 1R, the capacitor charging time is about 50us, and when the switch is flipped to 100m=0.1R, charging that same capacitor takes.. 485us? That's pretty odd. When the resistor is changed to even lower value, like 10m=0.01R, it's even worse, current and time rises up to the sky.
It seems like the voltage source and the capacitor enter some ping-pong ringing state: capacitor is overcharged by a tiny amount, then discharged too much, and re-charged, and so on. At first I thought the 'wires' have some inductance modelled-in :), but I played around and changing the timestep from default 5us to 0.1us helps a lot (while leaving default 5us and turning on 'auto-adjust timestep' makes almost no difference).
Then, I noticed this happens only when the capacitor has "Trapezoidal approximation" option turned on, which, frankly, is by default on.
Btw. I'm pretty sure there is a similar problem with inductors, and disabling approximation also helped with that.
I understand what approximation is :) and I don't know if this behavior is a bug, or is a sideeffect of the approximation and time-stepping, but if disabling approximation (even with the same time step) makes these problems go away, if it can make such a huge difference even for simple circuit like R-C, should this approx be turned on by default?