# Second law of thermodynamics

Thermodynamics :
The classical Carnot heat engine :
Branches
Classical
Statistical
Chemical
Quantum thermodynamics
Equilibrium / Non-equilibrium :
Laws
Zeroth
First
Second
Third :
Systems
Closed system
Open system
Isolated system
State
Equation of state
Ideal gas
Real gas
State of matter
Phase (matter)
Equilibrium
Control volume
Instruments
Processes
Isobaric
Isochoric
Isothermal
Adiabatic
Isentropic
Isenthalpic
Quasistatic
Polytropic
Free expansion
Reversibility
Irreversibility
Endoreversibility
Cycles
Heat engines
Heat pumps
Thermal efficiency :
System propertiesNote: Conjugate variables in italics
Property diagrams
Intensive and extensive properties
Process functions
Work
Heat
Functions of state
Temperature / Entropy (introduction)
Pressure / Volume
Chemical potential / Particle number
Vapor quality
Reduced properties :
Material properties
Property databases
Specific heat capacity 
$c=$
$T$$\partial S$$N$$\partial T$
Compressibility 
$\beta =-$
$1$$\partial V$$V$$\partial p$
Thermal expansion 
$\alpha =$
$1$$\partial V$$V$$\partial T$ :
Equations
Carnot's theorem
Clausius theorem
Fundamental relation
Ideal gas law
Maxwell relations
Onsager reciprocal relations
Bridgman's equations
Table of thermodynamic equations :
Potentials
Free energy
Free entropy
Internal energy $U(S,V)$Enthalpy $H(S,p)=U+pV$Helmholtz free energy $A(T,V)=U-TS$Gibbs free energy $G(T,p)=H-TS$ :
HistoryCulture
History
General
Entropy
Gas laws
"Perpetual motion" machines
Philosophy
Entropy and time
Entropy and life
Brownian ratchet
Maxwell's demon
Heat death paradox
Loschmidt's paradox
Synergetics
Theories
Caloric theory
Vis viva ("living force")
Mechanical equivalent of heat
Motive power
Key publications
An Inquiry Concerning the Source ... Friction
On the Equilibrium of Heterogeneous Substances
Reflections on the Motive Power of Fire
Timelines
Thermodynamics
Heat engines
ArtEducation
Maxwell's thermodynamic surface
Entropy as energy dispersal :
Scientists
Bernoulli
Boltzmann
Bridgman
Carathéodory
Carnot
Clapeyron
Clausius
de Donder
Duhem
Gibbs
von Helmholtz
Joule
Kelvin
Lewis
Massieu
Maxwell
von Mayer
Nernst
Onsager
Planck
Rankine
Smeaton
Stahl
Tait
Thompson
van der Waals
Waterston :
Other
Nucleation
Self-assembly
Self-organization
Order and disorder :
Category :
vte :
The second law of thermodynamics is a physical law based on universal empirical observation concerning heat and energy interconversions. A simple statement of the law is that heat always flows spontaneously from hotter to colder regions of matter (or 'downhill' in terms of the temperature gradient). Another statement is: "Not all heat can be converted into work in a cyclic process."
The second law of thermodynamics establishes the concept of entropy as a physical property of a thermodynamic system. It predicts whether processes are forbidden despite obeying the requirement of conservation of energy as expressed in the first law of thermodynamics and provides necessary criteria for spontaneous processes. For example, the first law allows the process of a cup falling off a table and breaking on the floor, as well as allowing the reverse process of the cup fragments coming back together and 'jumping' back onto the table, while the second law allows the former and denies the latter. The second law may be formulated by the observation that the entropy of isolated systems left to spontaneous evolution cannot decrease, as they always tend toward a state of thermodynamic equilibrium where the entropy is highest at the given internal energy. An increase in the combined entropy of system and surroundings accounts for the irreversibility of natural processes, often referred to in the concept of the arrow of time.
Historically, the second law was an empirical finding that was accepted as an axiom of thermodynamic theory. Statistical mechanics provides a microscopic explanation of the law in terms of probability distributions of the states of large assemblies of atoms or molecules. The second law has been expressed in many ways. Its first formulation, which preceded the proper definition of entropy and was based on caloric theory, is Carnot's theorem, formulated by the French scientist Sadi Carnot, who in 1824 showed that the efficiency of conversion of heat to work in a heat engine has an upper limit. The first rigorous definition of the second law based on the concept of entropy came from German scientist Rudolf Clausius in the 1850s and included his statement that heat can never pass from a colder to a warmer body without some other change, connected therewith, occurring at the same time.
The second law of thermodynamics allows the definition of the concept of thermodynamic temperature, but this has been formally delegated to the zeroth law of thermodynamics.

## Introduction

The first law of thermodynamics provides the definition of the internal energy of a thermodynamic system, and expresses its change for a closed system in terms of work and heat. It can be linked to the law of conservation of energy. Conceptually, the first law describes the fundamental principle that systems do not consume or 'use up' energy, that energy is neither created nor destroyed, but is simply converted from one form to another.
The second law is concerned with the direction of natural processes. It asserts that a natural process runs only in one sense, and is not reversible. That is, the state of a natural system itself can be reversed, but not without increasing the entropy of the system's surroundings, that is, both the state of the system plus the state of its surroundings cannot be together, fully reversed, without implying the destruction of entropy.
For example, when a path for conduction or radiation is made available, heat always flows spontaneously from a hotter to a colder body. Such phenomena are accounted for in terms of entropy change. A heat pump can reverse this heat flow, but the reversal process and the original process, both cause entropy production, thereby increasing the entropy of the system's surroundings. If an isolated system containing distinct subsystems is held initially in internal thermodynamic equilibrium by internal partitioning by impermeable walls between the subsystems, and then some operation makes the walls more permeable, then the system spontaneously evolves to reach a final new internal thermodynamic equilibrium, and its total entropy, $S$, increases.
In a reversible or quasi-static, idealized process of transfer of energy as heat to a closed thermodynamic system of interest, (which allows the entry or exit of energy – but not transfer of matter), from an auxiliary thermodynamic system, an infinitesimal increment ($\mathrm {d} S$) in the entropy of the system of interest is defined to result from an infinitesimal transfer of heat ($\delta Q$) to the system of interest, divided by the common thermodynamic temperature $(T)$ of the system of interest and the auxiliary thermodynamic system:
    $\mathrm {d} S={\frac {\delta Q}{T}}\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,{\text{(closed system; idealized, reversible process)}}.$
Different notations are used for an infinitesimal amount of heat $(\delta )$ and infinitesimal change of entropy $(\mathrm {d} )$ because entropy is a function of state, while heat, like work, is not.
For an actually possible infinitesimal process without exchange of mass with the surroundings, the second law requires that the increment in system entropy fulfills the inequality
    $\mathrm {d} S>{\frac {\delta Q}{T_{\text{surr}}}}\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,{\text{(closed system; actually possible, irreversible process).}}$
This is because a general process for this case (no mass exchange between the system and its surroundings) may include work being done on the system by its surroundings, which can have frictional or viscous effects inside the system, because a chemical reaction may be in progress, or because heat transfer actually occurs only irreversibly, driven by a finite difference between the system temperature (T) and the temperature of the surroundings (T$_{surr}$).
The equality still applies for pure heat flow (only heat flow, no change in chemical composition and mass),
    $\mathrm {d} S={\frac {\delta Q}{T}}\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,{\text{(actually possible quasistatic irreversible process without composition change).}}$
