giferrari.net Gia's personal site

Salvaged Battery Pack Optimizer

written by Gia Ferrari on 2025-10-07

tl;dr A tool to design better battery packs by dividing cells into groups of similar capacity (mAh). Uses iterative maximum weight maximum cardinality matching to create optimal groups of 2S, 4S, 8S, or 16S configurations.

Carrot: Salvaging good cells from condemned packs is fun, I get to play with my RC toys for free, and useful materials are kept out of the landfill.

Problem: Salvaged lithium cells exhibit capacity variance. Manual grouping yields suboptimal pack performance.

Solution: Graph-theoretic optimization for series string assembly adjusts glasses

Technical Specifications

Optimization Modes

Mode 1 - Total Loss Minimization: Minimizes sum of capacity differences across all groups. i.e., maximize usable energy across all packs, at the cost of slightly poorer balancing and pack longevity.

Mode 2 - Individual Balance: Minimax optimization. Minimizes worst-case group variance. Improves pack reliability at the cost of some total capacity loss.

Implementation

Web-based interface. Real-time calculation. No server dependency. Feel free to Save Page As in the browser ✨.

Access Tool | Source Code

Note: Tool addresses capacity matching only. You're on the hook for internal resistance matching.

Warning: High-energy density systems. Observe safety protocols.

I did not write the graph library, I used: @graph-algorithm/maximum-matching