The Heat pump principle.The refrigerant in the heat pump evaporates (Boyle's Law) at low temperatures, the source energy whether air or water routes through the evaporator (heat ex-changer) where the refrigerant circulates. The refrigerant extracts the energy and the refrigerant changes from a liquid into a gas, a scroll compressor draws the refrigeration in and compresses it.
The increase in pressure raises the temperature. The compressor is is of a suction gas cooled designed so the energy/heat of the electric motor is not lost but reaches the downstream condenser together with the compressed refrigeration.
The refrigerant releases it's absorbed energy to the circulating system via the condenser to the circulating system to the hot water and heating circuit, The expansion valve deduces the pressure of the refrigerant for the process to start all over again.