which is the basis of the accurate determination of the absolute entropy of pure substances from measured heat capacity curves and entropy changes at phase transitions, i.e. by calorimetry.
The zeroth law of thermodynamics in its usual short statement allows recognition that two bodies in a relation of thermal equilibrium have the same temperature, especially that a test body has the same temperature as a reference thermometric body. For a body in thermal equilibrium with another, there are indefinitely many empirical temperature scales, in general respectively depending on the properties of a particular reference thermometric body. The second law allows a distinguished temperature scale, which defines an absolute, thermodynamic temperature, independent of the properties of any particular reference thermometric body.

## Various statements of the law

The second law of thermodynamics may be expressed in many specific ways, the most prominent classical statements being the statement by Rudolf Clausius (1854), the statement by Lord Kelvin (1851), and the statement in axiomatic thermodynamics by Constantin Carathéodory (1909). These statements cast the law in general physical terms citing the impossibility of certain processes. The Clausius and the Kelvin statements have been shown to be equivalent.

### Carnot's principle

The historical origin of the second law of thermodynamics was in Sadi Carnot's theoretical analysis of the flow of heat in steam engines (1824). The centerpiece of that analysis, now known as a Carnot engine, is an ideal heat engine fictively operated in the limiting mode of extreme slowness known as quasi-static, so that the heat and work transfers are between subsystems that are always in their own internal states of thermodynamic equilibrium. It represents the theoretical maximum efficiency of a heat engine operating between any two given thermal or heat reservoirs at different temperatures. Carnot's principle was recognized by Carnot at a time when the caloric theory represented the dominant understanding of the nature of heat, before the recognition of the first law of thermodynamics, and before the mathematical expression of the concept of entropy. Interpreted in the light of the first law, Carnot's analysis is physically equivalent to the second law of thermodynamics, and remains valid today. Some samples from his book are:
       ...wherever there exists a difference of temperature, motive power can be produced.
       The production of motive power is then due in steam engines not to an actual consumption of caloric, but to its transportation from a warm body to a cold body ...
       The motive power of heat is independent of the agents employed to realize it; its quantity is fixed solely by the temperatures of the bodies between which is effected, finally, the transfer of caloric.
In modern terms, Carnot's principle may be stated more precisely:
    The efficiency of a quasi-static or reversible Carnot cycle depends only on the temperatures of the two heat reservoirs, and is the same, whatever the working substance. A Carnot engine operated in this way is the most efficient possible heat engine using those two temperatures.

### Clausius statement

The German scientist Rudolf Clausius laid the foundation for the second law of thermodynamics in 1850 by examining the relation between heat transfer and work. His formulation of the second law, which was published in German in 1854, is known as the Clausius statement:
   Heat can never pass from a colder to a warmer body without some other change, connected therewith, occurring at the same time.
The statement by Clausius uses the concept of 'passage of heat'. As is usual in thermodynamic discussions, this means 'net transfer of energy as heat', and does not refer to contributory transfers one way and the other.
Heat cannot spontaneously flow from cold regions to hot regions without external work being performed on the system, which is evident from ordinary experience of refrigeration, for example. In a refrigerator, heat is transferred from cold to hot, but only when forced by an external agent, the refrigeration system.

### Kelvin statements

Lord Kelvin expressed the second law in several wordings.
       It is impossible for a self-acting machine, unaided by any external agency, to convey heat from one body to another at a higher temperature.
       It is impossible, by means of inanimate material agency, to derive mechanical effect from any portion of matter by cooling it below the temperature of the coldest of the surrounding objects.

### Equivalence of the Clausius and the Kelvin statements

Suppose there is an engine violating the Kelvin statement: i.e., one that drains heat and converts it completely into work (the drained heat is fully converted to work) in a cyclic fashion without any other result. Now pair it with a reversed Carnot engine as shown by the right figure. The efficiency of a normal heat engine is η and so the efficiency of the reversed heat engine is 1/η. The net and sole effect of the combined pair of engines is to transfer heat ΔQ=Q( 1/η−1){\textstyle \Delta Q=Q\left({\frac {1}{\eta }}-1\right)} from the cooler reservoir to the hotter one, which violates the Clausius statement. This is a consequence of the first law of thermodynamics, as for the total system's energy to remain the same; Input+Output=0⟹(Q+Q$_c$)−Q/η=0{\textstyle {\text{Input}}+{\text{Output}}=0\implies (Q+Q_{c})-{\frac {Q}{\eta }}=0}, so therefore Q$_c$=Q( 1/η−1){\textstyle Q_{c}=Q\left({\frac {1}{\eta }}-1\right)}, where (1) the sign convention of heat is used in which heat entering into (leaving from) an engine is positive (negative) and (2) ${\frac {Q}{\eta }}$ is obtained by the definition of efficiency of the engine when the engine operation is not reversed. Thus a violation of the Kelvin statement implies a violation of the Clausius statement, i.e. the Clausius statement implies the Kelvin statement. We can prove in a similar manner that the Kelvin statement implies the Clausius statement, and hence the two are equivalent.

### Planck's proposition

Planck offered the following proposition as derived directly from experience. This is sometimes regarded as his statement of the second law, but he regarded it as a starting point for the derivation of the second law.
       It is impossible to construct an engine which will work in a complete cycle, and produce no effect except the production of work and cooling of a heat reservoir.

### Relation between Kelvin's statement and Planck's proposition

It is almost customary in textbooks to speak of the "Kelvin–Planck statement" of the law, as for example in the text by ter Haar and Wergeland. This version, also known as the heat engine statement, of the second law states that
       It is impossible to devise a cyclically operating device, the sole effect of which is to absorb energy in the form of heat from a single thermal reservoir and to deliver an equivalent amount of work.

### Planck's statement

Max Planck stated the second law as follows.
       Every process occurring in nature proceeds in the sense in which the sum of the entropies of all bodies taking part in the process is increased. In the limit, i.e. for reversible processes, the sum of the entropies remains unchanged.
Rather like Planck's statement is that of George Uhlenbeck and G. W. Ford for irreversible phenomena.
       ... in an irreversible or spontaneous change from one equilibrium state to another (as for example the equalization of temperature of two bodies A and B, when brought in contact) the entropy always increases.

### Principle of Carathéodory

Constantin Carathéodory formulated thermodynamics on a purely mathematical axiomatic foundation. His statement of the second law is known as the Principle of Carathéodory, which may be formulated as follows:
   In every neighborhood of any state S of an adiabatically enclosed system there are states inaccessible from S.
With this formulation, he described the concept of adiabatic accessibility for the first time and provided the foundation for a new subfield of classical thermodynamics, often called geometrical thermodynamics. It follows from Carathéodory's principle that quantity of energy quasi-statically transferred as heat is a holonomic process function, in other words, $\delta Q=TdS$.
Though it is almost customary in textbooks to say that Carathéodory's principle expresses the second law and to treat it as equivalent to the Clausius or to the Kelvin-Planck statements, such is not the case. To get all the content of the second law, Carathéodory's principle needs to be supplemented by Planck's principle, that isochoric work always increases the internal energy of a closed system that was initially in its own internal thermodynamic equilibrium.

### Planck's principle

In 1926, Max Planck wrote an important paper on the basics of thermodynamics. He indicated the principle
       The internal energy of a closed system is increased by an adiabatic process, throughout the duration of which, the volume of the system remains constant.
This formulation does not mention heat and does not mention temperature, nor even entropy, and does not necessarily implicitly rely on those concepts, but it implies the content of the second law. A closely related statement is that "Frictional pressure never does positive work." Planck wrote: "The production of heat by friction is irreversible."
Not mentioning entropy, this principle of Planck is stated in physical terms. It is very closely related to the Kelvin statement given just above. It is relevant that for a system at constant volume and mole numbers, the entropy is a monotonic function of the internal energy. Nevertheless, this principle of Planck is not actually Planck's preferred statement of the second law, which is quoted above, in a previous sub-section of the present section of this present article, and relies on the concept of entropy.
A statement that in a sense is complementary to Planck's principle is made by Claus Borgnakke and Richard E. Sonntag. They do not offer it as a full statement of the second law:
       ... there is only one way in which the entropy of a [closed] system can be decreased, and that is to transfer heat from the system.
