ChEn-3170: Computational Methods in Chemical Engineering Spring 2020 UMass Lowell; Prof. V. F. de Almeida 30Mar20
$ \newcommand{\Amtrx}{\boldsymbol{\mathsf{A}}} \newcommand{\Bmtrx}{\boldsymbol{\mathsf{B}}} \newcommand{\Cmtrx}{\boldsymbol{\mathsf{C}}} \newcommand{\Mmtrx}{\boldsymbol{\mathsf{M}}} \newcommand{\Imtrx}{\boldsymbol{\mathsf{I}}} \newcommand{\Pmtrx}{\boldsymbol{\mathsf{P}}} \newcommand{\Qmtrx}{\boldsymbol{\mathsf{Q}}} \newcommand{\Lmtrx}{\boldsymbol{\mathsf{L}}} \newcommand{\Umtrx}{\boldsymbol{\mathsf{U}}} \newcommand{\xvec}{\boldsymbol{\mathsf{x}}} \newcommand{\yvec}{\boldsymbol{\mathsf{y}}} \newcommand{\zvec}{\boldsymbol{\mathsf{z}}} \newcommand{\avec}{\boldsymbol{\mathsf{a}}} \newcommand{\bvec}{\boldsymbol{\mathsf{b}}} \newcommand{\cvec}{\boldsymbol{\mathsf{c}}} \newcommand{\rvec}{\boldsymbol{\mathsf{r}}} \newcommand{\norm}[1]{\bigl\lVert{#1}\bigr\rVert} \DeclareMathOperator{\rank}{rank} \DeclareMathOperator{\abs}{abs} $
your name
¶Content | Points |
---|---|
Precision of the answer | 80% |
Answer Markdown readability | 10% |
Code readability | 10% |
Import the reaction rate constant data from the course repository data/modified-k_x_T_10pts.dat
and make a plot of $k$ versus $T$.
'''1.1 Read and plot experimental data'''
R = 8.314 [J/(mol.K)] m = 10 T = [373.15 402.93 432.71 462.48 492.26 522.04 551.82 581.59 611.37 641.15] k = [ 9.63 10.35 10.31 11.12 11.18 11.5 11.6 11.64 12.15 12.41]
'''1.2 Build the matrix system'''
matrix shape = (10, 3)
Rank(A) = 3
'''1.3 Compute LS values of the parameters in the modified Arrhenius expression'''
x_vec = [ 3.894e+00 2.320e+03 -1.473e-01] k_0 = 4.91257e+01 [1/s] E_a = 2.31978e+03 [J/mol] alpha = -1.47323e-01 []
'''1.3 Plot of the transformed plane data and fit'''
Is the fit a straight line? Explain:
'''1.3 Plot the data and fit in the Cartesian plane'''
'''1.4 Goodness of fit'''
phi(x_LS) = 2.10546e-03 sqrt(phi(x_LS)) = 4.58853e-02 Mean(r_vec) = 3.10862e-16 STD(r_vec) = 1.45102e-02 Goodness of fit = 1.45102e-02
'''1.4 Contour plot of objective function'''
'''1.4 Contour plot of objective function'''
Import the reaction rate constant data from the course repository data/modified-k_x_T_30pts.dat
and make a plot of $k$ versus $T$.
'''2.1 Read and plot experimental data'''
R = 8.314 [J/(mol.K)] m = 30 T = [373.15 382.39 391.63 400.87 410.12 419.36 428.6 437.84 447.08 456.32 465.56 474.81 484.05 493.29 502.53 511.77 521.01 530.25 539.5 548.74 557.98 567.22 576.46 585.7 594.94 604.18 613.43 622.67 631.91 641.15] k = [ 9.98 9.65 10.22 10.43 10.13 10.21 10.48 10.58 10.43 10.71 10.85 10.74 11.11 11.04 11.42 11.21 10.81 11.32 11.65 11.53 11.77 11.87 11.68 11.89 11.95 11.67 11.81 11.76 12.48 12.26]
'''2.2 Build the matrix system'''
matrix shape = (30, 3)
Rank(A) = 3
'''2.3 Compute LS values of the parameters in the modified Arrhenius expression'''
x_vec = [7.616e-01 4.546e+02 2.825e-01] k_0 = 2.14173e+00 [1/s] E_a = 4.54575e+02 [J/mol] alpha = 2.82450e-01 []
'''2.3 Plot of the transformed plane data and fit'''
Is the fit a straight line? Explain:
'''2.3 Plot the data and fit in the Cartesian plane'''
plot_mod_arrhenius_fit_cartesian(r_cte, temp_vec, k_cte_vec, k_0, energy_a, alpha)
'''2.4 Goodness of fit'''
r_vec = b_vec - a_mtrx @ x_vec
phi_ls = np.linalg.norm(r_vec)**2
print('phi(x_LS) = %8.5e'%phi_ls)
print('sqrt(phi(x_LS)) = %8.5e'%math.sqrt(phi_ls)) # norm of the residual vector
print('Mean(r_vec) = %8.5e'%np.mean(r_vec))
print('STD(r_vec) = %8.5e'%np.std(r_vec))
print('Goodness of fit = %8.5e'%math.sqrt(phi_ls/n_pts))
phi(x_LS) = 9.04154e-03 sqrt(phi(x_LS)) = 9.50870e-02 Mean(r_vec) = 4.44089e-16 STD(r_vec) = 1.73604e-02 Goodness of fit = 1.73604e-02
'''2.4 Contour plot of objective function'''
n_plot_pts = 300
objective_function_data = get_mod_arrhenius_objective_function_data(n_plot_pts, a_mtrx, x_vec, b_vec)
plot_mod_arrhenius_objective_function( objective_function_data, x_vec, delta_factor=1 )
Import the reaction rate constant data from the course repository data/modified-k_x_T_90pts.dat
and make a plot of $k$ versus $T$.
'''3.1 Read and plot experimental data'''
(r_cte, r_cte_units, n_pts, temp_vec, k_cte_vec) = read_arrhenius_experimental_data('data/modified-k_x_T_90pts.dat')
print('R = %4.3f %s'%(r_cte,r_cte_units))
print('m = ',n_pts)
np.set_printoptions(precision=2)
print('T =',temp_vec)
print('k =', k_cte_vec)
plot_arrhenius_experimental_data(temp_vec, k_cte_vec)
R = 8.314 [J/(mol.K)] m = 90 T = [373.15 376.16 379.17 382.18 385.19 388.21 391.22 394.23 397.24 400.25 403.26 406.27 409.29 412.3 415.31 418.32 421.33 424.34 427.35 430.36 433.38 436.39 439.4 442.41 445.42 448.43 451.44 454.45 457.46 460.48 463.49 466.5 469.51 472.52 475.53 478.54 481.55 484.57 487.58 490.59 493.6 496.61 499.62 502.63 505.64 508.66 511.67 514.68 517.69 520.7 523.71 526.72 529.73 532.75 535.76 538.77 541.78 544.79 547.8 550.81 553.82 556.84 559.85 562.86 565.87 568.88 571.89 574.9 577.91 580.92 583.94 586.95 589.96 592.97 595.98 598.99 602. 605.01 608.03 611.04 614.05 617.06 620.07 623.08 626.09 629.11 632.12 635.13 638.14 641.15] k = [ 9.61 9.78 9.66 10.07 10.19 10.38 9.83 9.86 10.05 9.79 10.39 10.26 10.1 9.96 10.28 10.31 10.49 10.44 10.38 10.5 10.33 10.62 10.45 11.09 10.9 10.39 10.71 10.75 10.63 10.79 10.63 11.01 10.98 10.81 10.64 11.27 10.56 10.73 10.99 10.9 11.06 10.68 11.42 10.95 11.11 10.98 10.99 10.79 11.2 11.43 11.33 11.54 11.49 11.57 11.23 11.18 11.46 11.89 11.34 11.51 11.55 11.71 11.94 11.3 11.81 11.42 11.71 11.84 11.48 11.89 11.81 12.21 11.88 11.8 11.97 12.19 11.7 12.08 12.1 11.94 12. 12.07 12.05 12.41 12.13 11.83 12.14 12.13 12.54 12.2 ]
'''3.2 Build the matrix system'''
(a_mtrx, b_vec) = build_mod_arrhenius_matrix( r_cte, temp_vec, k_cte_vec )
#print('a_mtrx =\n',a_mtrx)
#print('b_vec =',b_vec)
plot_matrix(a_mtrx, title='Arrhenius Fit Matrix')
print('Rank(A) =',matrix_rank(a_mtrx))
#print('np.linalg rank(A) =',np.linalg.matrix_rank(a_mtrx))
matrix shape = (90, 3)
Rank(A) = 3
'''3.3 Compute LS values of the parameters in the modified Arrhenius expression'''
x_vec = solve( a_mtrx.transpose()@a_mtrx, a_mtrx.transpose()@b_vec, pivoting_option='partial' )
#print('||x_vec - x_vec NumPy|| = %1.3e'%np.linalg.norm(x_vec-np.linalg.solve( a_mtrx.transpose()@a_mtrx, a_mtrx.transpose()@b_vec )))
np.set_printoptions(precision=3,threshold=100,edgeitems=3)
print('x_vec =',x_vec)
k_0 = math.exp(x_vec[0])
energy_a = x_vec[1]
alpha = x_vec[2]
print('k_0 = %8.5e [1/s]'%k_0)
print('E_a = %8.5e [J/mol]'%energy_a)
print('alpha = %8.5e []'%alpha)
x_vec = [ 0.327 269.689 0.345] k_0 = 1.38731e+00 [1/s] E_a = 2.69689e+02 [J/mol] alpha = 3.44934e-01 []
'''3.3 Plot of the transformed plane data and fit'''
plot_mod_arrhenius_fit_transformed(r_cte, temp_vec, k_cte_vec, k_0, energy_a, alpha)
Is the fit a straight line? Explain:
'''2.3 Plot the data and fit in the Cartesian plane'''
plot_mod_arrhenius_fit_cartesian(r_cte, temp_vec, k_cte_vec, k_0, energy_a, alpha)
'''2.4 Goodness of fit'''
r_vec = b_vec - a_mtrx @ x_vec
phi_ls = np.linalg.norm(r_vec)**2
print('phi(x_LS) = %8.5e'%phi_ls)
print('sqrt(phi(x_LS)) = %8.5e'%math.sqrt(phi_ls)) # norm of the residual vector
print('Mean(r_vec) = %8.5e'%np.mean(r_vec))
print('STD(r_vec) = %8.5e'%np.std(r_vec))
print('Goodness of fit = %8.5e'%math.sqrt(phi_ls/n_pts))
phi(x_LS) = 3.04631e-02 sqrt(phi(x_LS)) = 1.74537e-01 Mean(r_vec) = -2.91125e-16 STD(r_vec) = 1.83978e-02 Goodness of fit = 1.83978e-02
'''2.4 Contour plot of objective function'''
n_plot_pts = 300
objective_function_data = get_mod_arrhenius_objective_function_data(n_plot_pts, a_mtrx, x_vec, b_vec)
plot_mod_arrhenius_objective_function( objective_function_data, x_vec, delta_factor=.2 )
Make a table and compare the values of the modified Arrhenius parameters for each Assignment 1 to 3. Compare the values of the norm of the residual and goodness of fit for each data set. Which data set fits the model best? Explain.
2. Would you say the experimental data is consistent? Explain. 3. Based on the values of the parameters computed for the experimental data, what advice would you give to a company designing a chemical reaction system based on this experimental data?Best fit?
Data consistency?
Design advice?