To solve the optimization problems we used sequential quadratic programming (sqp) (see for example . More precisely the implementation provided by the MATLAB R Optimization Toolbox TM , version 8.0 and the function fmincon was used. The algorithm was run with the default settings. The accuracy demanded for the final constraint violation was set to 10 -6 . Optimization algorithms can benefit, if clean analytic derivatives are provided and they do not have to be calculated using finite differences. In the stage-to-stage calculations presented in Section 3.1 the MESH equations for a control volume are solved and the dependent variables are calculated. Derivatives for the dependent variables can thus be calculated using the implicit function theorem In MATLAB R the code is compiled after the calculations are started. This can make the calculations slower than necessary. To avoid this loss in speed, the stage-to-stage calculations have been precompiled using MATLAB R Coder TM , version 3.4. This decreases the time needed for each evaluation in the optimization routine.