sharpie7 / circuitjs1

Electronic Circuit Simulator in the Browser
GNU General Public License v2.0
2.29k stars 633 forks source link

Suggestions regarding capacitors: allow loops #634

Open Jeppe53 opened 3 years ago

Jeppe53 commented 3 years ago

When two or more capacitors are connected in parallel the simulation stops (in real life is it not a problem :) ). Couldn't it be smart if a capacitor basically had a small resistor (like 1 microohm) in series by default. It should be made possible to change the value during editing of the capacitor.

/Jeppe

pfalstad commented 3 years ago

We could allow this now. This used to be necessary, but I changed the capacitor model so it's possible now. We'd just have to do some extra work in the circuit validation to ensure that two capacitors connected in parallel have the same voltage, or else we'd get oscillation.

A resistor in series would work but it would make capacitors twice as expensive to create (an extra circuit node for each capacitor), which would make large circuits run a lot slower. Probably not a good idea to do that just to handle this unusual case.

nulldg commented 3 years ago

To add to Paul's point: The capacitors found in simulations are theoretical capacitors, so they exclusively simulate theoretical capacitor behavior and nothing else. Parallel capacitor pairs with zero internal resistance can be put into states which act in undefined ways (which is what you'd expect from a device which cannot exist in reality) so if you need internal resistance, I would recommend simply include a tiny series resistor to each relevant capacitor to explicitly simulate it. We create equivalent circuits like this whenever we need to explicitly simulate something, such as electrical noise, trace inductance, heat, internal resistance, trace resistance, etc.

Jeppe53 commented 3 years ago

Thanks for the responses. I been using "falstad/circuit" for years and are fully aware how to overcome this minor problem by putting a resistor in series with the "second" capacitor and my students are learning it quickly. But I also notice that the simulator keep getting improved. Hence my suggestion what could be changed to make the use more "userfriendly".

But Im aware that this will interfere with the principles of using ideal components-models.

ZVSphiler commented 2 years ago

Maybe allow specifying components as parasitic components to explicit them from drawing. Or integrate them directly into (standard) components just like how it was done in ltspice. Just an idea

Killeroid17 commented 1 year ago

AGREED, because in REAL LIFE every conductor / wire have at least 0.001m OHM ! :)

Killeroid17 commented 1 year ago

looks like this problem is an old one and still didn't get a REAL-LIFE- update... as they say, theory is theory, nothing to do with practice...

Killeroid17 commented 1 year ago

We could allow this now. This used to be necessary, but I changed the capacitor model so it's possible now. We'd just have to do some extra work in the circuit validation to ensure that two capacitors connected in parallel have the same voltage, or else we'd get oscillation.

A resistor in series would work but it would make capacitors twice as expensive to create (an extra circuit node for each capacitor), which would make large circuits run a lot slower. Probably not a good idea to do that just to handle this unusual case.

or at least eliminate this error and leave it as is, without the simulation being stopped...

r3a1d3a1 commented 2 weeks ago

Frequency dependent ESR would be ideal.