Flexible Methane Production Using a Proportional Integral Controller with SimulationBased Soft Sensor

Anaerobic digestion plants have the potential to produce biogas on demand to help balance renewable energy production and energy demand by consumers. A proportional integral (PI) controller is constructed and tuned with a novel tuning method to control biogas production in an optimal manner. In this approach, the proportional part of the controller is a function of the feeding rate and system’s degree of stability. To estimate the degree of stability, a simulation-based soft sensor is developed. By means of the PI controller, the requirement for gas storage capacity of the digester is reduced by approximately 30 % compared to a constant, continuous feeding regime of the digester.


Introduction
Limitations on fossil resources combined with the demand for eco-friendly power generation have motivated more investments in renewable energy resources [1,2]. However, renewable energy sources like wind and solar power are weatherdependent and uncontrollable, which leads to a divergence between required and produced energy [1]. Since anaerobic digestion plants have the potential to produce biogas on demand, they can play a significant role in balancing power production and consumption [3].
In a demand-driven biogas production approach, the surplus in biogas production could be stored and fed to the power system when there is high demand. However, gas storage systems, particularly their installation and maintenance, always come with extra costs and are very expensive due to security aspects that need to be considered. An advantageous strategy for flexible production of biogas is managing the feeding regime to produce biogas based on demand instead of installing large gas storage capacities [4,5]. Although variations in feeding regime can be a threat to system stability [1], results of full-scale experiments in [2] demonstrated that long-term stability of the system can be maintained during flexible feeding and that the gas storage requirement can be reduced.
In literature, there are only a few control relevant works on demand-driven biogas plants. In [6], using an ADM1-based dynamic model [7], flexible biogas production is tested for different substrates. Then, using a proportional integral (PI) controller, amounts of available substrates to feed and times of feeding are calculated to meet the energy demand. In [3], a nonlinear model predictive controller is utilized on a full-scale plant to find the optimal feeding strategy to meet the biogas demand. Comparing to constant feeding, this algorithm could fulfill the biogas requirement and also ensure the stability of the process whilst requiring less biogas storage.
The objective of this work is to develop a control system to produce biogas on demand and to minimize the required storage capacity; thus, investment and operating costs can be reduced. Stable control of the nonlinear anaerobic digestion process is a challenge, in particular when it is operated over a wide range of biogas production rates, which further increases the nonlinear behavior of these plants. A PI controller can be easily implemented on biogas plants making it a cost-effective solution. However, conventional PI controllers with fixed tuning parameters cannot compensate for the nonlinear behavior for all operating ranges. Besides, high feeding amounts can cause stability issues.
The proposed tuning method for the PI controller can compensate for the nonlinearity of the system, whilst guaranteeing system stability. The tuning approach consists of a two-step parameter tuning. In the first step to handle nonlinear process dynamics, a primary gain scheduling tuning method is applied. Secondly, a simulation-based soft sensor, proposed in [8] with a few modifications is utilized to estimate the stability degree of the plant. Based on the current stability degree, a secondary tuning variable is defined to moderate the proportional parameter of the PI controller. As a result, avoiding large feeding amounts when the plant is close to process inhibition, stability can be ensured. The developed controller is tested on the simulation model. To evaluate the efficiency of this method, it is compared to the case of constant feeding of the digester.

