Effects on Biodiesel Production Caused by Feed Oil Changes in a Continuous Stirred-Tank Reactor

Featured Application: Mathematical models for continuous biodiesel reactors developed with the methodology presented in this study can be used for economic analysis of supply changes in continuous processes of biodiesel production. Furthermore, these models can be used in the development of strategies that will be able to improve or ensure the economic viability of the process. For example, these models can be used to develop control systems that are able to ensure the production speciﬁcations when disturbances caused by oil changes occur during the continuous operation of a continuous stirred-tank reactor of biodiesel. Moreover, the model can be used to develop observers for the online estimation of concentration variables which are not available for online measurements. Abstract: Continuous production processes and an adequate supply of raw materials are necessary to satisfy the growing demand for biodiesel. The use of different feed oils could be necessary to ensure sufﬁcient supply for biodiesel production in certain circumstances; however, changing feed oil during the operation of a continuous reactor causes process disturbances. The present study analyses the effect of feed oil changes on the continuous operation of a industrial continuous stirred-tank reactor (CSTR) using a model which takes the dynamics of oil changes into account. The models previously reported only consider the operation of reactor with only one vegetable oil. The model in this work was developed by mass and energy balances. A methodology to model oil changes is presented. Glycerides and esters were characterized using adequate approaches. Moreover, accurate methods for predicting essential properties in the biodiesel manufacturing were used for the estimation of their thermo-physical properties. The kinetic parameters of the transesteriﬁcations were calculated from consistent studies selected from an exhaustive literature revision. The results show that temperature is practically not affected after oil changes; however, the ester concentration varies considerably. The ester mass fraction varying by up to 22.07% after an disturbance.


