Instead of solving the MESH equations repeatedly and performing the optimization in an outer loop, the presented approach embeds the process simulation into an optimization problem. In this way, the MESH equations are solved only once and the optimization is performed simultaneously. To avoid a large and very non linear optimization problem, not all MESH equations are considered as constraints and not all process variables are considered as optimization variables. A subset of the process variables is chosen as optimization variables. From this subset, the remaining process variables are calculated by a robust and fast calculation procedure. This procedure guarantees that a large subset of the MESH equations is already satisfied.