In thermodynamics, heat is a type of energy transfer in which energy flows from a warmer substance or object to a colder one. It can be defined as the total amount of transferred energy excluding any macroscopic work that was done and any transfer of part of the object itself. Transfer of energy as heat can occur through direct contact, through a barrier that is impermeable to matter (as in conduction), by radiation between separated bodies, by way of an intermediate fluid (as in convective circulation), or by a combination of these. By contrast to work, heat involves the stochastic (random) motion of particles (such as atoms or molecules) that is equally distributed among all degrees of freedom, while work is confined to one or more specific degrees of freedom such as those of the center of mass.
Since heat (like work) is a quantity of energy being transferred between two bodies by certain processes, neither body "has" a definite amount of heat (much like a body in itself doesn't "have" work). In contrast, a body indeed has properties (state functions) such as temperature and internal energy. Energy exchanged as heat during a given process changes the (internal) energy of each body by equal and opposite amounts. The sign of the quantity of heat indicates the direction of the transfer, for example from system A to system B; negation indicates energy flowing in the opposite direction.
Although heat flows spontaneously from a hotter body to a cooler one, it is possible to construct a heat pump or refrigeration system that does work to increase the difference in temperature between two systems. In contrast, a heat engine reduces an existing temperature difference to do work on another system.
Historically, many energy units for measurement of heat have been used. The standards-based unit in the International System of Units (SI) is the joule (J). Heat is measured by its effect on the states of interacting bodies, for example, by the amount of ice melted or a change in temperature. The quantification of heat via the temperature change of a body is called calorimetry, and is widely used in practice. In calorimetry, sensible heat is defined with respect to a specific chosen state variable of the system, such as pressure or volume. Sensible heat causes a change of the temperature of the system while leaving the chosen state variable unchanged. Heat transfer that occurs at a constant system temperature but changes the state variable is called latent heat with respect to the variable. For infinitesimal changes, the total incremental heat transfer is then the sum of the latent and sensible heat.