Differing from Planck's just foregoing principle, this one is explicitly in terms of entropy change. Removal of matter from a system can also decrease its entropy.

### Relating the second law to the definition of temperature

The second law has been shown to be equivalent to the internal energy U defined as a convex function of the other extensive properties of the system. That is, when a system is described by stating its internal energy U, an extensive variable, as a function of its entropy S, volume V, and mol number N, i.e. U = U (S, V, N), then the temperature is equal to the partial derivative of the internal energy with respect to the entropy (essentially equivalent to the first TdS equation for V and N held constant):
    $T=\left({\frac {\partial U}{\partial S}}\right)_{V,N}$

### Second law statements, such as the Clausius inequality, involving radiative fluxes

The Clausius inequality, as well as some other statements of the second law, must be re-stated to have general applicability for all forms of heat transfer, i.e. scenarios involving radiative fluxes. For example, the integrand (đQ/T) of the Clausius expression applies to heat conduction and convection, and the case of ideal infinitesimal blackbody radiation (BR) transfer, but does not apply to most radiative transfer scenarios and in some cases has no physical meaning whatsoever. Consequently, the Clausius inequality was re-stated so that it is applicable to cycles with processes involving any form of heat transfer. The entropy transfer with radiative fluxes (δS$_{NetRad}$\delta S_{\text{NetRad}}) is taken separately from that due to heat transfer by conduction and convection (δQ$_{CC}$\delta Q_{CC}), where the temperature is evaluated at the system boundary where the heat transfer occurs. The modified Clausius inequality, for all heat transfer scenarios, can then be expressed as,$\int _{\text{cycle}}({\frac {\delta Q_{CC}}{T_{b}}}+\delta S_{\text{NetRad}})\leq 0$
In a nutshell, the Clausius inequality is saying that when a cycle is completed, the change in the state property S will be zero, so the entropy that was produced during the cycle must have transferred out of the system by heat transfer. The δ\delta (or đ) indicates a path dependent integration.
Due to the inherent emission of radiation from all matter, most entropy flux calculations involve incident, reflected and emitted radiative fluxes. The energy and entropy of unpolarized blackbody thermal radiation, is calculated using the spectral energy and entropy radiance expressions derived by Max Planck using equilibrium statistical mechanics,$K_{\nu }={\frac {2h}{c^{2}}}{\frac {\nu ^{3}}{\exp \left({\frac {h\nu }{kT}}\right)-1}},$ $L_{\nu }={\frac {2k\nu ^{2}}{c^{2}}}((1+{\frac {c^{2}K_{\nu }}{2h\nu ^{3}}})\ln(1+{\frac {c^{2}K_{\nu }}{2h\nu ^{3}}})-({\frac {c^{2}K_{\nu }}{2h\nu ^{3}}})\ln({\frac {c^{2}K_{\nu }}{2h\nu ^{3}}}))$ where c is the speed of light, k is the Boltzmann constant, h is the Planck constant, ν is frequency, and the quantities K$_v$ and L$_v$ are the energy and entropy fluxes per unit frequency, area, and solid angle. In deriving this blackbody spectral entropy radiance, with the goal of deriving the blackbody energy formula, Planck postulated that the energy of a photon was quantized (partly to simplify the mathematics), thereby starting quantum theory.
A non-equilibrium statistical mechanics approach has also been used to obtain the same result as Planck, indicating it has wider significance and represents a non-equilibrium entropy. A plot of K$_v$ versus frequency (v) for various values of temperature (T) gives a family of blackbody radiation energy spectra, and likewise for the entropy spectra. For non-blackbody radiation (NBR) emission fluxes, the spectral entropy radiance L$_v$ is found by substituting K$_v$ spectral energy radiance data into the L$_v$ expression (noting that emitted and reflected entropy fluxes are, in general, not independent). For the emission of NBR, including graybody radiation (GR), the resultant emitted entropy flux, or radiance L, has a higher ratio of entropy-to-energy (L/K), than that of BR. That is, the entropy flux of NBR emission is farther removed from the conduction and convection q/T result, than that for BR emission. This observation is consistent with Max Planck's blackbody radiation energy and entropy formulas and is consistent with the fact that blackbody radiation emission represents the maximum emission of entropy for all materials with the same temperature, as well as the maximum entropy emission for all radiation with the same energy radiance.

### Generalized conceptual statement of the second law principle

Second law analysis is valuable in scientific and engineering analysis in that it provides a number of benefits over energy analysis alone, including the basis for determining energy quality (exergy content), understanding fundamental physical phenomena, and improving performance evaluation and optimization. As a result, a conceptual statement of the principle is very useful in engineering analysis. Thermodynamic systems can be categorized by the four combinations of either entropy (S) up or down, and uniformity (Y) – between system and its environment – up or down. This 'special' category of processes, category IV, is characterized by movement in the direction of low disorder and low uniformity, counteracting the second law tendency towards uniformity and disorder.
The second law can be conceptually stated as follows: Matter and energy have the tendency to reach a state of uniformity or internal and external equilibrium, a state of maximum disorder (entropy). Real non-equilibrium processes always produce entropy, causing increased disorder in the universe, while idealized reversible processes produce no entropy and no process is known to exist that destroys entropy. The tendency of a system to approach uniformity may be counteracted, and the system may become more ordered or complex, by the combination of two things, a work or exergy source and some form of instruction or intelligence. Where 'exergy' is the thermal, mechanical, electric or chemical work potential of an energy source or flow, and 'instruction or intelligence', although subjective, is in the context of the set of category IV processes.
Consider a category IV example of robotic manufacturing and assembly of vehicles in a factory. The robotic machinery requires electrical work input and instructions, but when completed, the manufactured products have less uniformity with their surroundings, or more complexity (higher order) relative to the raw materials they were made from. Thus, system entropy or disorder decreases while the tendency towards uniformity between the system and its environment is counteracted. In this example, the instructions, as well as the source of work may be internal or external to the system, and they may or may not cross the system boundary. To illustrate, the instructions may be pre-coded and the electrical work may be stored in an energy storage system on-site. Alternatively, the control of the machinery may be by remote operation over a communications network, while the electric work is supplied to the factory from the local electric grid. In addition, humans may directly play, in whole or in part, the role that the robotic machinery plays in manufacturing. In this case, instructions may be involved, but intelligence is either directly responsible, or indirectly responsible, for the direction or application of work in such a way as to counteract the tendency towards disorder and uniformity.
There are also situations where the entropy spontaneously decreases by means of energy and entropy transfer. When thermodynamic constraints are not present, spontaneously energy or mass, as well as accompanying entropy, may be transferred out of a system in a progress to reach external equilibrium or uniformity in intensive properties of the system with its surroundings. This occurs spontaneously because the energy or mass transferred from the system to its surroundings results in a higher entropy in the surroundings, that is, it results in higher overall entropy of the system plus its surroundings. Note that this transfer of entropy requires dis-equilibrium in properties, such as a temperature difference. One example of this is the cooling crystallization of water that can occur when the system's surroundings are below freezing temperatures. Unconstrained heat transfer can spontaneously occur, leading to water molecules freezing into a crystallized structure of reduced disorder (sticking together in a certain order due to molecular attraction). The entropy of the system decreases, but the system approaches uniformity with its surroundings (category III).
On the other hand, consider the refrigeration of water in a warm environment. Due to refrigeration, as heat is extracted from the water, the temperature and entropy of the water decreases, as the system moves further away from uniformity with its warm surroundings or environment (category IV). The main point, take-away, is that refrigeration not only requires a source of work, it requires designed equipment, as well as pre-coded or direct operational intelligence or instructions to achieve the desired refrigeration effect.

