A Control Algorithm for the Optimization of Batch Reactor-Based Processes

: Levenberg-Marquardt (LM) algorithm is applied for the optimization of the heat transfer of a batch reactor. The validity of the approach is verified through comparison with experimental results. It is found that the mathematical model can properly describe the heat transfer relationships characterizing the considered system, with the error being kept within ±2°C. Indeed, the difference between the actual measured values and the model calculated value curve is within ±1.5°C, which is in agreement with the model assumptions and demonstrates the reliability and effectiveness of the algorithm applied to the batch reactor heat transfer model. Therefore, the present work provides a theoretical reference for the conversion of practical problems in the field of chemical production into mathematical models. of the establishment of the model. The experimental results show that the difference between the actual measured value and the calculated value of the model is within ±


Introduction
With the continuous development of various technologies, mathematical modeling has become a new subject developed in recent years. Mathematical modeling is the product of the combination of mathematical theory and practical application, which realizes the mutual transformation between real problems and mathematical problems. This transformation describes practical problems from the perspective of qualitative or quantitative analysis, and provides accurate data and reliable information guidance for practical problems [Aichinger, DeBarbadillo, Al-Omari et al. (2019)]. Nowadays, there are many mathematical models, such as static model and dynamic model, distributed parameter model and centralized parameter model, continuous time model and discrete time model, stochastic model and deterministic model, etc. [Ahmad, Zawawi, Kasim et al. (2016)]. In the fine chemical industry, the reactor is a commonly used reaction vessel, and the temperature is the main controlled variable, which is an important factor to ensure the quality of the product. The reactor uses thermal conductivity medium to improve the temperature of the materials in the reactor through the jacket, makes the materials uniform by the mixing of the mixer, improves the thermal conductivity speed, and makes the temperature uniform. The main structure of the batch reactor is the reaction kettle body, which is mainly a steel tank that can be filled with materials. Many accessories are welded on the tank body, including heat transfer device, stirring device, voltage regulator, and observation parts. Batch process is a kind of process in chemical production, which is often applied in the situation of low yield, long reaction time or special requirement for temperature in different reaction periods. Batch polymerization reactor is the core of the production process. Due to the special chemical production, it is relatively difficult to control the temperature in the production process, so it is necessary to establish accurate temperature mathematical model to realize the automation of the production process [Brito, Vasconcelos, Neto et al. (2018)]. However, due to the nonlinear and time-varying characteristics of the polymerization process, it is difficult for the directly derived mathematical model to meet the exact requirements. Previously, the reactors applied in various industry all have relatively large heat capacity, which inevitably leads to a long lag time. For this reactor, the same problem exists. In order to establish a proper mathematical model, it is necessary to carry out corresponding mathematical analysis on the characteristics of the research object. Specifically, to explore the heat transfer relationship between each part of the reactor and each reaction period, real-time measurement of some thermal parameters in specific reactors should be carried out, so as to analyze the heat transfer mechanism in the whole process according to the equilibrium principle. Accordingly, it is urgent to establish corresponding mathematical models [Endres, Roth and Brück (2016)]. For the establishment of mathematical model, it is necessary to conduct the design experiment of batch reactor to find out the heat transfer relationship among various organizational structures of the reactor, and then analyze the mechanism of each time periods in the whole process. After consulting the data, it is found that the reactor has the characteristics of strong time-delay, time-varying, and nonlinear. If viewed from a micro perspective, it would inevitably cause great difficulties to the experiment, so it is much easier to describe the whole process from a macro perspective starting from the law of heat conservation [Eypasch, Schimpe, Kanwar et al. (2017); Gokon, Kumaki, Miyaguchi et al. (2019)]. The establishment of heat transfer model cannot be separated from the estimation of parameters, and the essence of parameter optimization estimation is the problem of nonlinear least square method [Han, Hagos, Ji et al. (2016)]. Today, the most widely used algorithm is the LM algorithm. The LM algorithm performs a certain ordinary convergence by approaching a certain minimum point, which is an algorithm proposed to solve the problem of the error squared sum and minimality. In addition, this algorithm has the characteristics of fast local convergence in Gauss-Newton method, and can overcome the problems related to singularity and positive definite matrix that Newton method can't effectively deal with. Therefore, in this study, LM algorithm is applied to the establishment of the heat transfer model of batch reactor, and the rationality of this algorithm is verified through experiments.

