Optimal Operation Of Energy Storage In Power Transmission And Distribution