The first practical thermal engine was invented in England by Thomas Newcomen in 1792. It was used to pump water out of mines. Steam is first generated by the boiler and pushes the piston up inside the cylinder. When the piston reaches the top, water is sprayed into the cylinder to cool the steam and hence create a partial vacuum. Air pressure then pushes the piston back down and the cycle repeats.