## Corollaries
### Perpetual motion of the second kind

Before the establishment of the second law, many people who were interested in inventing a perpetual motion machine had tried to circumvent the restrictions of first law of thermodynamics by extracting the massive internal energy of the environment as the power of the machine. Such a machine is called a "perpetual motion machine of the second kind". The second law declared the impossibility of such machines.

### Carnot's theorem

Carnot's theorem (1824) is a principle that limits the maximum efficiency for any possible engine. The efficiency solely depends on the temperature difference between the hot and cold thermal reservoirs. Carnot's theorem states:
* All irreversible heat engines between two heat reservoirs are less efficient than a Carnot engine operating between the same reservoirs.
* All reversible heat engines between two heat reservoirs are equally efficient with a Carnot engine operating between the same reservoirs.
In his ideal model, the heat of caloric converted into work could be reinstated by reversing the motion of the cycle, a concept subsequently known as thermodynamic reversibility. Carnot, however, further postulated that some caloric is lost, not being converted to mechanical work. Hence, no real heat engine could realize the Carnot cycle's reversibility and was condemned to be less efficient.
Though formulated in terms of caloric (see the obsolete caloric theory), rather than entropy, this was an early insight into the second law.

### Clausius inequality

The Clausius theorem (1854) states that in a cyclic process
    $\oint {\frac {\delta Q}{T_{\text{surr}}}}\leq 0.$
The equality holds in the reversible case and the strict inequality holds in the irreversible case, with T$_{surr}$ as the temperature of the heat bath (surroundings) here. The reversible case is used to introduce the state function entropy. This is because in cyclic processes the variation of a state function is zero from state functionality.

### Thermodynamic temperature

For an arbitrary heat engine, the efficiency is:
where W$_n$ is the net work done by the engine per cycle, q$_H$ > 0 is the heat added to the engine from a hot reservoir, and q$_C$ = −|q$_C$| < 0 is waste heat given off to a cold reservoir from the engine. Thus the efficiency depends only on the ratio |q$_C$| / |q$_H$|.
Carnot's theorem states that all reversible engines operating between the same heat reservoirs are equally efficient. Thus, any reversible heat engine operating between temperatures T$_H$ and T$_C$ must have the same efficiency, that is to say, the efficiency is a function of temperatures only:
In addition, a reversible heat engine operating between temperatures T$_1$ and T$_3$ must have the same efficiency as one consisting of two cycles, one between T$_1$ and another (intermediate) temperature T$_2$, and the second between T$_2$ and T$_3$, where T$_1$ > T$_2$ > T$_3$. This is because, if a part of the two cycle engine is hidden such that it is recognized as an engine between the reservoirs at the temperatures T$_1$ and T$_3$, then the efficiency of this engine must be same to the other engine at the same reservoirs. If we choose engines such that work done by the one cycle engine and the two cycle engine are same, then the efficiency of each heat engine is written as the below.
    $\eta _{1}=1-{\frac {|q_{3}|}{|q_{1}|}}=1-f(T_{1},T_{3})$,
    $\eta _{2}=1-{\frac {|q_{2}|}{|q_{1}|}}=1-f(T_{1},T_{2})$,
    $\eta _{3}=1-{\frac {|q_{3}|}{|q_{2}|}}=1-f(T_{2},T_{3})$.
Here, the engine 1 is the one cycle engine, and the engines 2 and 3 make the two cycle engine where there is the intermediate reservoir at T$_2$. We also have used the fact that the heat $q_{2}$ passes through the intermediate thermal reservoir at $T_{2}$ without losing its energy. (I.e., $q_{2}$ is not lost during its passage through the reservoir at $T_{2}$.) This fact can be proved by the following.
    ${\begin{aligned}&{{\eta }_{2}}=1-{\frac {|{{q}_{2}}|}{|{{q}_{1}}|}}\to |{{w}_{2}}|=|{{q}_{1}}|-|{{q}_{2}}|,\\&{{\eta }_{3}}=1-{\frac {|{{q}_{3}}|}{|{{q}_{2}}^{*}|}}\to |{{w}_{3}}|=|{{q}_{2}}^{*}|-|{{q}_{3}}|,\\&|{{w}_{2}}|+|{{w}_{3}}|=(|{{q}_{1}}|-|{{q}_{2}}|)+(|{{q}_{2}}^{*}|-|{{q}_{3}}|),\\&{{\eta }_{1}}=1-{\frac {|{{q}_{3}}|}{|{{q}_{1}}|}}={\frac {(|{{w}_{2}}|+|{{w}_{3}}|)}{|{{q}_{1}}|}}={\frac {(|{{q}_{1}}|-|{{q}_{2}}|)+(|{{q}_{2}}^{*}|-|{{q}_{3}}|)}{|{{q}_{1}}|}}.\\\end{aligned}}$
In order to have the consistency in the last equation, the heat $q_{2}$ flown from the engine 2 to the intermediate reservoir must be equal to the heat $q_{2}^{*}$ flown out from the reservoir to the engine 3.
Then
    $f(T_{1},T_{3})={\frac {|q_{3}|}{|q_{1}|}}={\frac {|q_{2}||q_{3}|}{|q_{1}||q_{2}|}}=f(T_{1},T_{2})f(T_{2},T_{3}).$
Now consider the case where $T_{1}$ is a fixed reference temperature: the temperature of the triple point of water as 273.16 K; $T_{1}=\mathrm {273.16~K}$. Then for any T$_2$ and T$_3$,
    $f(T_{2},T_{3})={\frac {f(T_{1},T_{3})}{f(T_{1},T_{2})}}={\frac {273.16{\text{ K}}\cdot f(T_{1},T_{3})}{273.16{\text{ K}}\cdot f(T_{1},T_{2})}}.$
Therefore, if thermodynamic temperature T* is defined by
    $T^{*}=273.16{\text{ K}}\cdot f(T_{1},T)$
then the function f, viewed as a function of thermodynamic temperatures, is simply
    $f(T_{2},T_{3})=f(T_{2}^{*},T_{3}^{*})={\frac {T_{3}^{*}}{T_{2}^{*}}},$
and the reference temperature T$_1$* = 273.16 K × f(T$_1$,T$_1$) = 273.16 K. (Any reference temperature and any positive numerical value could be used – the choice here corresponds to the Kelvin scale.)

### Entropy

According to the Clausius equality, for a reversible process
    $\oint {\frac {\delta Q}{T}}=0$
That means the line integral $\int _{L}{\frac {\delta Q}{T}}$ is path independent for reversible processes.
So we can define a state function S called entropy, which for a reversible process or for pure heat transfer satisfies
    $dS={\frac {\delta Q}{T}}$
With this we can only obtain the difference of entropy by integrating the above formula. To obtain the absolute value, we need the third law of thermodynamics, which states that S = 0 at absolute zero for perfect crystals.
For any irreversible process, since entropy is a state function, we can always connect the initial and terminal states with an imaginary reversible process and integrating on that path to calculate the difference in entropy.
Now reverse the reversible process and combine it with the said irreversible process. Applying the Clausius inequality on this loop, with T$_{surr}$ as the temperature of the surroundings,
    $-\Delta S+\int {\frac {\delta Q}{T_{\text{surr}}}}=\oint {\frac {\delta Q}{T_{\text{surr}}}}\leq 0$
Thus,
    $\Delta S\geq \int {\frac {\delta Q}{T_{\text{surr}}}}$
