How geothermal energy is harnessed to generate power