The systematic structure of batch reactor
The main structure of the batch reactor is the reaction kettle, as shown in Fig. 1. Among them, the jacket used in the system is a heat transfer device, which is a steel structure outside the tank. It forms a closed space with the outer layer of the tank, in which heat transfer oil is added, and heat is transferred in the inner layer of the jacket to heat the materials in the tank. There is a serpentine pipe in the tank body, which leads to cooling water to regulate the temperature in the tank. Cooling water is controlled by electric valve and regulated by upper computer. The agitator is installed in the tank, and the external motor drives the agitator shaft and the impeller to rotate, providing corresponding power for the material circulation [Han and Bollas (2016)]. The heating system of the reactor is 12 thermal resistance heating rods installed in the jacket, which are evenly distributed around the reactor and controlled by adjusting the conduction angle of crystal valve tube by PLC. The crystal valve tube is adjusted in the form of voltage regulation. The voltage is adjusted according to the signal transmitted by PLC, and then the heating power of the heating rod is adjusted [Jin, Guo, Guo et al. (2016); Kaiser and Flassig (2018)]. The specific circuit diagram is shown in Fig. 2 Figure 2: Structure of heating system The cooling system of the reactor consists of electric control valve, power pump, temperature transmitter, and flow meter. Among them, the electric regulating valve receives the standard current signal from PLC and controls the reaction temperature in the reactor by adjusting the flow of cooling water [Kasmuri, Kamarudin, Abdullah et al. (2017)]. Normally, the batch reactor is in a state of only heat exchange with the outside world. However, when the pressure in the reactor exceeds the set range, the pressure needs to be adjusted. The pressure control loop in this study mainly includes the regulating valve, buffer tank, and pressure gauge. When the pressure is too high, PLC would send a control signal, and the pressure would return to the normal range by the regulating valve to keep the pressure constant in the kettle [Lucian and Fiori (2017)].
In addition to the above several control loops, there are feeding control loops and stirring loops. Among them, the stirring control is to adjust the motor speed through the frequency converter [Li and Wang (2016)].

LM algorithm
The advantage of the LM algorithm is that it can be corrected when it is far away from the solution, and the search is performed along the error value surface, which not only has the characteristics of the global search of the gradient descent method, but also has high accuracy. At the same time, LM algorithm adopts the approximate second derivative information, which is much faster than the gradient method and does not require too much adjustment of parameters, so it is widely used. The main ideas of the LM algorithm are as follows: Let x(k) be the vector composed of the threshold and weight of the k th iteration, and the vector x(k+1) composed of the new threshold and weight can be obtained according to the following rules [Pedersen, Grigoras, Hoffmann et al. (2016)]: represents the gradient. Set the error index function as formula 1: Among them, ei(x) is th Among e error. And the Gauss-Newton method is calculated as follows [Quitian and Ancheyta (2016)]: J(x) is the Jacobian matrix of E(x). And LM algorithm is an improved Gauss-Newton method in the following form [Roman-Gonzalez, Moro, Burgoa et al. (2018)]: In the above formula, the proportional coefficient p>0 is a constant, and J is the identity matrix. If the proportional coefficient μ=0, it is the Gauss-Newton method. If the value of μ is large, the LM algorithm is infinitely close to the gradient descent method, and the iterative step is reduced step by step, so that it is gradually coincident with the Gauss-Newton method while approaching the error direction.
Since the LM algorithm is much faster than the gradient descent method, when μ is large enough, it is always guaranteed that [J T (x)J(x)+ μI] -1 is positive definite, thus ensuring its reversibility. That is, each iteration of the LM algorithm is a self-adjustment and adaptation of μ, and as it gets closer to the solution, μ would gradually decrease, and the weight adjustment would be consistent with the Gauss-Newton method. With a similar second derivative, this solution can be quickly converged. If μ gradually increases as it moves away from the solution, the weight adjustment starts to be consistent with gradient descent method, allowing for a full search. Therefore, LM algorithm has the advantages of Gauss-Newton and gradient algorithm. The only disadvantage is that it requires a lot of memory. Because of these advantages of LM algorithm, LM algorithm is used to estimate parameters in this research [Rollins, Roggendorf, Khor et al. (2015)].