Model Validation and Usage Scenario
The anaerobic digestion model used in this simulation is the ADM1da [9]. To ensure that the simulation model performs close to reality, the model accuracy is evaluated using real measurement data from the pilot biogas plant of the research site :metabolon, which is located in Lindlar (Germany). To avoid numerical issues in simulation, the real reactor volume and the input substrate flow rate are scaled up by a factor of 100, which can be seen in Tab. 1. Since the real data is measured once a day, the simulation step size is also considered to be 1 day for the evaluation of model accuracy. The maize silage composition values were found in [10,11] and modified manually to make the simulation as close as possible to the measurement data. The substrate composition parameters are also given in Tab. 1. All the other calibration parameters are set to default values.
In Fig. 1, simulation results and measurement data are displayed. The experiment has a duration of 52 days and each week the feeding amount is increased by 1 kg d -1 . To evaluate the accuracy of the model, the root mean square error (RMSE) 1) as well as R 2 [3] values are given in Tab. 2.
whereŷ i is the simlated value, y i is the measured value, N is the number of data samples, and m is the mean of measured values.
Based on the obtained results in Fig. 1 and Tab. 2, it can be concluded that the model has sufficient accuracy. To evaluate the performance of the controller, the utilization scenario in Tab. 3 is taken. It is assumed that the capacity of the combined heat and power unit (CHP) is 1.6 times larger than the average biogas production by the plant, which is 9.83 m 3 h -1 .

1)
List of symbols at the end of the paper.

Simulation Platform
The controller and simulation of the plant are developed in SIMBA# Biogas [12] software. The simulation model is comprised of a continuous stirred-tank reactor (CSTR) and maize silage as substrate feed. The anaerobic digestion model used in this simulation is the ADM1da [9].

Control Strategy and Tuning
In Fig. 2, an overview of the developed control algorithm is illustrated. The input error to the controller is the difference between the desired gas storage filling level of 150 m 3 and the summation of current storage level and 2 h ahead gas utilization requirement. Adding the 2 h ahead utilization demand is obtained to be beneficial to prepare for the upcoming demands. The proportional part of the controller will be adjusted using the information from the soft sensor and substrate flow rate. As a result, the PI controller can keep the storage level at the desired value. In Tab. 4, more detailed information on the experimental setup is given. In this paper, the internal model control (IMC) design or equivalently direct synthesis method [13] is employed. According to this approach, a step test is applied to the simulation model and the respective transfer function for each operating point is estimated. The defined step input signal starts from 0.2 t d -1 and increases to 3.6 t d -1 with a length of 10 d. Because of the long length of the step test, only the first 50 d of the step input signal and the biogas response are illustrated in Figs. 3a and 3b, respectively.
From the biogas production response (Fig. 3b), a first-order behavior can be observed which can be estimated by a first-order transfer function in Eq. (5).
where ΔF feed is the applied input step amplitude equal to 0.1 t d -1 , ΔF biogas-ss is the change in the steady-state value of the biogas production, k p represents gain, ΔF biogas is the deviation of biogas production caused by a step change in F feed , and t p is the time constant of the plant. The time constant t p of the plant is obtained around 3 d. However, the calculated gain k p for different operating points Table 3. Weekly biogas utilization scenario used for controller evaluation [3].
Step input signal on the substrate feed maize silage (F feed ), (b) simulation step response of biogas production (F biogas ).
varies from 101.21 to 337.078 m 3 t -1 . Therefore, the nonlinearity comes from the gain of the process. In the next step, parameters of the PI controller, given in Eq. (6), should be calculated: Based on the IMC design approach for a first-order delayfree system, the proportional gain (k c ) is a function of openloop gain (t p ) and desired closed-loop time constant (l): For a process with dominant integral behavior, the integral time (t I ) should be smaller than t p to reduce the settling time [13]. Considering the long-time constant of the biogas process and demand for providing biogas in a few hours, it is necessary to reduce t I . For this purpose, the characteristic equation of the closed-loop system with the PI controller is obtained: Comparing the above equation with the prototype secondorder form t 0 2 s 2 + 2t 0 zs + 1 and inserting the value for k c from Eq. (7), t I can be calculated as below: The desired closed-loop time constant of the plant is set to l = t p /4 to have a fast response. To have a short settling time while overshoot is in a reasonable range, z = 0.7 is considered [8]. As a result, the integral time of the controller is t I = 0.29 d. However, the k c value would be different for different operating points.

Primary Gain Scheduling
Gain scheduling is an approach to compensate for the nonlinearity of the plant [14]. In this method, the proportional parameter of the controller (k c ) varies depending on the operating range of the system. In this paper, the gain of the process depends on the feeding value, and the proportional part of the controller is defined as a function of the process gain in Eq. (7). Therefore, a look-up table in Tab. 5 is defined which gives the current proportional gain value k c based on the current feeding rate.

