DEV Community

Surendra Singh Kamboj
Surendra Singh Kamboj

Posted on AI-assisted

Where does the energy go when two capacitors share charge? A JavaScript check

When a charged capacitor is connected to an empty one, the charge spreads out, but one third of the energy disappears in a typical case. A short simulation shows that the loss does not depend on the resistance of the wire. (I build PractiSci, which has a free capacitor charge-sharing lab.)

What happens when two capacitors share charge?

Take C₁ = 4 µF charged to 12 V and C₂ = 2 µF empty. Charge is conserved: Q = C₁V. After joining, both have the same voltage V′ = C₁V/(C₁ + C₂) = 8 V. Energy is not conserved:

const C1 = 4e-6, C2 = 2e-6, V = 12;
const Ui = 0.5 * C1 * V * V;                 // 288 microjoule
const Vf = C1 * V / (C1 + C2);               // 8 V
const Uf = 0.5 * (C1 + C2) * Vf * Vf;        // 192 microjoule
console.log(Ui - Uf, ((Ui - Uf) / Ui * 100).toFixed(1) + '%');  // 96 microjoule, 33.3%
Enter fullscreen mode Exit fullscreen mode

The loss is 96 µJ, which is 33.3% of the starting energy. It equals ½ · C₁C₂/(C₁ + C₂) · V² = 96 µJ.

Where does the energy go?

It becomes heat in the connecting wire (and some radiation). I check this by integrating I²R over time for two very different resistances:

for (const R of [1, 1000]) {
  const Ce = C1 * C2 / (C1 + C2), tau = R * Ce, dt = tau / 2000;
  let heat = 0, v = V;
  for (let t = 0; t < 12 * tau; t += dt) {
    const i = v / R;
    heat += i * i * R * dt;
    v -= i * dt / Ce;
  }
  console.log('R', R, 'heat', heat.toExponential(4));
}
Enter fullscreen mode Exit fullscreen mode

Both runs give 9.6024 × 10⁻⁵ J, which is the same 96 µJ. A smaller R makes the current larger and shorter, a larger R makes it smaller and longer, but the total heat is identical. Even a wire with almost no resistance loses the same energy (as radiation and sparks).

FAQ

Is charge conserved?

Yes, always. The total charge stays 48 µC. Only the energy is lost.

When is no energy lost?

When the two capacitors are already at the same voltage before they are joined.

Where can I try it?

The free capacitor charge sharing lab lets you change the capacitances and voltage and see the energy before and after. The capacitance guide covers the theory.

Top comments (0)