Gain scheduling control applied to oil and gas separator level loop

Modeling and simulation applied to level control of oil and gas separators in production facilities is a very important tool because makes possible to perform tests that probably could not be viable due to operation and safety constraints. Asides the level dynamics can be well understood regarding the physical model, there will always be non-linearities to approach using a system identification procedure, requiring reasonable care on linear model identification. In order to assure a desired control performance, an adaptive control strategy has been proposed for level control for an oil and gas separator using the gain scheduling technique. Based on a first order process without time delay, the static gain and time period were determined for each point inside the operational space range of the equipment and by Internal Model Control (IMC), the tuning matrix found and converted into a function of operational parameters using polynomial interpolation methodology for future application in a real commercial PI controller. The horizontal separator was simulated using MATLAB/SIMULINK® and data from a real separator vessel were used to identify and validate the proposed process modeling in attempt to test an adaptive control strategy for practical applications. Once the GSC was implemented, simulations were performed over the non-linear system and results have shown better performance indexes for GSC while compared to the conventional PI controller for both servo and regulatory problems with reductions up to 17.65% for IAE, 29.88% for ISE, 16.38% for ITAE, 29.00% for ITSE and 13.20% for Control Effort (CE).


Introduction
Oil, gas and water are present in all hydrocarbon reservoirs under thermodynamics equilibrium. This equilibrium is broken when the reservoir is depressurized to get its fluids up to the surface, operation this known as production. Fluids need to reach surface through the production string and at surface they are conducted by pipeline to the production headers and manifolds where liquid and gas from many wells can be mixed all together in a unique stream and driven onto production facility. In the first stage separator, after retention time, decanting, and stabilization of pressure and level, oil, gas and water leave the separator in separated lines. The thermodynamic analysis of the separation process is widely discussed and can be found elsewhere (Sayda & Taylor, 2007).
All crude oil processing requires process variables (PV) to be controlled, e.g. pressure and liquid level,. This control is mostly implemented using proportional integral derivative (PID) controllers as part of a programmable logical controller (PLC) instructions in order to keep the PV inside an acceptable range centered by a desired value, defined as set point (SP), trying to minimize the error. Quite often one may find operational teams not very familiar with control theory, leading to control parameters set based only on the practical experience, resulting in not interests nor encouragement for control loop upgrade.
However, this situation brings up great opportunity of improvements with minor modifications (John-Morten, Stig & Gunleiv, 2005).
Tuning analysis should be the first attempt while aiming better control performance. As example, in order to overcome slugging problems in offshore three-phase inlet separator, Zhenyu, Michael, and Løhndorf (2010) had proposed a simplified approach to a conventional PI controller of the level loop working on enhanced tuning procedures such as trial-and-error method, Butterworth filter design method and IMC method getting satisfactory results.
The development of adaptive control strategies for liquid level regulation in a set of two coupled tanks were the object of research of many papers. Some authors have compared three different types of adaptive controller, i. e. a direct model reference adaptive controller MRAC, an indirect MRAC with Lyapunov estimation, and an indirect MRAC with recursive least-squares (RLS) updating estimation for liquid level control (David & Lei, 2005), being the best results obtained using RLS estimation.
Among several manners of adaptation there is the Gain Scheduling. The controller projected that way has been named Gain Scheduling Controller (GSC). Bagyaveereswaran and Arulmozhivarman (2019) worked with Gain Scheduling to develop a RTD-A controller, where RTD-A stands for Robustness, setpoint Tracking, Disturb rejection and overall Aggressiveness).
They have analyzed three industrial application model including a conical shape tank. In the same thematic, Vikhe, Parvat and Kadu (2019) have applied GSC in a more concise form for a variable cross sectional area tank. They have realized integral time be independent of the tank parameters and, differently, the proportional gain be directly related to the cross sectional area (scheduling variable) to each value of stationary level. More references about the Gain Scheduling application are present in (Bisowarno, Tian & TADÉ, 2003), (Fernandes, Moraes, Paulo & Oliveira, 2013), (Onat, 2014), (Ban & Wu, 2015), (Gao & Lakerveld, 2019), (Sarkar & Banerjee, 2019).
Thus, considering the non-linearities of level dynamics in a real horizontal cylindrical separator, this article proposes a non-linear control technique for level regulation using an adaptive gain scheduling PI controller and a control valve with exponential curve feature. Materials and methods are covered in section 2 which presents the mathematical model development, followed by its linearization and implementation in a simulation. Section 3 ends the article validating an actual data set to the model and performing a study case comparing a standard PI controller tuned by IMC method to the gain scheduling controller (GSC) using performance criteria as integral of absolute error (IAE), Integral Square Error (ISE), Integral Time-weighted Absolute Error (ITAE), Integral Time-weighted Square Error (ITSE) and control effort (CE).

