The principle is very similar to the operation of a refrigerator, but in reverse. There is latent heat energy in the air and this is transferred to the heating system.
The heat pump system contains extremely cold liquid refrigerant, which travels through a copper pipe. The air passing through this evaporator contains latent heat which is absorbed by the refrigerant. A compressor then pulls the refrigerant inside where it is naturally compressed.
As the pressure rises, the temperature increases. From here the refrigerant travels to the condenser, where the heat from the refrigerant is transferred to the water tank.
An expansion valve finally provides the pressure reduction to the refrigerant and the cycle starts again.