Add thermodynamic potentials

Not ready to be merged. Opening for comments/suggestions.
I have no idea, what is the function supposed to do exactly anyway?