Usually, heat flows from a hot place to a cold place, according to the second law of thermodynamics. Heat will not move from a cold place to a warmer place by itself. Because of this, a heat pump must use extra energy to move the heat. This is sort of like pumping water uphill.
Most heat pumps use electric motors to provide energy. Some heat pumps use heat energy, supplied by a flame or an electric heater.
Most heat pumps use a refrigeration cycle. A refrigeration cycle uses a fluid which moves through tubes and carries the heat. The fluid is called a refrigerant. During the refrigeration cycle, the refrigerant changes from a liquid to a gas and back to a liquid.
When the refrigerant changes from a liquid to a gas, it gains (absorbs) heat energy. This is just like boiling. When the refrigerant changes from a gas back to a liquid, it loses heat energy.
The heat pump is set up so that the refrigerant gains heat from one place that will be cooled, and moves it to another place that will be warmed.
A heat pump forces the refrigerant to change from a gas to a liquid.
It uses a compressor to do this. Often, an electric motor drives the compressor. The compressor compresses the refrigerant, and this makes it change from a gas to a liquid. When the refrigerant changes from a gas to a liquid, it also gives up some of the heat that it has been carrying.
At the other end of the cycle, the refrigerant boils again. It changes from a liquid to a gas. But it needs heat to do this. When it takes up heat from its surroundings, it cools them down. So where the refrigerant is changing from a liquid to a gas, it feels cooler.
This is the complete cycle, from the cooling side to the heating side:
On the cooling side, heat is taken up to boil the refrigerant from a liquid to a gas. Then the fluid moves to the heating side.There, the compressor forces the refrigerant back to a liquid again. This makes it give up its heat. So heat has moved from the cooling side to the heating side. Then, the cycle repeats.
If the cooling side is the inside of a refrigerator, it gets cold.
If the cooling side is the inside of a building, and the warming side is the outside of the building, the inside of the building gets cold. This is how an air conditioner works.
If the cooling side is the outside of the building, and the warming side is the inside of the building, this is how a heat pump can heat a building during the winter.
Second law of thermodynamics
The second law of thermodynamics says that when energy changes from one form to another form, or matter moves freely, entropy (disorder) in a closed system increases.
Differences in temperature, pressure, and density tend to even out horizontally after a while. Due to the force of gravity, density and pressure do not even out vertically. Density and pressure on the bottom will be more than at the top.
Entropy is a measure of spread of matter and energy to everywhere they have access.
The most common wording for the second law of thermodynamics is essentially due to "Rudolf Clausius":
In other words, everything tries to maintain the same temperature over time.
There are many statements of the second law which use different terms, but all mean the same thing. Another statement by Clausius is:
Heat cannot of itself pass from a colder to a hotter body.
An equivalent statement by Lord Kelvin is:
A transformation whose only final result is to convert heat, extracted from a source at constant temperature, into work, is impossible.
The second law only applies to large systems. The second law is about the likely behavior of a system where no energy or matter gets in or out. The bigger the system is, the more likely the second law will be true.
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 thermal energy occurs, when work is done and entropy increases. Pressure, density and temperature differences in an isolated system, all tend to equalize if given the opportunity; density and pressure, but not temperature, are affected by gravity. A heat engine is a mechanical device that provides useful work from the difference in temperature of two bodies.
Air conditioner
An air conditioner is a system or a machine that treats air in a defined, usually enclosed area via a refrigeration cycle in which warm air is removed and replaced with cooler air.
In construction, a complete system of heating, ventilation, and air conditioning is referred to as HVAC. Whether in homes, offices or vehicles, its purpose is to provide comfort by altering the properties of the air, usually by cooling the air inside.The main function of air conditioner is to change adverse temperature.
In the 19th century British scientist and inventor Michael Faraday discovered that compressing and liquefying ammonia could chill air when the liquefied ammonia was allowed to evaporate.
In 1842, American physician Dr. John Gorrie used compressor technology to create ice, which he used to cool air for his patients. He hoped eventually to use his ice-making machine to regulate the temperature of buildings and even considered cooling entire cities with a system of centralized air conditioning units.
Air conditioning engineers broadly divide air conditioning applications into "comfort" and "process".
Comfort applications aim to provide an indoor environment that remains relatively constant in a range preferred by humans despite changes in external weather conditions or in internal heat loads.
Process applications aim to provide a suitable environment for an industrial or a commercial process, regardless of internal heat loads and external weather conditions. Although often in the same comfort range, it is the requirements of  the process that determines conditions, not human preference. Process applications include:
Other examples include:
In both comfort and process applications, the objective is not only to control temperature (although in some comfort applications this is all that is controlled) but also factors like humidity, air movement and air quality.
In the refrigeration cycle, a pump transfers heat from a lower temperature source into a higher temperature heat sink. Heat will naturally flow in the opposite direction. This is the most common type of air conditioning.
A refrigerated air conditioning system works in much the same way pumping heat out of the room in which it stands.
This cycle takes advantage of the universal gas law "PV" = "nRT", where "P" is pressure, "V" is volume, "R" is the universal gas constant, "T" is temperature, and "n" is the number of molecules of gas (1 mole = 6.022×10 molecules).
The most common refrigeration cycle uses an electric motor to drive a compressor. In an automobile the compressor is driven by a pulley on the engine's crankshaft, with both using electric motors for air circulation. Since evaporation occurs when heat is absorbed, and condensation occurs when heat is released, air conditioners are designed to use a compressor to cause pressure changes between two compartments, and actively pump a coolant around an enclosed system. The cooling liquid, or refrigerant is pumped into the cooled compartment (the evaporator coil). Low pressure then causes the refrigerant to evaporate taking the heat with it. In the other compartment (the condenser), the refrigerant vapour is compressed and forced through another heat exchange coil, condensed into a liquid which then rejects the heat previously absorbed from the cooled space.