Modelling and pH Control in Raceway and Thin-Layer Photobioreactors for Wastewater Treatment

: One of the most critical variables in microalgae-related processes is the pH; it directly deter-mines the overall performance of the production system especially when coupling with wastewater treatment. In microalgae-related wastewater treatment processes, the adequacy of pH has a large impact on the microalgae/bacteria consortium already developing on these systems. For cost-saving reasons, the pH is usually controlled by classical On/Off control algorithms during the daytime period, typically with the dynamics of the system and disturbances not being considered in the design of the control system. This paper presents the modelling and pH control in open photobioreactors, both raceway and thin-layer, using advanced controllers. In both types of photobioreactors, a classic control was implemented and compared with a Proportional–Integral (PI) control, also the operation during only the daylight period and complete daily time was evaluated. Thus, three major variables already studied include (i) the type of reactors (thin-layers and raceways), (ii) the type of control algorithm (On/Off and PI), and (iii) the control period (during the daytime and throughout the daytime and nighttime). Results show that the pH was adequately controlled in both photobioreactors, although each type requires different control algorithms, the pH control being largely improved when using PI controllers, with the controllers allowing us to reduce the total costs of the process with the reduction of CO 2 injections. Moreover, the control during the complete daily cycle (including night) not only not increases the amount of CO 2 to be injected, otherwise reducing it, but also improves the overall performance of the production process. Optimal pH control systems here developed are highly useful to develop robust large-scale microalgae-related wastewater treatment processes.


