Identification and optimal control of an electrical storage system for microgrids with renewables