The Gouy-Stodola theorem is often applied upon an open thermodynamic system, which can exchange heat with some thermal reservoirs. It holds both for systems which cannot exchange mass, and systems which mass can enter and leave.
Observe such a system, as sketched in the image shown, as it is going through some process. It is in contact with multiple reservoirs, of which one, that at temperature , is the environment reservoir. During the process, the system produces work and generates entropy. Under these conditions, the theorem has two general forms.