First law of thermodynamics
In thermodynamics, the first law of thermodynamics is an expression of the more universal physical law of the conservation of energy.  Succinctly, the first law of thermodynamics states:

# Description
The first law of thermodynamics basically states that a thermodynamic system can store or hold energy and that this internal energy is conserved. Heat is a process by which energy is added to a system from a high-temperature source, or lost to a low-temperature sink.  In addition, energy may be lost by the system when it does mechanical work on its surroundings, or conversely, it may gain energy as a result of work done on it by its surroundings. The first law states that this energy is conserved: The change in the internal energy is equal to the amount added by heating minus the amount lost by doing work on the environment. The first law can be stated mathematically as:
where dU is a small increase in the internal energy of the system, \delta Q is a small amount of heat added to the system, and \delta W is a small amount of work done by the system.
The 's before the heat and work terms are used to indicate that they describe an increment of energy which is to be interpreted somewhat differently than the dU increment of internal energy. Work and heat are processes which add or subtract energy, while the internal energy U is a particular form of energy associated with the system. Thus the term "heat energy" for \delta Q means "that amount of energy added as the result of heating" rather than referring to a particular form of energy. Likewise, the term "work energy" for \delta w means "that amount of energy lost as the result of work". The most significant result of this distinction is the fact that one can clearly state the amount of internal energy possessed by a thermodynamic system, but one cannot tell how much energy has flowed into or out of the system as a result of its being heated or cooled, nor as the result of work being performed on or by the system. The first explicit statement of the first law of thermodynamics was given by Rudolf Clausius in 1850: "There is a state function E, called energy, whose differential equals the work exchanged with the surroundings during an adiabatic process."
Note that the above formulation is favored by engineers and physicists. Chemists prefer a second form, in which the work term \delta w  is defined as the work done on the system, and therefore insert a plus sign in the above equation before the work term. This article will use the first definition exclusively.

# Mathematical formulation
The mathematical statement of the first law is given by:
where dU is the infinitesimal increase in the internal energy of the system, \delta Q is the infinitesimal amount of heat added to the system, and \delta w is the infinitesimal amount of work done by the system. The infinitesimal heat and work are denoted by  rather than d  because, in mathematical terms, they are not exact differentials. In other words, they do not describe the state of any system. The integral of an inexact differential depends upon the particular "path" taken through the space of thermodynamic parameters while the integral of an exact differential depends only upon the initial and final states. If the initial and final states are the same, then the integral of an inexact differential may or may not be zero, but the integral of an exact differential will always be zero. The path taken by a thermodynamic system through state space is known as a thermodynamic process.
An expression of the first law can be written in terms of exact differentials by realizing that the work that a system does is, in case of a reversible process, equal to its pressure times the infinitesimal change in its volume. In other words \delta w=PdV where P is pressure and V is volume. Also, for a reversible process, the total amount of heat added to a system can be expressed as \delta Q=TdS where T is temperature and S is entropy. Therefore, for a reversible process, :
Since U, S and V are thermodynamic functions of state, the above relation holds also for non-reversible changes. The above equation is known as the fundamental thermodynamic relation.
In the case where the number of particles in the system is not necessarily constant and may be of different types, the first law is written:
where dN_i is the (small) number of type-i particles added to the system, and \mu_i is the amount of energy added to the system when one type-i particle is added, where the energy of that particle is such that the volume and entropy of the system remains unchanged. \mu_i is known as the chemical potential of the type-i particles in the system. The statement of the first law, using exact differentials is now:
If the system has more external variables than just the volume that can change, the fundamental thermodynamic relation generalizes to:
Here the X_{i} are the generalized forces corresponding to the external variables x_{i}.
A useful idea from mechanics is that the energy gained by a particle is equal to the force applied to the particle multiplied by the displacement of the particle while that force is applied. Now consider the first law without the heating term: dU=-PdV. The pressure P  can be viewed as a force (and in fact has units of force per unit area) while dV  is the displacement (with units of distance times area). We may say, with respect to this work term, that a pressure difference forces a transfer of volume, and that the product of the two (work) is the amount of energy transferred as a result of the process.
It is useful to view the TdS  term in the same light: With respect to this heat term, a temperature difference forces a transfer of entropy, and the product of the two (heat) is the amount of energy transferred as a result of the process. Here, the temperature is known as a "generalized" force (rather than an actual mechanical force) and the entropy is a generalized displacement.
Similarly, a difference in chemical potential between groups of particles in the system forces a trasfer of particles, and the corresponding product is the amount of energy transferred as a result of the process. For example, consider a system consisting of two phases: liquid water and water vapor. There is a generalized "force" of evaporation which drives water molecules out of the liquid. There is a generalized "force" of condensation which drives vapor molecules out of the vapor. Only when these two "forces" (or chemical potentials) are equal will there be equilibrium, and the net transfer will be zero.
The two thermodynamic parameters which form a generalized force-displacement pair are termed "conjugate variables". The two most familiar pairs are, of course, pressure-volume, and temperature-entropy.

# Types of thermodynamic processes
Paths through the space of thermodynamic variables are often specified by holding certain thermodynamic variables constant. It is useful to group these processes into pairs, in which each variable held constant is one member of a conjugate pair.
The pressure-volume conjugate pair is concerned with the transfer of mechanical or dynamic energy as the result of work.
- An isobaric process occurs at constant pressure. An example would be to have a movable piston in a cylinder, so that the pressure inside the cylinder is always at atmospheric pressure, although it is isolated from the atmosphere. In other words, the system is dynamically connected, by a movable boundary, to a constant-pressure reservoir.
- An isochoric (or isovolumetric) process is one in which the volume is held constant, meaning that the work done by the system will be zero. It follows that, for the simple system of two dimensions, any heat energy transferred to the system externally will be absorbed as internal energy. An isochoric process  is also known as an isometric process. An example would be to place a closed tin can containing only air into a fire. To a first approximation, the can will not expand, and the only change will be that the gas gains internal energy, as evidenced by its increase in temperature and pressure. Mathematically, \delta Q=dU. We may say that the system is dynamically insulated, by a rigid boundary, from the environment
The temperature-entropy conjugate pair is concerned with the transfer of thermal energy as the result of heating.
- An isothermal process occurs at a constant temperature. An example would be to have a system immersed in a large constant-temperature bath. Any work energy performed by the system will be lost to the bath, but its temperature will remain constant. In other words, the system is thermally connected, by a thermally conductive boundary to a constant-temperature reservoir.
- An isentropic process occurs at a constant entropy. For a reversible process this is identical to an adiabatic process (see below). If a system has an entropy which has not yet reached its maximum equilibrium value, a process of cooling may be required to maintain that value of entropy.
- An adiabatic process is a process in which there is no energy added or subtracted from the system by heating or cooling. For a reversible process, this is identical to an isentropic process. We may say that the system is thermally insulated from its environment and that its boundary is a thermal insulator. If a system has an entropy which has not yet reached its maximum equilibrium value, the entropy will increase even though the system is thermally insulated.
The above have all implicitly assumed that the boundaries are also impermeable to particles. We may assume boundaries that are both rigid and thermally insulating, but are permeable to one or more types of particle. Similar considerations then hold for the (chemical potential)-(particle number) conjugate pairs.