Add thermodynamic potentials

Not ready to be merged. Opening for comments/suggestions.
then maybe this file should be moved to misc/?