Methodology
The methodology proposed in this article is according to Koche (2011).

Horizontal separators
Production facilities widely uses horizontal separators because they can process more efficiently larger volumes of gas, and they are less expensive when compared with vertical or spherical separators for a similar dimension and gas capacity (Arnold, & Stwart, 2010). To analyze the level dynamics, it is necessary to find the relationship among level rate of change and others operational conditions and geometrical relations in the horizontal separator. The process model development hereafter used is according to Zhenyu, Michael, and Løhndorf (2010), Sundaram (2013), Giovani, Medeiros, and Araújo (2010), Seborg, Edgar, Mellichamp and Doyle (2011).

Process modeling
From basic trigonometric rules, the volume of liquid inside the vessel indicated in Figure 1 can be found as a function of the liquid level h and vessel diameter D, represented in Equation 1. Research, Society and Development, v. 10, n. 4, e55010414397, 2021 (CC BY 4. Source: Authors. In this paper, the liquid is considered to be incompressible, which means that its specific mass ( ) is constant and the liquid mass rate can be determined using Equation 2, and applying the chain rule, the liquid volume rate is calculated as indicated in Equation 3.

( ) = (2)
and, applying the chain rule Thus, one can easily find using Equations 1 to 3 the fundamental relationship between the rate of level change to the difference between the inlet and the outlet flow rate, represented by Equation 4. As expected, the liquid level has a nonlinear dynamic in horizontal separators, which requires an adaptive control strategy to better regulate the liquid level.
In oil and gas facilities, the most common final control element is electro-pneumatic control valve. Considering a quick opening feature (Giovani, Medeiros & Araújo, 2010), the volumetric flow rate can be calculated using Equation 5.
The volumetric flow rate is calculated considering the flow coefficient ( ) , the valve opening position ( ), the pressure drop (∆ ) through the valve in bar, the relative density ( ) of the fluid at a specific temperature.
The standard PI controller finalizes the model. GSC has the same control law however, instead of fixed values for the parameters, the proportional gain and the integral time adapt themselves according to the operational conditions of the equipment. The error signal ( ) have been normalized to values between 0-1 as well as the valve position .

Differential-algebraic model system
Mathematically, the modeling discussed above can be represented as a non-linear differential-algebraic system stated in the Table 1.
Table 1 -Model of differential-algebraic system.

Equation Input
Output Model above involves an algebraic loop and require some care during implementation. Under proper initial conditions the system can be solved using MATLAB/SIMULINK ode45 (Dormand-Prince) solver. The system must be properly conditioned, capturing, for example, that ℎ, as integrator output, is a state variable of the system. Secondly, inputs must be in accordance. For instance, for a given ̅̅̅̅ , a corresponding ̅̅̅ is expected. Non-linear model will be simulated with GSC designed in this work. Non-linear system implemented in SIMULINK can be seen in APPENDIX A.
For GSC design, the equations in Table 1 must be linearized, combined and using Laplace´s Transformation converted into the transfer function representation for PI control tuning using IMC method.
Expanding Equation 4 in a Taylor´s series, not accounting for the second and higher order terms and defining deviation variables, one can find its linear and deviated form (f') stated in Equation 6.
Applying the same methodology for Equation 5, the flow rate through control valve can be represented by its linear and deviated form in Equation 7.
Replacing Equation 7 in 6 and applying Laplace´s transformation, the Equation 8 is obtained in terms of liquid level, valve control opening, pressure and inlet flow rate.
Starting from Equation 8 one can find the model transfer functions (TF) as stated in Table 2, along with its respective derivatives in Table 3.
Source: Authors. Table 3 -Derivative terms of the process model.

Process control and model validation
Operational data set of a real production facility, including the liquid level, control valve position and outlet flow rate information of an actual horizontal separator, described in Table 4, were used for linear model validation, and outputs values comparison.    Source: Authors.
A calculation routine was prepared in Matlab ® to perform all calculations presented in the methodology for a set of inputs parameters and expected disturbs. These calculations were necessary to feed data to the model.

Performance indexes
In order to quantify the performance attained in the simulations, the following index were used: Integral Absolute

Error (IAE), Integral Squared Error (ISE), Integral Time-weighted Absolute Error (ITAE) and Integral Time-weighted Squared
Error (ITSE) defined as stated in Equations from 9 to 12 (Ogunnaike & Ray, 1994). Control Effort ( In the above equations the upper integral limit has been replaced by the simulation duration time.

Model validation
Analysis of the control valve output flow rate against its opening position has indicated that the internal plug and cage assembly has exponential flow pattern as measured for several operational points with results in Figure 4.
For the conditions informed in Table 4, the controller was changed to manual mode and the valve position changed from 0.309 m to 0.255 in attempt to validate the horizontal separator modeling, and the results plotted in Figure 5. With similar objective, tests in closed loop were also carried out and compared to simulated output values for the same input conditions, and the results are shown in Figures 6 and 7.    .

Source: Authors.
As can be seen in Figures 5, 6 and 7, the model can adequately represent liquid level dynamic in a horizontal separator considering both open and closed loop control system, respectively. Then, the proposed model was used to evaluate the gain scheduling control performance against a linear PI control law.

Gain Scheduling Control (GSC)
Application of the data set to the model has revealed non-linearity behavior in the model regarding the liquid level (ℎ) and strongly due to valve position ( ). To develop the GSC control law, the operational space for liquid level h and valve position was divided into eight intervals generating an 8x8 matrix. For each combination pair (ℎ, ), the static process gain and time constants were calculated generating the results in Tables 5 and 6, respectively.  Research, Society andDevelopment, v. 10, n. 4, e55010414397, 2021 (CC BY 4.0) | ISSN 2525-3409 | DOI: http://dx.doi.org/10.33448/rsd-v10i4.14397  Tuning method adopted in this paper was the Internal Model Control (IMC) which for a FOP proposes a PI with gains according to [24] and represented in Equations 18 and 19.
The parameter λ is the performance criteria of the IMC tuning procedure and defines how fast the process output tracks the setpoint Bartys and Hryniewicki (2019). It´s recognizable that the closed loop containing 2 ( ), along with controller FT, , defines a second order system, Equation 20. The system of Figure 4 has been simulated, with a 5% SP step input, for = 30, 90, 270, 810 . Results indicates that to = 90, 270, 810 the system is underdamped. For = 30 , a damping ratio, = 1,23 is achieved and, since oscillation induction is not meant by the controller, this value was chosen. Lower value, say it 10 seconds, are not recommended because it generates huge values for which in turn causes unnecessary control effort and even, eventually, instabilities in the presence of noises.
Considering equal to 30 seconds, the matrix can be found as in Table 7. Based on IMC method rules, very large values were observed and, as a compromising solution, the values of the interpolation is divided by a factor of 10 3 , still resulting in integral action observation (offset removal of the permanent response).    Source: Authors.
The results of the simulations can be seen in Figures 8 to 11 while the performance indexes can be found in Table 11 below. Gain adaptation of GSC, presented only for simulation #1 is showed in the Figure 12.    Source: Authors.  Figure 12 -Gain Scheduling gains compared to conventional PI gains for simulation #1.

Results analysis
The comparison of model versus actual data set has been considered satisfactory for both open and closed loop cases.
Major non-linearities found for the level dynamics were the level itself and specially the valve flow curve with exponential feature. Users of the linearized model ( Figure 3) must have in mind the intrinsic limitations of the mathematical modeling because the transfer functions are determined based in the model linearization in the stationary point so steps in disturbs of liquid load flow rate or level setpoint must be applied in thick steps. Time constants are the same for 1 ( ), 2 ( ) and 3 ( ) with high magnitude (many hours) and similar value were observed in Zhenyu, Michael and Løhndorf (2010). This way, any attempt of system identification like step response were not feasible because, for any practical observation window, the system looked like a pure capacitive system. Analyzing actual data sets it was not detected dead time and so not included in the model. The non-linear model, as stated in Table 1, was implemented in SIMULINK. Simulations were carried out for setpoint step changes and inlet flow rate for both Gain Scheduling Control (GSC) and standard PI controller. GSC had better results for all simulations. The indexes for simulation #2 were better for conventional PI but, due to control valve saturation at 100% opened, this controller was reproved for this operational condition since, with = 1, an output flowrate, = 2825 3 , well above , cause operational problems like gas flashing due to pressure transients and flow turbulences.
GSC adaptation is very clear at Figure 12 and is the reason why the actuator respond properly for any position inside the equipment operational values,

Conclusion
Although apparently standard PI may indicate as good performance as GSC based on the Table 11, the nature of the strong non-linear control valve makes impossible a fixed parameter controller work efficiently in all control loop operational range. GSC has get better performance with reductions up to 17,65% for IAE, 29,88% for ISE, 16,38% for ITAE, 29,00% for ITSE and 13,20% for Control Effort (CE). As conclusion, in order to achieve efficient control with stability, avoiding control valve saturation and still having a smooth outlet flow rate, GSC is the choice despite simplicity of the standard PI controller.