Battery Management Systems: Design by Modelling