Thermodynamic optimisation of a heat exchanger