where the equality holds if the transformation is reversible. If the process is an adiabatic process, then $\delta Q=0$, so $\Delta S\geq 0$.

### Energy, available useful work

An important and revealing idealized special case is to consider applying the second law to the scenario of an isolated system (called the total system or universe), made up of two parts: a sub-system of interest, and the sub-system's surroundings. These surroundings are imagined to be so large that they can be considered as an unlimited heat reservoir at temperature T$_R$ and pressure P$_R$ – so that no matter how much heat is transferred to (or from) the sub-system, the temperature of the surroundings will remain T$_R$; and no matter how much the volume of the sub-system expands (or contracts), the pressure of the surroundings will remain P$_R$.
Whatever changes to dS and dS$_R$ occur in the entropies of the sub-system and the surroundings individually, the entropy S$_{tot}$ of the isolated total system must not decrease according to the second law of thermodynamics:
    $dS_{\mathrm {tot} }=dS+dS_{\text{R}}\geq 0$
According to the first law of thermodynamics, the change dU in the internal energy of the sub-system is the sum of the heat δq added to the sub-system, minus any work δw done by the sub-system, plus any net chemical energy entering the sub-system d Σμ$_{iR}$N$_i$, so that:
    $dU=\delta q-\delta w+d\left(\sum \mu _{iR}N_{i}\right)$
where μ$_{iR}$ are the chemical potentials of chemical species in the external surroundings.
Now the heat leaving the reservoir and entering the sub-system is
    $\delta q=T_{\text{R}}(-dS_{\text{R}})\leq T_{\text{R}}dS$
where we have first used the definition of entropy in classical thermodynamics (alternatively, in statistical thermodynamics, the relation between entropy change, temperature and absorbed heat can be derived); and then the second law inequality from above.
It therefore follows that any net work δw done by the sub-system must obey
    $\delta w\leq -dU+T_{\text{R}}dS+\sum \mu _{iR}dN_{i}$
It is useful to separate the work δw done by the subsystem into the useful work δw$_u$ that can be done by the sub-system, over and beyond the work p$_R$ dV done merely by the sub-system expanding against the surrounding external pressure, giving the following relation for the useful work (exergy) that can be done:
    $\delta w_{u}\leq -d\left(U-T_{\text{R}}S+p_{\text{R}}V-\sum \mu _{iR}N_{i}\right)$
It is convenient to define the right-hand-side as the exact derivative of a thermodynamic potential, called the availability or exergy E of the subsystem,
    $E=U-T_{\text{R}}S+p_{\text{R}}V-\sum \mu _{iR}N_{i}$
The second law therefore implies that for any process which can be considered as divided simply into a subsystem, and an unlimited temperature and pressure reservoir with which it is in contact,
    $dE+\delta w_{u}\leq 0$
i.e. the change in the subsystem's exergy plus the useful work done by the subsystem (or, the change in the subsystem's exergy less any work, additional to that done by the pressure reservoir, done on the system) must be less than or equal to zero.
In sum, if a proper infinite-reservoir-like reference state is chosen as the system surroundings in the real world, then the second law predicts a decrease in E for an irreversible process and no change for a reversible process.
    $dS_{\text{tot}}\geq 0$ is equivalent to $dE+\delta w_{u}\leq 0$
This expression together with the associated reference state permits a design engineer working at the macroscopic scale (above the thermodynamic limit) to utilize the second law without directly measuring or considering entropy change in a total isolated system (see also Process engineer). Those changes have already been considered by the assumption that the system under consideration can reach equilibrium with the reference state without altering the reference state. An efficiency for a process or collection of processes that compares it to the reversible ideal may also be found (see Exergy efficiency).
This approach to the second law is widely utilized in engineering practice, environmental accounting, systems ecology, and other disciplines.

## Direction of spontaneous processes

The second law determines whether a proposed physical or chemical process is forbidden or may occur spontaneously. For isolated systems, no energy is provided by the surroundings and the second law requires that the entropy of the system alone must increase: ΔS > 0. Examples of spontaneous physical processes in isolated systems include the following:
* 1) Heat can be transferred from a region of higher temperature to a lower temperature (but not the reverse).
* 2) Mechanical energy can be converted to thermal energy (but not the reverse).
* 3) A solute can move from a region of higher concentration to a region of lower concentration (but not the reverse).
However, for some non-isolated systems which can exchange energy with their surroundings, the surroundings exchange enough heat with the system, or do sufficient work on the system, so that the processes occur in the opposite direction. This is possible provided the total entropy change of the system plus the surroundings is positive as required by the second law: ΔS$_{tot}$ = ΔS + ΔS$_R$ > 0. For the three examples given above:
* 1) Heat can be transferred from a region of lower temperature to a higher temperature in a refrigerator or in a heat pump. These machines must provide sufficient work to the system.
* 2) Thermal energy can be converted to mechanical work in a heat engine, if sufficient heat is also expelled to the surroundings.
* 3) A solute can move from a region of lower concentration to a region of higher concentration in the biochemical process of active transport, if sufficient work is provided by a concentration gradient of a chemical such as ATP or by an electrochemical gradient.

### Second law in chemical thermodynamics

For a spontaneous chemical process in a closed system at constant temperature and pressure without non-PV work, the Clausius inequality ΔS > Q/T$_{surr}$ transforms into a condition for the change in Gibbs free energy
    $\Delta G<0$
or dG < 0. For a similar process at constant temperature and volume, the change in Helmholtz free energy must be negative, $\Delta A<0$. Thus, a negative value of the change in free energy (G or A) is a necessary condition for a process to be spontaneous. This is the most useful form of the second law of thermodynamics in chemistry, where free-energy changes can be calculated from tabulated enthalpies of formation and standard molar entropies of reactants and products. The chemical equilibrium condition at constant T and p without electrical work is dG = 0.

## History

The first theory of the conversion of heat into mechanical work is due to Nicolas Léonard Sadi Carnot in 1824. He was the first to realize correctly that the efficiency of this conversion depends on the difference of temperature between an engine and its surroundings.
Recognizing the significance of James Prescott Joule's work on the conservation of energy, Rudolf Clausius was the first to formulate the second law during 1850, in this form: heat does not flow spontaneously from cold to hot bodies. While common knowledge now, this was contrary to the caloric theory of heat popular at the time, which considered heat as a fluid. From there he was able to infer the principle of Sadi Carnot and the definition of entropy (1865).
Established during the 19th century, the Kelvin-Planck statement of the second law says, "It is impossible for any device that operates on a cycle to receive heat from a single reservoir and produce a net amount of work." This statement was shown to be equivalent to the statement of Clausius.
The ergodic hypothesis is also important for the Boltzmann approach. It says that, over long periods of time, the time spent in some region of the phase space of microstates with the same energy is proportional to the volume of this region, i.e. that all accessible microstates are equally probable over a long period of time. Equivalently, it says that time average and average over the statistical ensemble are the same.
There is a traditional doctrine, starting with Clausius, that entropy can be understood in terms of molecular 'disorder' within a macroscopic system. This doctrine is obsolescent.

### Account given by Clausius

In 1865, the German physicist Rudolf Clausius stated what he called the "second fundamental theorem in the mechanical theory of heat" in the following form:
    $\int {\frac {\delta Q}{T}}=-N$
where Q is heat, T is temperature and N is the "equivalence-value" of all uncompensated transformations involved in a cyclical process. Later, in 1865, Clausius would come to define "equivalence-value" as entropy. On the heels of this definition, that same year, the most famous version of the second law was read in a presentation at the Philosophical Society of Zurich on April 24, in which, in the end of his presentation, Clausius concludes:
   The entropy of the universe tends to a maximum.
