To formulate the RTPO problem, many constraints such as water and gas production capacities must be considered. The motivation of this research is to add constraints related to the fluid temperature. These constraints are important to, for instance, avoid hydrates in gas production and wax in oil production pipelines. In the previous works, only the mass and the momentum balances have been considered in the optimization models. However, in order to obtain the temperature at different parts of the network, we require an energy balance model for the network. To this end we use B-splines to model the difficult, nonlinear relations in the energy model.