Control and capacity planning for energy storage systems to enhance the stability of renewable generation under weak grids | Synapse