BVP: Finite Differences or Method of Lines C ∂

advertisement
10.34, Numerical Methods Applied to Chemical Engineering
Professor William H. Green
Lecture #36: TA-Led Final Review.
BVP: Finite Differences or Method of Lines
∂C
= Forward/Upwind/Central difference formulas
∂x
∂ 2C
= Central difference-like
∂x 2
Understand when to use the different formulas.
Boundary Condition (Flux)
D
∂C
∂x
=Reaction per surface area [moles/m2·s]
boundary
[m2/s] Internal Flux [(mol/m3)/m]
A
The flux is the same for these two arrows
B
can solve even if A and B are not known
Partition
function
coefficient
Figure 1. The flux is the same for arrows at A and B.
Method of Lines
Solve a differential equation
Initial Condition
gradient stiff in y-directon
Sparse
Discretize
123
x
y
along line i = 2, …, N-1
∂C
∂x
=
2
C3 − C1
2x
Boundary Condition –
may need to use
shooting method
Figure 2. Example problem good for method of lines.
If this is the B.C.:
C − C1
∂C
= 2
∂x 1
Δx
Use this additional equation with rest to solve for C1
D.A.E.
Cite as: William Green, Jr., course materials for 10.34 Numerical Methods Applied to Chemical Engineering, Fall
2006. MIT OpenCourseWare (http://ocw.mit.edu), Massachusetts Institute of Technology. Downloaded on [DD
Month YYYY].
Models vs. Data
y = f(x,θ)
y1 = f(x1,θ)
y2 = f(x2,θ)
|
yn = f(xn,θ)
Assumption: 1) y distributed normally around
ŷ
2) x are known exactly
P(y)
σ
Figure 3. A normal distribution.
y
ŷ
WANT:
1) Find the best θ
2) Is the model consistent?
3) Error bars on parameters θ
Assume model is exact
xi
yi
ŷ i = f(xi,θ)  data will be distributed around model
x1
y1
x2
y2
…
xn
yn
⎡ − ( y i − f ( x i , θ ) )2 ⎤
⎥
2σ 2
⎢⎣
⎥⎦
P(yi) ∝ exp ⎢
⎡ − ( y i − f ( x i , θ ) )2 ⎤
⎡ −1
P(y) ∝ ∏ exp ⎢
⎥ ∝ exp ⎢ 2
2
2σ
i =1
⎣ 2σ
⎣⎢
⎦⎥
N
N
FIT: Max P(y)
∑ (y
Min
i =1
N
∑ (y
i =1
i
2⎤
− f ( x i ,θ )) ⎥
⎦
− f ( x i ,θ ))
2
i
k = A·exp(-Ea/RT)
ln k = ln A y = xn·θ
Ea
/R (1/T)
T
Linear in parameters ln k, ln A,
Ea
/R
-1 T
θ = [x x] x ·y
xn: n rows (measurements), m parameters
10.34, Numerical Methods Applied to Chemical Engineering
Prof. William Green
Lecture 36
Page 2 of 6
Cite as: William Green, Jr., course materials for 10.34 Numerical Methods Applied to Chemical Engineering, Fall
2006. MIT OpenCourseWare (http://ocw.mit.edu), Massachusetts Institute of Technology. Downloaded on [DD
Month YYYY].
S.V.D.: x = UmxmΣmxnVnxn
N
⎛ vi ⋅ y ⎞
⎟v i
θ = ∑⎜
⎜
⎟
i =1 ⎝ σ i ⎠
N
Sample variance guess for σ: s2 =
∑(y
i =1
i
− y) 2
N − dim(θ )
y is mean y, f(x,θ)
If non-linear, use optimization methods.
For correctness, compare s to σ. Quantitatively, use χ2 (chi squared)
χ2 =
N
∑
i =1
( y i − f ( x i , θ ) )2
Transform to z
σ2
Goodness of fit: area
under curve χ2min to ∞
P(y)
σ
1
y
ŷ
z
0
mean of 0, σ = 1
[N-dim(θ)]
χ2min
χ2
Figure 4. Usually we will accept a model with the integral greater than 5%, but we would
like it higher. If 99% chance it is wrong, reject.
Error Bars – Difficult
If linear in parameters and σ is known, covariance(θ) = σ2[xTx]-1
θi = θmin,i±z2,5σ[x
T
x]i,i-1/2
(diagonal mxm matrix)
m = # parameters
0.025
2.5%
Figure 5. Chi-squared distribution.
θmin,i
from χ2
Non-linear: σ[xTx]i,i
point that bounds
error on θmin,i
xi,j =
∂f ( x i ,θ )
∂θ j
10.34, Numerical Methods Applied to Chemical Engineering
Prof. William Green
Find xi,j
Lecture 36
Page 3 of 6
Cite as: William Green, Jr., course materials for 10.34 Numerical Methods Applied to Chemical Engineering, Fall
2006. MIT OpenCourseWare (http://ocw.mit.edu), Massachusetts Institute of Technology. Downloaded on [DD
Month YYYY].
In MATLAB, use nlinfit, nlparei
95% confidence
θ2
θ2,m
χ2min
θ2
θ1
θ1,m
θ1
Figure 6. Location of chi-squared and 95% confidence interval in θ1-θ2 space.
ν = 2 additional degrees of freedom: let θ1, θ2 vary
∆χ2 ≡ [χ12 – χmin2]
If σ unknown, use student t distribution based on s.
Report T(χ,ν), ν being N-dim. θ
normal
student t
broader
as N increases, student t approaches normal distribution
Figure 7. Comparison of normal and
Student-t distributions.
yi = θ ( you want to calculate θ)
σ is known, yi is to be measured.
Average value of parameter: θm = (Σyi)/N
⎡ ⎤
x= ⎢ ⎥
⎣ ⎦N
xTx =
[
]⎡⎢
⎤
⎥ =N
⎣ ⎦
σ[xTx]-1/2
σ/√N
Global Optimization
Convex function – H ≥ 0
(Hessian Matrix is positive definite)
Figure 8. Example of a convex function.
Only 1 minimum
Non-convex:
10.34, Numerical Methods Applied to Chemical Engineering
Prof. William Green
Lecture 36
Page 4 of 6
Cite as: William Green, Jr., course materials for 10.34 Numerical Methods Applied to Chemical Engineering, Fall
2006. MIT OpenCourseWare (http://ocw.mit.edu), Massachusetts Institute of Technology. Downloaded on [DD
Month YYYY].
Figure 9. An example of a
non-convex function.
Branch and bound
Professor Barton – Non convex function guarantees global minimum
Divide domain
Bound from above
Underestimate below
Find mimina.
Bound again…
Split
Figure 10. An illustration of the branch and bound algorithm.
If new upper bound is lower than the lower bound, use other region; can stop considering
that section.
Multistart:
Take a bunch of initial guesses and then run local minimization.
No guarantee.
100 points, 6 variables – 1006 calculations.
10.34, Numerical Methods Applied to Chemical Engineering
Prof. William Green
Lecture 36
Page 5 of 6
Cite as: William Green, Jr., course materials for 10.34 Numerical Methods Applied to Chemical Engineering, Fall
2006. MIT OpenCourseWare (http://ocw.mit.edu), Massachusetts Institute of Technology. Downloaded on [DD
Month YYYY].
Simulated annealing
E
0
2π
φ
Dihedral angle
Figure 11. The energy varies with dihedral angle.
Start at high temperature, decrease T eventually can sample wells once the point is caught
in a minimum.
Genetic Algorithms
Hybrid system: integer variables and continuous variables
Sample space by allowing function values to live, die, replicate, switch values, etc.
Monte Carlo: Metropolis Monte Carlo
Gillespie Kinetics Monte Carlo
Stochastics
Look at homework solutions to 10 and 11.
Additional Topics
Fourier Transforms and operator splitting may make a showing.
10.34, Numerical Methods Applied to Chemical Engineering
Prof. William Green
Lecture 36
Page 6 of 6
Cite as: William Green, Jr., course materials for 10.34 Numerical Methods Applied to Chemical Engineering, Fall
2006. MIT OpenCourseWare (http://ocw.mit.edu), Massachusetts Institute of Technology. Downloaded on [DD
Month YYYY].
Download