Analysis of a Variational Model for Lithium-Ion Batteries