Design and optimization of a reverse electrodialysis stack for energy generation through salinity gradients