Optimising energy flows and synergies between energy networks