Sizing of energy storage for microgrids