Second law of thermodynamics
The second law of thermodynamics is an expression of the universal law of increasing entropy, stating that the entropy of an isolated system which is not in equilibrium will tend to increase over time, approaching a maximum value at equilibrium.
The second law traces its origin to French physicist Sadi Carnot's 1824 paper Reflections on the Motive Power of Fire, which presented the view that motive power (work) is due to the fall of caloric (heat) from a hot to cold body (working substance). In simple terms, the second law is an expression of the fact that over time, ignoring the effects of self-gravity, differences in temperature, pressure, and density tend to even out in a physical system that is isolated from the outside world. Entropy is a measure of how far along this evening-out process has progressed.
There are many versions of the second law, but they all have the same effect, which is to explain the phenomenon of irreversibility in nature.

# Introduction

## Versions of The Law
There are many ways of stating the second law of thermodynamics, but all are equivalent in the sense that each form of the second law logically implies every other form Template:Ref harvard. Thus, the theorems of thermodynamics can be proved using any form of the second law and third law
The formulation of the second law that refers to entropy directly is due to Rudolf Clausius:
In an isolated system, a process can occur only if it increases the total entropy of the system.
Thus, the system can either stay the same, or undergo some physical process that increases entropy. (An exception to this rule is a reversible or "isentropic" process, such as frictionless adiabatic compression.)  Processes that decrease total entropy of an isolated system do not occur. If a system is at equilibrium, by definition no spontaneous processes occur, and therefore the system is at maximum entropy.
Also due to Clausius is the simplest formulation of the second law, the heat formulation:
Heat cannot spontaneously flow from a material at lower temperature to a material at higher temperature.
Informally, "Heat doesn't flow from cold to hot (without work input)", which is obviously true from everyday experience.  For example in a refrigerator, heat flows from cold to hot, but only when aided by an external agent, i.e. the compressor. Note that from the mathematical definition of entropy, a process in which heat flows from cold to hot has decreasing entropy.  This is allowable in a non-isolated system, however only if entropy is created elsewhere, such that the total entropy is constant or increasing, as required by the second law.  For example, the electrical energy going into a refrigerator is converted to heat and goes out the back, representing a net increase in entropy.
A third formulation of the second law, the heat engine formulation, by Lord Kelvin, is:
It is impossible to convert heat completely into work.
That is, it is impossible to extract energy by heat from a high-temperature energy source and then convert all of the energy into work. At least some of the energy must be passed on to heat a low-temperature energy sink. Thus, a heat engine with 100% efficiency is thermodynamically impossible.

## Microscopic systems
Thermodynamics is a theory of macroscopic systems at equilibrium and therefore the second law applies only to macroscopic systems with well-defined temperatures. On scales of a few atoms, the second law does not apply; for example, in a system of two molecules, it is possible for the slower-moving ("cold") molecule to transfer energy to the faster-moving ("hot") molecule. Such tiny systems are outside the domain of classical thermodynamics, but they can be investigated in quantum thermodynamics by using statistical mechanics. For any isolated system with a mass of more than a few picograms, the second law is true to within a few parts in a million.

## Energy dispersal
The second law of thermodynamics is an axiom of thermodynamics concerning heat, entropy, and the direction in which thermodynamic processes can occur. For example, the second law implies that heat does not spontaneously flow from a cold material to a hot material, but it allows heat to flow from a hot material to a cold material. Roughly speaking, the second law says that in an isolated system, concentrated energy disperses over time, and consequently less concentrated energy is available to do useful work. Energy dispersal also means that differences in temperature, pressure, and density even out. Again roughly speaking, thermodynamic entropy is a measure of energy dispersal, and so the second law is closely connected with the concept of entropy.

# Overview
In a general sense, the second law says that temperature differences between systems in contact with each other tend to even out and that work can be obtained from these non-equilibrium differences, but that loss of heat occurs, in the form of entropy, when work is done. Pressure differences, density differences, and particularly temperature differences, all tend to equalize if given the opportunity. This means that an isolated system will eventually come to have a uniform temperature.  A heat engine is a mechanical device that provides useful work from the difference in temperature of two bodies:
During the 19th century, the second law was synthesized, essentially, by studying the dynamics of the Carnot heat engine in coordination with James Joule's Mechanical equivalent of heat experiments. Since any thermodynamic engine requires such a temperature difference, it follows that no useful work can be derived from an isolated system in equilibrium; there must always be an external energy source and a cold sink. By definition, perpetual motion machines of the second kind would have to
violate the second law to function.

# History
The first theory on the conversion of heat into mechanical work is due to Nicolas Leonard 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 environment.
Recognizing the significance of James Prescott Joule's work on the conservation of energy, Rudolf Clausius was the first to formulate the second law in 1850, in this form: heat does not spontaneously flow 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 liquid.  From there he was able to infer the law of Sadi Carnot and the definition of entropy (1865).
Established in 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 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 long period of time. Equivalently, it says that time average and average over the statistical ensemble are the same.
Using quantum mechanics it has been shown that the local von Neumann entropy is at its maximum value with an extremely high probability, thus proving the second law. The result is valid for a large class of isolated quantum systems (e.g. a gas in a container). While the full system is pure and has therefore no entropy, the entanglement between gas and container gives rise to an increase of the local entropy of the gas. This result is one of the most important achievements of quantum thermodynamics.

