Integrating renewable energy into the grid