Application of automatic differentiation for the simulation of nonisothermal, multiphase flow in geothermal reservoirs