Quality Control of a Paint Production Process
Introduction
1. Formulation of Reaction Kinetics Equation
2. Derivation of the Reaction Kinetics Model
3. Validation of the Reaction Kinetics Model
4. Updated Reaction Kinetics Model
Quality control in terms of paint production consists of sampling at regular intervals to ensure that the end product meets a set of target criteria, which include desired yield and concentration levels. These criteria are determined by developing a model to accurately represent the reaction kinetics of the system. With a highly accurate model of the chemical process one can quickly identify and correct sources of error during the production process.
During a routine sample control inspection, a quality control engineer identified a significant discrepancy between the expected and actual concentration of paint produced in the reactor; the concentration of paint produced was double the expected value. This application illustrates how Maple was used to identify and subsequently correct the source of error between the model-predicted and actual concentrations of paint produced.
1. Formulation of the Reaction Kinetics Equation
The equations that define the chemical process are shown below. The reactants, A and B, are mixed together while carbon dioxide is continuously added to produce a desired third compound C. In the interest of commercial competition, the names of the chemical species have been changed.
We can define the above reaction scheme as a mathematical system, using the equation below:
M⋅ⅆydt=fy, y0=y0
with y∈ℝ6 and 0≤t≤180.
The matrix, M, is of rank 5 and given by:
M≔100000010000001000000100000010000000:
and the function f by:
f≔y→−2⁢r1+r2−r3−r4−12⁢r1−r4−12⁢r5+Finr1−r2+r3−r2+r3−2⁢r4r2−r3+r5Ks⁢y1⁡t⁢y4⁡t−y6⁡t:
where the ri and Fin are auxiliary variables given by:
r1:=k1⁢y1⁡t4⁢y2⁡t:
r2:=k2⁢y3t⁢y4t:
r3:=k2⁢y1⁡t⁢y5⁡tK:
r4:=k3⁢y1t⁢y4⁡t2:
r5:=k4⁢y6⁡t2⁢y2⁡t:
Fin:=klA⁢ρH−y2⁡t:
The variables y1t, y2t, y3t, y4t, y5t, and y6t, are the concentrations of the following compounds A, CO2, AT, B, C and A.B, respectively. The partial pressure of CO2 is given by ρ and H is Henry's law constant.
Using the information above, we can derive the system of nonlinear differential-algebraic equations (DAEs) that models the chemical process described above.
dy:=ⅆⅆt⁢y1⁡tⅆⅆt⁢y2⁡tⅆⅆt⁢y3⁡tⅆⅆt⁢y4⁡tⅆⅆt⁢y5⁡tⅆⅆt⁢y6⁡t:
syst_of_DAEs≔M.dy=fy
syst_of_DAEs≔ⅆⅆty1⁡tⅆⅆty2⁡tⅆⅆty3⁡tⅆⅆty4⁡tⅆⅆty5⁡t0=−2⁢k1⁢y1⁡t4⁢y2⁡t+k2⁢y3⁡t⁢y4⁡t−k2⁢y1⁡t⁢y5⁡tK−k3⁢y1⁡t⁢y4⁡t2−k1⁢y1⁡t4⁢y2⁡t2−k3⁢y1⁡t⁢y4⁡t2−k4⁢y6⁡t2⁢y2⁡t2+klA⁢ρH−y2⁡tk1⁢y1⁡t4⁢y2⁡t−k2⁢y3⁡t⁢y4⁡t+k2⁢y1⁡t⁢y5⁡tK−k2⁢y3⁡t⁢y4⁡t+k2⁢y1⁡t⁢y5⁡tK−2⁢k3⁢y1⁡t⁢y4⁡t2k2⁢y3⁡t⁢y4⁡t−k2⁢y1⁡t⁢y5⁡tK+k4⁢y6⁡t2⁢y2⁡tKs⁢y1⁡t⁢y4⁡t−y6⁡t
Rearranging the equations derived above, we end up with a stiff system of 6 non-linear DAEs of index 1. Although there is no single formulation, stiffness is usually defined as an equation (or system of equations) with terms that can lead to rapid variations in the solution.
for i from 1 to 6 do eqi ≔lhssyst_of_DAEsi = rhssyst_of_DAEsi end do:
eq1 = ⅆⅆty1⁡t=−2⁢k1⁢y1⁡t4⁢y2⁡t+k2⁢y3⁡t⁢y4⁡t−k2⁢y1⁡t⁢y5⁡tK−k3⁢y1⁡t⁢y4⁡t2
eq2 = ⅆⅆty2⁡t=−k1⁢y1⁡t4⁢y2⁡t2−k3⁢y1⁡t⁢y4⁡t2−k4⁢y6⁡t2⁢y2⁡t2+klA⁢ρH−y2⁡t
eq3 = ⅆⅆty3⁡t=k1⁢y1⁡t4⁢y2⁡t−k2⁢y3⁡t⁢y4⁡t+k2⁢y1⁡t⁢y5⁡tK
eq4 = ⅆⅆty4⁡t=−k2⁢y3⁡t⁢y4⁡t+k2⁢y1⁡t⁢y5⁡tK−2⁢k3⁢y1⁡t⁢y4⁡t2
eq5 = ⅆⅆty5⁡t=k2⁢y3⁡t⁢y4⁡t−k2⁢y1⁡t⁢y5⁡tK+k4⁢y6⁡t2⁢y2⁡t
eq6 = 0=Ks⁢y1⁡t⁢y4⁡t−y6⁡t
We now create a system model containing the equations derived above and the initial conditions.
System≔seqeqi,i=1..6 union ics
System≔ics,0=Ks⁢y1⁡t⁢y4⁡t−y6⁡t,ⅆⅆty1⁡t=−2⁢k1⁢y1⁡t4⁢y2⁡t+k2⁢y3⁡t⁢y4⁡t−k2⁢y1⁡t⁢y5⁡tK−k3⁢y1⁡t⁢y4⁡t2,ⅆⅆty2⁡t=−k1⁢y1⁡t4⁢y2⁡t2−k3⁢y1⁡t⁢y4⁡t2−k4⁢y6⁡t2⁢y2⁡t2+klA⁢ρH−y2⁡t,ⅆⅆty3⁡t=k1⁢y1⁡t4⁢y2⁡t−k2⁢y3⁡t⁢y4⁡t+k2⁢y1⁡t⁢y5⁡tK,ⅆⅆty4⁡t=−k2⁢y3⁡t⁢y4⁡t+k2⁢y1⁡t⁢y5⁡tK−2⁢k3⁢y1⁡t⁢y4⁡t2,ⅆⅆty5⁡t=k2⁢y3⁡t⁢y4⁡t−k2⁢y1⁡t⁢y5⁡tK+k4⁢y6⁡t2⁢y2⁡t
The values of the physical parameters and initial conditions of the system are given by:
Parameters
Initial Conditions
k1
y10
k2
y20
k3
y30
k4
y40
K
y50
klA
y60
Ks
ρ
H
params
k1=28.7,k2=0.58,k3=0.09,k4=0.42,K=34.4,klA=3.3,Ks=115.83,ρ=0.9,H=737
ic
y1⁡0=0.444,y2⁡0=0.00123,y3⁡0=0,y4⁡0=0.007,y5⁡0=0,y6⁡0=0.36
We can now solve the DAE system and plot how the concentrations of the various compounds change with time using the odeplot command
sol≔dsolvesubsics=ic,params, System,y1t,y2t,y3t,y4t,y5t,y6t,numeric,output=procedurelist:
3. Validation of Reaction Kinetics Model
The discrepancy between the actual and expected concentration of compound C was revealed by comparing the experimental reaction kinetics for each compound to the predicted values.
The experimental data, stored in an Excel file, was extracted using the following commands:
ExcelDirectoryLocation ≔ catkerneloptsdatadir, /Excel/:ExcelFilePath ≔ catExcelDirectoryLocation, ExperimentalData.xls:
ExperimentalData≔ImportExcelFilePath, Experimental, A2:G12
The following commands extract the values from Excel:
ExperimentalConcA ≔ MatrixExperimentalData1 .. −1, 1 .. 2:ExperimentalConcCO2 ≔ ArrayTools:-Concatenate2, VectorcolumnExperimentalData1 .. −1, 1, VectorcolumnExperimentalData1 .. −1, 3:ExperimentalConcAT ≔ ArrayTools:-Concatenate2, VectorcolumnExperimentalData1 .. −1, 1, VectorcolumnExperimentalData1 .. −1, 4:ExperimentalConcB ≔ ArrayTools:-Concatenate2, VectorcolumnExperimentalData1 .. −1, 1, VectorcolumnExperimentalData1 .. −1, 5:ExperimentalConcC ≔ ArrayTools:-Concatenate2, VectorcolumnExperimentalData1 .. −1, 1, VectorcolumnExperimentalData1 .. −1, 6:ExperimentalConcAB ≔ ArrayTools:-Concatenate2, VectorcolumnExperimentalData1 .. −1, 1, VectorcolumnExperimentalData1 .. −1, 7:
The following plots show the experimental versus predicted reaction kinetics for each compound. From these results, it is apparent that the model derived in the previous section does not adequately predict the experimental results for compound A and compound C.
In fact, the concentration of compound C at steady state is 0.0142085⁢mol, which is 1.5 times lower than the steady state concentration observed via the experimental data. Similarly, the concentration of compound A at steady state is 0.0963959⁢mol, which is 1.3 times smaller than the steady state concentration obtained via the experimental data.
SteadyStateConcentrationC≔evalf6rhsselecthas,sol200,y5t⋅mol = 0.0142085⁢mol
SteadyStateConcentrationA≔evalf6rhsselecthas,sol200,y1t⋅mol = 0.0963959⁢mol
The statistical calculations (mean, standard deviation, and root-mean square error), confirm the presence of an error in one of the rate constants controlling the concentration of compound A. The data, summarized below, show the root mean square error of compound A to be 0.00301799 which is several orders larger than the root mean square error values of the other compounds.
StatsA≔StatsTheoreticalConcA,ExperimentalConcA
StatsA≔Predicted Mean=0.246700,Experimental Mean=0.211500,Mean Difference=0.035180,Predicted Std.=0.078450,Experimental Std.=0.122800,Std. Difference=-0.044320,Root Mean Square Error=0.0104358
StatsCO2≔StatsTheoreticalConcCO2,ExperimentalConcCO2
StatsCO2≔Predicted Mean=0.000776,Experimental Mean=0.001145,Mean Difference=-0.000370,Predicted Std.=0.000351,Experimental Std.=0.000116,Std. Difference=0.000236,Root Mean Square Error=4.76021e-08
StatsAT≔StatsTheoreticalConcAT,ExperimentalConcAT
StatsAT≔Predicted Mean=0.096910,Experimental Mean=0.136600,Mean Difference=-0.039650,Predicted Std.=0.038230,Experimental Std.=0.048210,Std. Difference=-0.009976,Root Mean Square Error=0.00110483
StatsB≔StatsTheoreticalConcB,ExperimentalConcB
StatsB≔Predicted Mean=0.003504,Experimental Mean=0.001394,Mean Difference=0.002110,Predicted Std.=0.002067,Experimental Std.=0.002190,Std. Difference=-0.000123,Root Mean Square Error=6.47920e-06
StatsC≔StatsTheoreticalConcC,ExperimentalConcC
StatsC≔Predicted Mean=0.009181,Experimental Mean=0.019370,Mean Difference=-0.010190,Predicted Std.=0.004153,Experimental Std.=0.006637,Std. Difference=-0.002484,Root Mean Square Error=2.91804e-05
StatsAB≔StatsTheoreticalConcAB,ExperimentalConcAB
StatsAB≔Predicted Mean=0.118000,Experimental Mean=0.047870,Mean Difference=0.070090,Predicted Std.=0.102600,Experimental Std.=0.101900,Std. Difference=0.000698,Root Mean Square Error=0.00373211
Predicted and Experimental Mean of the Reaction Kinetics for each Compound
Predicted Mean
Experimental Mean
Difference
A
CO2
AT
B
C
A.B
Predicted and Experimental Standard Deviation of the Reaction Kinetics for each Compound
Predicted Std
Experimental Std
Root-Mean Square Error
A better prediction for the reaction kinetics of compound A can be obtained by parameterizing the numerical solution for the differential equation obtained earlier, and fitting the theoretical model to the experimental data using the least-squares approach.
The following procedure calculates the sum of the squares of the error between the experimental data and the model prediction for the rate constant k1. It assumes that the only uncertainty in the experimental data exists in the concentration, y1t. In reality, the time the reading was taken will also be subject to a degree of error. If this was to be taken into account, then the following procedure can be easily modified to calculate the sum of the short orthogonal distance between the data points and model predictions; this is also known as orthogonal regression.
SumOfSquaresError≔prock1_vallocal temp, y1_temp,i; if not typek1_val,numeric then return 'procname'args; end if;temp≔dsolvesubsk1=k1_val, ics=ic,params, System,y1t,y2t,y3t,y4t,y5t,y6t,numeric,output=listprocedure,range=0..200:y1_temp≔rhsselecta→lhsa=y1t, temp:return addExperimentalConcAi,2 − y1_tempExperimentalConcAi,12,i=1..11:end proc:
The value of k1 that best describes the experimental data is
k1experimental≔evalf6 rhsMinimize'SumOfSquaresError'var,var=1..502 = 10.9258
This value for k1 is much smaller than the value of k1 that was used to develop the original model (that is, 10.925 vs. 28.7).
Taking into account the new value of k1 as shown below, the theoretical model accurately predicts the experimental results.
UpdatedSystem≔dsolvesubsk1=k1experimental, ics=ic,params, System,y1t,y2t,y3t,y4t,y5t,y6t,numeric,output=listprocedure:
UpdatedSteadyStateConcentrationA≔evalf6rhsselecta→lhsa=y1t,UpdatedSystem200⋅mol = 0.132042⁢mol
UpdatedSteadyStateConcentrationC≔evalf6rhsselecta→lhsa=y5t,UpdatedSystem200⋅mol = 0.0227358⁢mol
With this new rate constant, the concentration of compound C now more accurately matches the concentration being produced at the plant.
Download Help Document