Secondary Gain Scheduling
The secondary gain scheduling parameter k s is associated with the stability degree of the digester. For high stability degrees, this parameter gets close to 1 and for lower degrees it becomes close to 0.7. Hence, the PI controller will be able to reduce the feeding value under low-stability conditions. The proportional part of the controller will be obtained as the product of the primary and secondary gain scheduling parameters. The final PI controller formula results from the following equation: In [8], a simulation-based soft sensor is proposed which can estimate the stability degree of the digester in three categories of strongly stable, moderately stable, and weakly stable. The only information this soft sensor needs for the classification is the feeding amount and the biogas production flow rate. As it is mentioned in [8], shortage in reliable economic online instrumentation has limited the implementation of real-time controllers in full-scale biogas plants. Therefore, real-time estimators of the process operating condition can be a good solution to apply control methods in a full-scale biogas plant. In this paper, a similar approach with a few modifications is utilized to design the soft sensor.

Soft Sensor Development
In this approach, short feed pulses should be added to the digester, and depending on the response of biogas production to these pulses the stability condition of the digester can be identified. To develop a soft sensor that can identify the stability condition of the digester, the following design procedure should be taken in the simulation platform: defining simulation scenario, designing pulses, and categorization of stability degree.

Simulation Scenarios
A simulation scenario should be defined to cover approximately all the conditions that a flexible biogas plant might go through. In the original paper [8], steady-state scenarios are specified that cover all the probable operating conditions.  However, because of the variable feeding strategy in flexible biogas production, the state of the plant is always changing and does not reach a steady-state condition. Since the most alterations in feeding regime take place in the first weeks of operation, most probable operating conditions can be covered during this period. Therefore, the PI controller with only primary gain scheduling is applied to the simulation plant and the data captured for the first four weeks of operation is used to build the soft sensor.

Pulse Characteristics
As mentioned in [8], pulse amplitude and length need to be in the range that make an observable effect but are not altering normal operation. In this paper, based on simulation results, one-tenth of the maximum feeding amount with a length of 7 min is considered for the pulse characteristic. Each of these pulses is applied 1 h before the new feeding value enters the digester to avoid any overlap between the influences of the superimposed pulses and the controller feeding inputs.

Stability State Experiment
According to the experiment performed in [8], it is proven that high relative changes in biogas production happen when the concentration of volatile fatty acids (VFA) is low, and lower changes take place for high VFA concentration. Low concentration of VFA is interpreted as a high digester capacity to accept higher feed loads, while high concentration of VFA can be an indicator for instability and low capacity to accept feed loads. Therefore, relative biogas production can be an indirect sign for system stability. In Fig. 4, the difference between the initial and the maximum biogas production value (ΔQ in m 3 d -1 ), while the superimposing feed pulse is being applied, is calculated. It is expected that high relative changes in ΔQ happen when the stability degree of the plant is high, and lower changes take place under weaker stability conditions. However, in this experiment, variations in ΔQ are not in a high range and the stability condition of the system is varying between strongly and moderately stable. A better interpretation of the stability of the system based on ΔQ requires an experimental test on the pilot plant and additional model calibration to develop an accurate soft sensor to estimate the stability degree.
Another interpretation from Fig. 4 is that large ΔQ values are happening in the period for which the controller calculated higher input feeding values and smaller ΔQ values for the case that the demand for biogas production is less. By considering the lower values of ΔQ as moderately stable, the proportional gain will be reduced for cases that the biogas production should be reduced. This reduction in proportional gain diminishes the saturation phenomenon in the controller. As a result, the controller speed will be improved.

Categorization and Tuning Function
Considering the simulation results presented in Fig. 4, the ranges for stability state of the system as well as the secondary proportional parameter (k s ) are defined in Eq. (11):