Introduction
Nowadays, three of the great problems that concern society focus on the search for new systems of production based on renewable energies, the reduction of greenhouse gases, and the availability of clean water. All of these aspects are directly related to existing pollution worldwide. In particular, one of the main causes of water pollution is the discharge of wastewater, therefore, the treatment of wastewater is becoming increasingly important. However, conventional purification systems have not only an economic cost but also an environmental cost mainly due to the pollution derived from the form of generation of the energy required in this activity. Additionally, wastewater treatment regulations are increasingly strict, which is why new treatment techniques are necessary not only for being more efficient but also more sustainable.
The elimination of the organic matter present in the wastewater is one of the most optimized aspects of the purification process. The same is not the case with nitrogen and phosphorus purification, which entails higher energy costs in addition to the need to install additional equipment and processes. In the last two decades, low-cost and environmentally friendly alternatives to convection-activated sludge processes have emerged [1][2][3][4].
Bioprocess technology or biotechnology has been presented as an emerging area that makes it possible to widely contribute to the challenge of the problems described above. Bioprocess operations use microbial metabolisms, animal cells, plant cells, and cellular components to produce new biotechnological products (animal feed, pharmaceutical products, biomass, biogas, biodiesel, etc.) and eliminate waste such as CO 2 or other types of pollutants. Inside the field of biotechnology, microalgae are one of the bioprocesses with greater potential in relation to problems previously mentioned.
Microalgae are single-cell phototrophic microorganisms capable of obtaining energy from the solar energy radiation and synthesize their biomolecules employing a source of carbon, water, and other simple inorganic elements, such as phosphorous and nitrogen. Microalgae have a great biotechnological potential for obtaining products with high added value to the food, cosmetic and pharmaceutical industries, such as food ingredients, animal feed, and aquaculture, antioxidants, and bioactive substances, also to their use in processes of wastewater treatment, CO 2 capture, biodiesel production, among others [5].
Microalgae production is mainly performed using open photobioreactors, in particular, raceway photobioreactors are the most common ones on an industrial scale due to their operational simplicity and their low maintenance costs. They consist of a recirculation tank with a culture height between 0.15 and 0.30 m, with a paddle drive device for agitation. Recently, the use of thin-layer reactors has been introduced. Thin-layer reactors are characterized by their low-depth culture (0.5-5.0 cm), recirculated over a flat surface by providing an adequate slope of 0.1-2.0%. This type of photobioreactor has the advantage of achieving significantly higher biomass concentrations, which offers higher area productivity (between 30 and 50 g·m −2 ·day −1 ) with lower processing cost. Furthermore, despite being open systems, the contamination of cultures by other species is not very high, since the high biomass concentrations reached prevent this type of contamination. For example, in a study conducted in Almería (Spain), it was observed that the productivity of Scenedesmus sp. in a thin-layer photobioreactor, with an area of 32 m 2 , could reach 42 g· m −2 ·day −1 while using a raceway, with the same area, the maximum productivity was barely half this value: 24 g·m −2 ·day −1 [6].
It should be noted that the process of production of microalgae, as any biological process has nonlinear and complex dynamics. Additionally, it incorporates a non-stationary steady-state, the presence of changing disturbances, as well as strong feedback from the population level to the cell through the attenuation of light [7]. All of this makes control a difficult task. The variables with the greatest influence on the behavior of the microalgae culture are temperature, solar radiation, pH, and dissolved oxygen [8]. The operating conditions of both temperature and solar radiation are determined by the design of reactors, so they are not controllable variables and act as disturbances [9]. Therefore, the controlled variables are pH and dissolved oxygen, both of which are disturbed by solar radiation. Both have a strong dependence on the rate of photosynthesis and therefore on the production of biomass. For this reason, mathematical models and the design of adequate control strategies are required to capture the dynamics of the system and to keep these variables close to their optimal values [10]. If adequate control is not achieved, the growth of the microalgae could be considerably impaired, causing a reduction in the production of biomass, and in some extreme cases, it could lead to situations of damage to the microorganisms.
In the case of dissolved oxygen, there are not many control strategies in the literature. Usually, excess air is supplied into the sump to prevent high values are reached, causing desorption of the oxygen released by the microalgae during photosynthesis. This produces high consumption energy and performance losses. In this way, new control strategies based on Proportional-Integral-Derivative (PID) control and event-based control have recently been proposed which allow adequate control of dissolved oxygen [9]. On the other hand, other recent contributions have made it possible to improve the mass transfer capacity in the reactor by adjusting the mass transfer coefficient of dissolved oxygen [11], which has allowed the development of control strategies capable of regulating the gas flow in an optimal way to achieve the desired value of dissolved oxygen in the system [12].
In the case of pH, which is the one of interest in this work, the pH regulation in open photobioreactors is usually performed using classical On/Off controllers during the daytime taking into account the photosynthesis process, and leaving the system in an open loop during nighttime, mainly due to the lack of dynamical models, appropriate proportional valves for supplying low flow values of injected gas, and the simplicity of this control scheme. However, this control architecture causes the pH to vary during the daytime, and this one increases significantly during nighttime, which is harmful to the algae. Moreover, this supposes a high consumption and losses of CO 2 (greater than 75%), with the cost in CO 2 around 30% of the production costs [13]. To address these problems, different types of control strategies have been proposed in the literature, mainly the PID control. This control strategy is widely used in industry with satisfactory control results (performance) and can be used for these types of processes. In [14], a decrease in CO 2 cost is demonstrated with a linear PI controller with feedforward for pH control in tubular bioreactors. A robust PID controller for pH control in raceway reactors based on Quantitative Feedback Theory (QFT) was used in [15]. Recently, in [16,17], results were obtained in which it is better to control the pH throughout the day, also without increasing the CO 2 injections. Specifically, it shows that the dynamics of the pH has a different behavior during the day and at night, being able to obtain different models and allowing a control based on events that allow switching a slow control during the night (since the evolution of the pH is not affected by disturbances) and a fast controller during the day (to cope with changes due to solar radiation and the effect of photosynthesis). Event-based control has presented a very satisfactory result allowing an adequate balance between control performance and cost reduction and/or losses to the environment. Precisely, in [18,19], in open photobioreactors where the use of control was combined predictive with event-based strategies a 40% reduction in gas injection time and a 30% increase in biomass concentration were achieved compared to usual modes of operation in tests carried out.
The fundamental objective of industrial photobioreactors utilized for wastewater treatment consists of maximizing performance in the production of microalgae while ensuring adequate wastewater treatment, employing an adequate balance between optimization of conditions growth and associated production costs. Therefore, this work presents the development and implementation of a PI control system in raceway and thin-layer photobioreactors, showing, on the one hand, the advantages of this over conventional On/Off control, and the improvement in the pH control considering the differences in the daytime and nighttime dynamics. On the other hand, the differences in dynamics and behavior between both types of reactors are also shown. CO 2 injections involve associated economic costs (especially when uses pure CO 2 ) and unnecessary emissions to the atmosphere when they are not provided adequately, also affecting the performance of the biological system. Therefore, the developed control algorithm should find a trade-off between reaching the desired pH value and the amount of CO 2 contributed to it, to maximize the yield of the biological system. With the implementation of PI control, it is possible to reduce the consumption of CO 2 , although the number of injections is greater. In this way, the necessary amount of CO 2 is injected to maintain the pH at certain levels to maximize algae growth and minimizing CO 2 losses to the atmosphere. Another advantage is the reduction in the Integrated Absolute Error (IAE) for pH because it stays close to the set-point throughout daytime and nighttime, unlike conventional control where the pH fluctuates. Note that all the experiments were performed in outdoor conditions in two raceway and two thin-layer reactors.

