Intelligent Energy Storage for a Stable Grid