Internal energy
In thermodynamics, the internal energy of a thermodynamic system, or a body with well-defined boundaries, denoted by U, or sometimes E, is the total of the kinetic energy due to the motion of molecules (translational, rotational, vibrational) and the potential energy associated with the vibrational and electric energy of atoms within molecules or crystals. It includes the energy in all the chemical bonds, and the energy of the free, conduction electrons in metals.
One can also calculate the internal energy of electromagnetic or blackbody radiation. It is a state function of a system, and is an extensive quantity. The SI unit of energy is the joule although other historical, conventional units are still in use, such as the (small and large) calorie for heat.

# Overview
Internal energy does not include the translational or rotational kinetic energy of a body as a whole. It also does not include the relativistic mass-energy equivalent E = mc2. It excludes any potential energy a body may have because of its location in external gravitational or electrostatic field, although the potential energy it has in a field due to an induced electric or magnetic dipole moment does count, as does the energy of deformation of solids (stress-strain).
The principle of equipartition of energy in classical statistical mechanics states that each molecular quadratic degree of freedom receives 1/2 kT of energy,
a result which was modified when quantum mechanics explained certain anomalies; e.g., in the observed specific heats of crystals (when  h > kT). For monoatomic helium and other noble gases, the internal energy consists only of the translational kinetic energy of the individual atoms. Monoatomic particles, of course, do not (sensibly) rotate or vibrate, and are not electronically excited to higher energies except at very high temperatures.
From the standpoint of statistical mechanics, the internal energy is equal to the ensemble average of the total energy of the system.

# Composition
Internal energy  the sum of all microscopic forms of energy of a system.  It is related to the molecular structure and the degree of molecular activity and may be viewed as the sum of kinetic and potential energies of the molecules; it is comprised of the following types of energies:

# The first law of thermodynamics
The internal energy is essentially defined by the first law of thermodynamics which states that energy is conserved:
where
The first law may be stated equivalently in infinitesimal terms as:
where the terms now represent infinitesimal amounts of the respective quantities. The d before the internal energy function indicates that it is an exact differential. In other words it is a state function or a value which can be assigned to the system. On the other hand, the 's before the other terms indicate that they describe increments of energy which are not state functions but rather they are processes by which the internal energy is changed. (See the discussion in the first law article.)
From a microscopic point of view, the internal energy may be found in many different forms. For a gas it may consist almost entirely of the kinetic energy of the gas molecules. It may also consist of the potential energy of these molecules in a gravitational, electric, or magnetic field. For any material, solid, liquid or gaseous, it may also consist of the potential energy of attraction or repulsion between the individual molecules of the material.

# Expressions for the internal energy
The internal energy may be expressed in terms of other thermodynamic parameters. Each term is composed of an intensive variable (a generalized force) and its conjugate infinitesimal extensive variable (a generalized displacement).
For example, for a non-viscous fluid, the mechanical work done on the system may be related to the pressure p and volume V. The pressure is the intensive generalized force, while the volume is the extensive generalized displacement:
Taking the default direction of work, W, to be from the working fluid to the surroundings,
Taking the default direction of heat transfer, q, to be into the working fluid and assuming a reversible process, we have
The above two equations in the first law of thermodynamics imply for a closed system:
If we also incude the dependence on the numbers of paticles in the system, the internal energy function may be written as U(S,V,N_{1}, N_{2},\ldots) where the N_{j} are the numbers of particles of type j in the system. The fact that U is an extensive function when considered as a function of the variables S, V, N_{1}, N_{2},\ldots, we have:
From Euler's homogeneous function theorem we may now write the internal energy as:
where the \mu_{i} are the chemical potentials for the particles of type i in the system. These are defined as:
For an elastic substance the mechanical term must be replaced by the more general expression involving the stress \sigma_{ij} and strain \varepsilon_{ij}. The infinitesimal statement is:
where Einstein notation has been used for the tensors, in which there is a summation over all repeated indices in the product term. 
The Euler theorem yields for the internal energy Template:Ref harvard:
For a linearly elastic material, the stress can be related to the strain by: