Making batteries from magnetic materials