Principle of minimum energy

The principle of minimum energy is essentially a restatement of the second law of thermodynamics. It states that for a closed system, with constant external parameters and entropy, the internal energy will decrease and approach a minimum value at equilibrium. External parameters generally means the volume, but may include other parameters which are specified externally, such as a constant magnetic field.
In contrast, for isolated systems (and fixed external parameters), the second law states that the entropy will increase to a maximum value at equilibrium. An isolated system has a fixed total energy and mass. A closed system, on the other hand, is a system which is connected to another, and cannot exchange matter (i.e. particles), but other forms of energy (e.g. heat), with the other system. If, rather than an isolated system, we have a closed system, in which the entropy rather than the energy remains constant, then it follows from the first and second laws of thermodynamics that the energy of that system will drop to a minimum value at equilibrium, transferring its energy to the other system. To restate:
Mathematical explanation.
The total energy of the system is formula_1 where "S" is entropy, and the formula_2 are the other extensive parameters of the system (e.g. volume, particle number, etc.). The entropy of the system may likewise be written as a function of the other extensive parameters as formula_3. Suppose that "X" is one of the formula_2 which varies as a system approaches equilibrium, and that it is the only such parameter which is varying. The principle of maximum entropy may then be stated as:
The first condition states that entropy is at an extremum, and the second condition states that entropy is at a maximum. Note that for the partial derivatives, all extensive parameters are assumed constant except for the variables contained in the partial derivative, but only "U", "S", or "X" are shown. It follows from the properties of an exact differential (see equation 8 in the exact differential article) and from the energy/entropy equation of state that, for a closed system:
It is seen that the energy is at an extremum at equilibrium. By similar but somewhat more lengthy argument it can be shown that
which is greater than zero, showing that the energy is, in fact, at a minimum.
Examples.
Consider, for one, the familiar example of a marble on the edge of a bowl. If we consider the marble and bowl to be an isolated system, then when the marble drops, the potential energy will be converted to the kinetic energy of motion of the marble. Frictional forces will convert this kinetic energy to heat, and at equilibrium, the marble will be at rest at the bottom of the bowl, and the marble and the bowl will be at a slightly higher temperature. The total energy of the marble-bowl system will be unchanged. What was previously the potential energy of the marble, will now reside in the increased heat energy of the marble-bowl system. This will be an application of the maximum entropy principle as set forth in the principle of minimum potential energy, since due to the heating effects, the entropy has increased to the maximum value possible given the fixed energy of the system.
If, on the other hand, the marble is lowered very slowly to the bottom of the bowl, so slowly that no heating effects occur (i.e. reversibly), then the entropy of the marble and bowl will remain constant, and the potential energy of the marble will be transferred as energy to the surroundings. The surroundings will maximize its entropy given its newly acquired energy, which is equivalent to the energy having been transferred as heat. Since the potential energy of the system is now at a minimum with no increase in the energy due to heat of either the marble or the bowl, the total energy of the system is at a minimum. This is an application of the minimum energy principle.
Alternatively, suppose we have a cylinder containing an ideal gas, with cross sectional area "A" and a variable height "x". Suppose that a weight of mass "m" has been placed on top of the cylinder. It presses down on the top of the cylinder with a force of "mg" where "g" is the acceleration due to gravity.
Suppose that "x" is smaller than its equilibrium value. The upward force of the gas is greater than the downward force of the weight, and if allowed to freely move, the gas in the cylinder would push the weight upward rapidly, and there would be frictional forces that would convert the energy to heat. If we specify that an external agent presses down on the weight so as to very slowly (reversibly) allow the weight to move upward to its equilibrium position, then there will be no heat generated and the entropy of the system will remain constant while energy is transferred as work to the external agent. The total energy of the system at any value of "x" is given by the internal energy of the gas plus the potential energy of the weight:
where "T" is temperature, "S" is entropy, "P" is pressure, μ is the chemical potential, "N" is the number of particles in the gas, and the volume has been written as "V=Ax". Since the system is closed, the particle number "N" is constant and a small change in the energy of the system would be given by:
Since the entropy is constant, we may say that "dS"=0 at equilibrium and by the principle of minimum energy, we may say that "dU"=0 at equilibrium, yielding the equilibrium condition:
which simply states that the upward gas pressure force ("PA") on the upper face of the cylinder is equal to the downward force of the mass due to gravitation ("mg").
Thermodynamic potentials.
The principle of minimum energy can be generalized to apply to constraints other than fixed entropy. For other constraints, other state functions with dimensions of energy will be minimized. These state functions are known as thermodynamic potentials. Thermodynamic potentials are at first glance just simple algebraic combinations of the energy terms in the expression for the internal energy. For a simple, multicomponent system, the internal energy may be written:
where the intensive parameters (T, P, μj) are functions of the internal energy's natural variables formula_13 via the equations of state. As an example of another thermodynamic potential, the Helmholtz free energy is written:
where temperature has replaced entropy as a natural variable. In order to understand the value of the thermodynamic potentials, it is necessary to view them in a different light. They may in fact be seen as (negative) Legendre transforms of the internal energy, in which certain of the extensive parameters are replaced by the derivative of internal energy with respect to that variable (i.e. the conjugate to that variable). For example, the Helmholtz free energy may be written:
and the minimum will occur when the variable "T"  becomes equal to the temperature since
The Helmholtz free energy is a useful quantity when studying thermodynamic transformations in which the temperature is held constant. Although the reduction in the number of variables is a useful simplification, the main advantage comes from the fact that the Helmholtz free energy is minimized at equilibrium with respect to any unconstrained internal variables for a closed system at constant temperature and volume. This follows directly from the principle of minimum energy which states that at constant entropy, the internal energy is minimized. This can be stated as:
where formula_18 and formula_19 are the value of the internal energy and the (fixed) entropy at equilibrium. The volume and particle number variables have been replaced by "x" which stands for any internal unconstrained variables.
As a concrete example of unconstrained internal variables, we might have a chemical reaction in which there are two types of particle, an "A" atom and an "A2" molecule. If formula_20 and formula_21 are the respective particle numbers for these particles, then the internal constraint is that the total number of "A" atoms formula_22 is conserved: 
we may then replace the formula_20 and formula_21 variables with a single variable formula_26 and minimize with respect to this unconstrained variable. There may be any number of unconstrained variables depending on the number of atoms in the mixture. For systems with multiple sub-volumes, there may be additional volume constraints as well.
The minimization is with respect to the unconstrained variables. In the case of chemical reactions this is usually the number of particles or mole fractions, subject to the conservation of elements. At equilibrium, these will take on their equilibrium values, and the internal energy formula_18 will be a function only of the chosen value of entropy formula_19. By the definition of the Legendre transform, the Helmholtz free energy will be:
The Helmholtz free energy at equilibrium will be:
where formula_31 is the (unknown) temperature at equilibrium. Substituting the expression for formula_18:
By exchanging the order of the extrema:
showing that the Helmholtz free energy is minimized at equilibrium.
The Enthalpy and Gibbs free energy, are similarly derived.