Experimental design of algorithm application
In this heat transfer model, parameters can be divided into two categories: P, T1, T2, T1 (0) , T2 (0) /t and Δt which can be directly measured, and the parameters moil, Coil, Qloss, T2 (∞) and α which need to be experimentally determined. Eqs. (6) and (7) Among them, Qoil is the heat absorbed by the heat transfer oil, moil is the weight of the heat transfer oil in the jacket, T1 is the temperature of the heat transfer oil, T1 (0) is the initial temperature of the heat transfer oil, and Coil is the specific heat capacity of the heat transfer oil.
(max) (0) oil oil 1 1 loss PΔt = m C (T -T ) + Q Among them, P is the heating power of the heating rod, Δt is the heating time for electric heating rod, T1 (max) is the maximum temperature value reached by the heat heat transfer oil, and Qloss is the heat loss. Temporarily, the interference of temperature on the physical properties of the equipment is excluded, and moil and Coil are regarded as constants. During the process of this experiment, the volume and mass of the heat transfer oil in the jacket remain unchanged, and moil and Coil are estimated. In the first stage, the size of Qloss, room temperature, and the lag time of temperature increase of the heat transfer oil are correlated. Changes in Qloss can be found through experiments. Subsequently, the heat transfer oil is heated at different time periods. Since the lag time of temperature increase of the heat transfer oil varies little under different heating-up times, Qloss can also be regarded as constant [Schwolow, Neumüller, Abahmane et al. (2016)]. moil and Coil represent the mass and specific heat capacity of the heat transfer oil in the jacket of reactor, respectively. Qloss is the heat loss in the first stage. In the design experiment, water is added to the reaction kettle, wherein the volume of the kettle is 50 L, and the volume of water is 30 L. The heat transfer oil is heated, and the heating is stopped when the oil temperature reaches different temperatures. The corresponding heating power, time, the initial temperature, and the maximum temperature are recorded. In addition, it is necessary to repeat the same test at different temperature points and record the results. Finally, the values of moilCoil and Qloss under different conditions are calculated by LM algorithm and global optimal algorithm. The temperature at which the heat transfer oil ceases to heat is different, and the maximum temperature T1 (max) reached by the heat transfer oil is also different, so the corresponding temperature T2 (∞) in the reactor and temperature rise slope α are also different. Here, formula 8 needs to be introduced to estimate the values of T2 (∞) and α [Thakkar, Shah, Kodgire, et al. (2019)].
Specifically, water is added into the reactor as material, where the volume of the reactor is 50 L and the volume of water is 30 L. Heat the heat transfer oil with full power, stop heating when the heat transfer oil reaches different temperature values, and write down the highest temperature value that the heat transfer oil can reach. At the same time, the temperature change in the corresponding batch reactor is recorded. At different temperature points, the experiment is repeated and the results are recorded; The parameter values of moilCoil and Qloss under different temperature conditions are calculated by LM algorithm [Zhang, Lv, Tao et al. (2018)].

Establishment and verification of algorithm application model
LM algorithm and global optimal algorithm are used to determine the model parameters.
The intermediate variable is replaced by the highest temperature point of heat transfer oil, and the corresponding dynamic model of the temperature in the reactor and the heating power and time of the heating rod is obtained. Before determining the model, it is necessary to make assumptions according to the actual situation and simulate each stage of chemical engineering by adding water as material in the reaction kettle. The heat transfer coefficient between the heating rod and the heat transfer oil and some heat loss energy to be consumed are regarded as the components of Qloss.
According to the characteristics of batch reactor, Qloss is regarded as constant. The influence of later time should be ignored when describing the initial rising trend of the reactor temperature, and then the dynamic relationship model of the temperature of the reactor changing with the temperature of heat transfer oil is established. In the preheating process, full power heating jacket is required to rapidly heat the heat transfer oil. The change of α obtained by the LM algorithm and the global optimization algorithm is not large, so the average value is calculated. All the above experiments are carried out in the laboratory. The initial oil temperature of the batch reactor and the heat transfer oil of jacket should be consistent with the indoor temperature, so as to conduct numerical estimation by obtaining the average value in the data fitting process. The above assumptions need to introduce Eq. (9)