Digitalization of the Controller
In a biogas plant with a solid substrate feed, such as maize silage, continuous adjustment of the feeding input is not possible, and a digital controller is required. The transformation of the designed PI controller from continuous domain to the discrete domain using a zero-order hold (ZOH) approximation is defined as below [15]: where T s is the sampling time equal to 8 h, which is obtained based on a rule of thumb to define the sampling time approximately one-tenth of the time constant. The output signal of PI(z) will have a constant value between the sampling times. However, considering the feeding strategy, which has to be built, pulses of substrate feed equivalent to the feeding value are calculated by the controller. These pulses are generated every 8 h and their amplitude and length should be such that the space under the pulse would be the same as that of the   Figure 4. Changes to the biogas production (ΔQ) during the period of each superimposing feed pulse, while the PI controller with only primary gain scheduling is used for this experiment.
signal calculated by the controller. Therefore, the length of 15 min for each pulse corresponds to the amplitude of 32 times larger than the signal calculated by the controller. In Fig. 5, this transformation is illustrated graphically.

Simulation Results
In this section, the performance of the controller is evaluated for the duration of 15 weeks. To be able to compare the results, the superimposed feed pulses are also applied for all the cases. Initially, the developed controller is employed without primary and secondary gain scheduling. A value of k c equal to 0.012 is set, as this is the average of values for different operating points given in Tab. 5. In Fig. 6, the reason for the behavior of the controller is the windup effect. Since the input error value is large, the output of the controller saturates and the error remains non-zero for a significant time. Hence, error accumulates in the integral part and causes the delayed response of the controller. To cope with this issue, an anti-windup strategy is required.

Tracking Anti-windup Strategy
The anti-windup approach used in this paper is tracking antiwindup as illustrated in Fig. 7 [16]. Here, the difference between the saturated output and the actual output multiplied by the limitation gain (K lim ) is fed back to decrease the amount of input error entering the integrator [16]. The value of K lim is chosen to be 0.6. Fig. 8 demonstrates that by applying the tracking anti-windup, the issue with the delayed response is solved and the storage filling level could be kept above zero during the experiment.

Simulation Results After Anti-windup
In Fig. 9a, the results before and after applying the primary gain scheduling are indicated. From day 30 till the end of day 33, the filling level without primary gain scheduling drops below 10 m 3 and very close to zero. However, after the scheduling, this drop occurs only in few hours of day 31 and day 32. The same behavior can be seen for the duration of day 57 until  day 61. Therefore, primary gain scheduling could minimize the time spent in the undesired situation of a very low storage filling level. According to the results, after day 70, the fluctuations in filling level is less than 300 m 3 with gain scheduling, while without the scheduling even on day 98 still the maximum overshoot goes above 300 m 3 . As a result, the primary gain scheduling could reduce the required storage capacity after a few weeks of operation. In the last experiment, the soft sensor is utilized. Fig. 9b indicates the biogas storage filling level for the simulations with and without secondary gain scheduling. After applying the soft sensor, the storage filling level could be kept below 300 m 3 after 30 d. In contrast, without the soft sensor this required 70 d of operation.

Comparing with Constant Feeding
The average produced biogas during the 15 weeks of operation with the controller is approximately equal to 236 m 3 d -1 . This average value is considered to be the continuous gas production amount with a constant feeding regime of 0.618 t d -1 . As demonstrated in Fig. 10, for the same usage scenario the storage requirement would be 450 m 3 , and for 10 d of operation (day 94 till day 104), the demanded biogas could not be provided.

Conclusion
The design of a PI controller is presented which was used to operate a flexible demand-driven simulated biogas plant. The proposed tuning approach enabled a faster response from the  plant to provide the required biogas amount. The controller was compared to a constant biogas production scenario, and the results demonstrated that after the first three weeks of operation the developed controller reduces the required storage capacity by 150 m 3 . The controller required three weeks to identify the appropriate feeding regime, and this time is considered as the start-up phase. The improvements are discussed for after this start-up duration.
The authors have declared no conflict of interest.