Introduction

Sorghum, a cereal which belongs to the family Gramineae is now used in most breweries as locally available alternative to imported barley malt. In a generalized view of processing and brewing sorghum, though involves several unit operations, the fermentation step is the crux of the process, regarded as the heart of the entire production where a near optimal environment is desired for microorganisms to grow, multiply and produce the desired product [3]. However, the use of fermenters at a large scale is usually hampered by sub-optimal conditions in terms of yield and productivity, resulting from low tolerance of strains to process stresses, such as substrate and product inhibition, and other fermentation inhibitors [10, 14, 17]. In several attempts to improve the industrial efficacy of fermenters, a variety of approaches have been proposed; genetic techniques involving detailed, mechanistic studies of metabolic pathways, inherently involving inverse problem that cannot be understood with certainty [7]; statistical design of experiments [3], which again requires the construction of expensive prototype systems and most often leads to local optima due to the relatively small dimensional space covered by the experiments [3, 23].

Alternatively, design and optimization of bioreactors can be enhanced via validated mathematical models developed from mechanistic studies that lead to a more in depth understanding of process stresses such as ethanol inhibition [23]. In this regard, optimal temperature profiles have been determined to maximize beer flavor [19], maximize ethanol formation from sugarcane molasses (Marcus and Normey-Rico [13], minimize acetyl acetate production [9], maintain cell viability and reduce glycerol production [5]. However, the aforementioned as well as other studies have focused on temperature and rarely pH for optimization of batch fermentation processes. Fermentation principles consist of exploiting the metabolic reactions that take place in the cell of a microorganism for the production of valuable products [16]. To activate the metabolic pathways of interest within the cell, specific environmental conditions (temperature, pH, nutrient concentration) are applied to enable the yeast cell grow and produce the required ethanol. In addition, due to the dynamic nature of the culture medium, yeast cells often suffer from various stresses resulting from both the environmental conditions, and from both product and or substrate imbibition [2]. To maximized ethanol yield, all the main aspect (ethanol inhibition kinetics, temperature and pH) should be considered simultaneously [8]. This paper presents the optimal pH and temperature profiles in the alcoholic fermentation of sorghum extracts using a linear product inhibition model developed in our previous study [1]. Optimal profiles of temperature and pH are important in the control these stresses, flavor active compounds such as esters and in the control of these stresses, compounds such as esters and higher molecular mass alcohols can be maximized which can lead to increase in alcohol (ethanol) yield [20, 22].

Bioreactor modeling and parameter estimation

The Monod equation for cell growth and product formation, respectively, was chosen to describe the kinetics of cell growth and product formation, as given in the following equation:

$$\mu \left( S \right) = \frac{{\mu_{\rm{max} } S}}{{K_{\text{sx}} + S}},$$
(1a)
$$q_{\text{p}} \left( S \right) = \frac{{q_{\rm{max} } S}}{{K_{\text{sp}} + S}}.$$
(1b)

In our previous study [1], we proposed a simple linear factor to describe product inhibition in the alcoholic fermentation of sorghum extracts, expressed as

$$f = \left( {1 - K_{\text{ip}} P} \right).$$
(2)

Introducing this effect on the specific rate of product formation, Eq. (1b) becomes

$$q_{\text{p}} \left( S \right) = \frac{{q_{\rm{max} } S}}{{K_{\text{sp}} + S}}\left( {1 - K_{\text{ip}} P} \right).$$
(3)

The dynamic equations describing the cell growth, product formation and substrate utilization were developed by applying the principle of conservation of mass, resulting in the systems of first-order ordinary differential equations presented in Eqs. (4a, 4b, 4c). The change in substrate concentration depends on four terms: substrate assimilation into biomass (\(\mu X/Y_{\text{x}}\)), substrate assimilation into extracellular product (\(qX/Y_{\text{p}}\)), substrate utilization for cell growth (\(G_{\text{s}} X\)) and substrate utilization for maintenance energy (\(M_{\text{s}} X\)).

$$\frac{{{\text{d}}X}}{{{\text{d}}t}} = \mu X - k_{\text{d}} X,$$
(4a)
$$\frac{{{\text{d}}P}}{{{\text{d}}t}} = qX + M_{\text{p}} X,$$
(4b)
$$\frac{{{\text{d}}S}}{{{\text{d}}t}} = - \frac{\mu X}{{Y_{\text{x}} }} - \frac{qX}{{Y_{\text{p}} }} - G_{\text{s}} X - M_{\text{s}} X.$$
(4c)

Introducing the expressions for \(\mu\) and \(q\) from Eqs. (1a) and (3), Eqs. (4a, 4b, 4c) becomes

$$\frac{{{\text{d}}X}}{{{\text{d}}t}} = \frac{{\mu_{\rm{max} } S}}{{K_{\text{sx}} + S}}X - k_{\text{d}} X,$$
(5a)
$$\frac{{{\text{d}}P}}{{{\text{d}}t}} = \left( {1 - K_{\text{ip}} P} \right)\frac{{q_{\rm{max} } S}}{{K_{\text{sp}} + S}}X + M_{\text{p}} X,$$
(5b)
$$\frac{{{\text{d}}S}}{{{\text{d}}t}} = - \frac{\mu X}{{Y_{\text{x}} }} - \frac{qX}{{Y_{\text{p}} }} - G_{\text{s}} X - M_{\text{s}} X.$$
(5c)

Optimal control problem formulation

The objective of the control is to determine the optimal temperature and pH profiles that will minimize the effect of ethanol inhibition on cell growth and hence maximize ethanol yield at the end of fermentation. The temperature dependency of the cellular activity was modeled using the following Arrhenius-like equation:

$$\mu = f\left\{ {\left[ {\mu_{\rm{max} } \exp \left( { - \frac{{E_{\text{g}} }}{\text{RT}}} \right)} \right]} \right\},$$
(6a)
$$k_{\text{d}} = f\left\{ {\left[ {k_{\text{d}} \exp \left( { - \frac{{E_{\text{g}} }}{RT}} \right)} \right]} \right\}.$$
(6b)

Typical values for these parameters were taken from the literature [21].

A typical term, Eq. (7) that accounts for pH dependence was also introduced into the specific growth rate expression.

Although this simple model cannot possibly explain pH dependence, the literature shows that it gives an adequate fit for many microorganisms [15]. The additional term is in the following form:

$$\mu = f\left( {\frac{{\mu_{\rm{max} } }}{{1 + \frac{{k_{1} }}{{10^{{ - {\text{pH}}}} }} + \frac{{10^{{ - {\text{pH}}}} }}{{k_{2} }}}}} \right).$$
(7)

The values of \(k_{1}\) and \(k_{2}\) that were used for the numerical simulations are chosen to be in their typical ranges from the literature [15, 21]. Introducing the effect of temperature and pH into Eqs. (5a, 5b, 5c), we arrive at the following system of differential equation:

$$\frac{{{\text{d}}X}}{{{\text{d}}t}} = \frac{{\mu_{\rm{max} } k_{\text{g}} \exp \left( { - \frac{{E_{\text{g}} }}{RT}} \right)}}{{1 + \frac{{k_{1} }}{{10^{{ - {\text{pH}}}} }} + \frac{{10^{{ - {\text{pH}}}} }}{{k_{2} }}}}\frac{S}{{K_{\text{sx}} + S}}X - k_{\text{d}} \exp \left( { - \frac{{E_{\text{g}} }}{RT}} \right)X,$$
(8a)
$$\frac{{{\text{d}}P}}{{{\text{d}}t}} = q_{\rm{max} } (1 - K_{\text{ip}} P)\frac{S}{{K_{\text{sp}} + S}}X + M_{\text{p}} X,$$
(8b)
$$\frac{{{\text{d}}S}}{{{\text{d}}t}} = \frac{{ - \mu_{\rm{max} } k_{\text{g}} \exp \left( { - \frac{{E_{\text{g}} }}{\text{RT}}} \right)}}{{1 + \frac{{k_{1} }}{{10^{{ - {\text{pH}}}} }} + \frac{{10^{{ - {\text{pH}}}} }}{{k_{2} }}}}\frac{\text{SX}}{{Y_{\text{x}} (K_{\text{sx}} + S)}} - \frac{{q_{\rm{max} } S\left( {1 - K_{\text{ip}} P} \right)X}}{{Y_{\text{p}} \left( {K_{\text{sp}} + S} \right)}} - X(G_{\text{s}} + M_{\text{s}} ).$$
(8c)

The optimal control problem to be maximized is then formulated with Eqs. (8a, 8b, 8c). The general objective of the optimal control problem is to determine the control signals (temperature and pH) that will cause the controlled system (batch fermentation process) to satisfy the physical constraints (state equation, Eqs. (9b)–(9d) as well as temperature and pH bounds, Eqs. (9e) and (9f), at the same time, maximize the performance criterion (\(J\))”, which has been defined in the Lagrangian form, Eq. (9a). The performance criterion (\(J\)) is a functional used for quantitative evaluation of a system’s performance and can depend on both the control and state variables and on the initial and/or terminal times too (if not fixed) [12].

In this study, the final fermentation time is fixed and the performance criterion is formulated to depend only on the product concentration and the controlled variables.

Weights are introduced to differentiate the degree of dependence of the performance criterion on the state and controlled variables. The constants \(A,B,C\) are the respective weights of the product (state to be maximized), temperature and pH (controlled variables). In this study, all the variables were assumed to have the same importance and the weights were all given a unit value.

$$J = \mathop \int \limits_{0}^{{t_{f} }} \left[ {AP^{2} + B\exp \left( { - \frac{{E_{\text{g}} }}{\text{RT}}} \right) + C\left( {\frac{{k_{1} }}{{10^{{ - {\text{pH}}}} }} + \frac{{10^{{ - {\text{pH}}}} }}{{k_{2} }}} \right)} \right]{\text{d}}t,$$
(9a)

s.t.

$$\frac{{{\text{d}}X}}{{{\text{d}}t}} = \frac{{\mu_{\rm{max} } \exp \left( { - \frac{{E_{\text{g}} }}{\text{RT}}} \right)}}{{1 + \frac{{k_{1} }}{{10^{{ - {\text{pH}}}} }} + \frac{{10^{{ - {\text{pH}}}} }}{{k_{2} }}}}\frac{S}{{K_{\text{sx}} + S}}X - k_{\text{d}} \exp \left( { - \frac{{E_{\text{g}} }}{\text{RT}}} \right)X,$$
(9b)
$$\frac{{{\text{d}}P}}{{{\text{d}}t}} = q_{\rm{max} } (1 - K_{\text{ip}} P)\frac{S}{{K_{\text{sp}} + S}}X + M_{\text{p}} X,$$
(9c)
$$\frac{{{\text{d}}S}}{{{\text{d}}t}} = \frac{{ - \mu_{\rm{max} } \exp \left( { - \frac{{E_{\text{g}} }}{\text{RT}}} \right)}}{{1 + \frac{{k_{1} }}{{10^{{ - {\text{pH}}}} }} + \frac{{10^{{ - {\text{pH}}}} }}{{k_{2} }}}}\frac{\text{SX}}{{Y_{x} (K_{\text{sx}} + S)}} - \frac{{q_{\rm{max} } S\left( {1 - K_{\text{ip}} P} \right)X}}{{Y_{\text{p}} \left( {K_{\text{sp}} + S} \right)}} - X(G_{\text{s}} + M_{\text{s}} ),$$
(9d)
$$T_{\rm{min} } \le T(t) \le T_{\rm{max} } ,$$
(9e)
$${\text{pH}}_{\rm{min} } \le {\text{pH}}\left( t \right) \le {\text{pH}}_{\rm{max} } ,$$
(9f)

To facilitate subsequent mathematical manipulations of the objective function, we define the following transformations:

$$\begin{aligned} x_{1} = X,\quad x_{2} = P,\quad x_{3} = S\quad p_{1} = \mu_{\rm{max} } ,\quad p_{2} = q_{\rm{max} } \hfill \\ p_{3} = K_{\text{sx}} ,\quad p_{4} = K_{\text{sp}} ,\quad p_{5} = Y_{\text{x}} ,\quad p_{6} = k_{\text{d}} \hfill \\ p_{6} = G_{\text{s}} ,\quad p_{7} = M_{s} ,\quad p_{9} = M_{\text{p}} ,\quad p_{10} = K_{\text{ip}} \quad p_{11} = Y_{\text{p}} \hfill \\ u_{1} = \exp \left( { - \frac{{E_{\text{g}} }}{RT}} \right) ,\quad u_{2} = \frac{{k_{1} }}{{10^{{ - {\text{pH}}}} }} + \frac{{10^{{ - {\text{pH}}}} }}{{k_{2} }} \hfill \\ \end{aligned}$$

Replacing these variables into Eqs. (9a, 9b, 9c, 9d, 9e, 9f), we obtain the following equation:

$$\text{Max} J = \mathop \int \limits_{0}^{{t_{f} }} \left[ {Ax_{2} (t)^{2} + Bu_{1} (t)^{2} + Cu_{2} (t)^{2} } \right]{\text{d}}t,$$
(10a)

s.t.

$$\frac{{{\text{d}}x_{1} }}{{{\text{d}}t}} = \frac{{p_{1} }}{{1 + u_{2} }}\frac{{u_{1} x_{3} }}{{p_{3} + x_{3} }}x_{1} - p_{6} u_{1} x_{1} ,$$
(10b)
$$\frac{{{\text{d}}x_{2} }}{{{\text{d}}t}} = (1 - p_{10} x_{2} )\frac{{p_{2} x_{3} }}{{p_{4} + x_{3} }}x_{1} + p_{9} x_{1} ,$$
(10c)
$$\frac{{{\text{d}}x_{3} }}{{{\text{d}}t}} = \frac{{ - p_{1} u_{1} }}{{1 + u_{2} }}\frac{{x_{3} x_{1} }}{{p_{5} (p_{3} + x_{3} )}} - \frac{{p_{2} x_{3} \left( {1 - p_{10} x_{2} } \right)x_{1} }}{{p_{11} \left( {p_{4} + x_{3} } \right)}} - x_{1} \left( {p_{7} + p_{8} } \right),$$
(10d)
$$u_{1\rm{min} } \le u_{1} \left( t \right) \le u_{1\rm{max} } ,$$
(10e)
$$u_{2\rm{min} } \le u_{2} \left( t \right) \le u_{2\rm{max} } ,$$
(10f)

If the state, control, and static parameters can each be written in component form as

$$x\left( t \right) = \left[ {\begin{array}{*{20}c} {x_{1} \left( t \right)} \\ \vdots \\ {x_{3} (t)} \\ \end{array} } \right]; \quad u\left( t \right) = \left[ {\begin{array}{*{20}c} {u_{1} \left( t \right)} \\ \vdots \\ {u_{2} (t)} \\ \end{array} } \right]; \quad p\left( t \right) = \left[ {\begin{array}{*{20}c} {p_{1} \left( t \right)} \\ \vdots \\ {p_{10} (t)} \\ \end{array} } \right];$$
(11)
$$f\left[ {x\left( t \right),u\left( t \right),t;\,p} \right] = \left[ {\begin{array}{*{20}c} {f_{1} \left[ {x\left( t \right),u\left( t \right),t;\,p} \right]} \\ \vdots \\ {f_{3} \left[ {x\left( t \right),u\left( t \right),t;\,p} \right])} \\ \end{array} } \right],$$
(12)

where

$$f_{1} \left[ {x\left( t \right),u\left( t \right),t;\,p} \right] = \frac{{p_{1} }}{{1 + u_{2} }}\frac{{u_{1} x_{3} }}{{p_{3} + x_{3} }}x_{1} - p_{6} u_{1} x_{1} ,$$
(13)
$$f_{2} \left[ {x\left( t \right),u\left( t \right),t;\,p} \right] = \left( {1 - p_{10} x_{2} } \right)\frac{{p_{2} x_{3} }}{{p_{4} + x_{3} }}x_{1} + p_{9} x_{1} ,$$
(14)
$$f_{3} \left[ {x\left( t \right),u\left( t \right),t;\,p} \right] = \frac{{ - p_{1} u_{1} }}{{1 + u_{2} }}\frac{{p_{5}^{ - 1} x_{3} x_{1} }}{{(p_{3} + x_{3} )}} - \frac{{p_{2} x_{3} \left( {1 - p_{10} x_{2} } \right)x_{1} }}{{p_{11} \left( {p_{4} + x_{3} } \right)}} - x_{1} \left( {p_{7} + p_{8} } \right).$$
(15)

Then optimal control problem can be simply written as follows:

$$\text{Max}\;J\left( u \right) = \mathop \int \limits_{{t_{0} }}^{{t_{f} }} {\mathcal{L}}\left[ {x\left( t \right),u\left( t \right),t;\,p} \right]{\text{d}}t.$$
(16a)

Subject to

$$\dot{x}(t) = f\left[ {x\left( t \right),u\left( t \right),t;\,p} \right]$$
(16b)
$$u_{\rm{min} } \le u\left( t \right) \le u_{\rm{max} } ,$$
(16c)
$${\text{where}}\;{\mathcal{L}}\left[ {x\left( t \right),u\left( t \right),t;\,p} \right] = \left[ {Ax_{2} (t)^{2} + Bu_{1} (t)^{2} + Cu_{2} (t)^{2} } \right]$$

Referred to as the Lagrangian form of an optimal control problem.

Solution technique by calculus of variations

In an indirect method, calculus of variations is applied to determine the first-order optimality conditions first-order necessary conditions for an optimality conditions and the first-order necessary conditions for an optimal trajectory. These conditions can be obtained by using the augmented Hamiltonian (\(H\)) defined by equation (17)

$$H\left( {x,\lambda ,u,t;\,p} \right) = {\mathcal{L}} + \lambda^{\text{T}} f,$$
(17)

where \(\lambda \left( t \right) \in {\mathbb{R}}^{n}\) is the costate or adjoint state. In the case of a single phase optimal control problem with no static parameters, the first-order optimality conditions of the continuous-time problem are given as follows:

$$\dot{x} = \left[ {\frac{\partial H}{\partial \lambda }} \right]^{\text{T}} ,$$
(18a)
$$\dot{\lambda } = - \left[ {\frac{\partial H}{\partial x}} \right]^{\text{T}} ,$$
(18b)
$$u^{*} = \arg \mathop {\rm{min} }\limits_{u \in U} H,$$
(19)

where \(U\) is the feasible control set

The systems of differential equations presented in Eqs. (18a, 18b) are referred to as the Hamiltonian system, derived from the differentiation of a Hamiltonian [6, 11]. Furthermore, the optimal control profile to the system is determined from the application of the Pontryagin’s minimum principle (PMP) resulting in Eq. (19) and this is the classical method of determining the control [18]. The Hamiltonian system, together with the boundary, transversality, is referred to as a Hamiltonian boundary-value problem (HBVP) [4, 6] and the solution to such a system is called an extremal.

Now applying calculus of variations to Eqs. (10a, 10b, 10c, 10d, 10e, 10f), the Hamiltonian can be written as follows:

$$H = Ax_{2} (t)^{2} + Bu_{1} (t)^{2} + Cu_{2} (t)^{2} + \lambda_{1} \left( {\frac{{p_{1} u_{1} x_{1} }}{{1 + u_{2} }}M - p_{6} u_{1} x_{1} } \right) + \lambda_{2} \left( {p_{2} Nx_{1} + p_{9} x_{1} } \right) + \lambda_{3} \left( {\frac{{ - p_{1} u_{1} x_{1} }}{{1 + u_{2} }}\frac{M}{{p_{5} }} - \frac{{p_{2} Nx_{1} }}{{p_{11} }} - x_{1} (p_{7} + p_{8} )} \right),$$
(20)
$${\text{where}}\;M = \frac{{x_{3} }}{{p_{3} + x_{3} }}\quad {\text{and}}\quad N = (1 - p_{10} x_{2} )\frac{{x_{3} }}{{p_{4} + x_{3} }} .$$

State equations

If we differentiate the Hamiltonian, Eq. (17) with respect to the co-states, Eq. (18a), we obtain the following state equations:

$$\frac{{{\text{d}}x_{1} }}{{{\text{d}}t}} = \frac{{p_{1} }}{{1 + u_{2} }}\frac{{u_{1} x_{3} }}{{p_{3} + x_{3} }}x_{1} - p_{6} u_{1} x_{1} ,$$
(21a)
$$\frac{{{\text{d}}x_{2} }}{{{\text{d}}t}} = (1 - p_{10} x_{2} )\frac{{p_{2} x_{3} }}{{p_{4} + x_{3} }}x_{1} + p_{9} x_{1} ,$$
(21b)
$$\frac{{{\text{d}}x_{3} }}{{{\text{d}}t}} = \frac{{ - p_{1} u_{1} }}{{1 + u_{2} }}\frac{{x_{3} x_{1} }}{{p_{5} (p_{3} + x_{3} )}} - \frac{{p_{2} x_{3} \left( {1 - p_{10} x_{2} } \right)x_{1} }}{{p_{11} \left( {p_{4} + x_{3} } \right)}} - x_{1} \left( {p_{7} + p_{8} } \right),$$
(21c)

Costate equations

If we differentiate the Hamiltonian, Eq. (17) with respect to the states, Eq. (18b), we obtain the following state equations:

$$\frac{{{\text{d}}\lambda_{1} }}{{{\text{d}}t}} = \lambda_{1} \left( {p_{6} u_{1} - \frac{{p_{1} u_{1} M}}{{1 + u_{2} }} } \right) - \lambda_{2} \left( {p_{9} + p_{2} N} \right) + \lambda_{3} \left( {\frac{{p_{1} u_{1} M}}{{p_{5} \left( {1 + u_{2} } \right)}} + \frac{{p_{2} N}}{{p_{11} }} + p_{7} + p_{8} } \right),$$
(22a)
$$\frac{{{\text{d}}\lambda_{2} }}{{{\text{d}}t}} = - 2Ax_{2 } + \frac{{p_{2} p_{10} x_{1} N}}{{\left( {1 - p_{10} x_{2} } \right)}}\left( {\lambda_{2} + \frac{{\lambda_{3} }}{{p_{11} }}} \right),$$
(22b)
$$\frac{{{\text{d}}\lambda_{3} }}{{{\text{d}}t}} = - \lambda_{1} \left( {\frac{{p_{1} }}{{1 + u_{2} }}} \right)p_{3} u_{1} Q - \lambda_{2} Zp_{4} p_{2} - \lambda_{3} \left( {\frac{{ - p_{1} u_{1} }}{{1 + u_{2} }}} \right)\left( {\frac{{p_{3} Q}}{{p_{5} }}} \right) + \lambda_{3} \frac{{Zp_{4} p_{2} }}{{p_{11} }},$$
(22c)
$${\text{where}}\; Q = \frac{{x_{1} }}{{\left( {p_{3} + x_{3} } \right)^{2} }}\quad {\text{and}}\quad Z = \left( {1 - p_{10} x_{2} } \right)\frac{{x_{1} }}{{\left( {p_{4} + x_{3} } \right)^{2} }}.$$

Optimal control equations

The optimal control equations are obtained by applying the Pontryagin’s minimum principles in Eqs. (17)–(15). The Hamiltonian gradient can be represented by differentiating the Hamiltonian with respect to the controls to obtain the following equations:

$$\frac{{{\text{d}}H}}{{{\text{d}}u_{1} }} = 2Bu_{1} + \lambda_{1} \left( {\frac{W}{{1 + u_{2} }} - p_{6} x_{1} } \right) - \lambda_{3} \frac{W}{{p_{5} \left( {1 + u_{2} } \right)}},$$
(23a)
$$\frac{{{\text{d}}H}}{{{\text{d}}u_{2} }} = 2Cu_{2} - \lambda_{1} \frac{{u_{1} W}}{{\left( {1 + u_{2} } \right)^{2} }} + \lambda_{3} \frac{{u_{1} W}}{{p_{5} \left( {1 + u_{2} } \right)^{2} }},$$
(23b)
$$W = \frac{{p_{1} x_{1} x_{3} }}{{p_{3} + x_{3} }}.$$

The necessary optimality conditions for a local maximizer are that this gradient should be equal to zero as shown by the following equations:

$$2Bu_{1}^{*} + \lambda_{1} \left( {\frac{W}{{1 + u_{2}^{*} }} - p_{6} x_{1} } \right) - \lambda_{3} \frac{W}{{p_{5} \left( {1 + u_{2}^{*} } \right)}} = 0,$$
(24a)
$$2Cu_{2}^{*} + \frac{{u_{1}^{*} W}}{{\left( {1 + u_{2}^{*} } \right)^{2} }}\left( { - \lambda_{1} + \frac{{\lambda_{3} }}{{p_{5} }}} \right) = 0.$$
(24b)

The expressions for temperature and pH can then be written as Eqs. (25) and (26), respectively, and the optimal control trajectories become Eqs. (27) and (28).

$$T = \frac{1}{R}\ln \frac{{k_{g} }}{{u_{1}^{*} }} ,$$
(25)
$${\text{pH}} = \frac{1}{\ln 10}\ln \left( {\frac{{k_{2} u_{2}^{*} + \sqrt {\left( {k_{2} u_{2}^{*} } \right)^{2} - 4k_{1} k_{2} } }}{{2k_{1} k_{2} }}} \right),$$
(26)
$$T^{*} = \rm{min} (T_{\rm{max} } ,\rm{max} \left( {T_{\rm{min} } ,T} \right),$$
(27)
$${\text{pH}}^{*} = \rm{min} (pH_{\rm{max} } ,\rm{max} \left( {pH_{\rm{min} } ,pH} \right),$$
(28)

Numerical simulations and control validation

The states, costate and optimal control equations are referred to as the Hamiltonian boundary-value problem (HBVP) with boundary conditions given by the following equation:

$$\lambda \left( {t_{f} } \right) = \left[ {\begin{array}{*{20}c} 0 \\ 0 \\ 0 \\ \end{array} } \right]\quad x\left( {t_{0} } \right) = \left[ {\begin{array}{*{20}c} {0.1} \\ {0.7} \\ {16.8} \\ \end{array} } \right].$$
(29)

A collocation method based on the Labatto IIIA formula was used to simulate the HBVP, and a Matlab code was written to implement this algorithm using the Matlab routine ‘bvp4c’. The collocation polynomial provides a C1-continuous solution that is fourth-order accurate uniformly in [a b]. Mesh selection and error control are based on the residual of the continuous solution. The numerical solution for the necessary optimality conditions, Eqs. (24a, 24b) is obtained using the Matlab routine ‘fsolve’, which finds the roots for systems of nonlinear equations. In validating the controls, the alcohol fermentation model described in section III was implemented in the SIMULINK environment. This implemented model includes the objective function to be maximized.

Results and discussion

Figures 1 and 2 present the optimal temperature and pH profiles optimize the fermentation process. Simulation using the Simulink model, Fig. 7 shows that the optimal temperature and pH profiles obtained an increment in cell growth of 71.96%, product formation by 14.18% and substrate utilization by 84.77% compared to using the conventional temperature and pH values used by the industry. This improvement in process performance observed can be explained by the fact that due to the dynamic nature of the culture medium, yeast cells often suffer from various stresses resulting from both the environmental conditions, and from both product and or substrate imbibition as the fermentation proceeds.

Fig. 1
figure 1

Optimal temperature profile

Fig. 2
figure 2

Optimal pH profile

Optimal profiles (and not constant values) of temperature and pH are important in the controlling these stresses, and ensure that the culture medium conditions stays constant, hence maximizing yield [20]. The increase in substrate utilization did not balance up with product formation because some of the substrate was utilized for cell growth and maintenance. Table 1 presents the values of the final states and cost functional for both the Optimal and the conventional operation conditions. Figure 3 presents the fitting for the model taking into consideration the death rate and Table 2 the parameter values. Table 1 presents the values of the final states of both the optimal and conventional operation conditions. Figures 4, 5, 6, and 7 compare the optimal and conventional operating strategies, clearly depicting increase in process performance.

Table 1 Final states for optimal and conventional conditions
Fig. 3
figure 3

Experimental and model results

Table 2 Simulated kinetic parameter values
Fig. 4
figure 4

Dynamics of cell growth with optimal and conventional controls

Fig. 5
figure 5

Dynamics of product formation with optimal and conventional controls

Fig. 6
figure 6

Dynamics of substrate utilization with optimal and conventional controls

Fig. 7
figure 7

Proposed Simulink Model for alcoholic fermentation of Sorghum Extract

Conclusion and recommendations

This paper presented the modeling of a batch alcoholic fermentation process using sorghum extracts, followed by the application of optimal control to determine the optimal temperature and pH profiles that maximizes yield. Since the model was developed using industrial scale fermentation data, the results obtained in the simulations can satisfactorily represent a real operation unit. From the comparative results presented in the simulations, it is concluded that the proposed strategy can be used in practice to improve the performance of industrial scale alcoholic fermentation using sorghum.