Capacitive mixing (CAPMIX) and capacitive deionization (CDI) are promising candidates for harvesting clean, renewable energy and for the energy efficient production of potable water, respectively. Both CAPMIX and CDI involve water-immersed porous carbon (supercapacitors) electrodes at voltages of the order of hundreds of millivolts, such that counter-ionic packing is important for the electric double layer (EDL) which forms near the surfaces of these porous materials. Thus, we propose a density functional theory (DFT) to model the EDL, where the White-Bear mark II fundamental measure theory functional is combined with a mean-field Coulombic and a mean spherical approximation-type correction to describe the interplay between dense packing and electrostatics, in good agreement with molecular dynamics simulations. We discuss the concentration-dependent potential rise due to changes in the chemical potential in capacitors in the context of an over-ideal theoretical description and its impact on energy harvesting and water desalination. Compared to less elaborate mean-field models our DFT calculations reveal a higher work output for blue-energy cycles and a higher energy demand for desalination cycles.