This statement is the best-known phrasing of the second law. Because of the looseness of its language, e.g. universe, as well as lack of specific conditions, e.g. open, closed, or isolated, many people take this simple statement to mean that the second law of thermodynamics applies virtually to every subject imaginable. This is not true; this statement is only a simplified version of a more extended and precise description.
In terms of time variation, the mathematical statement of the second law for an isolated system undergoing an arbitrary transformation is:
    ${\frac {dS}{dt}}\geq 0$
where
    S is the entropy of the system and
    t is time.
The equality sign applies after equilibration. An alternative way of formulating of the second law for isolated systems is:
    ${\frac {dS}{dt}}={\dot {S}}_{\text{i}}$ with ${\dot {S}}_{\text{i}}\geq 0$
with ${\dot {S}}_{\text{i}}$ the sum of the rate of entropy production by all processes inside the system. The advantage of this formulation is that it shows the effect of the entropy production. The rate of entropy production is a very important concept since it determines (limits) the efficiency of thermal machines. Multiplied with ambient temperature $T_{\text{a}}$ it gives the so-called dissipated energy $P_{\text{diss}}=T_{\text{a}}{\dot {S}}_{\text{i}}$.
The expression of the second law for closed systems (so, allowing heat exchange and moving boundaries, but not exchange of matter) is:
    ${\frac {dS}{dt}}={\frac {\dot {Q}}{T}}+{\dot {S}}_{\text{i}}$ with ${\dot {S}}_{\text{i}}\geq 0$
Here,
    ${\dot {Q}}$ is the heat flow into the system
    $T$ is the temperature at the point where the heat enters the system.
The equality sign holds in the case that only reversible processes take place inside the system. If irreversible processes take place (which is the case in real systems in operation) the >-sign holds. If heat is supplied to the system at several places we have to take the algebraic sum of the corresponding terms.
For open systems (also allowing exchange of matter):
    ${\frac {dS}{dt}}={\frac {\dot {Q}}{T}}+{\dot {S}}+{\dot {S}}_{\text{i}}$ with ${\dot {S}}_{\text{i}}\geq 0$
Here, ${\dot {S}}$ is the flow of entropy into the system associated with the flow of matter entering the system. It should not be confused with the time derivative of the entropy. If matter is supplied at several places we have to take the algebraic sum of these contributions.

## Statistical mechanics

Statistical mechanics gives an explanation for the second law by postulating that a material is composed of atoms and molecules which are in constant motion. A particular set of positions and velocities for each particle in the system is called a microstate of the system and because of the constant motion, the system is constantly changing its microstate. Statistical mechanics postulates that, in equilibrium, each microstate that the system might be in is equally likely to occur, and when this assumption is made, it leads directly to the conclusion that the second law must hold in a statistical sense. That is, the second law will hold on average, with a statistical variation on the order of 1/√N where N is the number of particles in the system. For everyday (macroscopic) situations, the probability that the second law will be violated is practically zero. However, for systems with a small number of particles, thermodynamic parameters, including the entropy, may show significant statistical deviations from that predicted by the second law. Classical thermodynamic theory does not deal with these statistical variations.

## Derivation from statistical mechanics

The first mechanical argument of the Kinetic theory of gases that molecular collisions entail an equalization of temperatures and hence a tendency towards equilibrium was due to James Clerk Maxwell in 1860; Ludwig Boltzmann with his H-theorem of 1872 also argued that due to collisions gases should over time tend toward the Maxwell–Boltzmann distribution.
Due to Loschmidt's paradox, derivations of the second law have to make an assumption regarding the past, namely that the system is uncorrelated at some time in the past; this allows for simple probabilistic treatment. This assumption is usually thought as a boundary condition, and thus the second law is ultimately a consequence of the initial conditions somewhere in the past, probably at the beginning of the universe (the Big Bang), though other scenarios have also been suggested.
Given these assumptions, in statistical mechanics, the second law is not a postulate, rather it is a consequence of the fundamental postulate, also known as the equal prior probability postulate, so long as one is clear that simple probability arguments are applied only to the future, while for the past there are auxiliary sources of information which tell us that it was low entropy. The first part of the second law, which states that the entropy of a thermally isolated system can only increase, is a trivial consequence of the equal prior probability postulate, if we restrict the notion of the entropy to systems in thermal equilibrium. The entropy of an isolated system in thermal equilibrium containing an amount of energy of $E$ is:
    $S=k_{\mathrm {B} }\ln \left[\Omega \left(E\right)\right]$
where $\Omega \left(E\right)$ is the number of quantum states in a small interval between $E$ and $E+\delta E$. Here $\delta E$ is a macroscopically small energy interval that is kept fixed. Strictly speaking this means that the entropy depends on the choice of $\delta E$. However, in the thermodynamic limit (i.e. in the limit of infinitely large system size), the specific entropy (entropy per unit volume or per unit mass) does not depend on $\delta E$.
Suppose we have an isolated system whose macroscopic state is specified by a number of variables. These macroscopic variables can, e.g., refer to the total volume, the positions of pistons in the system, etc. Then $\Omega$ will depend on the values of these variables. If a variable is not fixed, (e.g. we do not clamp a piston in a certain position), then because all the accessible states are equally likely in equilibrium, the free variable in equilibrium will be such that $\Omega$ is maximized at the given energy of the isolated system as that is the most probable situation in equilibrium.
If the variable was initially fixed to some value then upon release and when the new equilibrium has been reached, the fact the variable will adjust itself so that $\Omega$ is maximized, implies that the entropy will have increased or it will have stayed the same (if the value at which the variable was fixed happened to be the equilibrium value). Suppose we start from an equilibrium situation and we suddenly remove a constraint on a variable. Then right after we do this, there are a number $\Omega$ of accessible microstates, but equilibrium has not yet been reached, so the actual probabilities of the system being in some accessible state are not yet equal to the prior probability of $1/\Omega$. We have already seen that in the final equilibrium state, the entropy will have increased or have stayed the same relative to the previous equilibrium state. Boltzmann's H-theorem, however, proves that the quantity H increases monotonically as a function of time during the intermediate out of equilibrium state.

### Derivation of the entropy change for reversible processes

The second part of the second law states that the entropy change of a system undergoing a reversible process is given by:
    $dS={\frac {\delta Q}{T}}$
where the temperature is defined as:
    ${\frac {1}{k_{\mathrm {B} }T}}\equiv \beta \equiv {\frac {d\ln \left[\Omega \left(E\right)\right]}{dE}}$
See Microcanonical ensemble for the justification for this definition. Suppose that the system has some external parameter, x, that can be changed. In general, the energy eigenstates of the system will depend on x. According to the adiabatic theorem of quantum mechanics, in the limit of an infinitely slow change of the system's Hamiltonian, the system will stay in the same energy eigenstate and thus change its energy according to the change in energy of the energy eigenstate it is in.
The generalized force, X, corresponding to the external variable x is defined such that $Xdx$ is the work performed by the system if x is increased by an amount dx. For example, if x is the volume, then X is the pressure. The generalized force for a system known to be in energy eigenstate $E_{r}$ is given by:
    $X=-{\frac {dE_{r}}{dx}}$
Since the system can be in any energy eigenstate within an interval of $\delta E$, we define the generalized force for the system as the expectation value of the above expression:
    $X=-\left\langle {\frac {dE_{r}}{dx}}\right\rangle \,$
To evaluate the average, we partition the $\Omega \left(E\right)$ energy eigenstates by counting how many of them have a value for ${\frac {dE_{r}}{dx}}$ within a range between $Y$ and $Y+\delta Y$. Calling this number $\Omega _{Y}\left(E\right)$, we have:
    $\Omega \left(E\right)=\sum _{Y}\Omega _{Y}\left(E\right)\,$
