Optimal Heat Extraction For Geothermal Energy Applications