Materials and Methods
This section describes in detail the characteristics of the reactors used, as well as the control architectures used in the different tests.

Raceway and Thin-Layer Reactors
The raceway and thin-layer photobioreactors used for the tests are located at the IFAPA center, next to the University of Almería (Almería, Spain). On the one hand, there are two fiberglass thin-layer reactors with similar characteristics formed by a shallow channel together with a polyethylene tank of a volume of 0.5 m 3 (see Figure 1). They have a total area of 10 m 2 and they are operated at 0.02 m constant depth (0.45 m 3 total volume). At the bottom of the tank, a plate membrane diffuser injects CO 2 with a flow rate of 2.2 L·min −1 . On the other hand, raceways reactors are made of fiberglass with a total surface of 7.13 m 2 , operated at 0.12 m constant depth of culture to give the best overall hydraulic performance in terms of power consumption to reduce dark zones. They have also a sump with a volume of 0.2 m 3 where a plate membrane diffuser injects CO 2 with a flow rate of 10 L· min −1 or air with a flow rate of 5 L·min −1 . Mixing is made with a 0.2 m diameter paddlewheel with eight steel blades, operated by an electric motor (see Figure 2).  In each reactor, there is a pH probe (in thin-layers, HI 61,014 of Hanna instruments and in the raceways, electrode 53 42 of Crison), and a dissolved oxygen probe (in the thin-layer, HI 76,410 of Hanna instruments and in the raceways, InPro 6050 of Mettler Toledo) placed the furthest away from the CO 2 injection point as it is located at the end of the loop, where microalgae have completed a cycle so that the effects of a control action can be better evaluated. These sensors also allow knowing the temperature of the culture. The disturbance, the solar radiation, is measured with a pyranometer (CMP11, Kipp and Zonen, Delft, The Netherlands). Each photobioreactor has a solenoid valve for automatic control of the injection of air and CO 2 . In the case of thin-layers have two 2/2-way direct-acting plunger valves installed (model 6013 from Burkert, Barcelona, Spain) and raceways have 3/2 pneumatic solenoid valves (series VT307, SMC, Madrid, Spain).
These sensors and actuators are connected to a data acquisition card (LabJack UE9) for communication with the Supervisory Control And Data Acquisition (SCADA) system used. The software used for the SCADA system is DAQFactory, Azeotech (Ashland, Oregon, USA), where the different control strategies are implemented, and the parameters of the system are monitored and controlled.

Operating Conditions
The microalgae strain used corresponds to Scenedesmus almeriensis (CCAP 276/24). It is a strain robust to environmental conditions and, it has a high growth rate, withstanding temperature up to 45 • C and pH values from 7 up to 10, although its optimum conditions are 30 • C and pH around 8. In this work, a set-point of 8 will be considered. The culture medium used was wastewater from the secondary treatment of the "El Bobar" waste-water treatment plant, WWTP (Almería, Spain), which was limited in nutrients.

