Reversible reaction kinetics

This Notebook finds a fit for the  complete data set in Denn 6.5

The fit is done to the solution to the ode for the 2nd order reaction.  
This allows direct calculation of concentration versus time.  As seen below, the model fits the data quite well.

A separate calculation of just the first order reaction gives a similar value for the forward rate constant -- much closer than Denn gives in text example

Mark J. McCready  3/31/20

Directory[ ]

SetDirectory[  "/Users/markmccready/Box Sync/Current_classwork/20255_19/Excel_files"]

data = Import["Denn6_5.csv"]

Note that I made the ∞ time point, 700 s.  You could alter this if you wish

dataplot =ListPlot[data,AxesLabel->{"time (s)","c1, mole/l"}]

Here is the equation for 2nd order reversible kinetics.

rateeq = D[cA[t],t] == -k1 cA[t]^2 + k2  (2( cA0-cA[t]))^2

DSolve[{rateeq, cA[0]==cA0},cA[t],t]

Somehow I know this is [[2]], but I think that [[4]] also works.

model = cA[t]/.%[[2]]

model1 =FullSimplify[model]

To get the fit to work, I have to force the values in the equation above to stay real -- which they should be!

FindFit[data,Re[model1/.{cA0->5.5}],{{k1,.001},{k2,.0001}},t]

modelplot=Plot[model1/.{cA0->5.5, k1->.000641,k2->.0001176},{t,0,700}, PlotStyle->Red]

Show[dataplot,modelplot]

initialdata = Table[{data[[i,1]],1/data[[i,2]]},{i,1,Length[data]}]

initialdataplot =ListPlot[initialdata,AxesLabel->{"time (s)","1/c1"}]

FindFit[ Table[{data[[i,1]],1/data[[i,2]]},{i,1,9}],α + β t,{α,β},t]

linearmodelplot = Plot[(α + β t)/.%164,{t,0,200},PlotStyle->Red]

Show[initialdataplot,linearmodelplot]