Real-time tool for management of smart polygeneration grids including thermal energy storage