Modeling Two-Phase Fluid and Heat Flows in Geothermal Wells