Thermodynamically derived model and simulation of intercalation currents and overpotentials in Li ion batteries