Lecture 5: Feedback Systems of Reactors

Download Report

Transcript Lecture 5: Feedback Systems of Reactors

Lecture 7: Computer Methods
for Well-Mixed Reactors
CE 498/698 and ERS 685
Principles of Water Quality
Modeling
CE 498/698 and ERS 485
(Spring 2004)
Lecture 7
1
more complexity
Modeling Tradeoff
more realism
CE 498/698 and ERS 485
(Spring 2004)
Lecture 7
2
Simplifying Assumptions
• Idealized loading curves
• Q, k, V are constant
• First-order reactions
What if these don’t apply????
Computers and numerical methods
CE 498/698 and ERS 485
(Spring 2004)
Lecture 7
3
Completely Mixed Lake Model
dc
W t 
 c 
dt
V
dc W t 

 c
dt
V
where
CE 498/698 and ERS 485
(Spring 2004)

Q
v
k 
V
H
Lecture 7
4
Euler’s Method
Ch. 25 in Chapra and Canale
conc. at future ti+1
conc. at present ti
c
ci+1
ci
+
+
h
ti
forward difference:
CE 498/698 and ERS 485
(Spring 2004)
ti+1
t
dci c ci1  ci ci1  ci



dt t ti1  ti
h
Lecture 7
5
Euler’s Method
Ch. 19 in Chapra and Canale
dci ci 1  ci W ti 
fwd difference: dci  ci 1  ci


 c i
dt
h
V
dt
h
or
W ti 

ci1  ci  
 c i  h
 V

or
ci 1  ci  f ti , ci h
where
CE 498/698 and ERS 485
(Spring 2004)
W ti 
dci
f ti , ci  
 ci 
V
dt
Lecture 7
6
Example 7.1
Given:
Q = 10000 m3 yr-1
V = 106 m3
Z=5m
k = 0.2 yr-1
v = 0.25 m yr-1
c0 = 15 mg L-1
At t = 0, step loading = 50106 g yr-1
Simulate concentration from t = 0 to 20 yr
using timestep of 1 year
Q
v 105
0.25
   k   6  0.2 
 0.35 yr -1
V
H 10
5
CE 498/698 and ERS 485
(Spring 2004)
Lecture 7
7
Example 7.1
At ti = 0, ci = 15 mg L-1 and W(ti) = 50106 g yr-1
50 106

-1
ci1  c1  15  

0
.
35

15

1
.
0

59
.
75
mg
L
6

10


ci for next computation
CE 498/698 and ERS 485
(Spring 2004)
Lecture 7
8
Euler’s Method
Two equations:
dc1
 f1 t , c1 , c2   k1
dt
dc2
 f 2 t , c1 , c2   k 2
dt
CE 498/698 and ERS 485
(Spring 2004)
Lecture 7
9
Heun’s method
Ch. 25 in Chapra and Canale
c
ci+1
ci
+
+
ti
ti+1
t
dci
 f ti , ci   ci01  ci  f ti , ci h
dt
slope 1 (predictor)
CE 498/698 and ERS 485
(Spring 2004)
Lecture 7
10
Heun’s method
c0i+1
dci1
 f ti1 , ci01 
dt
slope 2
c
ci+1
ci
+
+
ti
ti+1
dc slope 1  slope 2 f ti , ci   f ti1 , ci01 


dt
2
2
CE 498/698 and ERS 485
(Spring 2004)
Lecture 7
t
11
Heun’s method
c0i+1
f ti , ci   f ti1 , ci01 
ci1  ci 
h
2
c
ci+1
ci
+
+
ti
ti+1
dc slope 1  slope 2 f ti , ci   f ti1 , ci01 


dt
2
2
CE 498/698 and ERS 485
(Spring 2004)
Lecture 7
t
12
Example
without iteration
From previous calcs:   0.35 yr -1
At ti = 0, ci = 15 mg L-1 and W(ti) = 50106 g yr-1
50 106
f ti , ci   f 0,15 
 0.3515  44.75
6
10
ci01  c1  15  44.751
h
6
50

10
f ti1 , ci01   f 1,59.75 
 0.3559.75  29.0875
6
10
44.75  29.0875
c1  15 
1  51.91875
2
CE 498/698 and ERS 485
(Spring 2004)
Lecture 7
13
4th-order Runge-Kutta
general form of RK methods: ci 1  ci  h
slope estimate
Euler:
Heun:
4th-order RK:
CE 498/698 and ERS 485
(Spring 2004)
ci 1  ci  k1h
1

ci1  ci   k1  k 2  h
2

1
ci1  ci   k1  2k 22k3  k4  h
6

Lecture 7
14
4th-order Runge-Kutta
1
ci1  ci   k1  2k 22k3  k4  h
6

where
k1  f ti , ci 
1
1


k 2  f  ti  h, ci  hk1 
2
2 