Modelling and Control Architectures
The pH culture is mainly influenced by two phenomena: CO 2 supplied and solar radiation. The injected CO 2 contributes to the formation of carbonic acid causing a decrease in the pH. On the other hand, microalgae perform photosynthesis in the presence of solar radiation, generating O 2 and consuming CO 2 , thus causing a gradual increase in pH.
From a theoretical point of view, pH control is a nonlinear problem that can only be linearized under certain circumstances, taking into account that the output of the process is the pH of the culture, the opening of the CO 2 injection discontinuous valve is the manipulated variable, and the solar radiation is the main disturbance of the system. To analyze a system, its dynamic behavior must be studied around an operating point where the system behaves linearly.
Thus, in this work, the pH dynamics were obtained by applying a train of pulses around the pH value equal to 8. These tests were performed at daytime and nighttime periods for several days, giving rise to two different dynamics for daytime and nighttime periods, respectively. The linear resulting models are based on first-order transfer functions that relate the pH output with the CO 2 injection and the solar radiation effects [9,20]: where pH is the pH of the culture, u CO 2 is the percentage valve opening, I is the solar radiation, k and k r are the static gains, τ y τ r the corresponding time constants and, t r , refers to a time delay between the CO 2 injection point and the pH measure point. Note that in this work, only the model representing the effect of the CO 2 on the pH was used for control design purposes. The transfer function regarding the solar radiation effect can be considered in future works to account for sudden changes in solar radiation as an external disturbance (e.g., because of pausing clouds) [10].

On/Off Control
The On/Off control is the most common method of operation for photobioreactors, mainly operated for the daytime period. In this control, when the injection valve opens, CO 2 is injected until the pH measurement falls below the setpoint (in this case, the optimum pH of 8) then, the control valve closes until the pH reaches a value above the set point, and so on. The control architecture for this case is shown in Figure 3.

PI Control
The PI control architecture used in this work is shown in Figure 4. This type of control allows the pH to be maintained close to the set-point, reducing the characteristic oscillations of On/Off control and, in addition, improving the control signal of the valve. The PI control law is given by the following equation [21]: where K p is the proportional gain of the controller and T i is the integral time. For the design of the controllers, the Simple-Internal-Model-Control (SIMC) tuning rule was used because it is one of the best methods, ensuring a compromise between performance and robustness [22]. This rule states that the PI parameters are obtained with the following equations: where τ bc closed-loop time constants. In this case, the closed-loop time constant equals the system delay time for fast response with good robustness [22].
On the other hand, the CO 2 valves installed in the photobioreactors are not proportional valves, but discontinuous ones, so the continuous signal obtained from the PI controller must be translated into a discontinuous signal used to drive the valve. That is, it takes to control the opening range from 0 to 100%, corresponding with a flow rate of 0 to 2.2 L·min −1 in thin-layers and 0 to 10 L·min −1 in raceways. For this purpose, a Pulse Width Modulation (PWM) technique is used, with a frequency of 0.2 Hz. Additionally, for the PI configuration, the anti-windup technique was exploited to deal with the control signal saturation.

Results and Discussion
This section shows the results obtained from the modelling already performed when using wastewater as a culture medium, and the control strategies proposed, in the latter case, during the experiments carried out in thin-layer and raceway photobioreactors for several days. Specifically, three-day tests will be presented for each evaluated control structure. The different tests present results for the On/Off controller and PI controller, both during the daytime period and all day, for comparison purposes.
First, both thin-layer and raceways are operated in one reactor (one thin-layer and one raceway) with the classic On/Off control and in another one (one thin-layer and one raceway) with the PI control, operated only during the daytime period. Second, both control architectures are applied to control the system all-day (during daytime and nighttime periods). Note that for the PI control, two controllers are designed and implemented, corresponding to the daytime and nighttime dynamics.

