Variational Methods for Energy Systems