  In this paper, we consider dynamic optimization of thermal and isothermal oil
recovery processes which involve multicomponent three-phase flow in porous
media. We present thermodynamically rigorous models of these processes based on
1) conservation of mass and energy, and 2) phase equilibrium. The conservation
equations are partial differential equations. The phase equilibrium problems
that are relevant to thermal and isothermal models are called the UV and the VT
flash, and they are based on the second law of thermodynamics. We formulate
these phase equilibrium problems as optimization problems and the phase
equilibrium conditions as the corresponding first order optimality conditions.
We demonstrate that the thermal and isothermal flow models are in a
semi-explicit differential-algebraic form, and we solve the dynamic
optimization problems with a previously developed gradient-based algorithm
implemented in C/C++. We present numerical examples of optimized thermal and
isothermal oil recovery strategies and discuss the computational performance of
the dynamic optimization algorithm in these examples.
