Distributed Energy Storage Systems: Microgrid Application, Market-Based Optimal Operation And Harmonic Analysis