Explained simply in 4 steps
1. The environmental heat is transferred to the refrigerant. This heating causes the refrigerant to evaporate.
2. The refrigerant is compressed and heated even more.
3. The heat is extracted from the warm gas and transferred to the heating system. During this cooling process, the refrigerant liquefies again.
4. The pressure of the liquefied refrigerant is reduced, causing the refrigerant to cool down and the cycle starts again (1.).