The heat transfer relationship between the temperature of the reactor and the temperature of the heat transfer oil
When the temperature of the heat transfer oil reaches its maximum value, the oil temperature gradually decreases, while the temperature in the reactor gradually rises and reaches equilibrium. In this process, heat transfer between the heat transfer oil and the reactor becomes the main part of heat exchange. From the above experiments, it can be concluded that the heat transfer oil would reach different maximum temperature with different heating time, and the corresponding temperature curve and equilibrium temperature would also be different. And Fig. 3 shows the change curve of the internal temperature of the reactor at different heating temperatures. In this stage, due to the long time, the reactor is exchanged with the external environment through the top of the kettle and some devices connected to the outside world, so heat loss is also an indispensable part. The heat loss at this time is not only related to the ambient temperature, but also related to the time required for the temperature in the kettle to reach equilibrium. It is difficult to describe by mathematical expression, and many factors need to be considered. However, in this stage, the relationship between the temperature change in the kettle and the maximum temperature value that the heat transfer oil can reach is the main content to be described, so another way is needed to describe the relationship between these parameters. It can be observed from Fig. 3 that the kettle temperature curve has a certain rule to follow. Therefore, parameter estimation method is adopted, and the selected estimation method is LM algorithm, which reflects the necessity of LM in the establishment of the heat transfer model of batch reactor.

Analysis of experimental results
The results of the above experiments are listed in Tab. 1. According to the results in Tab. 1, moilCoil tends to be stable, and it no correlation with the temperature that stops the heat transfer oil, so the influence of temperature change on the physical characteristics of heat transfer oil should be ignored. moilCoil remains constant in the experiment. In addition, the value of Qloss is relatively stable, so the average value of moilCoil and Qloss can be calculated. In this test, the heat transfer oil is heated by full power, so the input energy value of the system program is at least above 10 6 , and the estimated Qloss value is roughly 1/3 of the total input energy, which also proves the rationality of the whole test process and data. The values of T2 (∞) and α of each T1 (max) are obtained by fitting according to the formula 8 and averaged. The results are shown in Tab. 2.  (∞) and α corresponding to T1 (max) can be obtained, and the change relationship is shown in Fig. 4  It is obvious from the Fig. 4 and Fig. 5 that T2 (∞) changes linearly with T1 (max) , while α does not change significantly with T1 (max) . Therefore, it can be concluded that the algorithm adopted in the reactor temperature transfer model is effective to some extent.

Analysis of the verification results of the model
Throughout the course of the experiment, it heats the heat transfer oil with the full power. By selecting different heating time and substituting corresponding parameters into Eq. (10), the relation curve between corresponding temperature and time of the reactor can be obtained. In addition, corresponding values should be recorded to comprehensively observe the changing trend of the reactor. The final value of reactor temperature can be obtained through the above numerical observation. The corresponding comparison results are represented by the curve in Fig. 6. When t is infinite, the value of T2 and the value obtained from the experiment tend to be within the range of the corresponding stable temperature value. In Fig. 6, the upper half represents the linear relationship between the actual measured value and the calculated value of the model, while the lower half is the difference between the two. It can be clearly observed that the difference between the two is about ± 1.5°C. Such error value is within a reasonable range. Corresponding model assumptions and model abstractions are made at the early stage of model establishment, and water is used as a substitute, so this error is reasonable and effective. It can also be concluded that the application of LM algorithm in the establishment of the heat transfer model of batch reactor has certain rationality.

Conclusion
Based on the above mentioned, the intermittent reactor transfer model can well describe the heat transfer relationship of the whole device. Meanwhile, the heating power and heating time can be adjusted correspondingly, and then the corresponding reaction temperature can be obtained. The parameter determination method of the model is practical and feasible, and the error of the experimental verification can also be guaranteed at about ±2°C. In addition, a series of assumptions are made at the beginning of the establishment of the model. The experimental results show that the difference between the actual measured value and the calculated value of the model is within ± 1.5°C, which conforms to the model hypothesis conditions, and also proves the rationality and effectiveness of LM algorithm applied to the establishment of the heat transfer model of the batch reactor. However, due to the limited space, the interference factor analysis of the model is not comprehensive enough. In the future research, interference factors can be introduced to modify the model, so as to better transform the actual problems into mathematical models and solve a series of problems in the actual production faster and better.