## State Estimation and Optimal Control of an Industrial Copper Electrowinning

##### Abstract

This dissertation contains a solution for an industrial large-scale complex control problem. There are several challenges to be faced when handling control problems. One such challenge is to be able to handle the system’s scale. Developing mathematical models for large-scale complex control systems have become easier with the emergence of object-oriented, declarative, multidomain modeling languages for component-oriented modeling, such as Modelica. However, the analysis and synthesis of large-scale complex control systems are still highly demanding; new tools and methodologies are needed to simplify the task. The need of making Modelica models available for general use is emphasized. In order to stress the idea, a paper (Appendix A) is published where we present a case study demonstrating how to combine Modelica models and the Python Control Systems Library.
The central interest of this applied research is to implement optimal control strategies in relation to large-scale complex systems. Generally, an optimal control problem poses a state-parameterdisturbance estimation problem. Both these types of problems are challenging due to the scale and the complexity of the systems of interest. Even for moderately small systems, the algebraic analysis and synthesis may become complicated, tedious or even impractical. When investigating a system, several questions needs to be answered, such as if the system is controllable, if its state is observable, if parameters and disturbances can be estimated, if there are any disturbances which can be completely rejected via some state feedback and how to select appropriate models for disturbance augmentation. It is difficult to answer these questions using analytical tools, thus a new perspective is necessary. Interestingly, there are system properties which (almost) do not depend on the actual values of model parameters. These properties are so-called generic or structural properties, such as controllability and observability. The decisions (for example, about algebraic controllability) which are made by means of the state-space theory are susceptible to the uncertainties in the model. Therefore, a better approach is to structurally decompose the system into smaller systems and then analyze these subsystems. In large-scale systems, the state variables, inputs, disturbances and outputs are usually affecting each other. These dependencies often exhibit a nice sparsity pattern. Variable dependencies are captured by the system’s structure. Generic properties can be investigated with the use of graph theory. This approach constitutes a very powerful and simple-to-use tool for structural analysis. The structural investigation in the analysis of large-scale complex nonlinear control systems is a significant portion of this research. All proposed methodologies are tested using simulated data related to the copper leaching process. A mechanistic model containing many state variables (more than 50), unknown disturbances and uncertain parameters along with 4 output measurements is available. The system in question is of large-scale and the process is highly coupled. Consequently, the copper leaching process is an ideal candidate for testing the methodologies presented in the dissertation. The following paragraphs discuss the main milestones of my research work.
Linearization of DAEs: In general, mechanistic models of real physical systems are systems of High-Index Differential-Algebraic Equations (DAEs). The JModelica.org-CasADi interface provides a way of making Modelica models available in Python as symbolic DAE systems. Python is a powerful programming language for technical computing. This opens up a possibility of linearizing any Modelica model in Python. The procedure is demonstrated in [1].
Linear Analysis: Linear system theory is often used in nonlinear system analysis and design. There has been a lack of a general control tool for Python until the Python Control Systems Library (the python-control package) was developed. However, the Python Control Systems Library is underdeveloped as compared to MATLAB’s Control System Toolbox. An article is published showing a procedure of making Modelica models available for linear analysis in Python [2].
Structural Observability/Controllability Analysis: Estimating the internal state of a given dynamic system based on input-output information is crucial for optimal control. However, for some systems it may not be possible to uniquely estimate the state. Such systems are called unobservable systems. It is possible to define algebraic conditions for observability. For linear time invariant systems, we may for example check the rank of the observability matrix. For nonlinear systems, local observability should be checked. An observability rank condition is always associated with the rank of a matrix. For large-scale complex systems, the rank test becomes impractical to implement. An algebraic test merely tells whether the system is observable or not. Sometimes, the inverse observability problem could be more interesting, that is; defining the (minimum number of) output measurements which is needed to make the system observable. A rank test would not solve the inverse observability problem in an easy way, while the structural observability test does. Although the system’s structure provides valuable information, it still does not provide all we need—i.e., structural conditions always provide necessary, but not sufficient, conditions. For example, if a system fails to achieve the structural observability condition, then the system is (locally) unobservable. The converse is however not always true. Thus, structural observability/controllability analysis of a system should be conducted as follows: (1) Analyze the large system for structural observability; (2) as a consequence of structural observability analysis, we can decompose the system into observable and unobservable subsystems; and (3) these subsystems are analyzed algebraically as necessary. Structural observability analysis can be done with the aid of a graph-theoretic analogy which makes the analysis much simpler. A way of automating structural observability analysis using the NetwokX and PyGraphviz Python packages, where the copper leaching process is used as an example, is presented in [3].
State-Parameter-Disturbance Estimation: In reality, it is impractical or impossible to measure all the state variables. It is however often possible to reconstruct the system’s state based on a finite set of input-output measurements, providing that the state is observable. The Extended Kalman Filter, the Moving Horizon Estimate and the Unscented Kalman Filter are examples of available nonlinear estimators. An implementation of several state estimators in Python is presented in [4].
Optimal Control: The final objective of this research is to implement an optimal control strategy. An optimal control strategy is always coupled with an appropriate state estimator. In order to determine the control trajectory, the state information should be known. In this work, the Moving Horizon Estimator is used as the nonlinear estimator. A complete implementation is presented in [5], where two uncertain parameters and two unmeasured disturbances are estimated. [5] also contain a discussion about the divergence issue of the Extended Kalman Filter. It is shown that by some modifications to the Extended Kalman Filter algorithm, we can get comparable results from both of the estimators.
The dissertation contains two parts: Part I and Part II. Part I explains theories and methodologies used in Part II and additional information which is not presented in Part II. Part II consists of a list of published and submitted articles.

##### Has parts

Paper A: Perera, A., Pfeiffer, C., Lie, B. & Hauge, T.A.: Making Modelica Models Available for Analysis in Python Control Systems Library. Proceedings of the 55th International Conference of Scandinavian Simulation Society, SIMS 2014, p. 138-146, 2014. http://www.ep.liu.se/ecp/108/012/ecp14108012.pdfPaper B: Perera, A., Lie, B. & Pfeiffer, C.: Structural Observability Analysis of Large Scale Systems Using Modelica and Python. Modeling, Identification and Control, 31(1), (2010), 1–9. https://doi.org/10.4173/mic.2015.3.6

Paper C: Perera, A., Hauge, T.A. & Pfeiffer, C.: Parameter and State Estimation of Large-Scale Complex Systems Using Python Tools. Modeling, Identification and Control, 36(1), (2015), 53-65. https://doi.org/10.4173/mic.2015.1.4

Paper D: Perera, A., Hauge, T.A. & Pfeiffer, C.: A Case Study: State Estimation and Optimal Control of an Industrial Copper Electrowinning Process. Manuscript. Published in International Journal of Modeling and Optimization, 6(5), (2016), 277-288. https://doi.org/10.7763/IJMO.2016.V6.540