# Free energy changes in a canonical ensemble

## Main Question or Discussion Point

I have a question that has puzzled me during the last couple of days. Suppose that there is a system (e.g. a small box filled with gas) that is connected to a heat bath (much larger than the system) at a constant temperature T. The studied system and the heat bath are thought to be isolated from any other systems. The edges of the box could be interpreted as the interface to the heat bath.

Now we apply an amount of external work (W) to the system. The system is strongly thermally connected with the heat bath. Therefore as time passes, the work W will be transferred to the heat bath in the form of heat and the system will end up in a state similar to the initial state. From the Helmholtz free energy point of view we have dF = dW - SdT = dW, because the system is isothermal. Thus in the total process the free energy of the system has changed by an amount ΔF = W = ∫dW > 0.

On the other hand the system can be viewed as a canonical ensemble. Now we notice that the initial and final states of the system are similar and they are both described by the same partition function, $Z_{init}=Z_{final}$. This occurs, since the additional energy W gets absorbed by the heath bath and the temperature T is constant. The free energy change in a canonical ensemble is obtained by

$\Delta F = -k_BT \ln \frac{Z_{final}}{Z_{init}}$.

Because of the similarity of the partition functions, the free energy change would now be zero. This is clearly in contradiction with the previous reasoning, could someone think of a good explanation for this? For instance, sometimes the canonical ensemble is derived by interpreting the heat bath and the system to form a microcanonical ensemble. This could cause problems with the present system, since external energy W is added and the total energy of the bath and the system would not be constant.

Related Classical Physics News on Phys.org
WannabeNewton
Consider a system immersed in a thermal bath for which the volume is the only significant external parameter. Then ##d\ln Z = (\partial_{\beta}\ln Z )d\beta + (\partial_{V}\ln Z )dV## so even if one performs work ##\delta W = pdV## through a process for which ##d\beta = 0## one still has ##dV \neq 0## (certainly work done must change the volume of the system in this process) and so, contrary to what you said, ##d\ln Z = (\partial_V \ln Z) dV \neq 0## as ##Z## will in general depend on the volume through the energies of the microstates.

If there are other external parameters, and/or if volume is not one of them, the same argument carries over with an arbitrary generalized force ##X = \frac{1}{\beta}\partial_x \ln Z##, in place of pressure, and with ##\delta W = X dx##, where ##x## is the external parameter conjugate to the generalized force ##X##.

Last edited:
Thanks for the reply. This would seem to be the case when work is applied by making volume changes but the situation can vary quite a bit depending on the method of applying work. A more elaborate example could be constructed with a sufficiently large box of water or some other viscous fluid in contact with a thermal reservoir. Work would be applied to the system by moving slightly a paddle in the middle of the box. The work would be initially converted to mechanical waves in the fluid but sooner or later the waves are dissipated and turned into heat. When the system is allowed to equilibrate, the reservoir should absorb this additional heat. To preserve a connection to realistic systems, it can be thought that the system is so large that the waves are dampened before reaching the edges of the box (the interface to the reservoir). In this case I cannot think of any such differences between the initial and final (equilibrium) states of the system that would cause a change in the partition function. At most, the paddle is slightly displaced.

WannabeNewton
As stated above, any form of work will necessarily involve a change in at least one external parameter ##x## which need not be volume. We thus have ##\delta W = -(\partial_x \bar{E}) dx##, where ##\bar{E}## is the average energy of the system in equilibrium with the thermal bath (note therefore this definition entails a quasi-static process). ##X = -(\partial_x \bar{E})## is called the generalized force and it is the conjugate to ##x##. It can be shown from the definition of ##Z## that ##X = \frac{1}{\beta}\partial_x \ln Z##. Clearly then ##\delta W \neq 0## in a process, regardless of what external parameter(s) were changed by the process of doing the work, will result in ##d \ln Z \neq 0## even if ##d\beta = 0## between the two equilibrium states, which does hold in this case since the thermal bath is assumed to have infinite heat capacity.

Coming back to your question, it seems you are under the impression that if we start with the system in a given equilibrium state and perform work so as to drive it to a new equilibrium state then the partition function will remain unchanged. If I have a gas enclosed in a cylinder and install a paddle wheel that exerts a torque on the gas then between two equal volume equilibrium states the average energy ##\bar{E}## of the gas will increase as a result of the work done by the torque. This means the system now has access to more microstates ##n## hence there are more allowed energies ##E_n## and since ##Z = \sum e^{-\beta E_n}## in the canonical ensemble, the partition function certainly cannot be the same between the two equilibrium states.

Jano L.
Gold Member
...The system is strongly thermally connected with the heat bath. Therefore as time passes, the work W will be transferred to the heat bath in the form of heat and the system will end up in a state similar to the initial state. From the Helmholtz free energy point of view we have dF = dW - SdT = dW, because the system is isothermal. Thus in the total process the free energy of the system has changed by an amount ΔF = W = ∫dW > 0.
The formula
$$dF = dW -SdT$$
is only valid when infinitesimal work done on the system is given by ##-pdV##. In such case, however, the work done is accompanied by change of volume. For different volume the partition function will have different value and the free energy will change.