The average defining the generalized force can now be written:
    $X=-{\frac {1}{\Omega \left(E\right)}}\sum _{Y}Y\Omega _{Y}\left(E\right)\,$
We can relate this to the derivative of the entropy with respect to x at constant energy E as follows. Suppose we change x to x + dx. Then $\Omega \left(E\right)$ will change because the energy eigenstates depend on x, causing energy eigenstates to move into or out of the range between $E$ and $E+\delta E$. Let's focus again on the energy eigenstates for which dE$_r$/dx {\textstyle {\frac {dE_{r}}{dx}}} lies within the range between $Y$ and $Y+\delta Y$. Since these energy eigenstates increase in energy by Y dx, all such energy eigenstates that are in the interval ranging from E – Y dx to E move from below E to above E. There are
    $N_{Y}\left(E\right)={\frac {\Omega _{Y}\left(E\right)}{\delta E}}Ydx\,$
such energy eigenstates. If $Ydx\leq \delta E$, all these energy eigenstates will move into the range between $E$ and $E+\delta E$ and contribute to an increase in $\Omega$. The number of energy eigenstates that move from below $E+\delta E$ to above $E+\delta E$ is given by $N_{Y}\left(E+\delta E\right)$. The difference
    $N_{Y}\left(E\right)-N_{Y}\left(E+\delta E\right)\,$
is thus the net contribution to the increase in $\Omega$. If Y dx is larger than $\delta E$ there will be the energy eigenstates that move from below E to above $E+\delta E$. They are counted in both $N_{Y}\left(E\right)$ and $N_{Y}\left(E+\delta E\right)$, therefore the above expression is also valid in that case.
Expressing the above expression as a derivative with respect to E and summing over Y yields the expression:
    $\left({\frac {\partial \Omega }{\partial x}}\right)_{E}=-\sum _{Y}Y\left({\frac {\partial \Omega _{Y}}{\partial E}}\right)_{x}=\left({\frac {\partial \left(\Omega X\right)}{\partial E}}\right)_{x}\,$
The logarithmic derivative of $\Omega$ with respect to x is thus given by:
    $\left({\frac {\partial \ln \left(\Omega \right)}{\partial x}}\right)_{E}=\beta X+\left({\frac {\partial X}{\partial E}}\right)_{x}\,$
The first term is intensive, i.e. it does not scale with system size. In contrast, the last term scales as the inverse system size and will thus vanish in the thermodynamic limit. We have thus found that:
    $\left({\frac {\partial S}{\partial x}}\right)_{E}={\frac {X}{T}}\,$
Combining this with
    $\left({\frac {\partial S}{\partial E}}\right)_{x}={\frac {1}{T}}\,$
gives:
    $dS=\left({\frac {\partial S}{\partial E}}\right)_{x}dE+\left({\frac {\partial S}{\partial x}}\right)_{E}dx={\frac {dE}{T}}+{\frac {X}{T}}dx={\frac {\delta Q}{T}}\,$

### Derivation for systems described by the canonical ensemble

If a system is in thermal contact with a heat bath at some temperature T then, in equilibrium, the probability distribution over the energy eigenvalues are given by the canonical ensemble:
    $P_{j}={\frac {\exp \left(-{\frac {E_{j}}{k_{\mathrm {B} }T}}\right)}{Z}}$
Here Z is a factor that normalizes the sum of all the probabilities to 1, this function is known as the partition function. We now consider an infinitesimal reversible change in the temperature and in the external parameters on which the energy levels depend. It follows from the general formula for the entropy:
    $S=-k_{\mathrm {B} }\sum _{j}P_{j}\ln \left(P_{j}\right)$
that
    $dS=-k_{\mathrm {B} }\sum _{j}\ln \left(P_{j}\right)dP_{j}$
Inserting the formula for $P_{j}$ for the canonical ensemble in here gives:
    $dS={\frac {1}{T}}\sum _{j}E_{j}dP_{j}={\frac {1}{T}}\sum _{j}d\left(E_{j}P_{j}\right)-{\frac {1}{T}}\sum _{j}P_{j}dE_{j}={\frac {dE+\delta W}{T}}={\frac {\delta Q}{T}}$

### Initial conditions at the Big Bang

As elaborated above, it is thought that the second law of thermodynamics is a result of the very low-entropy initial conditions at the Big Bang. From a statistical point of view, these were very special conditions. On the other hand, they were quite simple, as the universe - or at least the part thereof from which the observable universe developed - seems to have been extremely uniform.
This may seem somewhat paradoxical, since in many physical systems uniform conditions (e.g. mixed rather than separated gases) have high entropy. The paradox is solved once realizing that gravitational systems have negative heat capacity, so that when gravity is important, uniform conditions (e.g. gas of uniform density) in fact have lower entropy compared to non-uniform ones (e.g. black holes in empty space). Yet another approach is that the universe had high (or even maximal) entropy given its size, but as the universe grew it rapidly came out of thermodynamic equilibrium, its entropy only slightly increased compared to the increase in maximal possible entropy, and thus it has arrived at a very low entropy when compared to the much larger possible maximum given its later size.
As for the reason why initial conditions were such, one suggestion is that cosmological inflation was enough to wipe off non-smoothness, while another is that the universe was created spontaneously where the mechanism of creation implies low-entropy initial conditions.

## Living organisms

There are two principal ways of formulating thermodynamics, (a) through passages from one state of thermodynamic equilibrium to another, and (b) through cyclic processes, by which the system is left unchanged, while the total entropy of the surroundings is increased. These two ways help to understand the processes of life. The thermodynamics of living organisms has been considered by many authors, including Erwin Schrödinger (in his book What is Life?) and Léon Brillouin.
To a fair approximation, living organisms may be considered as examples of (b). Approximately, an animal's physical state cycles by the day, leaving the animal nearly unchanged. Animals take in food, water, and oxygen, and, as a result of metabolism, give out breakdown products and heat. Plants take in radiative energy from the sun, which may be regarded as heat, and carbon dioxide and water. They give out oxygen. In this way they grow. Eventually they die, and their remains rot away, turning mostly back into carbon dioxide and water. This can be regarded as a cyclic process. Overall, the sunlight is from a high temperature source, the sun, and its energy is passed to a lower temperature sink, i.e. radiated into space. This is an increase of entropy of the surroundings of the plant. Thus animals and plants obey the second law of thermodynamics, considered in terms of cyclic processes.
Furthermore, the ability of living organisms to grow and increase in complexity, as well as to form correlations with their environment in the form of adaption and memory, is not opposed to the second law – rather, it is akin to general results following from it: Under some definitions, an increase in entropy also results in an increase in complexity, and for a finite system interacting with finite reservoirs, an increase in entropy is equivalent to an increase in correlations between the system and the reservoirs.
Living organisms may be considered as open systems, because matter passes into and out from them. Thermodynamics of open systems is currently often considered in terms of passages from one state of thermodynamic equilibrium to another, or in terms of flows in the approximation of local thermodynamic equilibrium. The problem for living organisms may be further simplified by the approximation of assuming a steady state with unchanging flows. General principles of entropy production for such approximations are a subject of ongoing research.

## Gravitational systems

Commonly, systems for which gravity is not important have a positive heat capacity, meaning that their temperature rises with their internal energy. Therefore, when energy flows from a high-temperature object to a low-temperature object, the source temperature decreases while the sink temperature is increased; hence temperature differences tend to diminish over time.
This is not always the case for systems in which the gravitational force is important: systems that are bound by their own gravity, such as stars, can have negative heat capacities. As they contract, both their total energy and their entropy decrease but their internal temperature may increase. This can be significant for protostars and even gas giant planets such as Jupiter. When the entropy of the black-body radiation emitted by the bodies is included, however, the total entropy of the system can be shown to increase even as the entropy of the planet or star decreases.

