Integrating renewable energy into grids