Modelling Results
Experiments were performed using wastewater from secondary treatment as a culture medium, which was limited in nutrients. As mentioned, two different models, for day and night periods, were obtained. In this case, the models belonging to each reactor were calculated under the required operating conditions. Table 1 shows the models of the different reactors, during the daytime and nighttime periods. Table 1. Transfer functions of the raceway and thin-layer reactor, daytime and nighttime models, using wastewater from secondary treatment as culture medium.

Reactor Day Model Night Model
Thin-layer As observed, there are significant differences in the dynamics of both reactors. The time constants of the thin-layer reactor models are much smaller than those of the raceway reactor models. Thus, the dynamics of the thin-layers are much faster than that of the raceways having the CO 2 injections a greater transfer effect and thus the repercussion on the pH. This is because the optical path that the incident radiation travels is smaller than in the raceway, causing the photosynthesis process to occur at a higher speed.
Additionally, the static gains of the thin-layer models are smaller than in the raceway, which means that to cause a change in the pH a greater amount of injected CO 2 is needed. Note that the pH presents different dynamics at the diurnal and nocturnal periods, where the day model obtained has a longer time constant than the night model. This means that the night dynamics are faster. Moreover, in general, the gains of the night period model are greater than those of the day model, so a lower amount of CO 2 is required to cause a change in pH.
Calibration and validation of the models were carried out from the different dynamics obtained. The input variable for all models is the opening of the CO 2 valve (0% to 100%), while the solar radiation acts as a disturbance in the case of the daytime period. To obtain a model that relates CO 2 injection with pH, it is necessary to take into account different situations. In this case, tests were carried out on similar days to consider constant the small variations in radiation and temperature. Figures 5 and 6 show an example of validation of the day and night models contrasted with real data. Specifically, they represent the validation of daytime and nighttime models of the thin-layer reactor, using wastewater as a culture medium.

Control Results
From the parameters of the calculated models, the PI controllers were obtained using the SIMC tuning rule presented in Equations (3) and (4). Table 2 shows the controllers of the different reactors, and during the day and night periods. This tuning rule states that a closed-loop time constant greater than or equal to the system delay should be used for robustness purposes. In this case, closed-loop time constants were equal to the time delays. Table 2. PI controllers of the raceway and thin-layer reactors using secondary treatment wastewater as culture medium.

