α α ϕ ϕ ϕ

advertisement
Statistical and Numerical
Methods for Chemical Engineers
HS2015
Exercise 7
ASSIGNMENT 1
Consider the following lab data
i
ti
qi
1
0
1
2
1
3
3
2
4
4
3
6
5
4
10
and the two models of the form
a. q(t )  0  1  t 2
b. q(t )  0  exp(1  t )
where  0 and 1 are the model parameters.
1. Specify for a. and b. whether the model is linear or non-linear in the parameters.
Since in both models the two parameters are overdetermined by the lab data, we want to obtain
them in the least square sense.
In the lecture the linear and non-linear least squares problems were introduced as
linear : min Ax  b
xD
2
nonlinear : min f ( x )  b
xD
2
where the symbols have been defined in the lecture.
2. For models a) and b) give expressions for A, x , b and f , x , b for the linear and nonlinear systems, respectively.
Let us define the scalar function ϕ for the linear and non-linear cases:
linear :  ( x ) 
1
Ax  b
2
nonlinear :  ( x ) 
2
2
1
f ( x)  b
2
2
2
The parameters in the least squares sense are then the solution of the following minimization
problem:
min  ( x )
xD
Turn page, v.s.
A necessary condition for an extremum, i.e. minimum or maximum is that the gradient of ϕ with
respect to the parameters vanishes
    / x1 ,  / x2 ,...,  / xn   0
T
(1)
Realize that this is a system of n equations and n variables (the parameters x1, x2,…, xn).
3. Suggest a method to solve the system (1) from the lecture.
In the lecture you will see that the solution of a linear least squares problem is given by the
solution of the following linear system
AT Ax  AT b
the so called normal equations.
4. With your expressions for A and b from 2. use MATLAB to determine x for the linear
problem. Plot the result together with the data. Use the template lstsqr_linear.m
For the remaining non-linear problem we will use Newton’s method. The Jacobian of the vectorvalued function is
  2 / x12
...  2 / x1xn 


H 

 2 / xnx1 ...  2 / xn2 


This matrix is actually called the Hessian matrix of the scalar-valued function ϕ.
Newton’s method would then be
x ( k 1)  x (k)  H 1 x ( k ) 
5. Implement Newton’s method to determine the parameters of the non-linear model. Use
the template lstsqr_nolinear.m as well as the file phi.m where the tedious computations
of ϕ,  and H are already implemented.
Statistical and Numerical
Methods for Chemical Engineers
HS2015
Exercise 7
ASSIGNMENT 2
Consider a batch reactor with second order reactions:
dA
 2k1A 2
dt
dB
 k1A 2  2k2 B2
dt
(2)
Solve the batch reactor and plot the solutions
 Use k1 = 1000; k2 = 0.1; y0 = [1, 0.1] and tSpan = [0,1];
 Do you expect the system to be stiff? Use the linearization method to check the stiffness
ratio at y = y0 (by hand), by calculating the eigenvalues of the Jacobian of the system
 Use ode45 to solve the system and plot the solutions. Is it stiff? Looking at the Jacobian,
can you say why? Note how y changes and how it changes the Jacobian and its
eigenvalues!
Turn page, v.s.
Download