Internal energy

In thermodynamics, a system is any object, any quantity of matter, any region, etc. selected for study and mentally set apart from everything else which is then called its surroundings. The imaginary envelope enclosing the system and separating it from its surroundings is called the boundary of the system. In this article the boundaries will be referred to as the walls of the system. The internal energy of a system is its energy, without the energy associated with the interaction of the system with external fields, such as gravitational, electric, magnetic, etc. fields. For instance, a system of non-zero mass m at a non-zero distance x above the surface of the Earth has gravitational  energy mxg; this gravitational energy is not part of the internal energy&mdash;one could refer to it as external energy, although this is not commonly done.

Internal energy, usually denoted by either U or E, is a state function, that is, its value depends upon the state of the system and not upon the nature of the processes by which it attained that state. The internal energy, which will be written as U, is a differentiable function of the independent variables that uniquely specify the state of the system. An example of such a variable is the volume V of the system.

When the system has thermally conducting walls, an amount of heat DQ  can go through the wall in either direction: if DQ > 0, heat enters the system and if DQ < 0 heat leaves the system. The internal energy of the system changes by dU as a consequence of the heat flow, and it is postulated that

dU = DQ \, $$ The symbol DQ indicates simply a small amount of heat, and not a differential of Q. Note that Q is not a function. The symbol dU indicates a differential of the differentiable function U, for instance, when U is seen as a function of V,

dU \equiv \lim_{\Delta V\rightarrow 0} \frac{U(V+\Delta V)-U(V)}{\Delta V} \Delta V = \left(\frac{\partial U}{\partial V}\right) dV $$

Most thermodynamic systems are such that work can be performed on them or by them. When a small amount of work DW is performed on the system, the internal energy increases,

dU = -DW\, $$ The minus sign is by convention.

As an example of work, we consider as a system a volume V containing gas of pressure p. Work pdV is performed on the system by compressing the gas (dV < 0). The sign convention gives that DW and dV have the same sign

DW = p dV \, \quad dV < 0, \quad DW < 0 $$ If dV > 0 (expansion), work DW > 0 is performed by the system. Hence the change in internal energy obtains indeed a minus sign:

dU = -D W  = -pdV \, $$ Note that other forms of work than pdV are possible. For instance DW = HdM, the product of an external magnetic field H with a small change in molar magnetization dM. This change in internal energy is caused by an alignment of the microscopic magnetic moments that constitute a  magnetizable material. This microscopic alignment must not be confused with an overall alignment of a macroscopic magnet&mdash;such an alignment would give a change in external energy.

When a small amount of heat DQ flows in or out the system and simultaneously a small amount of work DW is done by or on the system, the first law of thermodynamics states that the internal energy changes as follows

dU = DQ - DW\, \qquad\qquad\qquad (1) $$ Note that the sum of two small quantities, both not necessarily differentials, gives a differential of the state function U. Equation (1) postulates in fact the existence of a quantity (U) that keeps track of the work done on or by the system and the heat that flowed in or out the system.

Internal energy is an extensive property&mdash;that is, its magnitude depends on the amount of substance in a given state. Often one considers the molar energy, energy per mole of substance. The internal energy has the SI dimension joule.

Note that only a change in internal energy was defined. An absolute value can be obtained by defining a zero (reference) point with U(0) = 0 and integration

U(1) = \int_0^1 dU $$

Statistical thermodynamics definition
Consider a system of constant temperature T, constant number of molecules N, and constant volume V. In statistical mechanics one defines for such a system the density operator

\hat{\rho} \;\stackrel{\mathrm{def}}{=}\, \frac{e^{-\beta \hat{H}}}{\mathrm{Tr}(e^{-\beta \hat{H}})} $$ where $$\hat{H}$$ is the Hamiltonian (energy operator) of the total system, $$\mathrm{Tr}(\hat{O})$$ is the trace of the operator $$\hat{O}$$, &beta; = 1/(kT), and k is Boltzmann's constant.

The thermodynamic average of $$\hat{H}$$ is the internal energy,

U = \langle\langle \hat{H}\rangle\rangle \equiv \mathrm{Tr}( \hat{\rho}\, \hat{H}) = \frac{1}{Q} \mathrm{Tr}(\hat{H}\, e^{-\beta \hat{H}}) \quad\hbox{with}\quad Q \equiv\mathrm{Tr}(e^{-\beta \hat{H}}) $$ The quantity Q is the partition function. The internal energy is minus its logarithmic derivative

\frac{d\ln Q}{d\beta} = \frac{1}{Q}\frac{dQ}{d\beta} = -\frac{1}{Q} \mathrm{Tr}(\hat{H}\, e^{-\beta \hat{H}}) $$ Further

\frac{d\ln Q}{d\beta} = \frac{d\ln Q}{dT } \left(\frac{d\beta}{dT}\right)^{-1} = -kT^2 \frac{d\ln Q}{dT } $$ Hence

U = kT^2 \left(\frac{d\ln Q}{dT }\right) = kT^2 \left(\frac{\partial \ln Q}{\partial T }\right)_{V,N} $$