Reactor Day Controller Night Controller
Thin-layer C(s) = −4. To achieve a representative balance between the different control strategies, the different control architectures mentioned were implemented in the four reactors for three days, maintaining the reference at pH 8. The performed tests were oriented to establish a trade-off between control effort and control performance and present an alternative to traditional control. Figures 7 and 8 present the experimental results for the different control schemes in thin-layers (left graphs) and raceways (right graphs) during daytime and nighttime periods, respectively. Figure 7 represents On/Off and PI control approaches operated only during the daytime period. Looking at the left side of the figure, the first graph shows the evolution of the pH with an On/Off controller for three days in thin-layer reactors. The daytime variation of pH ranges from 7.51 to 8.22 and during the nighttime period, the pH reaches values of 8.89. The third graph shows the evolution of the pH with a PI controller, where the daytime variation of pH ranges from 7.78 to 8.18, and during the nighttime period, the pH reaches values of 8.59. On the right of the figure, the same test carried out in raceway reactors is shown, where the daytime variation of pH, with On/Off controller, ranges 7.56 to 8.03, and during the nighttime period, the pH reaches values of 8.74. The daytime variation of pH, with PI controller, ranges from 7.90 to 8.04, and during the nighttime period, the pH reaches values of 8.94. At night, where the system is in an open loop, pH values far from the reference are reached. The disconnection point of the controller is differentiated, causing an increase in pH during the night period and a sudden change in pH at the beginning of the day due to the high injection of CO 2 (control signal value 100%), being able to cause stress situations of the culture.  Fourth graphs represent the CO 2 valve state of PI control, PWM signal. Fifth graphs represent the control signal by PI control. Sixth graphs represent global radiation. Figure 8 represents a different test with On/Off and PI control operated all-day. In this case, the variation of pH with an On/Off controller in thin-layer reactors ranges from 7.61 to 8.33, and, with a PI controller, ranges from 7.85 to 8.13. In raceway reactors, the variation of pH with an On/Off controller ranges from 7.25 to 8.05, and, with a PI controller in thin-layer ranges from 7.84 to 8.03. The PI control keeps the pH close to reference during 24 h.
In addition to the differences observed in Figures 7 and 8, different indices were taken into account to compare the different control architectures implemented in the raceway and thin-layer reactors during the two tests. The Integrated-Absolute-Error (IAE) is used to know the variation of the pH concerning the setpoint during the three days. The index Gas is the total amount of CO 2 consumed. IT is the duration in minutes of the total CO 2 injection. P represents reactor area productivity. The Gas index is the normalized value of the amount of CO 2 used. P index is the normalized value of system performance. These índexes are in relative units with respect to the On/Off control operated during daytime in raceway reactor since it is the classic configuration and most used for the production of microalgae. Finally, the G/P index is the ratio between Gas index and the P index, which indicates how the efficiency of the system is improved, understood as a reduction in gas and increased productivity. Tables 3 and 4 show the performance indexes of each control architecture implemented in the two types of photobioreactor during three consecutive days. Table 3 shows the results of the control operated only during the daytime period. Starting with the thin-layer reactors, the PI controller reduces the IAE by up to 31.75% with respect to the On/Off controller. Observing this error in the daytime period, a reduction of the order of 39.10% for the IAE can be achieved. From the point of view of CO 2 consumption and injection time, the PI control reduces it by 38.38% and, therefore the cost as well. In the case of raceway reactors, the PI controller reduces the IAE daytime by up to 64.56% concerning the On/Off control, although a worse total IAE is obtained with the PI control because during this test the system reached higher pH levels in the night period (see Figure 7b). In any case, note that the control during the nighttime is in an open loop and the total IAE was included for comparative purposes with the control operated all-day. Regarding productivity, both in raceways and in thin-layers, PI control obtains higher productivity even though there is not a great difference with On/Off control. It must be taken into account that these tests were carried out in December, where the environmental conditions are the more adverse for microalgae growth. IAE represents the Integrated-Absolute-Error, Gas represents the CO 2 total gas consumption, IT represents the CO 2 injections time, in addition to IAE, Gas, and IT during the daytime and nighttime periods. P represents productivity. Gas index and P index represent normalized value of CO 2 consumed and productivity, respectively, with respect to the On/Off control operated during daytime period in raceway reactor. IAE represents the Integrated-Absolute-Error, Gas represents the CO 2 total gas consumption, IT represents the CO 2 injections time, in addition to IAE, Gas, and IT during the daytime and nighttime periods. P represents productivity. Gas index and P index represent normalized value of CO 2 consumed and productivity, respectively, with respect to the On/Off control operated during daytime period in raceway reactor. Table 4 shows the results of the control operated for daytime and nighttime. The pH control in thin-layer reactors shows that PI control reduces total IAE by 67.35%. This error is reduced by 54.43% in the daytime period and 74.36% in the nighttime period. It is very remarkable how the PI controller reduces the amount of total CO 2 injected by up to 62.02% with respect to On/Off control. Observing this index independently between the daytime and nighttime periods, reductions of the order of 64.72% and 57.98%, respectively, for the Gas can be achieved. In raceway reactors, the total IAE is reduced by 73.30%, 74.25% in the daytime period and 72.54% in the nighttime period. In the case of CO 2 consumption, the PI reduces this quantity by 19.84%, 11.88% in the daytime period and 30.22% in the nighttime period. Regarding productivity, like in the previous case, both in raceways and in thin-layers, PI control obtains higher productivity even though there is not a great difference with On/Off control.
In both tests, in the control operated during the daytime period and the control operated all-day, as expected the PI controller obtained better results than the On/Off control. The injection time is reduced improving the control performance (by means of the IAE reductions) at the same time.
Compared to the control operated only during the day with the control operated throughout the whole day, the noticeable improvement of the IAE can be observed, although we see greater consumption and injections of CO 2 , at the cost of improving the pH control. Note that the On/Off control operated throughout the day supposes very consumption, but if a PI controller is used, the consumption is very similar to the On/Off control operated only during the daytime period.
Additionally, both in the day-only control and the all-day control, the thin-layer reactors for both control architectures have higher CO 2 consumption than the raceways, which corroborates the higher static gains of the raceway models. This is due, as mentioned above, to the fact that, for design reasons (culture height), in the thin-layer, the optical path that the incident radiation travels is very small, which causes the culture to use light more efficient, thus obtaining higher concentrations of biomass (with faster time constants and, therefore, a greater requirement for CO 2 injections).
On the other hand, making a comparison concerning the classical configuration used in the production of microalgae (traditional On/Off control operated during the daytime in the raceway), in the case of the raceway, the PI control shows a lower Gas index and a higher P index, with a lower G/P index. This result means that the system is more efficient with lower consumption of CO 2 together with an increase in productivity. In the case of thin-layers, a higher Gas index and a higher P index are obtained, but the G/P ratio is lower, which means a higher efficiency of the system is obtained despite the higher consumption of CO 2 .
In addition, in order to observe the advantages of improving pH control on the microalgae growth, the term that describes the influence of the pH on the growth rate was analyzed to compare the different control approaches. The effect of the pH on the growth can be expressed by the following cardinal formula [23]: (pHopt, ALG −pH min, ALG )(((pHopt, ALG −pH min, ALG )(pH−pHopt, ALG ))−((pHopt, ALG −pH max, ALG )(pHopt, ALG +pH min, ALG −2·pH))) where pH [-] is the culture pH, whereas pH max [-], pH min [-] and pH opt [-] the respective maximal, minimal, and optimal pH for the microalgae strain. For the strain used in this work, the values are 12.9, 1.8 and 8, respectively. Values of µ ALG (pH) close to 1 means that pH control maximizes the microalgae growth rate. Figures 9 and 10 represent this factor for each control architecture in both reactors. It can be seen, as mentioned above, that the control throughout the day obtains values closer to 1, while during the night the values decrease when the control is not active. Specifically, the PI control throughout the day is the one that obtains the best results. Note how controlling the pH during 24 h a day with a PI controller, this term remains close to 1 all the time, which means that the growth rate is maximized according to the pH effect. Figure 9. Results of the growth rate influenced by the pH in thin-layer reactors. First graph represents the evolution of this term with On/Off controller operated during daytime period. Second graph represents the evolution of this term with PI controller operated during daytime period. Third graph represents the evolution of this term with On/Off controller operated all-day. Fourth graph represents the evolution of this term with PI controller operated all-day. Figure 10. Results of the growth rate influenced by the pH in raceway reactors. First graph represents the evolution of this term with On/Off controller operated during daytime period. Second graph represents the evolution of this term with PI controller operated during daytime period. Third graph represents the evolution of this term with On/Off controller operated all-day. Fourth graph represents the evolution of this term with PI controller operated all-day.

Conclusions
In this work, the modelling and control of pH by CO 2 injections in thin-layer and raceway photobioreactors utilized for producing microalgae using wastewater as a culture medium are analyzed. The control operation was performed in two cases, during the daytime only, and throughout the daytime and nighttime periods. A linear model for control purposes was obtained to capture the main dynamics used for the implementation of a PI control, presenting acceptable results. This type of control, compared to the classic On/Off control in both types of photobioreactors, improved the performance of the system with lower consumption of CO 2 and reducing the associated control effort of the valve. In addition, the control during the 24 h, although it increases slightly the consumption of CO 2 , reduces the error with respect to the setpoint. Regarding the type of reactor, thin-layer reactors have higher CO 2 consumption than raceway reactors, but this means higher productivity. In conclusion, according to the results, the set of a pH control operated throughout the day implemented in a thin-layer reactor obtains the best results, keeping the pH at an optimal level without variations and assuming a balanced cost.

Conflicts of Interest:
There are no potential financial or other interests that could be perceived as influencing the outcome of the research. No conflicts, informed consent, human or animal rights issues are applicable. All the authors confirmed authorship of the manuscript and agreed to submit it for peer review.