## Non-equilibrium states

The theory of classical or equilibrium thermodynamics is idealized. A main postulate or assumption, often not even explicitly stated, is the existence of systems in their own internal states of thermodynamic equilibrium. In general, a region of space containing a physical system at a given time, that may be found in nature, is not in thermodynamic equilibrium, read in the most stringent terms. In looser terms, nothing in the entire universe is or has ever been truly in exact thermodynamic equilibrium.
For purposes of physical analysis, it is often enough convenient to make an assumption of thermodynamic equilibrium. Such an assumption may rely on trial and error for its justification. If the assumption is justified, it can often be very valuable and useful because it makes available the theory of thermodynamics. Elements of the equilibrium assumption are that a system is observed to be unchanging over an indefinitely long time, and that there are so many particles in a system, that its particulate nature can be entirely ignored. Under such an equilibrium assumption, in general, there are no macroscopically detectable fluctuations. There is an exception, the case of critical states, which exhibit to the naked eye the phenomenon of critical opalescence. For laboratory studies of critical states, exceptionally long observation times are needed.
In all cases, the assumption of thermodynamic equilibrium, once made, implies as a consequence that no putative candidate "fluctuation" alters the entropy of the system.
It can easily happen that a physical system exhibits internal macroscopic changes that are fast enough to invalidate the assumption of the constancy of the entropy. Or that a physical system has so few particles that the particulate nature is manifest in observable fluctuations. Then the assumption of thermodynamic equilibrium is to be abandoned. There is no unqualified general definition of entropy for non-equilibrium states.
There are intermediate cases, in which the assumption of local thermodynamic equilibrium is a very good approximation, but strictly speaking it is still an approximation, not theoretically ideal.
For non-equilibrium situations in general, it may be useful to consider statistical mechanical definitions of other quantities that may be conveniently called 'entropy', but they should not be confused or conflated with thermodynamic entropy properly defined for the second law. These other quantities indeed belong to statistical mechanics, not to thermodynamics, the primary realm of the second law.
The physics of macroscopically observable fluctuations is beyond the scope of this article.

## Arrow of time

The second law of thermodynamics is a physical law that is not symmetric to reversal of the time direction. This does not conflict with symmetries observed in the fundamental laws of physics (particularly CPT symmetry) since the second law applies statistically on time-asymmetric boundary conditions. The second law has been related to the difference between moving forwards and backwards in time, or to the principle that cause precedes effect (the causal arrow of time, or causality).

## Irreversibility

Irreversibility in thermodynamic processes is a consequence of the asymmetric character of thermodynamic operations, and not of any internally irreversible microscopic properties of the bodies. Thermodynamic operations are macroscopic external interventions imposed on the participating bodies, not derived from their internal properties. There are reputed "paradoxes" that arise from failure to recognize this.

### Loschmidt's paradox

Loschmidt's paradox, also known as the reversibility paradox, is the objection that it should not be possible to deduce an irreversible process from the time-symmetric dynamics that describe the microscopic evolution of a macroscopic system.
In the opinion of Schrödinger, "It is now quite obvious in what manner you have to reformulate the law of entropy – or for that matter, all other irreversible statements – so that they be capable of being derived from reversible models. You must not speak of one isolated system but at least of two, which you may for the moment consider isolated from the rest of the world, but not always from each other." The two systems are isolated from each other by the wall, until it is removed by the thermodynamic operation, as envisaged by the law. The thermodynamic operation is externally imposed, not subject to the reversible microscopic dynamical laws that govern the constituents of the systems. It is the cause of the irreversibility. The statement of the law in this present article complies with Schrödinger's advice. The cause–effect relation is logically prior to the second law, not derived from it. This reaffirms Albert Einstein's postulates that cornerstone Special and General Relativity - that the flow of time is irreversible, however it is relative. Cause must precede effect, but only within the constraints as defined explicitly within General Relativity (or Special Relativity, depending on the local spacetime conditions). Good examples of this are the Ladder Paradox, time dilation and length contraction exhibited by objects approaching the velocity of light or within proximity of a super-dense region of mass/energy - e.g. black holes, neutron stars, magnetars and quasars.

### Poincaré recurrence theorem

The Poincaré recurrence theorem considers a theoretical microscopic description of an isolated physical system. This may be considered as a model of a thermodynamic system after a thermodynamic operation has removed an internal wall. The system will, after a sufficiently long time, return to a microscopically defined state very close to the initial one. The Poincaré recurrence time is the length of time elapsed until the return. It is exceedingly long, likely longer than the life of the universe, and depends sensitively on the geometry of the wall that was removed by the thermodynamic operation. The recurrence theorem may be perceived as apparently contradicting the second law of thermodynamics. More obviously, however, it is simply a microscopic model of thermodynamic equilibrium in an isolated system formed by removal of a wall between two systems. For a typical thermodynamical system, the recurrence time is so large (many many times longer than the lifetime of the universe) that, for all practical purposes, one cannot observe the recurrence. One might wish, nevertheless, to imagine that one could wait for the Poincaré recurrence, and then re-insert the wall that was removed by the thermodynamic operation. It is then evident that the appearance of irreversibility is due to the utter unpredictability of the Poincaré recurrence given only that the initial state was one of thermodynamic equilibrium, as is the case in macroscopic thermodynamics. Even if one could wait for it, one has no practical possibility of picking the right instant at which to re-insert the wall. The Poincaré recurrence theorem provides a solution to Loschmidt's paradox. If an isolated thermodynamic system could be monitored over increasingly many multiples of the average Poincaré recurrence time, the thermodynamic behavior of the system would become invariant under time reversal.

### Maxwell's demon

James Clerk Maxwell imagined one container divided into two parts, A and B. Both parts are filled with the same gas at equal temperatures and placed next to each other, separated by a wall. Observing the molecules on both sides, an imaginary demon guards a microscopic trapdoor in the wall. When a faster-than-average molecule from A flies towards the trapdoor, the demon opens it, and the molecule will fly from A to B. The average speed of the molecules in B will have increased while in A they will have slowed down on average. Since average molecular speed corresponds to temperature, the temperature decreases in A and increases in B, contrary to the second law of thermodynamics.
One response to this question was suggested in 1929 by Leó Szilárd and later by Léon Brillouin. Szilárd pointed out that a real-life Maxwell's demon would need to have some means of measuring molecular speed, and that the act of acquiring information would require an expenditure of energy. Likewise, Brillouin demonstrated that the decrease in entropy caused by the demon would be less than the entropy produced by choosing molecules based on their speed.
Maxwell's 'demon' repeatedly alters the permeability of the wall between A and B. It is therefore performing thermodynamic operations on a microscopic scale, not just observing ordinary spontaneous or natural macroscopic thermodynamic processes.

## Quotations

   The law that entropy always increases holds, I think, the supreme position among the laws of Nature. If someone points out to you that your pet theory of the universe is in disagreement with Maxwell's equations – then so much the worse for Maxwell's equations. If it is found to be contradicted by observation – well, these experimentalists do bungle things sometimes. But if your theory is found to be against the second law of thermodynamics I can give you no hope; there is nothing for it but to collapse in deepest humiliation.
   There have been nearly as many formulations of the second law as there have been discussions of it.
   Clausius is the author of the sibyllic utterance, "The energy of the universe is constant; the entropy of the universe tends to a maximum." The objectives of continuum thermomechanics stop far short of explaining the "universe", but within that theory we may easily derive an explicit statement in some ways reminiscent of Clausius, but referring only to a modest object: an isolated body of finite size.