1
1


k3  f  ti  h, ci  hk2 
2
2


k 4  f ti  h, ci  hk3 
CE 498/698 and ERS 485
(Spring 2004)
Lecture 7
15
Spreadsheet Applications
Example: Euler’s method for Example 7.1
Q=
V=
10000 m3 yr-3
1000000 m3
Z=
5 m
v=
0.25 m yr-1
k=
0.2 yr-1
h=
yr
(timestep)
=
CE 498/698 and ERS 485
(Spring 2004)
Lecture 7
16
Spreadsheet Applications
Example: Euler’s method for Example 7.1
10000 m3 yr-3
Q=
V=
1000000 m3
H=
5 m
v=
0.25 m yr-1
k=
0.2 yr-1
h=
=
yr

Q v
 k
V H
CE 498/698 and ERS 485
(Spring 2004)
(timestep)

Q v
 k
V H
Lecture 7
17
Spreadsheet Applications
Example: Euler’s method for Example 7.1
10000 m3 yr-3
Q=
V=
1000000 m3
Z=
5 m
v=
0.25 m yr-1
k=
0.2 yr-1
h=
=
yr

(timestep)
Q v
 k
V H
ti
W(ti)
ci
0
W(t0)
Initial conc.
1
W(t1)
CE 498/698 and ERS 485
(Spring 2004)
W ti 


 ci 
 V

Slope (dc/dt)
Lecture 7
W ti 


 ci 
 V

ci+1
18
Spreadsheet Applications
Example: Euler’s method for Example 7.1
10000 m3 yr-3
Q=
V=
1000000 m3
Z=
5 m
v=
0.25 m yr-1
k=
0.2 yr-1
h=
=
yr

(timestep)
Q v
 k
V H
ti
W(ti)
ci
0
W(t0)
Initial conc.
1
W(t1)
CE 498/698 and ERS 485
(Spring 2004)
Slope (dc/dt)
Lecture 7
W ti 


 ci 
 V

ci+1
=ci+slope*h
19
Spreadsheet Applications
Example: Euler’s method for Example 7.1
10000 m3 yr-3
Q=
V=
1000000 m3
Z=
5 m
v=
0.25 m yr-1
k=
0.2 yr-1
h=
=
yr

(timestep)
Q v
 k
V H
ti
W(ti)
ci
0
W(t0)
Initial conc.
1
W(t1)
=ci+1
CE 498/698 and ERS 485
(Spring 2004)
Slope (dc/dt)
Lecture 7
W ti 


 ci 
 V

ci+1
=ci+slope*h
20
Spreadsheet Applications
Heun’s method
ti
W(ti)
ci
0
W(t0)
Initial conc.
1
W(t1)
=ci+1
CE 498/698 and ERS 485
(Spring 2004)
Slope 1
(s1)
W ti 


 ci 
 V

c0i+1
=ci+s1*h
Lecture 7
Slope 2
(s2)
W ti 1 


 ci 1 
 V

ci+1
=ci+0.5(s1+s2)*h
21
Spreadsheet Applications
Heun’s method
ti
W(ti)
ci
0
W(t0)
Initial conc.
1
W(t1)
=ci+1
CE 498/698 and ERS 485
(Spring 2004)
Slope 1
(s1)
W ti 


 ci 
 V

c0i+1
=ci+s1*h
Lecture 7
Slope 2
(s2)
W ti 1 


 ci01 
 V

ci+1
=ci+0.5(s1+s2)*h
22
Spreadsheet Applications
Heun’s method
ti
W(ti)
ci
0
W(t0)
Initial conc.
1
W(t1)
=ci+1
CE 498/698 and ERS 485
(Spring 2004)
Slope 1
(s1)
W ti 


 ci 
 V

c0i+1
=ci+s1*h
Lecture 7
Slope 2
(s2)
W ti 1 


 ci 1 
 V

ci+1
=ci+0.5(s1+s2)*h
23
Major Homework #1
Parameters from
Example 5.3
Eigenvalues
Calculations
CE 498/698 and ERS 485
(Spring 2004)
Lecture 7
24
Major Homework #1
Parameters from Example 5.3
1
2
3
4
5
Depth
Area
Volume
Outflow
Loading
Settling
Reaction rate
One value for all 5 lakes
Timestep, h
CE 498/698 and ERS 485
(Spring 2004)
Lecture 7
25
Major Homework #1
Eigenvalues
CE 498/698 and ERS 485
(Spring 2004)
11
yr-1
22
yr-1
Lecture 7
26
Major Homework #1
Year
Time
ci,1 ci,2 ci,3 ci,4 ci,5 k1,1 k2,1 k3,1 k4,1 ci+1,1 k1,2 k2,2
1963 0
given
=prev+h
CE 498/698 and ERS 485
(Spring 2004)
Lecture 7
27