## Informal descriptions
The second law can be stated in various succinct ways, including:
- It is impossible to produce work in the surroundings using a cyclic process connected to a single heat reservoir (Kelvin, 1851).
- It is impossible to carry out a cyclic process using an engine connected to two heat reservoirs that will have as its only effect the transfer of a quantity of heat from the low-temperature reservoir to the high-temperature reservoir (Clausius, 1854).
- If thermodynamic work is to be done at a finite rate, free energy must be expended.

## Mathematical descriptions
In 1856, the German physicist Rudolf Clausius stated what he called the "second fundamental theorem in the mechanical theory of heat" in the following form:
where 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 24th, 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.  Moreover, owing to the general broadness of the terminology used here, e.g. universe, as well as lack of specific conditions, e.g. open, closed, or isolated, to which this statement applies, many people take this simple statement to mean that the second law of thermodynamics applies virtually to every subject imaginable.  This, of course, is not true; this statement is only a simplified version of a more complex description.
In terms of time variation, the mathematical statement of the second law for a closed system undergoing an adiabatic transformation is:
where
It should be noted that 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 nil. 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.

# 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 TR and pressure PR  so that no matter how much heat is transferred  to (or from) the sub-system, the temperature of the surroundings will remain TR; and no matter how much the volume of the sub-system expands (or contracts), the pressure of the surroundings will remain PR.
Whatever changes dS and dSR occur in the entropies of the sub-system and the surroundings individually, according to the Second Law the entropy Stot of the isolated total system must not decrease:
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, less any work w done by the sub-system, plus any net chemical energy entering the sub-system d iRNi, so that:
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
where we have first used the definition of entropy in classical thermodynamics (alternatively, the definition of temperature in statistical thermodynamics); and then the Second Law inequality from above.
It therefore follows that any net work w done by the sub-system must obey
It is useful to separate the work w done by the subsystem into the useful work wu that can be done by the sub-system, over and beyond the work pR dV done merely by the sub-system expanding against the surrounding external pressure, giving the following relation for the useful work that can be done:
It is convenient to define the right-hand-side as the exact derivative of a thermodynamic potential, called the availability or exergy X of the subsystem,
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,
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.

## Special cases: Gibbs and Helmholtz free energies
When no useful work is being extracted from the sub-system, it follows that
with the exergy X reaching a minimum at equilibrium, when dX=0.
If no chemical species can enter or leave the sub-system, then the term  iR Ni can be ignored.  If furthermore the temperature of the sub-system is such that T is always equal to TR, then this gives:
If the volume V is constrained to be constant, then
where A is the thermodynamic potential called Helmholtz free energy, A=UTS. Under constant volume conditions therefore, dA  0 if a process is to go forward; and dA=0 is the condition for equilibrium.
Alternatively, if the sub-system pressure p is constrained to be equal to the external reservoir pressure pR, then
where G is the Gibbs free energy, G=UTS+PV.  Therefore under constant pressure conditions, if dG  0, then the process can occur spontaneously, because the change in system energy exceeds the energy lost to entropy.  dG=0 is the condition for equilibrium.  This is also commonly written in terms of enthalpy, where H=U+PV.

## Application
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 X for an irreversible process and no change for a reversible process.
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. (Also, see 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 second law efficiency.)
This approach to the Second Law is widely utilized in engineering practice, environmental accounting, systems ecology, and other disciplines.

# Criticisms
Owing to the somewhat ambiguous nature of the formulation of the second law, i.e. the postulate that the quantity heat divided by temperature increases in spontaneous natural processes, it has occasionally been subject to criticism as well as attempts to dispute or disprove it.  Clausius himself even noted the abstract nature of the second law.  In his 1862 memoir, for example, after mathematically stating the second law by saying that integral of the differential of a quantity of heat divided by temperature must be greater than or equal to zero for every cyclical process which is in any way possible:
Clausius then states:
Although the necessity of this theorem admits of strict mathematical proof if we start from the fundamental proposition above quoted it thereby nevertheless retains an abstract form, in which it is with difficulty embraced by the mind, and we feel compelled to seek for the precise physical cause, of which this theorem is a consequence.
Recall that heat and temperature are statistical, macroscopic quantities that become somewhat ambiguous when dealing with a small number of atoms.

## Perpetual motion of the second kind
Before 1850, heat was regarded as an indestructible particle of matter.  This was called the material hypothesis, as based principally on the views of Isaac Newton.  It was on these views, partially, that in 1824 Sadi Carnot formulated the initial version of the second law.  It soon was realized, however, that if the heat particle was conserved, and as such not changed in the cycle of an engine, that it would be possible to send the heat particle cyclically through the working fluid of the engine and use it to push the piston and then return the particle, unchanged, to its original state.  In this manner perpetual motion could be created and used as an unlimited energy source.  Thus, historically, people have always been attempting to create a perpetual motion machine so to disprove the second law.

