The function of a steam engine is to convert thermal energy into mechanical energy. The structure is very simple, that is, a boiler has a piston with a transmission rod. When the boiler is heated, the steam generated by boiling water in the boiler pushes the piston and converts it into mechanical energy. After steam does work, the internal energy decreases, condenses into water, and the piston retracts. The steam engine does external work in this way.