If the work is not expressible in the form ##-Xdx##, the above formula does not apply. The system may end up in the same state as it began, with the same free energy, while all the energy transferred as work goes into the reservoir.

I don't think the formula $dF \leq dW - SdT$ should be restricted to some certain forms of work because the Helmholtz free energy has a definition independent of the concept of a canonical ensemble. I am more willing to think that when "pathological" forces are introduced, the connection with the canonical ensemble might not work as expected.

Through the definitions of free energy we could also study the form

$dF = dU - d(TS) = dU - TdS$

for an isothermal system. If the total change of internal energy in the process is zero, we have

$\Delta F = - T \Delta S$.

This implies that for the system that I described in my second post the free energy change is related to a change in the entropy of the system. With a positive amount of work that passes as heat to the reservoir we have a negative change in the entropy of the system, which is connected to a positive change in the free energy. An interesting question would be, can the sole entropy change between the initial and final state be somehow studied with the partition function (does the change manifest as a change in the phase space volumes). Or, do we conclude that the used definitions are not compatible.

Last edited:
Jano L.
Gold Member
I don't think the definition $dF \leq dW - SdT$ should be restricted to some certain forms of work because the Helmholtz free energy has a definition independent of the concept of a canonical ensemble.
That is inequality, not a definition. This inequality is valid even if the work is due to turning paddle. If the system returns into the initial state, the free energy returns to the initial value, so ##\Delta F = 0##. Integral form of the inequality
$$\Delta F \leq \Delta W - S\Delta T$$
is satisfied, since the right hand side is positive.

You should note that the equality that I presented between entropy and free energy changes is exact so there is a direct connection (not inequality) between these changes. Also, the inequality between work and free energy is an equality for quasistatic processes. Therefore using the inequality as an argument here is not the right way.

Jano L.
Gold Member
It is hard to understand what you're thinking. For quasi-static processes, equality is valid. Turning paddle inside a system and performing work is not quasi-static process and the equality is not satisfied, but the inequality is.

Turning a paddle can be done quasistatically by doing infinitesimal turns at a time. Thus the system is in equilibrium throughout the process and the equality $dS = dQ/T$ is valid. It is important to recognize that the inequality $dS \geq dQ/T$ (from which the other inequalities of thermodynamics follow) arises from the additional entropy production in realistic systems that are not exactly in equilibrium throughout the process. Thus the inequalities cannot be used blindly, but one has to think if the reasoning works also in the quasistatic limit.

I might have been a bit unclear before since I have been unable to point out the exact thing that puzzles me. This discussion has been very useful, since it has made it more clear to me what I am trying to ask. To be more exact than before, in the example of my second post the initial and final states are not the same. The energies of these states are similar but there is a negative entropy change caused by the heat flowing out of the system. Because of this negative entropy change there is a positive change in free energy. My greatest issue was to connect this with the change of the partition function. A partition function could be presented as an integral over the phase space

$Z = \int e^{-H/k_BT} d \Gamma$.

Intuitively, because the initial and final states have the same energy, it would seem that also the hamiltonians would be the same. But this would imply that the partition functions are the same (not possible because of the free energy change). The most elegant solution for this apparent problem would seem to be having a term in the hamiltonian that takes into account the changes in entropy. This was the thing I was originally wondering about; how to show the differences of $Z$ in the explicit presentation.

I had a more general look at things and it seems that in classical hamiltonian mechanics entropy changes and dissipation are not considered. Even so, some models have been made to add these effects with hamiltonian terms.

Last edited:
Jano L.
Gold Member
This discussion has been very useful, since it has made it more clear to me what I am trying to ask.
That's great to hear.

Thus the system is in equilibrium throughout the process and the equality $dS = dQ/T$ is valid.
This case with paddle is somewhat specific. This process may be quasi-static in the literal sense that it is very slow.

But in this sense quasi-staticity is not sufficient condition for the equation ##dS=dQ/T## to be valid. The other condition that is often taken for granted and sometimes thought to be part of the meaning of "quasi-staticity" is that any work done on the system is done in a Carnot reversible way, that is, the direction of the process can be reversed without any change in the system and its environment.

Slowly turning paddle in fluid is prime example of irreversible work. In this case, the relation ##dS = dQ/T## is not valid even for arbitrarily slow turning.

To be more exact than before, in the example of my second post the initial and final states are not the same. The energies of these states are similar but there is a negative entropy change caused by the heat flowing out of the system.
If the volume and all other macroscopic "generalized coordinates" are held constant, it would be nearly impossible to accomplish entropy decrease with system and reservoir at the same temperature. How would you do it?

The only way I see is to allow reversible work, which means volume or other coordinate will change, which means parameter of the partition function in the statistical physics calculation will change.