## Maxwell's Demon
In 1871, James Clerk Maxwell proposed a thought experiment, now called Maxwell's demon, which challenged the second law.  This experiment reveals the importance of observability in discussing the second law.  In other words, it requires a certain amount of energy to collect the information necessary for the demon to "know" the whereabouts of all the particles in the system.  This energy requirement thus negates the challenge to the second law.  Moreover, to reconcile this apparent paradox from another perspective, one may resort to a use of information entropy, although this is considered questionable by some.

## Time's Arrow
The second law is a law about macroscopic irreversibility, and so may appear to violate the principle of T-symmetry. Boltzmann first investigated the link with microscopic reversibility. In his H-theorem he gave an explanation, by means of statistical mechanics, for dilute gases in the zero density limit where the ideal gas equation of state holds. He derived the second law of thermodynamics not from mechanics alone, but also from the probability arguments. His idea was to write an equation of motion for the probability that a single particle has a particular position and momentum at a particular time. One of the terms in this equation accounts for how the single particle distribution changes through collisions of pairs of particles.  This rate depends of the probability of pairs of particles. Boltzmann introduced the assumption of molecular chaos to reduce this pair probability to a product of single particle probabilities. From the resulting Boltzmann equation he derived his famous H-theorem, which implies that on average the entropy of an ideal gas can only increase.
The assumption of molecular chaos in fact violates time reversal symmetry. It assumes that particle momenta are uncorrelated before collisions. If you replace this assumption with "anti-molecular chaos," namely that particle momenta are uncorrelated after collision, then you can derive an anti-Boltzmann equation and an anti-H-Theorem which implies entropy decreases on average.  Thus we see that in reality Boltzmann did not succeed in solving Loschmidt's paradox. The molecular chaos assumption is the key element that introduces the arrow of time.

## Applications to living systems
The second law of thermodynamics has been proven mathematically for thermodynamic systems, where entropy is defined in terms of heat divided by the absolute temperature.  The second law is often applied to other situations, such as the complexity of life, or orderliness. In sciences such as biology and biochemistry the application of thermodynamics is well-established, e.g. biological thermodynamics.  The general viewpoint on this subject is summarized well by biological thermodynamicist Donald Haynie; as he states: "Any theory claiming to describe how organisms originate and continue to exist by natural causes must be compatible with the first and second laws of thermodynamics."  This is very different, however, from the claim made by many creationists  that evolution violates the second law of thermodynamics.  In fact, evidence indicates that biological systems and obviously the evolution of those systems conform to the second law, since although biological systems may become more ordered, the net increase in entropy for the entire universe is still positive as a result of evolution.

## Small systems
In statistical thermodynamics, which uses probability theory to calculate thermodynamic variables, such as entropy, the second law only holds for ensemble averages and the probability for single systems to violate it increases with decreasing size. The fluctuation theorem describes this behaviour.

## Complex systems
It is occasionally claimed that the second law is incompatible with autonomous self-organisation, or even the coming into existence of complex systems.  This is a common creationist argument against evolution.  The entry self-organisation explains how this claim is a misconception. In fact, as hot systems cool down in accordance with the second law, it is not unusual for them to undergo spontaneous symmetry breaking, i.e. for structure to spontaneously appear as the temperature drops below a critical threshold. Complex structures, such as Benard cells, also spontaneously appear where there is a steady flow of energy from a high temperature input source to a low temperature external sink.
Furthermore, the concept of entropy in thermodynamics is not identical to the common notion of "disorder". For example, a thermodynamically closed system of certain solutions will eventually transform from a cloudy liquid to a clear solution containing large "orderly" crystals. Most people would characterize the former state as having "more disorder" than the latter state. However, in a purely thermodynamic sense, the entropy has increased in this system, not decreased. The units of measure of entropy in thermodynamics are "units of energy per unit of temperature". Whether a human perceives one state of a system as "more orderly" than another has no bearing on the calculation of this quantity. The common notion that entropy in thermodynamics is equivalent to a popular conception of "disorder" has caused many non-physicists to completely misinterpret what the second law of thermodynamics is really about.

# Quotes
"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."  Sir Arthur Stanley Eddington, The Nature of the Physical World (1927)
The tendency for entropy to increase in isolated systems is expressed in the second law of thermodynamics  perhaps the most pessimistic and amoral formulation in all human thought.  Greg Hill and Kerry Thornley, Principia Discordia (1965)
There are almost as many formulations of the second law as there have been discussions of it.  Philosopher / Physicist P.W. Bridgman, (1941)

# Miscellany
- Flanders and Swann produced a setting of a statement of the Second Law of Thermodynamics to music, called "First and Second Law".
- The economist Nicholas Georgescu-Roegen showed the significance of the Entropy Law in the field of economics (see his work The Entropy Law and the Economic Process (1971), Harvard University Press).
- Creationist Duane Gish incorrectly used the Second Law of Thermodynamics to argue that evolution was impossible, although stand-up comedian Dave Gorman has pointed out that Gish misunderstood the definition of a closed system.