# Clausius Inequality and Thermodynamic Potentials

One statement of the Clausius inequality is $$dS \geq \frac{\delta q}{T}$$ where $$\delta q$$ is the exchanged heat. My understanding is that $$T$$ refers to the temperature of the surroundings rather than the temperature of the system itself. This is because when deriving the Clausius inequality, we use $$dS = dS_\text{proc} + dS_\text{exch}$$ where the total entropy change of the system is the change in the entropy due to a spontaneous process plus the change in entropy due to heat exchange with surroundings. Since the surroungings are kept in thermal equilibrium, it follows that $$dS_\text{exch} = -dS_\text{surr} =\frac{\delta q}{T}$$ where $$T$$ is the tempreature of the surroundings. Since $$dS_\text{proc}\geq 0$$ (with equality only in the case of a reversible process), we obtain the Clausius inequality.

However, when considering thermodynamic potentials, it seems that $$T$$ is used to refer to temperature of the system rather than the temperature of the surroundings. For example, to derive the spontaneity criterion for Helmholtz free energy, we use $$dA = dU - TdS - SdT = \delta q + PdV - TdS - SdT.$$ At constant $$T$$ and $$V$$, this becomes $$dA = \delta q - TdS$$ and we use the Clausius inequality to state $$dA \leq 0$$. In this derivation, however, it seems that $$T$$ refers to the temperature of the system rather than the surroundings, so I am not sure how the Clausius inequality can be correctly applied here.

Your interpretation of the Clauius inequality is correct, and T is the temperature of the surroundings. However, your interpretation of how the Helmholtz free energy is applied is incorrect. In the case of applying the Helmholtz free energy. we assume that for both reversible and irreversible processes on a closed system, the surroundings are constantly maintained at the same temperature as the initial temperature of the system T throughout the process for both reversible and irreversible processes. So from the first law of thermodynamics, we have $$\Delta U=Q-W$$ and, from the 2nd law of thermodynamics we have $$\Delta S=\frac{Q}{T}+\sigma$$, where $$\sigma$$ is the generated entropy. If we combine these two equations, we obtain: $$\Delta U=T\Delta S-T\sigma-W$$or under these constant external temperature conditions, $$\Delta A=-W-T\sigma$$or$$W=-\Delta A-T\sigma$$So, for a given pair of end states, the maximum work that the system can do is for a reversible path, and is equal to $$-\Delta A$$. For irreversible paths between the same two end states, the irreversible work is less than for the reversible path. Again, all this applies only to cases where the surroundings are maintained at the same temperature as the initial temperature of the system.

The easiest way to think of this is as follows. In the formula $$\frac{\delta q}{T_0}$$ source of the heat $$\delta q$$ at temperature $$T_0$$ is actually transporting along with said heat an amount of entropy $$dS_0= \frac{\delta q }{T_0}$$ through the interface between the system and its environment that is the entropy (heat) source. There is no heat transport without an accompanying entropy transport, just as there is no chemical species mol transport without inertial mass and gravitational mass transport, these are always tied together. Similarly, there is no mass transport without also transporting some amount of entropy associated with the body, etc.

When looked at it from this point of view, the Clausius inequality states that the entropy increase of the system that has received through its interface with the reservoir an amount of $$\delta S_0$$ entropy by any process will have its own entropy increased by $$dS$$ so that $$dS \ge \delta S_0$$. Equality if and only if the process is reversible otherwise the local increase is larger than the transported entropy.

Regarding spontaneity, starting with energy conservation, write $$dU = TdS-pdV = \delta q - p_0dV$$ where $$p_0$$ is the external pressure and the temperature $$T,p$$ are the system's own temperature and pressure.

Since $$\frac{\delta q}{T_0} \le dS$$ we can rewrite this inequality as equality: $$\frac{\delta q}{T_0} +\delta S^* =dS_0+\delta S^* = dS$$ where $$\delta S^* \ge 0$$ represents the irreversibly produced entropy and then:

$$T(dS_0+\delta S^*)-pdV = T_0dS_0 - p_0dV \tag{1}$$ Upon rearranging (1) we get that in all natural processes $$(T_0-T)dS_0 -(p_0-p)dV = T\delta S^* \ge 0$$

Assume now $$p=p_0$$ then all natural processes $$(T_0-T)dS_0 = T\delta S^* \ge 0$$ showing that for $$dS_0>0$$, that is entropy( (and heat) to flow from the environment into the system the environmental temperature must exceed that of the system.

Thermodynamics is fundamentally the study of systems at equilibrium. A system at equilibrium is one 1) doesn't change in time, and 2) doesn't have any fluxes, meaning that there are no extensive quantities flowing (e.g. no electrical current, heat flux, mass transfer, etc.) Thermodynamics at its core works with systems that are big and mixed-up enough to have a well-defined temperature, and if they're at equilibrium with their surroundings, the temperature of their surroundings is the same. If some process occurs in an irreversible way, thermodynamics isn't able to describe the specifics of what was happening during that process, because irreversibility comes because of specifics about the evolution of the system over a finite time, during which thermodynamics quantities (like temperature) aren't well-defined. However, thermodynamics is able to make statements about the system before and after the irreversible process, once everything has come to equilibrium

The Clausius inequality is about the temperature of the external bath because it is a statement about all processes, including irreversible ones, and even for an irreversible process in our system it's a good assumption that the bath remains basically well-described by thermodynamics and has a well-defined temperature. The thermodynamic potentials are well-defined for the system only when it is in thermodynamic equilibrium.

Generalizations of these ideas certainly exist and are important and generally go under the name of "thermalization," describing how systems that are not in thermal equilibrium get there via approaches like the Boltzmann equation (or the eigenstate thermalization hypothesis if you're doing quantum things), but thermodynamics as formulated by Gibbs and Clausius and friends applies to equilibrium systems.

The Clausius (in)equality is as you stated:

$$dS \ge \frac{\delta Q}{T_{surr}}\tag1$$

where the equality holds for reversible procesess.

Using the fundamental thermodynamc relation:

$$dU=TdS-pdV$$

we can also define a simmilar sort of quantity, by just algebraic manipulation, to the Helmoltz free energy you provided.

It is called the Maximum (reversible) work:

$$dW_{max}:=dW_{rev}=dU-TdS+pdV.$$

After integrating we get the following function

$$W_{max}= U_1-U_0 -T_{surr}(S_1-S_0)+p_{surr}(V_1-V_0)\tag2.$$

This function represents the maximum possible work that can be extracted from a system at some state $$1$$ until it reaches some state $$0$$ when it will be in equilibrium with its surroundings.

The temperature in $$(2)$$ is the temperature of the surroundings, same as it is in $$(1)$$, so it is consistent with the Clausius inequality.

The Helmoltz free energy is basically the same equation as $$(2)$$, we just have $$T=const.$$ so the internal energy term vanishes, because $$dU \propto dT$$ usually.