sharpie7 / circuitjs1

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

Batteries that actually 'run down' #724

Open UFTL opened 2 years ago

UFTL commented 2 years ago

Hi, I had an idea for the Falstad.com circuit simulator... batteries that actually run down.

How? You'd have a checkbox in the 'Edit' dialog box for the voltage source which allows one to designate it as a battery, and a text box that allows one to put in the amp-hours of that battery. The circuit simulator then analogizes it to a capacitor thusly:

Two 12 V batteries (floating at 14 V each) in series, each battery with 100 Ah capacity... giving essentially a 28 V 100 Ah battery.

28 V 100 Ah 3600 s = 10,080,000 J

From the capacitor work equation:

W = 0.5 C V^2

10,080,000 J = 0.5 C 28^2

C = 25714.285714285714285714285714286 F

So while the circuit symbol in the simulator would still show a voltage source, in reality the code is treating it like a whomping huge cap.