Batch crystallization is crucial in the pharmaceutical industry because more than 90% of the active pharmaceutical ingredients (API) are in the form of crystals. The crystal size and shape distribution is important for both downstream processing and product quality. The size and shape distribution can be controlled by manipulating the cooling profile of the reactor, which directly affects the supersaturation ratio. The dynamic evolution of the crystal size and shape distribution has been modeled as a system of differential algebraic equations derived using the method of moments .
Here, we present a nonlinear model predictive control (NMPC) formulation for batch crystallization using the JModelica  platform. This DAE-constrained optimization problem is solved by discretizing the system using Radau collocation and optimizing the resulting algebraic nonlinear problem with Ipopt. We analyze the performance of the NMPC in terms of set point change, model mismatch, and system noise. For all cases, the performance of the NMPC is much better than the open-loop optimal control strategy.
Nevertheless, many state variables cannot be measured accurately online and some model parameters change from batch to batch. This challenge drives the need for an optimization approach like nonlinear moving horizon estimation (NMHE) to estimate unknown states and parameters prior to solving the NMPC problem. Therefore, using the same JModelica framework, we also present a NMHE formulation for the batch crystallization process. Given the batch process, and combining these two formulations, we obtain an expanding horizon estimation problem and a receding horizon model predictive control problem. We test the performance of this control strategy using a case study of a 90-minute batch crystallization process with 90 control steps and sampling steps. The combined solution time for the NMHE and the NMPC formulations is well within the sampling interval, allowing for real world application of the control strategy. Furthermore, significant performance improvements are possible with this online, model-based control strategy over the existing open-loop optimal solution.
 Acevedo, D., Tandy, Y., and Nagy, Z. K., Multiobjective Optimization of an Unseeded Batch Cooling Crystallizer for Shape and Size Manipulation, Industrial & Engineering Chemistry Research, 54(7), pp 2156-2166,2015.
 Åkesson, J., Årzén, K. E., Gäfvert, M., Bergdahl, T., & Tummescheit, H., Modeling and optimization with Optimica and JModelica. org—Languages and tools for solving large-scale dynamic optimization problems, Computers & Chemical Engineering, 34(11), pp1737-1749, 2010.