Conservation of energy
First law of thermodynamics

For a closed thermodynamic system, the first law of thermodynamics may be stated as:

where δ Q {\displaystyle \delta Q} is the quantity of energy added to the system by a heating process, δ W {\displaystyle \delta W} is the quantity of energy lost by the system due to work done by the system on its surroundings, and d U {\displaystyle \mathrm {d} U} is the change in the internal energy of the system.

The δ's before the heat and work terms are used to indicate that they describe an increment of energy which is to be interpreted somewhat differently than the d U {\displaystyle \mathrm {d} U} increment of internal energy (see Inexact differential). Work and heat refer to kinds of process which add or subtract energy to or from a system, while the internal energy U {\displaystyle U} is a property of a particular state of the system when it is in unchanging thermodynamic equilibrium. Thus the term "heat energy" for δ Q {\displaystyle \delta Q} means "that amount of energy added as a result of heating" rather than referring to a particular form of energy. Likewise, the term "work energy" for δ W {\displaystyle \delta W} means "that amount of energy lost as a result of work". Thus one can state the amount of internal energy possessed by a thermodynamic system that one knows is presently in a given state, but one cannot tell, just from knowledge of the given present state, how much energy has in the past flowed into or out of the system as a result of its being heated or cooled, nor as a result of work being performed on or by the system.

Entropy is a function of the state of a system which tells of limitations of the possibility of conversion of heat into work.

For a simple compressible system, the work performed by the system may be written:

where P {\displaystyle P} is the pressure and d V {\displaystyle dV} is a small change in the volume of the system, each of which are system variables. In the fictive case in which the process is idealized and infinitely slow, so as to be called quasi-static, and regarded as reversible, the heat being transferred from a source with temperature infinitesimally above the system temperature, the heat energy may be written

where T {\displaystyle T} is the temperature and d S {\displaystyle \mathrm {d} S} is a small change in the entropy of the system. Temperature and entropy are variables of the state of a system.

If an open system (in which mass may be exchanged with the environment) has several walls such that the mass transfer is through rigid walls separate from the heat and work transfers, then the first law may be written as

where d M i {\displaystyle dM_{i}} is the added mass of species i {\displaystyle i} and h i {\displaystyle h_{i}} is the corresponding enthalpy per unit mass. Note that generally d S ≠ δ Q / T {\displaystyle dS\neq \delta Q/T} in this case, as matter carries its own entropy. Instead, d S = δ Q / T + ∑ i s i d M i {\displaystyle dS=\delta Q/T+\textstyle {\sum _{i}}s_{i}\,dM_{i}}, where s i {\displaystyle s_{i}} is the entropy per unit mass of type i {\displaystyle i}, from which we recover the fundamental thermodynamic relation

because the chemical potential μ i {\displaystyle \mu _{i}} is the partial molar Gibbs free energy of species i {\displaystyle i} and the Gibbs free energy G ≡ H − T S {\displaystyle G\equiv H-TS}.
detectable_format:json_format