A steam engine is a heat engine that converts part of the energy carried by steam into mechanical work. In a reciprocating design, expanding steam pushes a piston; valves admit and exhaust the working fluid so that the motion can repeat. A crank can convert the reciprocation into rotation. A steam turbine instead extracts work from a continuously flowing stream.
The boiler supplies heat to water, but the engine's useful output depends on pressure changes during expansion and exhaust. For an idealized quasi-static piston, boundary work is . The net work over a cycle is the signed enclosed area on a pressure-volume diagram. Some input heat must be rejected: turning boiler heating into motion does not circumvent the Second law of thermodynamics.
New to topics? Read the docs here!