Introduction
Biofuels have become a recent focus for scientific research due to the fact that they are a sustainable alternative to fossil fuels and that their combustion is of minor environment impact. Specifically, biodiesel has been found to be a suitable alternative to conventional diesel. Biodiesel has similar properties to diesel, can be used in any conventional motor, is obtained from renewable sources (vegetable oil and animal fat), is biodegradable, can reduce most exhaust emissions, and has excellent lubricity and a higher flash point than diesel [1].
Biodiesel, which is mainly obtained from vegetable oils via the transesterification process, is formed by a mixture of fatty acid methyl esters (FAME). It is produced in industrial plants comprising several sections that carry out the pre-treatment of raw materials, the transesterification reaction, and the post-treatment of the products. For example, the complete biodiesel production line in a plant equipped with technology of the American Society of Agricultural Engineering comprises the following: two pre-treatment sections processing the crude vegetable oil (a degumming section and a refining section); a central section carrying out the transesterification process; and three post-treatment sections (an ester washing section, a glycerol separation section, and a methanol recovery section) [2]. Mainly comprising chemical reactors, the transesterification section plays the most important role in the biodiesel production process, with reactor operating conditions having a crucial impact on both the process variables and the quality specifications [3].
Modern plants generally use continuous reactors instead of batch systems, with the continuous stirred-tank reactor one of the most commonly used [2][3][4][5]. A constant supply of raw materials is required for continuous industrial biodiesel production processes to satisfy global demand. According to the "Organization for Economic Co-operation and Development" and the "Food and Agriculture Organization of the United Nations", global biodiesel production is projected to increase from the 36 bln L recorded in 2017 to 39 bln L by 2027 [6]. However, in some situations, the vegetable oil used in the biodiesel production process is not available. The availability of feedstock for producing biodiesel depends on the regional climate, geographical locations, local soil conditions, and agricultural practices of any country [7]. The oil yield from the crop itself is one of the key factors in deciding the suitability of a feedstock for biodiesel production [8,9]. For example, palm oil is mainly the raw material of the biodiesel production in Asia [8,10]. However, the oil palm yield is affected by a huge amount of pests (caterpillars, leaf miners, grasshoppers, moths, beetles, weevils, rats) and diseases (basal stem rot, upper stem rot, fusarium wilt, red ring disease, sudden wither, bunch rot), which, even if they do not kill the palm tree, considerably reduce palm yield [11]. When a nominal raw material is not available or is not suitable for the process, a feed oil change is necessary to maintain the production. It is a matter of significant impact given that such a change during the continuous operation of the transesterification reactor causes a disturbance of the process, which cannot be interrupted, even in the presence of disturbances. An appropriated mathematical model can be used to predict the effect of disturbances in biodiesel reactors, including these caused by oil change, and help to reduce the negative effects by the design of a control system [3,4,[12][13][14][15]. Nonetheless, the continuous reactor model previously reported does not consider the dynamics of feed oil changes. In this sense, Mjalli et al. presenting a rigorous mechanistic model of the biodiesel transesterification reactor [3]. The model was developed by applying mass and energy balances to a continuous stirred-tank reactor, but only considers the transesterification of palm oil. Brásio et al. presented a differential equation model for conducted in two continuous stirred-tank reactors in series and using two decanters considering only the transesterification of palm oil [4]. Montriwasuwat et al. developed a model, via mass and energy balances, for conducting transesterification in a continuous tubular reactor operating with only soybean oil supply [16]. Likozar et al. developed a mass balance for the chemical equilibrium, reaction kinetics, and mass transfer required for transesterification in a continuous tubular reactor, a model which considers the kinetics of glycerides containing different combinations of gadoleic, linoleic, linolenic, oleic, palmitic, and stearic acids [17]. Thus, a methodology for the modeling of oil changes in the feed stream during the continuous operation of a CSTR of biodiesel is presented in this work. Following the proposed methodology, a first principles model for a industrial continuous stirred-tank reactor of transesterification [3] was developed, and then an evaluation of the disturbances effects caused by feed oil changes during the continuous reactor operation was developed based on model simulations. Mass and energy balances techniques are used to model the reactor in this work. Palm, mustard, and sunflower oils were used as feedstock for the reaction operation. These oils were selected from an exhaustive literature revision because the kinetic parameters of their transesterification were determined with similar experimental conditions. The results show that temperature is practically not affected after oil changes; however, the ester concentration varies considerably. The ester mass fraction varying by up to 22.07% after a change from palm to mustard oil.
Mathematical models for continuous stirred-tank reactor of biodiesel developed with the methodology presented in this study have important practical applications. These models can help to improve the economic viability for biodiesel production process. Kern and Shastri enhance the economic performance of a batch transesterification reactor producing biodiesel by implementing advanced control strategies based on a first principle model [18]. In addition, these models can help in decision-making. For example, it can be used to estimate the cost of feedstock changing during the continuous operation of a biodiesel production line and evaluate the cheaper form to make the changes: stopping the production line or during the continuous operation. Furthermore, these models can be used in the design of control strategies that will be able to ensure the production specifications when disturbances occur caused by oil changes. Various studies in the literature present the design of advances control strategies based on first principle models, such as adaptive or predictive control systems, to ensure the production specifications and to face common disturbances and changes of the production requirements [3,4,[12][13][14][15]19]. Moreover, the model of biodiesel reactors can be used to develop observers for the online estimation of concentration variables which are not available for online measurements [4,20]. These practical implications for the present work are important because modern plants need technology capable of adapting to the challenging and changing operating conditions of biodiesel industry. This paper is divided in five sections: Introduction, General aspects of biodiesel, Methodology, Results and Discussion, and Conclusions. The Introduction posits the current work within the previous relevant literature; furthermore, it establishes the research problem, the main aim, and the solution proposed. Section 2 presents important aspects of biodiesel such as the processes for biodiesel production, type of raw materials, important variables in the production process, and others. Section 3 presents the methodology utilized in this work to develop the mathematical model that is used to develop the analysis of the disturbance effects caused by the oil changes. The Results and Discussion section presents the main results of the reactor model simulation and the analysis of the disturbances over the continuous operation of the reactor. Finally, Section 5 presents a brief summary of the research, the main conclusions obtained from the results, and the practical implications and limitations of the investigation.

General Aspects of Biodiesel
The American Society for Testing and Materials (ASTM International) with the standard D6751 defines to biodiesel as "a fuel comprised of mono-alkyl esters of long chain fatty acids derived from vegetable oils or animal fats, designated B100" [21]. The transesterification process is the method used to transform vegetable oils and animal fats into the esters that form the biodiesel fuel. In a general sense, transesterification is the reaction between the triglycerides (contained in the oils and fats) and an acyl-acceptor that may be carboxylic acids (acidolysis), alcohols (alcoholysis), or another ester (interesterification) [9]. However, most of the literature uses the term transesterification as synonymous with alcoholysis and, therefore, the word transesterification will be used to refer to alcoholysis in the present work. In the practice, only transesterification (alcoholysis) and interesterification are used to produce biodiesel, the transesterification being the usual process used in the industry to produce the biodiesel fuel.
Different alcohols can be used in the transesterification process such that: ethanol, methanol, propanol, butanol, and others. However, the most suitable alcohol for use in biodiesel production is methanol in terms of both practicality and cost [22]. Methanol is cheaper, more reactive, and the fatty acid methyl esters (FAME) derived from methanol are more volatile than the fatty acid ethyl esters (FAEE) derived from ethanol [9]. Furthermore, FAEE have slightly higher viscosities and slightly lower cloud and pour points than the corresponding FAME, and methyl esters produced slightly higher power and torque than ethyl esters [23].
The main parameters affecting transesterification reaction are the catalyst, the methanol to oil molar ratio, the mixing, the reaction temperature, the residence time and the feedstock state. Typically, in the transesterification process, there are some forms to accelerate the reaction rates, namely the use of a catalyst, a supercritical alcohol, or a co-solvent. The use of a catalyst is the most common way to produce biodiesel. The transesterification catalyst can be divided into three categories: homogeneous, heterogeneous and the ezymatic (biocatalyst). Both homogeneous and heterogeneous catalysts can be acid or basic. Moreover, immobilized or soluble lipases are used as biocatalysts in the biodiesel transesterification. Homogeneous basic catalysts are the most used in the biodiesel production because they are inexpensive and effective. The stoichiometry of the transesterification defines that the alcohol-to-oil molar ratio must be 3:1; however, a higher ratios are needed in real scenarios to raise the miscibility reactants and, consequently, the possibility of their contact for improving the final product yield [24]. In the literature, it has been reported that the formation of alkyl esters is adequate induced by an alcohol-to-oil molar ratio greater than or equal to 6:1 [25]. Agitation is a vital parameter in the biodiesel production process because it has an important influence on the reaction rate, on the mixing of reactants that are not miscible, and on the mass transfer. Intensities of agitation higher than 600 rpm produced acceleration of the reaction rate and, practically, eliminate the initial delay caused by reactant immiscibility the mass transfer in laboratory scale experiments. Temperature is an important factor in the transesterification process. Higher temperatures improve the transesterification process by reduction of the mass transfer effect and the higher energy state to the molecules [26]. The required residence time is directly dependent on other parameters that enhance the rate of transesterification reaction, such as mixing intensity, residence time distribution (RTD), and temperature [24]. Regarding feedstock state, the critical factors that influence the transesterification process are the content free fatty acids, moisture and water in the feedstock, and its composition.
A large amount of vegetable oils and animal fats have been studied for biodiesel production, but the vegetable oils are the main raw material used in the biodiesel industry. Globally, there are more than 350 oil-bearing crops identified as potential sources for biodiesel production [7]. Biofuels can be classified in four groups depending on the feedstock by which it is produced: first, second, third, and fourth generation. First, generation biodiesel is derived from edible oils as coconut, palm, soybean, mustard, sunflower oils, and others. Biodiesel produced from non-edible oils is the second generation of this biofuel. Feedstock for second generation of biodiesel are oils obtained from cotton seed, jatropha, jojoba, karanja, linseed, mahua, neem, rubber seed, and tabaco [27]. The third generation of biodiesel is the biofuel derived from algae, waste oils, and animal fats. Genetically modified algae are used for produce the fourth generation biodiesel. Only first and second generation biofuels are commercially produced [28]. Now, biodiesel is facing some important challenges that must be overcome in the future. Some challenges are associated with biodiesel feedstock selection, optimization and production processes, the oil extraction and conversion process, fuel characterization and property analysis, and storage and transport [29]. Moreover, the limitations of the usual catalysts used for the production of biodiesel have created a niche for the investigation of new catalysts as ionic liquid that can be recycled easily [30] or nano-catalysts [31]. The raw material selection and catalyst type play significant roles in the economic viability of biodiesel production [32]. In addition, to improve the biodiesel production, recently new research has been focused on the use of advanced transesterification reactors [24]; the use of novel transesterification by enzyme that has advantages in terms of conversion, yield and reusability conversion, yield and reusability [33], and the production of third-and fourth generation biodiesel [27].
Another challenge that biodiesel faces, and in general all biofuels, is the adequate transition from conventional fossil fuels to biofuel. It implies the establishment of adequate policies to achieve a sustainable energy transition. In this sense, recent studies have focused on this aspects. Falcone et al. (2017) identify and recommend the most effective policy combinations to steer a sustainable energy transition under alternative crisis scenarios in the case of biofuels in Italy [34]. Falcone et al. (2019) develop a methodological approach to the formulation of an effective policy aimed at supporting the development of an innovation niche (liquid biofuels in Italy) facing adverse conditions [35]. Glensor and Muñoz (2019) give policy recommendations for the conversion of car and urban bus fleets to 100% electric or biofuel (bioethanol and biodiesel) use by 2050 compared to a business as usual (BAU) by development of a life-cycle analysis of the Brazilian urban passenger transport system [36].
ASTM D6751 (USA), EN 14213 (European Union), IS 15607 (India), etc. standards are used to maintain the quality of produced biodiesel for marketing. These standards are used for pure biodiesel (B100), not for biodiesel blends. For biodiesel blends, standards are only given by ASTM [27].

Methodology
The aim of this work is to develop an analysis of the effects caused by oil changes in a continuous stirred-tank reactor during the continuous and steady state operation of the system. To achieve this purpose, a mathematical model for the reactor that considers the changes of the oil type in the feed stream was developed. In this work, a methodology to model the oil changes is proposed. The flow diagram presented in Figure 1 summarizes the general methodology used in the course of the investigation. First, an equation system that describes the dynamics of mass and energy into an industrial continuous stirred-tank reactor [3] was development. Typical modeling methods to develop first principle models for chemical system, mass and energy balances, were employed [37,38]. These techniques have been widely used for modeling of biodiesel production systems [3,4,12,16,18,19,39,40]. The dynamics of oil changes, which had not been considered previously in the literature, were modeled in this work. Then, the original equation system was simplified adopting adequate assumptions that are close to the operating condition in the reactor. The final model consists of a set of ordinary differential equations. Next, the physical and chemical properties of the system, model parameters, value for input variables and initial conditions for the model were determined to carry out the model simulation. Then, the ordinary differential equation system was solved in a computer using Matlab software (Model simulation) (version 2016a, MathWorks, Natick, MA, USA). Finally, the simulation results were used to analyze the effects caused by oil changes disturbances. The following subsections present a more detailed description of the important aspects in the methodology for the model construction.

Continuous Stirred-Tank Reactor Operation
The present study considers a model for a continuous stirred-tank reactor of biodiesel [3], which, initially, operates in a steady state and is fed with a type-i vegetable oil. Then, the oil supply is abruptly changed for a type-j oil (the subscripts i and j will be used to denote different unspecified oil types). This causes the glyceride properties (type and concentration) in the feed stream to change instantaneously. An abrupt oil change was considered in the model because it is the worst-case scenario for this type of disturbance. After an oil change, components from the transesterification of both oils are mixed inside the reaction tank over a short period of time which depends on the hold of the system. An internal cooling coil, which uses water at room temperature (30 • C) as a coolant fluid, is used to keep the reaction temperature below the boiling point of methanol.

Simulation of the continuous reactor operation with oil changes
Analysis of the disturbances effects caused by oil changes from simulation results.

Differential equation system
ODE23t matlab solver Numerical values of properties, parameters, input variables, and initial conditions Numerical solution of the ordinary differential equation system (model simulation).

Energy balance
Reaction kinetic Oil changes (innovation) CSTR model Figure 1. Methodology of the research work.

Transesterification Modeling for Pure Vegetable Oils
Transesterification is the chemical process that converts animal fats or vegetable oils into biodiesel. Vegetable oils are the most commonly used raw materials in biodiesel production and are mainly constituted by triglycerides and small amounts of diglycerides, monoglycerides, free fatty acids, water, and other substances. Triglycerides (TG), which make up about 95-98 wt% of vegetable oil, are tri-esterified glycerols with three fatty acid molecules, i.e., a triester [41]. Because fatty acids can be either different or identical, triglycerides can therefore be classified into mixed triglycerides and simple triglycerides.
During the transesterification process, the vegetable oil (triglyceride) reacts with a short chain alcohol, usually methanol (AL), wherein three methanol molecules react with one triglyceride molecule, producing three fatty acid methyl ester (ME) molecules and one glycerol (GL) molecule.
As transesterification is a reversible process, part of the total product formed in the forward reaction then reacts to form reactants again via a reverse reaction. The chemical Equation (1) presents the general transesterification process for a type-i vegetable oil reaction with methanol: The decomposition of triglycerides into three simple esters requires a three-step reversible mechanism (i.e., six elemental steps), with diglycerides (DG) and nonoglycerides (MG) formed as by-products during the intermediate steps. Monoglycerides and diglycerides are glycerol molecules esterified by one and two fatty acids, respectively. As in the triglyceride molecule, the fatty acids in diglyceride can be either different or identical. The chemical Equations (2)-(4) define the reaction mechanism occurring in vegetable oil transesterification [26].
With a 6:1 alcohol to oil molar ratio and using homogeneous base catalysts at atmospheric pressure, the transesterification reaction presents a second-order kinetic behavior; therefore, the elementary reactions in the transesterification mechanism can be modeled by second-order rate equations such that: where r n,i represents the rate of the n-th elementary reaction which occurs in the transesterification process, and C x i represents the concentration of component x i which is involved in the transesterification reaction. Furthermore, the term k n,i denotes the rate constant for an elementary reaction, which is defined by the Arrhenius equation k n,i = α n,i exp −Ea n,i RT , where α n,i is the frequency of collisions, Ea n,i is the activation energy, R is the universal gas constant, and T is the reaction mixture temperature. Thus, the velocity of reaction of the components in the transesterification of a single oil is defined as: The transesterification reaction rate is not only defined by the kinetics of the reactions, but by three regimes: an initial mass transfer-controlled regime (slow); a kinetically-controlled regime (fast); and a final regime occurring as equilibrium approaches (slow) [26]. The initial mass transfer regime is associated with the time that the triglyceride molecule spends in moving into the methanol phase and colliding with the methanol molecule [42], although an adequate mixing intensity minimizes the effects of the mass transfer. For example, various studies have demonstrated that the mass transfer region becomes insignificant (at approximately one minute), with, at laboratory scale, the impeller rotating at an intensity of 600 rpm [26,[42][43][44]; meanwhile, high reaction temperatures (50-65 • C) also reduce the mass transfer period due to the increased solubility of the oil in the methanol [26]. The present study does not focus on the mass transfer regime, assuming an adequate agitation and a high reaction temperature (60 • C); therefore, the transesterification rate can be modeled via the reaction rate equations in the form of Equation (5).
As the glycerides in the vegetable oils are formed by different fatty acids, there are a large variety of glycerides and esters in the reaction mixture, implying that two glyceride or ester molecules can be nonidentical and can react differently. If the kinetic parameters of the reactions for every possible glyceride and ester are known, the rate equations for all reactions can be used to formulate the kinetic model for the transesterification mixture, although this procedure involves the determination of a large number of kinetic parameters for all reactions. To simplify this, most kinetic studies reported in the literature characterize the reaction of glycerides and ester in the elementary steps with a unique rate constant. Thus, it is assumed that all glycerides or esters, regardless of whether they are formed by different fatty acids, react in the same way. Consequently, there are only three reversible reactions and six rate constants in the transesterification kinetic model.

Oil Changes Modeling
The characteristic transesterification reactions of the feed oil occur when the reactor is operating first with a nominal type-i oil (Figure 2a), with the glycerides from the other oil entering the system once after the oil has been changed from type i to j in the feed stream. These new glycerides from the type-j oil react by means of different kinetics and physicochemical properties; therefore, a second set of transesterification reactions, which are characteristic of type-j oil transesterification, occurs after the change of raw material (Figure 2b). Thus, glycerides, and esters from each oil react reversibly with components from the corresponding transesterification (Reactions (2)-(4)) or from the transesterification process for the other oil (Reactions (12)-(15)). These "cross-linking reactions" that occur between glycerides and esters from two different oils lead to the synthesis of a more complex glyceride formed by fatty acids characteristic of both oils and reacting reversibly to form diglycerides and monoglycerides again. The present study assumes that these complex glycerides, formed by the cross-linking reaction, decompose in the original molecules during the inverse reaction. The reversible cross-linking reactions are modeled by second-order rate equations in the form of Equation (5). Finally, the transesterification of the type-j oil solely occurs when the components of the type-i oil have been removed from the reaction tank (Figure 2c): MG j + ME i

Mass and Energy Balances for the CSTR
The CSTR model was developed using usual mass and energy balances [37,38], considering the following assumptions, which are close to the conditions in a real continuous reactor of biodiesel. (1) The chemical reactions of reactants in the input stream before entering the tank are not considered. (2) The reaction mixture can be considered pseudo-homogeneous due to an intense agitation (assumed) and the high temperature of reactor mixture (60 • C). (3) With these conditions, the mass transfer regimen is negligible and the reaction rate only depends on the activation energy and frequency factors of the kinetic constants associated with the fatty acids in the glycerides [26,42,43]. (4) The thermo-physical properties of the mixture components are constant within the system's temperature range because the change of temperature caused by the oil changes is negligible.
V d dt V d dt V d dt V d dt V d dt where V represents the total volume of the reaction mixture; F and F c represent the volumetric flow rates in the feed and cooling coil streams; ρ and ρ c are the density by reaction mixture and cooling coil, respectively; c p and c p,c are, respectively, the specific heat of the mixture in the tank and the water in the cooling coil; ∆H k,i represents the enthalpy of the k-th elementary reaction occurring during the transesterification of the vegetable oils and the cross-linking reactions; and, U t and A t are, respectively, the heat transfer coefficient and the area of heat transfer between both the cooler and the reactor. In the model, the terms G n,i (generation term) represent the net rates of the n-th component inside the tank and are defined by Equations (26)-(37): G ME,i,ji = −r 1,ji + r 2,ji − r 3,ji + r 4,ji , Due to the fact that diglycerides, monoglycerides, and esters may react in either a typical transesterification process or the cross-linking reactions, the mass fraction was used in order to estimate the quantity of each component reacting in each case. For example, the quantity of DG p that reacts with ME p in palm oil transesterification after a feed oil change is C DG,p,p = X ME,p C DG,p , where C DG,p,p is the quantity of palm oil diglycerides that intervene in palm oil transesterification and X ME,p is the mass fraction of palm esters calculated using all esters obtained from both oils.

Characterization of Glycerides and Esters
Some properties of the system are defined by components in the reaction mixture. For example, the density and specific heat of the mixture depend on the densities and heat capacities of each of its elements. Moreover, the enthalpy of the reactions depends on the particular elements that take part as reactants and products in the reactions. Ideally, in order to characterize the components of the mixture, it is necessary to estimate the properties of each individual compound (e.g., by a group or fragment contribution method); however, because glyceride and ester molecules may be formed by different fatty acids, there is a large variety of these components in the reaction mixture. To simplify characterization, all glycerides and esters, regardless of whether they are formed by different fatty acids, are characterized with similar properties.
In the the literature, there are three approaches for characterizing vegetable oil triglycerides: the mixed-TG method; the simple-TG method; and the pseudo-TG method [45]. The mixed-TG method determines the composition of each mixed triglyceride in the oil by means of either high-resolution gas chromatography (HRGC) or a probabilistic method [46]. The thermo-physical properties of the triglyceride mixture are then computed by applying a prediction method, such as a group contribution method or a fragment-based approach, using an appropriate mixing rule, although TG composition analysis is not commonly used. In both the literature and practice, the fatty acid (FA) composition is the most frequently used analytical criteria for characterizing feed oils [45]. For this reason, the use of methods based on FA composition is a more appropriate for oil triglyceride characterization. The simple-TG and pseudo-TG approaches use FA rather than TG composition. In the simple-TG method, the triglycerides are represented with an unique type of the fatty acids that appear in the FA composition and then the thermo-physical properties for each simple triglyceride are calculated via an appropriated method. Finally, the ideal mixing rule and the FA composition are used to estimate the properties of the triglyceride mixture. The pseudo-triglyceride approach represents the triglycerides as a simple molecule with the same weighted-average number of CH 2 groups in the FA chain and the same weighted-average number of CH=CH groups as the original feed oil mixture, based on the composition indicators and mole fractions for each FA component [47]. Then, the ideal mixing rule and the FA composition are used to estimate the properties of the simple-triglyceride mixture.
The above described methods (mixed-TG, simple-TG, and pseudo-TG) are efficient and provide equally accurate estimations [47]. Additionally, due to the fact that, in practice, most biodiesel plants are only able to characterize the feed oil via the FA composition, the simple-TG and pseudo-TG methods are sufficient for estimating the thermo-physical properties of vegetable oils. The present study used the simple-molecule and pseudo-molecule methodologies to characterize triglycerides, diglycerides, monoglycerides and esters from palm, mustard, and sunflower oils.
In the alkali-catalyzed transesterification of vegetable oils, the FA composition of methyl esters is identical to their corresponding oils [48]. For this reason, the FA composition of the oil was used to characterize the fatty acid methyl esters in the present study. Moreover, it is assumed that the FA composition of the diglycerides and monoglycerides is similar to their corresponding oils and thus the FA composition of the oil is used in the characterization of theses components.

Determination of the Density and Heat Capacity of the Reaction Mixture
The prediction method used to estimate the thermo-physical properties of the reaction mixture components is essential to obtaining accurate estimations. Su and Liu evaluated the methods for predicting ten essential properties of TG, DG, and MG from feed oils for biodiesel manufacturing, recommending the most appropriate methods for predicting each property based on accuracy, consistency, and generality [47]. The present study used these recommendations to estimate the densities and heat capacities of the glycerides (see Table 1). Moreover, the liquid heat capacity of fatty acid methyl esters was estimated by means of a group contribution method developed for fatty compounds presented in the biofuel industries [49]. A general-purpose group contribution method was used to determine the liquid density of the esters and glycerol [50], while the specific heat capacity for glycerol was computed using an algebraic equation adjusted using glycerol heat capacity measurements of 298 to 383 K [51]. The liquid density of the methanol was calculated using a modified Rackett equation [52], with the specific heat estimated using an algebraic equation [53]. Table 1 summarizes the methods used to both characterize the glyceride and ester molecules and estimate the thermo-physical properties of each component of the reaction mixture. The density and specific heat to every reaction component were estimated at 60 • C. Monoglyceride Simple-molecule Fragments-based [55] Methyl ester Pseudo-molecule Group Contribution [50] Group contribution [49] Glycerol -Group contribution [50] Algebraic eq. [51] Alcohol -Rackett eq. [52] Algebraic eq. [53] The properties of the mixture were calculated from the properties of each reaction component using the ideal mixing rule based on the mass fractions according to Equations (38) and (39): where X n,i is the mass fraction of n-th component in the mixture, ρ n,i and c p,n,i are, respectively, the density and heat capacity of each reaction component (including all components formed in the cross-linking reactions).

Reaction Enthalpies
The enthalpies for the reactions in the mixture were calculated from Hess's law using the standard enthalpies of formation, such as those described by [4]: where N p is the number of products, N r is the number of reactants, and ∆H k,i is the heat of the k-th reaction at T 0 = 298.15 K, which is calculated by means of a group contribution method [56]. The reactants and products for the reactions were characterized via the pseudo-molecule method before the application of the contribution group and Hess's Law.

Kinetic Parameters of the Reactions
The kinetic parameters for the Arrhenius equation (activation energy and frequency factor) were calculated from the kinetic constant reported in the literature at different temperatures. Ideally, a detailed study must determine the kinetic parameter for the reaction of every component of the mixture, namely it must consider the reaction of every different glyceride and ester; however, this means that the reaction kinetic model has a large number of equations [44]. Most studies characterize the reaction of every glyceride and ester with solely the kinetic constant; therefore, considering the reversible three-step mechanism, kinetic studies only determine six kinetic constants. Some researchers have even opted to represent the reaction with a one-step mechanism. Consequently, kinetic models with different mechanisms are available in the literature. However, most studies, even those that consider the same mechanism, were developed under different conditions (see Table 2). In order to correctly evaluate changes in oil supply, it is necessary to use consistent kinetic parameters. For this reason, in order to choose consistent reaction constants, a comprehensive review of different kinetics studies was undertaken in the present study and is presented in Table 2. The table shows that the research on vegetable oils conducted by Issariyakul (mustard and palm oils) and Vicente (sunflower oil) was developed under the same experimental conditions [42,43]. Hence, the Arrhenius equation parameters for elementary reactions in vegetable oil transesterification were determined from the kinetic constants reported in the above studies.

. Other Parameters, Input Variables, and Initial Conditions for Simulation
The reactor-to-cooling coil heat transfer coefficient was calculated according to the model proposed by Mjalli, whose geometrical parameters for the reactor were also used [3]. The molar mass for each component in the reactor mixture was estimated using the simple molecule methodology. The density and heat capacity of the water in the cooling coil were established at a nominal value of 60 • C.
For the reactor simulations, the velocities of flow for the input streams were established in line with the conditions reported by Mjalli [3], while the temperatures for the feed oil and the cooling streams were established at 60 • C and 30 • C, respectively. Furthermore, the glyceride concentrations in the input stream were modified according to the glyceride composition in the corresponding oils after the feed oil changes had been made. Therefore, in order to maintain a molar ratio of 6:1, the alcohol concentration in the feed stream was also adjusted post-feed oil change. Table 3 summarizes the operating conditions for the input variables of the reactor model. Moreover, the initial conditions were C TG,p = 0.97 mol L −1 , C DG,p = 0.1 mol L −1 , C AL = 5.82 mol L −1 , T = 60 • C, T s = 30 • C, and zero for the other state variables in the model and were established assuming that the reactor was initially loaded with palm oil. Table 3. Nominal operating conditions of the input variables.

Results and Discussion
An evaluation of the disturbances effects caused by feed oil changes during continuous reactor operation were developed based on model simulations. Two types of simulations were developed in the present study. First, the transesterification reaction for each pure vegetable oil, modeling in Equations (6)- (11), was simulated in order to evaluate the accuracy of the kinetic models. Then, the abrupt changes in the oil type entering via the feed stream during the continuous operation of the reactor were then simulated using the model system in Equations (16)- (25) in order to analyze the effect of these disturbances. All simulations were performed using the Simulink environment from Matlab. Transesterification reaction equations for single oils were salved using ODE45 algorithm while the differential equation system of the reactor was solved using the ODE23t algorithm (see Figure 1).

Simulation and Evaluation of the Transesterification Reaction Models
Accuracy evaluations of the kinetic models for palm, mustard, and sunflower oils were carried out. The mass fraction of esters estimated by assuming the complete separation of the glycerol and alcohol was used an indicator of biodiesel production (Equation (41)). As can be seen in Table 2, the kinetic constant for the transesterification of three oils were obtained with similar experimental conditions: 600 rpm for agitation intensity, 1% of KOH catalyst, 6:1 alcohol to oil molar ratio, and a temperature range around 60 • C. The results from the simulation of the reaction models were compared with the experimental data presented in the literature, with the relative error computed from experimental data and the results of the simulation, as in Equation (42), used as the accuracy indicator: Figure 3 presents the data from both experimental and simulation reactions. The average relative error of the models was calculated, respectively, as 4.39%, 5.54%, and 3.25% for the transesterification of palm, mustard, and sunflower oils for a 30-min reaction time. These errors are slow. However, the results also show that the model for palm transesterification shows a considerable deviation between the second and fourth minute of the simulation. Furthermore, the kinetic model for mustard oil transesterification shows a considerable error in the reaction equilibrium. This means that the kinetic parameters for palm transesterification could present model uncertainties for the reactor operation with short resident time. In contrast, the kinetic parameters for the mustard oil could present estimation mismatch with high resident times. The kinetic parameters for the sunflower oil show an adequate estimation throughout the reaction simulation.

Reactor Simulation and Analysis of the Effect of the Feed Oil Changes on the System
Three abrupt feed oil changes were simulated in order to analyze the effect of these disturbances on the reactor in continuous operation. The changes were simulated at the 500th, 2000th, and 3500th min, at which the system is operating in a steady state. While fed with palm oil at 500 min of simulation, at which point the reactor is operating in a steady state, the feed oil is replaced by mustard oil. At minute 2000, when the system is again operating in a steady state, the oil in the feed stream is replaced again, this time with sunflower oil. Finally, the reaction tank is fed with palm oil once more at minute 3500. Figure 4 shows the behavior of the ester concentrations after the oil changes, omitting the first transitional period when the state of the system moves from initial conditions to its first steady state. After a feed oil change, the esters from the previous oil begin to decrease due to the interrupted glyceride supply, while, in contrast, the esters from the new oil begin to be formed. As the rate at which the first esters leave the tank is higher than the formation rate of the new esters, a decrease in the total quantity of esters is observed after the feed oil changes (green curve), with the highest concentration in the new post-change steady state obtained with palm oil. The concentration of ester during the steady obtained with a particular oil mainly depends on the net reaction rate of the components and the triglyceride concentration in the input stream (see Equations (16)- (25)). However, the quantity of triglycerides has a greater influence than the kinetic parameter on the rate of reaction. For this reason, palm oil, which contains a higher proportion of triglycerides and lower kinetic constants than sunflower oil [42,43], was observed in higher concentrations during the steady state. Regarding mustard oil, palm oil has almost two times more triglycerides than mustard oil (see Table 3). This fact causes the esters produced with palm oil to be about two times the esters produced with mustard oil (see Figure 4). These results agree with those obtained for Issariyaku and Dalai in a batch system [42].
In the practice, ester molarity is not a useful indicator of ester production, while the mass fraction is a more convenient indicator because it is used to determine ester quality in the ester phase. Figure 5 presents the effect of the oil changes on the mass fraction, where, after the first change (at minute 500), the steady state conditions under which the reactor operates is disturbed. For a short period after the change, the mass fraction of the ester increases slightly; however, after a minute, it starts to rapidly decrease up to a minimum value of 46.96% by minute 505.40, causing a small peak in the mass fraction response. This initial peak is caused by the lower concentration of glycerides in the mustard oil. The ester mass fraction then increases until reaching a new steady value of 55.56% at minute 19.14 post-feed oil change. Similar results are obtained during the subsequent feed oil changes (except the initial small peak observed), wherein an initial decrease occurs after the change, followed by a different steady state mass fraction. In contrast to the molarity observed, the highest mass fraction was obtained with sunflower oil after the second change (at minute 2000), while the lowest mass fraction was obtained with the mustard oil. Moreover, the results show that the mass fraction changed considerably after each oil change. A variation of 10.90% in the mass fraction of methyl esters was observed during the change from palm to mustard oil. Moreover, a variation up to 22.07% was presented in the change from mustard to sunflower oil. Finally, the mass fraction had a difference of 9% between steady states after the final change from sunflower to palm oil (see Table 4).
Although the mixture temperature is also disturbed after each feed oil change, its variations are not significant, in contrast to what was previously observed for ester mass fraction. This is because the enthalpy of the reactions for different oils are practically identical. Although the temperature also depends on reaction rates (see Equation (24)), the differences between oils seem not to have an important influence on the temperature. The magnitude of temperature variations, in the worst-case scenario, was only 1.48%. Table 4 summarizes the results of the operational disturbances in the reactor.   Figure 6 shows the dynamics of triglyceride concentration, including those forming in the cross-linking reaction, during the transition from palm and mustard oil after the feed oil change at minute 500. The concentrations of these types of triglycerides are lower than the concentrations of triglycerides characteristic of pure oils. The low formation of triglycerides in cross-linking reaction is due to kinetic forward reactions being similar to the kinetic of reward reaction in the usual transesterification, which are lower. Similarly, small concentrations of triglycerides and diglycerides are produced in all cross-linking reactions, which only affect reactor dynamics during the transitory period, which is relatively short compared to the reactor operation time.

Conclusions
This study presents a methodology to model a continuous stirred-tank reactor considering oil changes in the feed stream during the continuous operation of the reactor. Following the methodology, a first principle model for and industrial reactor of biodiesel was developed. Based on the reactor simulation, an analysis of the perturbation effects caused by the oil changes were developed. The simulation results show that main reactor variables, reaction mixture temperature, and ester concentration (molarity) vary after each feed oil change, although the temperature variations were negligible (around 1.48% in the worst-case). In contrast, the effects of the disturbances on the variable of ester concentration were significant. The main factor affecting the steady state production of ester is the quantity of triglycerides in the oil. Hence, palm oil that has the higher triglyceride concentration achieves a mayor ester production regarding palm and mustard oils. Even palm oil, which has about two times more triglycerides than mustard, produces twice as many esters as mustard oil. This is consistent with the literature results in a batch process. Similarly, the mass fraction of the ester phase, which is a more practical indicator, is considerably disturbed. A variation of 10.90% in the mass fraction of methyl esters was observed during the change from palm to mustard oil. This concentration varied by up to 22.07% in the change from mustard to sunflower oil. Finally, the variation in this indicator was around 9% during the final change back to palm oil again.
Mathematical models for continuous stirred-tank reactor of biodiesel developed with the methodology presented in this study can be used to improve the economic viability of biodiesel production. In this sense, they can help in decision-making for the production processes or in the design of advances control strategy that ensure the production viability even when disturbances caused by oil changes occur. Moreover, observers for online estimation of concentration variables, which are not available for online measurements, can be developed based on the models. Therefore, this work presents an important tool for developing sophisticated technologies that are able to face the challenging and changing conditions of biodiesel manufacturing.
Nevertheless, the methodology for oil changes modeling is based on usual kinetic studies reported in the literature. These studies assume that glycerides and esters are all equal and only consider three reversible reactions (i.e., six elemental reactions). However, a lot of different glycerides and esters, reacting with different characteristics, take part in the transesterification reaction. In order to improve the model accuracy, detailed kinetic models must be used. Moreover, the model has not been validated due to the lack of experimental data. Thus, the validation of methodology is the next step for the actual investigation. Furthermore, advances in control systems can be designed to ensure the correct reactor performance and the productivity. In addition, state observers can be design based on models developed with the proposed methodology to enhance the productivity of production process.

Acknowledgments:
The authors thank the Consejo Nacional de Ciencia y Tecnología (National Council of Science and Technology) for the scholarship granted to J.P.C.G.

Conflicts of Interest:
The authors declare no conflict of interest.

Abbreviations
The following abbreviations are used in this manuscript: