Relational analysis of energy systems: Theory and applications