Yes, in this kind of a situation it is true that the quasistatical limit cannot be reached: events that increase entropy are certainly present in the fluid. However, it should be noted that actually in any realistic process we cannot really reach the quasistatical conditions. Thus it is not a realistic situation that is viewed but more like a hypothetical situation to view how the system behaves when additional entropy production is ignored. This gives a more clear understanding of the process even if it would not actually be realistic.

The entropy change of the system is related to the heat transfer from the system to the reservoir Q = W > 0 (a zero internal energy chenge). For this entropy change $\Delta S_s = -\Delta F/T \geq -Q/T$, where the inequality implies entropy production in the system. Correspondingly there is a positive entropy change in the reservoir for the incoming heat: $\Delta S_r \geq Q/T$. Now by combining these changes we have the total entropy change $\Delta S_{tot} = \Delta S_r + \Delta S_s \geq 0$ which explains the local negative change of the system. On the other hand this can also be expressed as $\Delta S_{tot} = -\Delta F/T + W/T \geq 0$ from which we have the inequality $W \geq \Delta F$. This could have been seen also from $\Delta S_s$ or directly from the formula $dW \geq dF$.

In this case you have to be careful, since we are only interested in the events of the system, but the events in the reservoir are closely related to these.

Jano L.
Gold Member
Everything you said is OK until

Now by combining these changes we have the total entropy change ΔStot=ΔSr+ΔSs≥0 which explains the local negative change of the system.
I do not see what negative change do you have in mind. If the process is isothermal and isochoric, entropy of the system will remain constant. Only entropy of the reservoir will increase.

Hmm, I guess I have to explain more carefully the nature of the exact system I have in mind. Work is done in a small (microscopic, if necessary) scale so that it is transfered directly as work to the internal energy of the system. The isothermality is taken care of by the reservoir and thus the system itself can be out of equilibrium during the process - it is not strictly isothermal.

To obtain a closer view we can 'partition' the process. If we disconnect the reservoir and the system the work would show up as a small rise in the temperature of the system (and yes, some entropy is produced). If the connection to the reservoir would be again established the internal energy related to the slight temperature rise in the system would be transfered as heat to the reservoir. Thus in total we have an internal energy rise caused by work done to the system and a corresponding amount internal energy decrease because of heat flow from the system to the reservoir. Simultaneously, some entropy is produced.

This could be contrasted with (strictly) isothermal compression. Work is done to a system but its internal energy does not change and thus all the added energy flows out of the system as heat. In this case there would be a negative change in entropy corresponding to the heat flow out of the system (according to the definitions). There would be no change in temperature and internal energy but in addition to the entropy, this time also the volume of the system would have changed.

In the situation we are studying the irreversible nature included in the process would seem to cause a 'malfunction' to the classical canonical formalism - no other parameters seem to have change in addition to the entropy. This could be probably taken care of by adding some Hamiltonian term to the partition function that accounts for the difference between the states. As in the case of compression, there is a negative entropy change related to the outflowing heat. Of course if there would be enough non-equilibrium behaviour and entropy generation the total entropy change in the system could be turned to positive. However, I think that it is also possible to have a case in which entropy generation plays a smaller role than the entropy change related to the outflowing heat.

Jano L.
Gold Member
Work is done in a small (microscopic, if necessary) scale so that it is transfered directly as work to the internal energy of the system. The isothermality is taken care of by the reservoir and thus the system itself can be out of equilibrium during the process - it is not strictly isothermal.
Then in addition to being irreversible, the process is not even quasi-static.

In the situation we are studying the irreversible nature included in the process would seem to cause a 'malfunction' to the classical canonical formalism - no other parameters seem to have change in addition to the entropy.
Your situation is a case of irreversible process to which relation like ##dS = dQ/T## does not apply. But that relation is part of thermodynamic formalism. I do no understand why you think canonical formalism shows malfunction here. Hamiltonian mechanics can describe thermodynamically irreversible process: just put particles in a box that can move and is connected to lager system of particles (reservoir) and calculate the motion of the system for prescribed motion of the paddle. Thermodynamic variables will show irreversible behaviour.

This could be probably taken care of by adding some Hamiltonian term to the partition function that accounts for the difference between the states. As in the case of compression, there is a negative entropy change related to the outflowing heat. Of course if there would be enough non-equilibrium behaviour and entropy generation the total entropy change in the system could be turned to positive. However, I think that it is also possible to have a case in which entropy generation plays a smaller role than the entropy change related to the outflowing heat.
If the process is quasi-static, since the system is connected to reservoir and maintains the same thermodynamic state (T,V,...), there is no reason to think its entropy decreases because entropy is function of state.

If the process is not quasi-static, the system may acquire greater kinetic temperature than that of the reservoir. But there is no clear reason to think entropy of the system will decrease. Entropy may not even have meaning if the process is not quasi-static. To show that entropy would decrease, first you need to state how the change in temperature is accomplished and how the entropy for such non-equilibrium state is to be defined. Then you have to show why it should be lower than the standard entropy in equilibrium.