Sei sulla pagina 1di 6

# CHEG 3253 Assignment 9

Problem Statement:
A process control set point for flow rate into a plug flow reactor is changed from 6.0 to
5.0 gpm. f it ta!es 50 minutes for the new flow rate to sta"ili#e\$ how much of the reactor
effluent should "e discarded% &he file found in this director' has the o"ser(ed flow rates
for the first 60 minutes after the set point change. Assume the residence time of the
reactor is )0 minutes and that it ta!es 3 residence times for the reactions to reach stead'
state after the flow rate has sta"ili#ed. Also assume that the fluid is incompressi"le.
Compare numerical integration of the data with onl' the trape#oidal rule to an integration
scheme that com"ines the trape#oidal and the two *impson+s rules with appropriate
inter(al selection.
&he transfer function for this process control scheme is !nown to 'ield the following flow
rate response,
where - is in gpm. Compare 'our two numerical results with the numerical integration of
the e.uation /using *impson+s 301 rule\$ with an appropriatel' selected step si#e2 gi(en
a"o(e.
Hint, find help on the 3atla" function 4cs(read4
Pseudo-Code:
inside 3atla".
2. *et up a 5while6 loop to chec! the data inter(als\$ and "ased on the inter(al\$
appl' the appropriate integral
a. f two consecuti(e inter(als are not e.ual use &rape#oidal ntegration 8ule
". f three consecuti(e inter(als are not e.ual\$ onl' two are\$ use *impson6s
)03 ntegration 8ule
c. 9hen three consecuti(e inter(als are e.ual\$ use *impson6s 301 ntegration
8ule
3. Calculate a numerical integration of the gi(en e.uation and compare it with
the earlier results.
):.59:55
).5sin ;cos/).5 2
20
5
cosh
)0
t
t
F
t
+

= +

Flow Chart:
Input Function for the Trapezoidal Integration:
%This file uses the Trapezoidal Integration to evaluate the data
5cs(read6 and set up a matri7
in 3atla"
*et the first column e.ual to < of the
matri7\$ and the second column e.ual
to = of the matri7
-ind the delta/i2 "etween
</i>)2 and </i2 from
<?),360
s @elta/i2
A@elta/i>)2Btolerance
=
C
Dse &rape#oidal
ntegrationAA
?//<2A<)2022;/=2A=)2
Dse *impson6s )03E
?//<3A<)2032;/=)>:;=2>=32
s @elta/i>)2
A@elta/i>22Btolerance
=
C
Dse *impson6s 301E
?3;//<:A<)2012;/=)>3;=2>3;=3>=:2
Compare with ntegration of function using
*impson6s 301 8ule and setting own inter(als
times
%and flowrates so that (atlab will read the columns
)!":*+%& %sets column +* time* in the e'cel spreadsheet as the variable )
,!":*-%& %sets column -* flowrate "gpm%* in the e'cel spreadsheet as the variable
,
%Trapezoidal Integration:
i!+&
I!.&
for i!+:/0.&
I!I1"")"+1i%-)"i%%2-%3","i1+%1,"i%%& %The Trapezoidal 4ule of Integration
end
I!I153-. %adds the -. e'tra minutes of residence time needed for the reaction to
stabilize&
%the flow rate is 5gpm2minute
6utput for the Trapezoidal Integration:
I !
/77\$7+89
Input Function for the Trapezoidal* Simpson:s +2/* and Simpson:s /28 Integration:
%This file uses a combination of Trapezoidal* Simpson#s +2/* and Simpson#s
%/28 Integrations to evaluate the data
times
%and flowrates so that (atlab will read the columns
)!":*+%& %sets column +* time* in the e'cel spreadsheet as the variable )
,!":*-%& %sets column -* flowrate "gpm%* in the e'cel spreadsheet as the variable
,
%Trapezoidal Integration and Simpson#s +2/ Integration and Simpson#s /28
Integration:
i!+&
I!.&
for i!+:/0.&
;elta"i%!")"+1i%-)"i%%& %Ta<es the difference between '- and '+
end
i!+&
while i=/58&
if abs";elta"i%-;elta"i1+%%!!.& %chec<s to see if the first interval is e>ual
if abs";elta"i1+%-;elta"i1-%%!!.& %chec<s to see if the second interval is e>ual
I!I1"/3")"i1+%-)"i%%28%3","i%1/3,"i1+%1/3,"i1-%1,"i1/%%& %if two intervals
%are e>ual* the Simpson#s /28 4ule is used\$
i!i1/& %Sets the ne't step
else
I!I1"")"i1+%-)"i%%2/%3","i1-%193,"i1+%1,"i%%& %if onl? one interval
%is e>ual* Simpson#s +2/ 4ule is used\$
i!i1-& %Sets the ne't step
end

else
I!I1"";elta"i%%2-%3","i1+%1,"i%%& %if none of the steps are e>ual* the
%Trapezoid 4ule is used\$
i!i1+& %Sets the ne't step
end
end
%The last three steps must use Trapezoidal because Simpson#s cannot
%evaluate the last steps
i!/58&
for i!/58:/0.&
I!I1"")"+1i%-)"i%%2-%3","i1+%1,"i%%&
end
I!I153-. %adds the -. e'tra minutes of residence time needed for the reaction to
stabilize&
%the flow rate is 5gpm2minute
6utput for the Trapezoidal* Simpson:s +2/* and Simpson:s /28 Integration:
I !
/77\$7-.0
Input Function for the Simpson:s /28 Integration with constant steps:
%This file integrates the following funcntion using constant steps with the
Simpson#s
%/28 Integration 4ule\$
%F!"+\$53sin""t1+9\$57955%2-.%3cos"+\$53t%%2"cosh"t2+.%%15
%I made a spreadsheet that solved the function with time as an input
%"called simpson\$csv%
%and flowrates so that (atlab will read the columns
(!":*+%& %sets column +* time* in the e'cel spreadsheet as the variable (
@!":*-%& %sets column -* flowrate "gpm%* in the e'cel spreadsheet as the variable
@
%Trapezoidal Integration and Simpson#s +2/ Integration and Simpson#s /28
Integration:
i!+&
I!.&
for i!+:5778&
;elta"i%!"("+1i%-("i%%& %Ta<es the difference between '- and '+
end
i!+&
while i=5778&
if abs";elta"i%-;elta"i1+%%!!.& %chec<s to see if the first interval is e>ual
if abs";elta"i1+%-;elta"i1-%%!!.& %chec<s to see if the second interval is e>ual
I!I1"/3"("i1+%-("i%%28%3"@"i%1/3@"i1+%1/3@"i1-%1@"i1/%%& %if two
intervals
%are e>ual* the Simpson#s /28 4ule is used\$
i!i1/& %Sets the ne't step
%Aecause all of the intervals are e>ual* the program will not use Simpson#s +2/
and TrapezoidalBB
else
I!I1""("i1+%-("i%%2/%3"@"i1-%193@"i1+%1@"i%%& %if onl? one interval
%is e>ual* Simpson#s +2/ 4ule is used\$
i!i1-& %Sets the ne't step
end

else
I!I1"";elta"i%%2-%3"@"i1+%1@"i%%& %if none of the steps are e>ual* the
%Trapezoid 4ule is used\$
i!i1+& %Sets the ne't step
end
end
%The last three steps must use Trapezoidal because Simpson#s cannot
%evaluate the last steps
i!5778&
for i!5778:0...&
I!I1""("+1i%-("i%%2-%3"@"i1+%1@"i%%&
end
I!I153-. %adds the -. e'tra minutes of residence time needed for the reaction to
stabilize&
%the flow rate is 5gpm2minute
6utput for the Simpson:s /28 Integration with constant steps:
I !
9..\$.--/
;iscussion:
&he more comple7 the integration routine\$ the more accurate the solutions will "e.
9hen the &rape#oidal 8ule was added to the *impson6s )03 and *impson6s 301 8ules\$ the
solution "ecame more accurate. &he solution for the &rape#oidal rule was 399.9)1:F the
solution for the &rape#oidal\$ *impson6s )03\$ and *impson6s 301 com"ination was
399.9206. &he numerical solution calculated using onl' *impson6s 301 integration was
the most accurate\$ and is the solution that the other answers are compared with. &his
(alue is :00.0223. &he percent errors "etween the different integrals can "e seen "elow
in &a"le ).),
Table +\$+: Integrations and Percent Crrors

-or this particular function\$ the
trape#oidal integration is more than
sufficient. t is not worth the e7tra effort to integrate it more accuratel' with the
*impson6s oneAthird and *impson6s threeAeighths rules.
Problem Solution:
Appro7imatel' :00 gallons of the reactor effluent should "e discarded after the
flow rate is changed from 6 gpm to 5 gpm. &his occurs after 10 minutes\$ which includes
30 minutes of residence time.
Integral %error
Trapazoidal
Integration 399.9184 0.025974
Simpson's 3/8,
Simpson's 1/3,
and
Trapezoidal
Integration 399.9206 0.025424
Numerical
Integration 400.0223 0