Gouy-Stodola Theorem as a variational principle for open systems.