Fogler Example COdes
-
Upload
aransari85 -
Category
Documents
-
view
288 -
download
0
Transcript of Fogler Example COdes
-
7/22/2019 Fogler Example COdes
1/105
Scilab Code for
Elements of chemical Reaction Engineering
by H. Scott Fogler1
Created bySantosh Kumar
Dual Degree studentB. tech + M. Tech (Chem. Engg.)
Indian Institute of Technology, Bombay
College Teacher and ReviewerArun Sadashio MoharirProfessor IIT Bombay
IIT Bombay
17 October 2010
1Funded by a grant from the National Mission on Education through ICT,http://spoken-tutorial.org/NMEICT-Intro.This text book companion and Scilabcodes written in it can be downloaded from the Textbook Companion ProjectSection at the website http://scilab.in/
-
7/22/2019 Fogler Example COdes
2/105
Book Details
Author: H. Scott Fogler
Title: Elements of chemical Reaction Engineering
Publisher: Prentice-Hall International, Inc., New Jersey
Edition: Third
Year: 2009
Place: New Jersey
ISBN: 0-13-973785-5
1
-
7/22/2019 Fogler Example COdes
3/105
Contents
List of Scilab Code 4
1 Mole Balances 91.1 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91.2 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2 Conversion and Reactor Sizing 11
2.1 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112.2 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3 Rate Laws and Stoichiometry 17
3.1 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173.2 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4 Isothermal Reactor Design 19
4.1 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194.2 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
5 Collection and Analysis of Rate Data 37
5.1 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375.2 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
6 Multiple Reactions 40
6.1 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
6.2 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
7 Nonelementary Reaction Kinetics 45
7.1 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457.2 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
2
-
7/22/2019 Fogler Example COdes
4/105
8 Steady State Nonisothermal Reactor Design 50
8.1 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508.2 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
9 Unsteady State Nonisothermal Reactor Design 69
9.1 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 699.2 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
10 Catalysis and Catalytic Reactors 86
10.1 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8610.2 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
11 External Diffusion Effects on Hetrogeneous Reactions 94
11.1 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9411.2 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
12 Diffusion and Reaction in Pours Catalysts 97
12.1 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9712.2 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
13 Distributions of Residence Times for Chemical Reactions 98
13.1 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9813.2 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
14 Models for Nonideal Reactors 102
14.1 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10214.2 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
3
-
7/22/2019 Fogler Example COdes
5/105
List of Scilab Code
1.3 1.3data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 91.3 1.3.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.1 2.1data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 112.1 2.1.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112.2 2.2data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.2 2.2.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.3 2.3data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.3 2.3.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132.4 2.4data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 132.4 2.4.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132.5 2.5data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 142.5 2.5.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142.6 2.6data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.6 2.6.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152.7 2.7data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 152.7 2.7.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163.5 3.5data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 173.5 3.5.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174.1 4.1data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 194.1 4.1.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194.2 4.2data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 204.2 4.2.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214.4 4.4data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 214.4 4.4.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.5 4.5data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 224.5 4.5.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234.6 4.6data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 234.6 4.6.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4
-
7/22/2019 Fogler Example COdes
6/105
-
7/22/2019 Fogler Example COdes
7/105
8.11 8.11.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
8.12 8.12data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 678.12 8.12.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 679.1 9.1data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 699.1 9.1.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 699.2 9.2data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 729.2 9.2.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 729.3 9.3data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 749.3 9.3.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 749.4 9.4data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 789.4 9.4.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 789.8 9.8data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
9.8 9.8.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8010.3 10.3data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 8610.3 10.3.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8610.5 10.5data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 8810.5 10.5.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9010.7 10.7data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 9110.7 10.7.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9211.1 11.1data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 9411.1 11.1.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9411.3 11.3data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 95
11.3 11.3.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9511.4 11.4data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 9611.4 11.4.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9611.5 11.5data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 9611.5 11.5.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9613.8 13.8data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 9813.8 13.8.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9813.9 13.9data.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 9913.9 13.9.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10014.3 14.3.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
6
-
7/22/2019 Fogler Example COdes
8/105
List of Figures
4.1 Output graph of S 4.1 . . . . . . . . . . . . . . . . . . . . . 204.2 Output graph of S 4.7 . . . . . . . . . . . . . . . . . . . . . 264.3 Output graph of S 4.7 . . . . . . . . . . . . . . . . . . . . . 274.4 Output graph of S 4.8 . . . . . . . . . . . . . . . . . . . . . 294.5 Output graph of S 4.9 . . . . . . . . . . . . . . . . . . . . . 314.6 Output graph of S 4.10 . . . . . . . . . . . . . . . . . . . . . 334.7 Output graph of S 4.11 . . . . . . . . . . . . . . . . . . . . . 354.8 Output graph of S 4.11 . . . . . . . . . . . . . . . . . . . . . 36
5.1 Output graph of S 5.2 . . . . . . . . . . . . . . . . . . . . . 38
6.1 Output graph of S 6.6 . . . . . . . . . . . . . . . . . . . . . 426.2 Output graph of S 6.8 . . . . . . . . . . . . . . . . . . . . . 44
7.1 Output graph of S 7.7 . . . . . . . . . . . . . . . . . . . . . 467.2 Output graph of S 7.9 . . . . . . . . . . . . . . . . . . . . . 49
8.1 Output graph of S 8.4 . . . . . . . . . . . . . . . . . . . . . 538.2 Output graph of S 8.6 . . . . . . . . . . . . . . . . . . . . . 558.3 Output graph of S 8.6 . . . . . . . . . . . . . . . . . . . . . 568.4 Output graph of S 8.6 . . . . . . . . . . . . . . . . . . . . . 578.5 Output graph of S 8.7 . . . . . . . . . . . . . . . . . . . . . 598.6 Output graph of S 8.7 . . . . . . . . . . . . . . . . . . . . . 608.7 Output graph of S 8.8 . . . . . . . . . . . . . . . . . . . . . 628.8 Output graph of S 8.11 . . . . . . . . . . . . . . . . . . . . . 64
8.9 Output graph of S 8.11 . . . . . . . . . . . . . . . . . . . . . 658.10 Output graph of S 8.12 . . . . . . . . . . . . . . . . . . . . . 68
9.1 Output graph of S 9.1 . . . . . . . . . . . . . . . . . . . . . 709.2 Output graph of S 9.1 . . . . . . . . . . . . . . . . . . . . . 71
7
-
7/22/2019 Fogler Example COdes
9/105
9.3 Output graph of S 9.2 . . . . . . . . . . . . . . . . . . . . . 73
9.4 Output graph of S 9.3 . . . . . . . . . . . . . . . . . . . . . 759.5 Output graph of S 9.3 . . . . . . . . . . . . . . . . . . . . . 769.6 Output graph of S 9.4 . . . . . . . . . . . . . . . . . . . . . 809.7 Output graph of S 9.4 . . . . . . . . . . . . . . . . . . . . . 819.8 Output graph of S 9.4 . . . . . . . . . . . . . . . . . . . . . 829.9 Output graph of S 9.8 . . . . . . . . . . . . . . . . . . . . . 849.10 Output graph of S 9.8 . . . . . . . . . . . . . . . . . . . . . 85
10.1 Output graph of S 10.5 . . . . . . . . . . . . . . . . . . . . . 8810.2 Output graph of S 10.5 . . . . . . . . . . . . . . . . . . . . . 8910.3 Output graph of S 10.5 . . . . . . . . . . . . . . . . . . . . . 91
10.4 Output graph of S 10.7 . . . . . . . . . . . . . . . . . . . . . 93
14.1 Output graph of S 14.3 . . . . . . . . . . . . . . . . . . . . . 104
8
-
7/22/2019 Fogler Example COdes
10/105
-
7/22/2019 Fogler Example COdes
11/105
10
-
7/22/2019 Fogler Example COdes
12/105
Chapter 2
Conversion and Reactor Sizing
2.1 Discussion
When executing the code from the editor, use the Execute File into Scilabtaband not the Load in Scilabtab. The .sci files of the respective problems con-tain the input parameters of the question
2.2 Scilab Code
Example 2.1 2.1data.sci
1 P0 = 10; //atm2 y A0 = 0 .5 ;
3 T 0 = 4 22 .2 ; //K4 R = 0 .0 82 ; // dm3 . atm/mol . K5 v 0 = 6 ; //dm3/ s
Example 2.1 2.1.sce
1 clc
2 c l ea r a ll3 exec ( 2. 1 dat a . s c i ) ;4 C A 0 = ( y A 0 * P 0 ) / ( R * T 0 ) ;
5 F A0 = C A0 * v0 ;
6 disp ( CA0 = )
11
-
7/22/2019 Fogler Example COdes
13/105
7 disp ( C A 0 )
8 disp ( mol/dm3)9 disp ( FA0 = )10 disp ( F A 0 )
11 disp ( m o l / s )
Example 2.2 2.2data.sci
1 P0 = 10; //atm2 y A0 = 0 .5 ;
3 T 0 = 4 22 .2 ; //K4 R = 0 .0 82 ; // dm3 . atm/mol . K5 v 0 = 6 ; //dm3/ s6 X = 0 . 8 ;
7 r A = - 1/ 80 0; //1/rA = 800//dm3 . s /mol
Example 2.2 2.2.sce
1 clc
2 c l ea r a ll
3 exec ( 2. 2 dat a . s c i ) ;4 C A 0 = ( y A 0 * P 0 ) / ( R * T 0 ) ;
5 F A0 = C A0 * v0 ;6 V = F A0 * X * (1 / - r A )
7
8 disp ( FA0 = )9 disp ( F A 0 )
10 disp ( m o l / s )11 disp ( V = )12 disp ( V )
13 disp ( dm3 )
Example 2.3 2.3data.sci
1 P0 = 10; //atm2 y A0 = 0 .5 ;
3 T 0 = 4 22 .2 ; //K
12
-
7/22/2019 Fogler Example COdes
14/105
4 R = 0 .0 82 ; // dm3 . atm/mol . K
5 v 0 = 6 ; //dm3/ s6 X = [0 0.1 0.2 0. 3 0.4 0.5 0.6 0.7 0. 8] ;7 p = [ 18 9 192 2 00 222 250 30 3 400 556 8 00 ]; //1/rA =
800//dm3 . s / mol s
Example 2.3 2.3.sce
1 clc
2 c l ea r a ll
3 exec ( 2. 3 dat a . s c i ) ;4 C A 0 = ( y A 0 * P 0 ) / ( R * T 0 ) ;
5 F A0 = C A0 * v0 ;6 //V = FA0X(1 /rA )7
8 V = F A 0 * inttrap ( X , p )
9 disp ( FA0 = )10 disp ( F A 0 )
11 disp ( m o l / s )12 disp ( V = )13 disp ( V )
14 disp ( dm3 )
15 disp ( Answer i s s l i g h t l y d i f f e r e n n t from t h e b ookb e c a u s e i n t t r a p command o f SCILAB u s e st r a p e z o i d a l i n t e g r a t i o n , w hi l e i n book i t ha sbe en c a l c u l a t e d u s in g f i v e p o in t f or mu l a e . )
Example 2.4 2.4data.sci
1 FA0 = 5; / / mol / s2 r A a t = - ( 1 / 4 0 0 ) ;
3
4 X = [0 0.1 0.2 0.3 0.4 0.5 0.6] ;
5 p = [ 18 9 192 2 00 222 250 30 3 4 00 ]; //1/r A = 800//dm 3 . s / m o ls
Example 2.4 2.4.sce
13
-
7/22/2019 Fogler Example COdes
15/105
1 clc
2 c l ea r a ll3 exec ( 2. 4 dat a . s c i ) ;4
5
6 V C ST R = F A 0 * X ( 7) * ( 1/ - r A at ) ;
7 V PF R = F A0 * inttrap ( X , p )
8 disp ( VCSTR = )9 disp ( V C S T R )
10 disp ( dm3)11 disp ( VPFR = )12 disp ( V P F R )
13 disp ( dm3 )
Example 2.5 2.5data.sci
1 F A0 = 0 .8 67 ; / / mol / s2 r A = - (1 /2 50 ) ;
3 r A2 = - (1 /8 00 ) ;
4 X = 0 . 8 ;
5 X1 = 0. 4;
6 X2 = 0.8
Example 2.5 2.5.sce
1 clc
2 c l ea r a ll
3 exec ( 2. 5 dat a . s c i ) ;4
5
6 V 1 = F A0 * X 1 *( 1/ - r A ) ;
7 V 2 = F A0 * ( X2 - X 1 ) *( 1/ - r A 2 ) ;
8 V = F A0 * X * (1 / - r A2 ) ;
9 disp ( V1 = )10 disp ( V 1 )
11 disp ( dm3)12 disp ( V2 = )13 disp ( V 2 )
14
-
7/22/2019 Fogler Example COdes
16/105
14 disp ( dm3 )
15 disp ( V = )16 disp ( V )17 disp ( dm3 )
Example 2.6 2.6data.sci
1 F A0 = 0 .8 67 ; / / mol / s2 X = [0 0.1 0.2 0. 3 0.4 0.5 0.6 0.7 0. 8] ;
3 p = [ 18 9 192 2 00 222 250 30 3 400 556 8 00 ]; //1/rA =800//dm3 . s / mol s
Example 2.6 2.6.sce
1 clc
2 c l ea r a ll
3 exec ( 2. 6 dat a . s c i ) ;4
5
6 X 1 = X ( 1: 5) ;
7 p 1 = p ( 1: 5) ;
8 V1 = FA0 * inttrap ( X 1 , p 1 )
9 X 2 = X ( 5: 9) ;10 p 2 = p ( 5: 9) ;
11 V2 = FA0 * inttrap ( X 2 , p 2 )
12 V = V 1 + V 2 ;
13 disp ( V1 = )14 disp ( V 1 )
15 disp ( dm3)16 disp ( V2 = )17 disp ( V 2 )
18 disp ( dm3 )19 disp ( V = )
20 disp ( V )21 disp ( dm3 )
Example 2.7 2.7data.sci
15
-
7/22/2019 Fogler Example COdes
17/105
1 F A0 = 0 .8 67 ; / / mol / s
2 X1 = 0. 5;3 X2 = 0. 8;
4 r A2 = - (1 /8 00 ) ;
5 X = [0 0.1 0.2 0. 3 0.4 0.5 0.6 0.7 0. 8] ;
6 p = [ 18 9 192 2 00 222 250 30 3 400 556 8 00 ]; //1/rA =800//dm3 . s / mol s
Example 2.7 2.7.sce
1 clc
2 c l ea r a ll
3 exec ( 2. 7 dat a . s c i ) ;4
5
6 X = X (1 :6 );
7 p = p (1 :6 );
8 V1 = FA0 * inttrap ( X , p ) ;
9 V 2 = F A0 * ( X2 - X 1 ) *( 1/ - r A 2 ) ;
10 V = V 1 + V 2 ;
11 disp ( V1 = )12 disp ( V 1 )
13 disp ( dm3)14 disp ( V2 = )15 disp ( V 2 )
16 disp ( dm3 )17 disp ( V = )18 disp ( V )
19 disp ( dm3 )
16
-
7/22/2019 Fogler Example COdes
18/105
Chapter 3
Rate Laws and Stoichiometry
3.1 Discussion
When executing the code from the editor, use the Execute File into Scilabtaband not the Load in Scilabtab. The .sci files of the respective problems con-tain the input parameters of the question
3.2 Scilab Code
Example 3.5 3.5data.sci
1 CA0 = 10;
2 CB0 = 2;
3 X = 0 . 2 ;
4 X 1 = 0 . 9
Example 3.5 3.5.sce
1 clc
2 c l ea r a ll
3 exec ( 3. 5 dat a . s c i ) ;4 C D = C A 0 * ( X / 3 ) ;
5 C B = C A 0 * ( ( C B 0 / C A 0 ) - ( X / 3 ) ) ;
6 C D 1 = C A 0 * ( X 1 / 3 ) ;
7 C B 1 = C A 0 * ( ( C B 0 / C A 0 ) - ( X 1 / 3 ) ) ;
17
-
7/22/2019 Fogler Example COdes
19/105
8 disp ( F or 2 0% c o n v e r s i o n )
9 disp ( CD = )10 disp ( C D )11 disp ( mol/dm3)12 disp ( CB = )13 disp ( C B )
14 disp ( mol/dm3)15 disp ( F or 9 0% c o n v e r s i o n )16 disp ( CD = )17 disp ( C D 1 )
18 disp ( mol/dm3)19 disp ( CB = )
20 disp ( C B 1 )21 disp ( mol/dm3)
18
-
7/22/2019 Fogler Example COdes
20/105
Chapter 4
Isothermal Reactor Design
4.1 Discussion
When executing the code from the editor, use the Execute File into Scilabtaband not the Load in Scilabtab. The .sci files of the respective problems con-tain the input parameters of the question
4.2 Scilab Code
Example 4.1 4.1data.sci
1 t = [ 0 0.5 1 1.5 2 3 4 6 1 0];
2 CC = [0 0 .1 45 .27 .3 76 .4 67 . 61 .7 15 .8 48 . 95 7] ;
3 CA0 = 1;
Example 4.1 4.1.sce
1 clc
2 c l ea r a ll
3 exec ( 4. 1 dat a . s c i ) ;
45 x = t ;
6 y = (( C A0 - C C ) / C A0 ) ;
7
8 yi = interpln ( [ x ; y ] , x ) ;
19
-
7/22/2019 Fogler Example COdes
21/105
Figure 4.1: Output graph of S 4.1
9 plot2d ( x , y , l o g f l a g = nl ) ;10
11 k = log ( y ( 9 ) / y ( 2 ) ) / ( t ( 9 ) - t ( 2 ) ) ;
12
13
14 disp ( k = )15 disp ( k )
16 disp ( min
1 )
Example 4.2 4.2data.sci
20
-
7/22/2019 Fogler Example COdes
22/105
1 k = 0 .3 11 ; / / min 1;
2 F C = 6 . 13 7 ; // l b . mol /min3 X = 0 . 8 ;4 C A0 1 = 1 ; //mol/dm3
Example 4.2 4.2.sce
1 clc
2 c l ea r a ll
3 exec ( 4. 2 dat a . s c i ) ;4
5 FA0 = FC /X ;
6 v A0 = F A0 / C A 01 ;7 vB0 = vA0 ;
8 v0 = v A0 + vB 0 ;
9 V = v 0 *X / ( k *( 1 - X )) ;
10
11 // CSTR i n p a r a l l e l12 V 1 = 8 0 0/ 7. 4 8;
13
14 T au = V 1 / ( v 0 / 2) ;
15 D a = T au * k ;
16 X p ar a ll e l = D a /( 1+ D a )
17
18 / / CSTR i n s e r i e s19 T au = V 1 / v0 ;
20 n = 2 ;
21 X se r ie s = 1 - ( 1/ (1 + T au * k ) ^n ) ;
22
23 disp ( R e a c t o r v ol um e )24 disp ( V )
25 disp ( f t 3 )26 disp ( CSTR i n p a r a l l e l X = )
27 disp ( X p a r a l l e l )28 disp ( CSTR i n s e r i e s X = )29 disp ( X s e r i e s )
Example 4.4 4.4data.sci
21
-
7/22/2019 Fogler Example COdes
23/105
1 k 1 = 0 .0 72 ; / / s 1;
2 yA0 = 1;3 P 0= 6; //atm4 R = 0. 73 ; // atm/ lb . mol . oR5 T0 = 1 98 0; //oR6 T1 = 1 00 0; //K7 T2 = 1 10 0; // K8 e = 1 ;
9 E = 8 20 00 ; // c a l /g . mol10 F B = 0 .3 4; // lb . mol/ s11 X = 0 . 8 ;
Example 4.4 4.4.sce
1 clc
2 c l ea r a ll
3 exec ( 4. 4 dat a . s c i ) ;4
5 FA0 = FB /X ;
6 C A0 = y A0 * P 0 /( R * T0 ) ;
7 R = 1 .9 87 ;
8 k 2 = k 1 * exp ( ( E / R ) * ( ( 1 / T 1 ) - ( 1 / T 2 ) ) ) ;
9 V = ( F A0 / ( k2 * C A0 ) ) * (( 1+ e ) * log ( 1 / ( 1 - X ) ) - e * X ) ;
10
11 disp ( R e a c t o r v ol um e )12 disp ( V )
13 disp ( f t 3 )
Example 4.5 4.5data.sci
1 A c = 0 .0 14 14 ; // f t 22 m = 1 04 .4 ; / / l bm / h3 m u = 0 .0 67 3; // l bm/ f t . h
4 D p = 0 .0 20 8; // f t5 g c = 4 .1 7 e8 ; // lbm . f t / l b f . h26 p hi = 0 .4 5;
7 r ho = 0 .4 13 ; // l bm/ f t 38 P0 = 10; / / atm
22
-
7/22/2019 Fogler Example COdes
24/105
-
7/22/2019 Fogler Example COdes
25/105
4
5 F T0 = F A0 + F B0 + F I ;6 y A0 = F A0 / FT 0 ;
7 e = y A0 * ( 1 -. 5 - 1) ;
8 P A0 = y A0 * P0 ;
9 k de s = k * P A0 * ( 1 /2 ) ^ ( 2/ 3) ;
10 a l ph a = 2 * b i ta 0 / ( A c * (1 - p h i ) * r h o c * P 0 ) ;
11 W = ( 1 - ( 1 - (3 * a lp ha * F A0 / ( 2* k d es ) ) * (( 1+ e ) * log ( 1 / ( 1 - X
) ) - e * X ) ) ^ ( 2 / 3 ) ) / a l p h a ;
12
13
14 disp ( W )
15 disp ( W )16 disp ( l b o f c a t a l y s t p e r t u b e )
Example 4.7 4.7data.sci
1 k pr i me = 0 .0 2 66 ; // lb . mol/atm . lb ca t . h2 a lp ha = 0 .0 1 66 ;
3 e = - 0. 15 ;
4 W 0 = 0 ;
5 F A 0 = 1 ;
Example 4.7 4.7.sce
1 clc
2 c l ea r a ll
3 exec ( 4. 7 dat a . s c i ) ;4 W = 0 :1 :6 0;
5 function w = f ( W , Y )
6
7 w = zeros ( 2 , 1 ) ;
8 w ( 1 ) = ( k p r i me / F A 0 ) * ( (1 - Y ( 1) ) / ( 1 + e * Y ( 1) ) ) * Y ( 2 ) ;
9 w ( 2 ) = - a l p ha * ( 1 + e * Y ( 1 ) ) / (2 * Y ( 2 ) ) ;10 e n d f u n c t i o n
11
12
13 x = ode ( [ 0 ; 1 ] , W 0 , W , f ) ;
24
-
7/22/2019 Fogler Example COdes
26/105
14 for i = 1 :6 1
15 F ( i ) = ( 1+ e * x (1 , i ) )/ x (2 , i ) ;16 end
17 F = F ;
18 for i = 1 :6 1
19 r a te ( i ) = ( k p r i me ) * ( (1 - x ( 1 , i ) ) / ( 1 + e * x (1 , i ) ) ) * x ( 2 , i
) ;
20 end
21 r a t e = r a te ;
22
23 s c f ( 1 )
24 plot2d ( W , r a t e ) ;
25 xtitle ( F i g u r e E47.1 R ea ct io n r a t e p o r f i l e downthe PBR , w , r a t e ) ;
26 s c f ( 2 )
27
28 l 1 =x ( 1 ,: )
29 l 2 =x ( 2 ,: )
30 l 3 = F
31 plot2d ( W ,[ l 1 l 2 l 3 ]) ;
32
33 xtitle ( F i g u r e E47.2 , w , x , y , z ) ;34 l e g e n d ( [
x ;
y ;
f ]) ;
Example 4.8 4.8data.sci
1 F A0 = 4 40 ;
2 P0 = 2 00 0;
3 C a0 = . 32 ;
4 R = 30;
5 phi = .4;
6 k pr i me = 0 .0 2; // lb . mol/atm . lb ca t . h
7 L = 27;8 r ho c at = 2 .6 ;
9 m = 4 4 ;
10
11 a lp ha = 0 .0 1 66 ;
25
-
7/22/2019 Fogler Example COdes
27/105
Figure 4.2: Output graph of S 4.7
26
-
7/22/2019 Fogler Example COdes
28/105
Figure 4.3: Output graph of S 4.7
27
-
7/22/2019 Fogler Example COdes
29/105
12 e = - 0. 15 ;
13 Z 0 = 0 ;
Example 4.8 4.8.sce
1 clc
2 c l ea r a ll
3 exec ( 4. 8 dat a . s c i ) ;4 Z = 0 :1 :1 2;
5 function w = f ( Z , Y )
6
7 w = zeros ( 2 , 1 ) ;
8 A c = 3 . 1 4* ( ( R ^ 2 ) - ( Z - L) ^ 2 ) ;9 C a = C a0 * ( 1 - Y ( 1 ) ) * Y (2 ) / ( 1 + Y ( 1) ) ;
10 r a = k p r i me * C a * r h o c at * ( 1 - p h i ) ;
11 G = m / Ac ;
12 V = 3 . 1 4 * ( Z * ( R ^ 2 ) - ( 1 .3 * ( Z - L ) ^ 3 ) - ( 1/ 3 ) * L ^ 3 )
13 b i ta = ( 9 8. 8 7 * G + 2 5 63 0 * G ^ 2 ) * 0 .0 1 ;
14 W = r h o c a t * ( 1 - p h i ) * V
15 w ( 1 ) = - r a * Ac / F A 0
16 w ( 2 ) = - b i ta / P 0 / ( Y ( 2 ) * (1 + Y ( 1 ) ) ) ;
17 e n d f u n c t i o n
1819
20 x = ode ( [ 0 ; 1 ] , Z 0 , Z , f ) ;
21 for i = 1: length ( Z )
22 V ( 1 , i ) = 3 .1 4 * Z ( 1 , i ) * (( R ^ 2 ) - ( Z (1 , i ) - L ) ^ 2 )
23 W 1 ( 1 , i ) = r h o c a t * ( 1 - p h i ) * V ( 1 , i )
24 end
25
26 l 1 =x ( 1 ,: )
27 l 2 =x ( 2 ,: )
28
29 plot2d ( W1 , [ l 1 l 2 ]) ;30
31 xtitle ( F i g u r e E48.2 , w , x , y ) ;32 l e g e n d ( [ x ; y ]) ;
28
-
7/22/2019 Fogler Example COdes
30/105
Figure 4.4: Output graph of S 4.8
29
-
7/22/2019 Fogler Example COdes
31/105
Example 4.9 4.9data.sci
1 ka = 2. 7;
2 kc = 1. 2;
3 Ct0 = .1;
4 f a0 = 10 ;
5 V 0 = 0 ;
Example 4.9 4.9.sce
1 clc
2 c l ea r a ll
3 exec ( 4. 9 dat a . s c i ) ;4 V = 0 :1 :1 00 ;
5 function w = f ( V , f a )
6
7 w = zeros ( 1 , 1 ) ;
8 f t = 2 *( f a 0 - f a ( 1 ) )
9 C a = C t0 * f a (1 ) / ft ;
10 f b = 2 *( f a0 - f a ( 1 ) );
11 Cb = C t0 * fb / ft ;
12 w ( 1 ) = - k a * ( Ca - ( C b ^ 2) / k c )
13
14 e n d f u n c t i o n
15
16
17 x = ode ( [ 9 . 9 9 ] , V 0 , V , f ) ;
18
19 for i = 1 :1 01
20 f b (1 , i ) = 2 *( f a0 - x ( 1 , i )) ;
21 end
22 l 1 = x ;
23 l 2 = f b ;
2425 plot2d ( V ,[ l 1 l 2 ]) ;
26
27 xtitle ( F i g u r e E49 .1 M ol a r f l o w r a t e p r o f i l e s , V , fa , fb ) ;
30
-
7/22/2019 Fogler Example COdes
32/105
Figure 4.5: Output graph of S 4.9
28 l e g e n d ( [ fa ; fb ]) ;
Example 4.10 4.10data.sci
1 kc = 0. 2;
2 Ct0 = .2;
3 k = .7;
4 V 0= 0;
Example 4.10 4.10.sce
31
-
7/22/2019 Fogler Example COdes
33/105
1 clc
2 c l ea r a ll3 exec ( 4. 10 dat a . sc i ) ;4 V = 0 :1 :5 00 ;
5 function w = f ( V , F )
6
7 w = zeros ( 3 , 1 ) ;
8
9 F t = F ( 1 ) + F ( 2 ) + F ( 3 ) ;
10 r a = - k * C t0 * ( ( F ( 1 ) / F t ) - ( Ct 0 / k c ) * ( F (2 ) / F t ) * ( F ( 3) / F t )
) ;
11 w ( 1) = r a;
12 w ( 2) = - ra - k c * C t0 * ( F (2 ) / Ft )13 w (3) = - ra ;
14
15 e n d f u n c t i o n
16
17
18 x = ode ( [ 1 0 ; 0 ; 0 ] , V 0 , V , f ) ;
19
20 l 1 =x ( 1 ,: )
21 l 2 =x ( 2 ,: )
22 l 3 =x ( 3 ,: )
23 plot2d ( V ,[ l 1 l 2 l 3 ]) ;
24
25 xtitle ( F i g u r e E410.2 , V , Fa , Fb , Fc ) ;26 l e g e n d ( [ Fa ; Fb ; Fc ]) ;
Example 4.11 4.11data.sci
1 k = 2 .2 ;
2 v 00 = . 05 ;
3 C b0 = . 02 5;4 v 0 = 5 ;
5 C a0 = . 05 ;
6 t 0 = 0 ;
32
-
7/22/2019 Fogler Example COdes
34/105
Figure 4.6: Output graph of S 4.10
33
-
7/22/2019 Fogler Example COdes
35/105
Example 4.11 4.11.sce
1 clc
2 c l ea r a ll
3 exec ( 4. 11 dat a . sc i ) ;4 t = 0 :1 :5 00 ;
5 function w = f ( t , C )
6
7 w = zeros ( 4 , 1 ) ;
8
9 v = v 0+ v 00 * t;
10 w ( 1 ) = - k * C ( 1) * C ( 2 ) - v 0 0 * C (1 ) / v ;
11 w ( 2 ) = - k * C ( 1) * C ( 2 ) + v 0 0 * ( Cb 0 - C ( 2 ) ) / v ;12 w ( 3 ) = k * C ( 1 ) * C ( 2) - v 0 0 * C ( 3 ) / v ;
13 w ( 4 ) = k * C ( 1 ) * C ( 2) - v 0 0 * C ( 4 ) / v ;
14
15 e n d f u n c t i o n
16
17
18 x = ode ( [ . 0 4 9 ; 0 ; 0 ; 0 ] , t 0 , t , f ) ;
19 l 1 =x ( 1 ,: )
20 l 2 =x ( 2 ,: )
21 l 3 =x ( 3 ,: )
22 for i = 1: length ( t )
23 r a te ( 1 , i ) = k * x (1 , i ) * x ( 2 , i )
24 end
25 s c f ( 1 )
26 plot2d ( t ,[ l 1 l 2 l 3 ]) ;
27
28 xtitle ( F i g u r e E41 1. 1 C o n c e n tr a t i o nt i m et r a j e c t o r i e s , t , Ca , Cb, Cc ) ;
29 l e g e n d ( [ Ca ; Cb ; Cc ]) ;30 s c f ( 2 )
31 plot2d ( t , r a t e )32 xtitle ( F i g u r e E41 1. 2 R e ac t io n r a t et i m e
t r a j e c t o r i e s , t , R e a c t i on R at e ( mol s dm3) );
33
34
-
7/22/2019 Fogler Example COdes
36/105
Figure 4.7: Output graph of S 4.11
34
35
36
37 V
35
-
7/22/2019 Fogler Example COdes
37/105
Figure 4.8: Output graph of S 4.11
36
-
7/22/2019 Fogler Example COdes
38/105
Chapter 5
Collection and Analysis of Rate
Data
5.1 Discussion
When executing the code from the editor, use the Execute File into Scilabtaband not the Load in Scilabtab. The .sci files of the respective problems con-tain the input parameters of the question
5.2 Scilab Code
Example 5.2 5.2data.sci
1 t = [0 2.5 5 10 15 20] ;
2 P = [ 7. 5 1 0. 5 1 2.5 1 5.8 1 7.9 1 9.4 ] ;
3 P0 = 7. 5;
Example 5.2 5.2.sce
1 clc
2 c l ea r a ll3 exec ( 5. 2 dat a . s c i ) ;4 for i =1: length ( t )
5 g (i ) = log ( 2 * P 0 / ( 3 * P 0 - P ( i ) ) ) ;
6 end
37
-
7/22/2019 Fogler Example COdes
39/105
Figure 5.1: Output graph of S 5.2
7 plot2d ( t , g ) ;
8
9 xtitle ( F i g u r e E411.2 P lo t o f p r o ce s s ed d at a , t( mi n) , 2PTo/3PToPT ) ;
Example 5.3 5.3data.sci
1 CHCl = [1 4 2 .1 .5];
2 r HC l = [ 1. 2 2 1 .3 6 . 36 . 74 ]* 1 e7 ;
Example 5.3 5.3.sce
38
-
7/22/2019 Fogler Example COdes
40/105
1 clc
2 c l ea r a ll3 exec ( 5. 3 dat a . s c i ) ;4
5 x = log ( C H C l ) ;
6 y = log ( - r H C l ) ;
7 plot2d ( x , y ) ;
8
9 xtitle ( F i g u r e E53.2 , CHCl ( g mol / l i t e r ) , r HC l0 ( g m ol / cm 2 . s ) ) ;
Example 5.4 5.4data.sci
1 C CH 4 = [ 2. 44 4 .4 4 10 1 .6 5 2 .4 7 1 .7 5] *1 e -4 ;
2 PCO = [1 1.8 4.08 1 1 1] ;
3 v 0 = 30 0;
4 W = 1 0;
Example 5.4 5.4.sce
1 clc
2 c l ea r a ll
3 exec ( 5. 4 dat a . s c i ) ;4
5 r CH 4 = ( v 0 /W ) * C CH 4 ; x
6 x = log ( P C O ) ;
7 y = log ( r C H 4 )
8 a l ph a = ( y ( 3 ) - y ( 2) ) / ( x ( 3 ) - x ( 2) ) ;
9 // pl ot 2d ( x , y )10 disp ( a l p h a )11 disp ( a l p h a )
39
-
7/22/2019 Fogler Example COdes
41/105
Chapter 6
Multiple Reactions
6.1 Discussion
When executing the code from the editor, use the Execute File into Scilabtaband not the Load in Scilabtab. The .sci files of the respective problems con-tain the input parameters of the question
6.2 Scilab Code
Example 6.6 6.6data.sci
1 k 1 = 5 5. 2;
2 k 2 = 3 0 . 2 ;
3 t 0 = 0 ;
Example 6.6 6.6.sce
1 clc
2 c l ea r a ll
3 exec ( 6. 6 dat a . s c i ) ;
4 t = 0 :. 01 :. 5;5 function w = f ( t , c )
6
7 w = zeros ( 3 , 1 ) ;
8
40
-
7/22/2019 Fogler Example COdes
42/105
9 r 1 = - k1 * c ( 2) * c ( 1) ^ . 5;
10 r 2 = - k2 * c ( 3) * c ( 1) ^ . 5;11 w ( 1) = r 1 + r2 ;
12 w (2) = r1 ;
13 w ( 3) = - r1 + r2 ;
14
15 e n d f u n c t i o n
16
17 x = ode ( [ . 0 2 1 ; . 0 1 0 5 ; 0 ] , t 0 , t , f ) ;
18
19 l 1 =x ( 1 ,: )
20 l 2 =x ( 2 ,: )
21 l 3 =x ( 3 ,: ) 22
23 plot2d ( t ,[ l 1 l 2 l 3 ]) ;
24
25 xtitle ( F i g u r e E66.1 , Tau ( hr ) , C o n c e n t r a t i o n( l b mol / f t 3 ) ;
26 l e g e n d ( [ CH ; CM ; CX ]) ;
Example 6.8 6.8data.sci
1 v 0 = 0;
Example 6.8 6.8.sce
1 clc
2 c l ea r a ll
3 exec ( 6. 8 dat a . s c i ) ;4 v = 0 :. 1: 10 ;
5 function w = F F (v , f )
6
7 w = zeros ( 6 , 1 ) ;8 f t = f ( 1 ) + f ( 2) + f ( 2 ) + f ( 4) + f ( 5 ) + f ( 6) ;
9 r 1a = - 5* 8* ( f ( 1 ) / ft ) * ( f ( 2 ) / ft ) ^ 2 ;
10 r 2a = - 2* 4* ( f ( 1 ) / ft ) * ( f ( 2 ) / ft ) ;
11 r 4c = - 5 *3 . 17 5 *( f ( 3 ) / f t ) * ( f ( 1) / f t ) ^ ( 2 / 3) ;
41
-
7/22/2019 Fogler Example COdes
43/105
Figure 6.1: Output graph of S 6.6
42
-
7/22/2019 Fogler Example COdes
44/105
12 r 3b = - 1 0* 8 *( ( f ( 3 ) / f t ) ^ 2) * ( f ( 2 ) / f t ) ;
13 C a = 2* f ( 1 ) / f t ;14 C b = 2* f ( 2 ) / f t ;
15 C c = 2* f ( 3 ) / f t ;
16 C d = 2* f ( 4 ) / f t ;
17 C e = 2* f ( 5 ) / f t ;
18 C f = 2* f ( 6 ) / f t ;
19 w ( 1 ) = 1 . 25 * r 1 a + . 7 5* r 2 a + r 3 b ;
20 w ( 2) = r 1a + r 2a + 2 * r 4c / 3 ;
21 w ( 3) = - r 1a + 2 * r3 b + r4 c ;
22 w ( 4 ) = - 1 . 5 * r 1a - 1 . 5 * r 2a - r 4 c ;
23 w ( 5 ) = . 5* r 2a - 5 * r 4c / 6 ;
24 w ( 6) = -2* r 3b ;25
26 e n d f u n c t i o n
27
28 x = ode ( [ 9 ; 9 ; 0 ; 0 ; 0 ; 0 ] , v 0 , v , F F ) ;
29
30 plot2d ( v , x ( 1 , : ) / 1 0 , r e c t = [ 1 , 0 , 1 0 , 1 . 5 ] ) ; //B31 plot2d ( v , x ( 2 , : ) / 1 0 , r e c t = [ 1 , 0 , 1 0 , 1 . 5 ] ) ; //A32 plot2d ( v , x ( 3 , : ) / 1 0 , r e c t = [ 1 , 0 , 1 0 , 1 . 5 ] ) ; //C33 plot2d ( v , x ( 4 , : ) / 1 0 , r e c t = [ 1 , 0 , 1 0 , 1 . 5 ] ) ;
34 plot2d ( v , x ( 5 , : ) / 1 0 , r e c t = [ 1 , 0 , 1 0 , 1 . 5 ] ) ;
35 plot2d ( v , x ( 6 , : ) / 1 0 , r e c t = [ 1 , 0 , 1 0 , 1 . 5 ] ) ;
36 xtitle ( Figu reE ) ;37 l eg e nd ( [ B ; A ; C ; D ; E ; F ]) ;
43
-
7/22/2019 Fogler Example COdes
45/105
Figure 6.2: Output graph of S 6.8
44
-
7/22/2019 Fogler Example COdes
46/105
Chapter 7
Nonelementary Reaction
Kinetics
7.1 Discussion
When executing the code from the editor, use the Execute File into Scilabtaband not the Load in Scilabtab. The .sci files of the respective problems con-tain the input parameters of the question
7.2 Scilab Code
Example 7.7 7.7data.sci
1 C ur ea = [ .2 . 02 . 01 . 00 5 . 00 2] ;
2 r ur ea = - [1 .0 8 . 55 . 38 .2 . 09 ] ;
Example 7.7 7.7.sce
1 clc
2 c l ea r a ll
3 exec ( 7. 7 dat a . s c i ) ;4 for i=1: length ( C u r e a )
5 x ( i ) = 1 / C u re a ( i ) ;
6 y ( i ) = 1 /( - r u r ea ( i ) ) ;
7 end
45
-
7/22/2019 Fogler Example COdes
47/105
Figure 7.1: Output graph of S 7.7
8 s l op e = ( y ( 5 ) - y ( 1) ) / ( x ( 5 ) - x ( 1) ) ;
9 plot2d ( x , y )
10
11 xtitle ( F i g u r e E77.1 , 1/C ur e a , 1/ r u r e a ) ;12
13 disp ( (Km/Vma = s l o p e )14 disp ( s l o p e )
Example 7.8 7.8data.sci
1 K m = 0 .0 26 6;
46
-
7/22/2019 Fogler Example COdes
48/105
2 V ma x1 = 1 .3 3;
3 E t2 = 0 .0 01 ;4 Et1 = 5;
5 X = .8;
6 C ur ea 0 = . 1;
Example 7.8 7.8.sce
1 clc
2 c l ea r a ll
3 exec ( 7. 8 dat a . s c i ) ;4 V ma x = ( E t2 / E t1 ) * V m ax 1
5 t = ( Km / V ma x )* log ( 1 / ( 1 - X ) ) + C u r e a 0 * X / V m a x ;6 disp ( t )7 disp ( t )
8 disp ( s )
Example 7.9 7.9data.sci
1 y s c = 1 / . 0 8 ;
2 y pc = 5 .6 ;
3 ks = 1. 7;
4 m = 0. 03 ;5 u ma x = . 33 ;
6 t 0 = 0 ;
Example 7.9 7.9.sce
1 clc
2 c l ea r a ll
3 exec ( 7. 9 dat a . s c i ) ;4 t = 0 :. 1: 12 ;
5 function w = f ( t , c )
6
7 w = zeros ( 3 , 1 ) ;
8
9 r d = c ( 1) * .0 1;
47
-
7/22/2019 Fogler Example COdes
49/105
10 r sm = m / c (1 ) ;
11 k o bs = ( u m a x * (1 - c ( 3 ) / 9 3 ) ^ . 5 2) ;12 r g = k o bs * c ( 1 ) * c ( 2 ) /( k s + c ( 2 ) ) ;
13 / / r 2 = k2 c ( 3 ) c ( 1 ) . 5 ;14 w ( 1) = rg - r d ;
15 w ( 2) = y sc * ( - rg ) - r sm ;
16 w ( 3) = rg * yp c ;
17
18 e n d f u n c t i o n
19
20 x = ode ( [ 1 ; 2 5 0 ; 0 ] , t 0 , t , f ) ;
21
22 l 1 =x ( 1 ,: ) 23 l 2 =x ( 2 ,: )
24 l 3 =x ( 3 ,: )
25
26 plot2d ( t ,[ l 1 l 2 l 3 ]) ;
27
28 xtitle ( F i g u r e E79.1 c o n c e n t r a t i o ns a s a f u nc t i o no f t im e , t ( hr ) , C ( g/dm3) ) ;
29 l e g e n d ( [ Cc ; Cs ; Cp ]) ;
48
-
7/22/2019 Fogler Example COdes
50/105
Figure 7.2: Output graph of S 7.9
49
-
7/22/2019 Fogler Example COdes
51/105
Chapter 8
Steady State Nonisothermal
Reactor Design
8.1 Discussion
When executing the code from the editor, use the Execute File into Scilabtaband not the Load in Scilabtab. The .sci files of the respective problems con-tain the input parameters of the question
8.2 Scilab Code
Example 8.3 8.3data.sci
1 H 0N H3 = - 11 02 0; / / c a l / m ol eN 22 H0 H2 = 0;
3 HN2 = 0;
4 C pN H3 = 8 .9 2; // c a l /mole H2 . K5 C pH 2 = 6 .9 92 ; // c a l /mole N2 . K6 C p N2 = 6 . 98 4 ; // c a l /moleNH3 .K7 T = 4 2 3 ; //K
8 TR = 29 8; //K
Example 8.3 8.3.sce
1 clc
50
-
7/22/2019 Fogler Example COdes
52/105
2 c l ea r a ll
3 exec ( 8. 3 dat a . s c i ) ;4 d e l ta H R x0 = 2 * H 0N H3 - 3* H 0 H2 - H N 2 ;5 d e l ta C p = 2 * C pN H3 - 3* C p H2 - C p N 2 ;
6 d e l ta H R x = d e l ta H R x0 + d e l ta C p * ( T - T R ) ;
7 disp ( The h e at o f r e a c t i o n on t he b a s i s on t he m ol eso f H2 r e ac t e d i s = )
8 disp ( ( 1 / 3 ) * d e l t a H R x * 4 . 1 8 4 )
9 disp ( J a t 4 23 K )
Example 8.4 8.4data.sci
1 T = [53 5 5 50 565 575 58 5 595 6 05 615 625] ;2 H 0C = - 2 26 0 00 ;
3 H 0B = - 12 30 00 ;
4 H 0A = - 66 60 0;
5 CpC = 46;
6 CpB = 18;
7 CpA = 35;
8 C pM = 1 9. 5;
9 TR = 52 8;
10 T i0 = 5 35 ;
11 v A0 = 4 6. 62 ;
12 v B0 = 4 6. 62 ;
13 V M0 = 2 33 .1 ;
14 V = 40 .1 ;
15 F A0 = 4 3 .0 4 ;
16 F M0 = 7 1. 8 7; ;
17 F B0 = 8 02 .8 ;
18 A = 1 6. 96 e 12 ;
19 E = 3 24 00 ;
20 R = 1 .9 87 ;
Example 8.4 8.4.sce
1 clc
2 c l ea r a ll
3 exec ( 8. 4 dat a . s c i ) ;
51
-
7/22/2019 Fogler Example COdes
53/105
4 H Rx 0 = H0 C - H0 B - H 0A ;
5 d e lt a Cp = C pC - C pB - C pA ;6 d e l ta H R x0 = H R x0 + d e l t a C p * ( TR - T R ) ;
7 v 0 = v A0 + v B0 + V M0 ;
8 tau = V / v0 ;
9 C A0 = F A0 / v0 ;
10 p hi M0 = F M0 / F A0 ;
11 p hi B0 = F B0 / F A0 ;
12 C pi = C pA + p h i B 0 * C pB + p h i M 0 * C pM ;
13
14 for i =1: length ( T )
15 X EB ( i ) = - C p i *( T ( i ) - T i 0 ) /( d e l t a H Rx 0 + d e l t a Cp * ( T ( i ) - T R
) ) ;16 X MB ( i ) = t au * A *exp ( - E / ( R * T ( i ) ) ) / ( 1 + t a u * A * exp ( - E / ( R * T
( i ) ) ) ) ;
17 end
18
19
20
21 plot2d ( T , [ X EB X MB ] ) ;
22
23 xtitle ( F i g u r e E84.2 , T(oR) , C o n v e rs i o n , X );
24 l e g e n d ( [ XEB ; XMB ]) ;
Example 8.6 8.6data.sci
1 F a0 = . 9* 1 63 ;
2 C a0 = 9 .3 ;
3 V 0 = 0 ;
Example 8.6 8.6.sce
1 clc
2 c l ea r a ll
3 exec ( 8. 6 dat a . s c i ) ;4 V = 0 :. 1: 3. 6;
52
-
7/22/2019 Fogler Example COdes
54/105
Figure 8.1: Output graph of S 8.4
53
-
7/22/2019 Fogler Example COdes
55/105
5 function w = f ( V , X )
67 w = zeros ( 1 , 1 ) ;
8 T = 3 3 0+ 4 3 .3 * X ;
9 k = 3 1 . 1 * exp ( 7 9 0 6 * ( T - 3 6 0 ) / ( T * 3 6 0 ) ) ;
10 Kc = 3 .0 3* exp ( - 8 3 0 . 3 * ( ( T - 3 6 0 ) / ( T * 3 6 0 ) ) ) ;
11 X e = Kc / (1 + Kc ) ;
12 r a = - k * C a0 * ( 1 - ( 1+ ( 1/ K c ) ) * X ) ;
13 w ( 1) = - ra / F a0 ;
14 r at e = - ra ;
15 e n d f u n c t i o n
16
17 x = ode ( [ 0 ] , V 0 , V , f ) ;18
19 for i =1: length ( x )
20 T ( 1 , i ) = 3 3 0 +4 3 . 3* x ( 1 , i )
21
22 k ( 1 , i ) = 3 1 . 1 * exp ( 7 9 0 6 * ( T ( 1 , i ) - 3 6 0 ) / ( T ( 1 , i ) * 3 6 0 ) ) ;
23 K c (1 , i ) = 3 .0 3* exp ( - 8 3 0 . 3 * ( ( T ( 1 , i ) - 3 6 0 ) / ( T ( 1 , i )
* 3 6 0 ) ) ) ;
24
25 r a (1 , i ) = k ( 1 , i ) * C a0 * ( 1 - ( 1+ ( 1/ K c ( 1 , i ) ) ) * x (1 , i ) ) ;
26 end
27 s c f ( 1 )
28 plot2d ( V , x ( 1 , : ) ) ;
29
30 xtitle ( F i g u r e E86.1a , V(m3 ) , X ) ;31 s c f ( 2 )
32 plot2d ( V , T ( 1 , : ) ) ;
33
34 xtitle ( F i g u r e E86.1b , V(m3 ) , T (K) ) ;35
36 s c f ( 3 )
37 plot2d ( V , r a ) ;38
39 xtitle ( F i g u r e E86. 1c , V(m3 ) , r a ( k mo l /m 3 h r) ) ;
54
-
7/22/2019 Fogler Example COdes
56/105
Figure 8.2: Output graph of S 8.6
Example 8.7 8.7data.sci
1 F a0 = 3 8. 3 ;
2 C a0 = 1 8. 3;
3 T0 = 1 03 5;
4 Tr = 29 8;
5 V 0 = 0 ;
Example 8.7 8.7.sce
1 clc
2 c l ea r a ll
55
-
7/22/2019 Fogler Example COdes
57/105
Figure 8.3: Output graph of S 8.6
56
-
7/22/2019 Fogler Example COdes
58/105
Figure 8.4: Output graph of S 8.6
57
-
7/22/2019 Fogler Example COdes
59/105
3 // t h i s c o de i s o nl y f o r t h e f i r s t p ar t o f t he
p r o b l em ( A d i a b a t i c PFR )4 exec ( 8. 7 dat a . s c i ) ;5 V = 0 :. 1: 5;
6 function w = f ( V , Y )
7
8 w = zeros ( 2 , 1 ) ;
9
10 k = ( 8 . 2 e 1 4 ) * exp ( - 3 4 2 2 2 / Y ( 1 ) ) ;
11
12 C pa = 2 6 . 6 3+ . 1 8 3* Y ( 1 ) - ( 45 . 86 e - 6 ) * ( Y ( 1 ) ^ 2) ;
13 d e lC p = 6 . 8 - ( 11 . 5 e - 3) * Y ( 1 ) - ( 3. 81 e - 6 ) * ( Y ( 1) ^ 2 ) ;
14 d e l t a H = 8 0 7 7 0 + 6 . 8 * ( Y ( 1 ) - T r ) - ( 5 .7 5 e - 3 ) * ( ( Y ( 1 ) ^ 2 ) - T r^ 2 ) - (1 . 2 7 e - 6 ) * ( ( Y ( 1 ) ^ 3 ) - T r ^ 3 ) ;
15 r a = - k * C a0 * ( ( (1 - Y ( 2 ) ) / ( 1+ Y ( 2 ) ) ) * ( T 0 / Y ( 1) ) ) ;
16 w ( 1 ) = - r a *( - d e l t a H ) / ( F a0 * ( C p a + Y ( 2) * d e l C p ) ) ;
17 w ( 2) = - ra / F a0 ;
18
19 e n d f u n c t i o n
20
21 x = ode ( [ 1 0 3 5 ; 0 ] , V 0 , V , f ) ;
22 s c f ( 1 )
23 plot2d ( V , x ( 1 , : ) ) ;
24
25 xtitle ( F i g u r e E87.1 , V (m3 ) , T (K) ) ;26
27 s c f ( 2 )
28 plot2d ( V , x ( 2 , : ) ) ;
29
30 xtitle ( F i g u r e E87.1 , V (m3 ) , X ) ;
Example 8.8 8.8data.sci
1 T = [ 3 00 :1 0 :6 0 0] ;
Example 8.8 8.8.sce
58
-
7/22/2019 Fogler Example COdes
60/105
Figure 8.5: Output graph of S 8.7
59
-
7/22/2019 Fogler Example COdes
61/105
Figure 8.6: Output graph of S 8.7
60
-
7/22/2019 Fogler Example COdes
62/105
1 clc
2 c l ea r a ll3 exec ( 8. 8 dat a . s c i ) ;4 for i = 1: length ( T )
5 X e (i ) = 1 0 00 0 0* exp ( - 3 3 . 7 8 * ( T ( i ) - 2 9 8 ) / ( T ( i ) ) ) / ( 1 +
100000* exp ( - 3 3 . 7 8 * ( T ( i ) - 2 9 8 ) / T ( i ) ) ) ;
6 X EB ( i ) = ( 2 .5 e - 3 ) * ( T ( i ) - 3 0 0) ;
7 end
8 plot2d ( T ,[ X e X EB ] )
9
10 xtitle ( F i g u r e E88.1 , T , X ) ;11 l e g e n d ( [ Xe ; XEB ]) ;
Example 8.10 8.10.sce
1 clc
2 c l ea r a ll
3 //eY ( 2 ) e c ( 8 . 6 dat a . s c i ) ;4 W = 0 : 1: 2 8. 5 8;
5 W 0 = 0 ;
6 function w = f ( W , Y )
7 w = zeros ( 3 , 1 ) ;
89
10 f a o = . 1 8 8
11 v i s c = . 0 9 0
12 T a = 1 2 6 4 . 6 7
13 d e l t a h = - 4 2 4 71 - 1 . 5 63 * ( Y ( 3 ) - 1 26 0 ) + . 0 0 1 3 6 * ( Y ( 3 )
* * 2 - 1 2 6 0 * * 2 ) - (2 . 4 5 9 *1 0 * * ( - 7 ) ) * ( Y ( 3 ) * * 3 - 1 2 6 0 * *3 ) ;
14 s u mm = 5 7 . 23 + . 0 14 * Y ( 3 ) - 1. 94 * 1 0* * ( - 6 . ) * Y ( 3) * * 2
15 d c p = - 1 . 5 6 2 5 +2 . 7 2 * 1 0 * *( - 3 ) * Y ( 3 ) - 7 . 38 * 1 0 ** ( - 7 ) * Y ( 3 ) * * 2
16 k = 3 6 0 D * exp ( -176008/Y (3) -(110.1* log ( Y ( 3 ) ) ) + 9 1 2 . 8 )
17 t h e t a s o = 0 ;18 P o = 2
19 P a o = . 2 2
20 t h e t a o = . 9 1
21 e p s = - . 0 5 5
61
-
7/22/2019 Fogler Example COdes
63/105
Figure 8.7: Output graph of S 8.8
62
-
7/22/2019 Fogler Example COdes
64/105
22 R = 1 . 9 8 7 ;
23 Kp = exp (42311/R/Y(3) -11.24);24 if ( Y ( 2 ) < = . 05 )
25
26 r a = ( - k * ( . 8 4 8 - . 0 1 2 / ( K p * * 2 ) ) ) ;
27 else
28 r a = ( - k * ( 1 - Y ( 2 ) ) / ( t h e t a s o + Y ( 2 ) ) ) * * . 5 * ( Y ( 1 ) / P o * P a o
* ( ( t h e ta o -. 5 * Y ( 2 ) ) / ( ( 1 + e p s * Y ( 2 ) ) ) - (( t h e t a s o + Y
( 2 ) ) / ( 1 - Y ( 2 ) ) ) * * 2 / ( K p * * 2 ) ) ) ;
29 end
30
31 w ( 1 ) = ( - 1 . 1 2 * 1 0 * * ( - 8 ) * ( 1 - . 0 5 5 * Y ( 2 ) ) * Y ( 3 ) ) * ( 5 5 0 0 * v i s c
+ 2 28 8 ) / Y ( 1 ) ;32 w ( 2 ) = - ( ra ) / f a o ;
33 w ( 3 ) = ( 5 . 11 * ( T a - Y ( 3) ) + ( - r a ) *( - d e l t a h ) ) / ( f a o *( s u m m + Y
( 2 ) * d c p ) )
34 e n d f u n c t i o n
35
36 X = ode ( [ 2 ; 0 ; 1 4 0 0 ] , W 0 , W , f ) ;
37
38 plot2d ( W , X ( 1 , : ) ) ;
39 plot2d ( W , X ( 3 , : ) ) ;
Example 8.11 8.11data.sci
1 V 0 = 0 ;
2 C t o = 0 . 1 ;
3 T o = 4 2 3 ;
Example 8.11 8.11.sce
1 clc
2 c l ea r a ll3 exec ( 8. 11 dat a . sc i ) ;4 V = 0 :. 01 :1 ;
5
6 function w = f ( V , Y )
63
-
7/22/2019 Fogler Example COdes
65/105
Figure 8.8: Output graph of S 8.11
64
-
7/22/2019 Fogler Example COdes
66/105
Figure 8.9: Output graph of S 8.11
65
-
7/22/2019 Fogler Example COdes
67/105
7
8 w = zeros ( 4 , 1 ) ;9
10 k 1 a = 1 0 * exp ( 4 0 0 0 * ( ( 1 / 3 0 0 ) - ( 1 / Y ( 4 ) ) ) ) ;
11 k 2 a = . 0 9 * exp (9000*((1/300) -(1/Y(4))))
12
13 F t = Y ( 1 ) + Y ( 2 ) + Y ( 3 ) ;
14
15 C a = C t o * ( Y ( 1 ) / F t ) * ( T o / Y ( 4 ) )
16 C b = C t o * ( Y ( 2 ) / F t ) * ( T o / Y ( 4 ) )
17 C c = C t o * ( Y ( 3 ) / F t ) * ( T o / Y ( 4 ) )
18 r 1 a = - k 1 a * C a ;
19 r 2 a = - k 2 a * C a ^ 2 ;20
21 w ( 1 ) = r 1 a + r 2 a ;
22 w ( 2 ) = - r 1 a ;
23
24 w ( 3 ) = - r 2 a / 2 ;
25 w ( 4 ) = ( 4 0 0 0 * ( 3 7 3 - Y ( 4 ) ) + ( - r 1 a ) * 2 0 0 0 0 + ( - r 2 a ) * 6 0 0 0 0 )
/ ( 9 0 * Y ( 1 ) + 9 0 * Y ( 2 ) + 1 8 0 * Y ( 3 ) ) ;
26 e n d f u n c t i o n
27
28 x = ode ( [ 1 0 0 ; 0 ; 0 ; 4 2 3 ] , V 0 , V , f ) ;
29
30 s c f ( 1 )
31 plot2d ( V , x ( 4 , : ) ) ;
32
33 xtitle ( F i g u r e E811.1 , V , T ) ;34
35 s c f ( 2 )
36
37 l 1 =x ( 1 ,: )
38 l 2 =x ( 2 ,: )
39 l 3 =x ( 3 ,: ) 40 plot2d ( V ,[ l 1 l 2 l 3 ]) ;
41
42 xtitle ( F i g u r e E811.2 , V , Fa , Fb , Fc ) ;43 l e g e n d ( [ Fa ; Fb ; Fc ]) ;
66
-
7/22/2019 Fogler Example COdes
68/105
Example 8.12 8.12data.sci
1 C p = 2 0 0
2 C a o = 0 . 3
3 T o = 2 8 3
4 t a u = . 0 1 ;
5 D H 1 = - 5 5 0 0 0 ;
6 D H 2 = - 7 1 5 0 0 ;
7 v o = 1 0 0 0 ;
8 E 2 = 2 7 0 0 0 ;
9 E 1 = 9 9 0 0 ;
10 U A = 4 0 0 0 0 ;
11 T a = 3 3 0 ;
Example 8.12 8.12.sce
1 clc
2 c l ea r a ll
3 exec ( 8. 12 dat a . sc i ) ;4 t = 1 : 1 0 : 2 5 0 ;
5 for i=1: length ( t )
6 T ( i ) = 2 * t ( i ) + 2 8 3 ;7
8 k 2 ( i ) = 4 . 5 8 * exp ( ( E 2 / 1 . 9 8 7 ) * ( ( 1 / 5 0 0 ) -( 1/ T ( i ) ) ) )
9 k 1 ( i ) = 3 . 3 * exp ( ( E 1 / 1 . 9 8 7 ) * ( ( 1 / 3 0 0 ) - (1 / T ( i ) ) ) )
10 C a ( i ) = C a o / ( 1 + t a u * k 1 ( i ) )
11 k a p p a = U A / ( v o * C a o ) / C p
12 G ( i ) = - ( t a u * k 1 ( i ) / ( 1 + k 1 ( i ) * t a u ) ) * D H 1 - ( k 1 ( i ) * t a u * k 2 ( i )
* t a u * D H2 / ( ( 1 + t a u * k 1 ( i) ) * ( 1+ t a u * k 2 ( i ) ) ) ) ;
13 T c = ( T o + k a p p a * T a ) / ( 1 + k a p p a ) ;
14 C b ( i ) = t a u * k 1 ( i ) * C a ( i ) / ( 1 + k 2 ( i ) * t a u ) ;
15 R ( i ) = C p * ( 1 + k a p p a ) * ( T ( i ) - T c ) ;
16 C c = C a o - C a ( i ) - C b ( i ) ;
17 F ( i ) = G ( i ) - R ( i ) ;
18 end
19 plot ( T ,[ G R ] )
67
-
7/22/2019 Fogler Example COdes
69/105
Figure 8.10: Output graph of S 8.12
20
21 xtitle ( F i g u r e E812.1 , T (K) , G(T) ,R(T) ) ;22 l e g e n d ( [ G(T) ; R(T) ]) ;
68
-
7/22/2019 Fogler Example COdes
70/105
Chapter 9
Unsteady State Nonisothermal
Reactor Design
9.1 Discussion
When executing the code from the editor, use the Execute File into Scilabtaband not the Load in Scilabtab. The .sci files of the respective problems con-tain the input parameters of the question
9.2 Scilab Code
Example 9.1 9.1data.sci
1 t 0 = 0 ;
Example 9.1 9.1.sce
1 clc
2 c l ea r a ll
3 exec ( 9. 1 dat a . s c i ) ;4 t = 0 :1 0: 15 00 ;
5 function w = f ( t , x )
6
7 w = zeros ( 1 , 1 ) ;
69
-
7/22/2019 Fogler Example COdes
71/105
Figure 9.1: Output graph of S 9.1
70
-
7/22/2019 Fogler Example COdes
72/105
Figure 9.2: Output graph of S 9.1
71
-
7/22/2019 Fogler Example COdes
73/105
8
9 t 1 = 5 3 5 + 9 0 . 4 5 * x10 k = . 0 0 02 7 3 * exp (16306*((1/535) -(1/t1)));
11 w ( 1 ) = k * ( 1 - x )
12 e n d f u n c t i o n
13
14 X = ode ( [ 0 ] , t 0 , t , f ) ;
15 T = 5 3 5 + 9 0 . 4 5 * X ;
16 s c f ( 1 )
17 plot2d ( t , T ) ;
18
19 xtitle ( F i g u r e E91.1 , t ( Se c on ds ) , T ( oR ) ) ;
2021 s c f ( 2 )
22 plot2d ( t , X ) ;
23
24 xtitle ( F i g u r e E91.1 , t ( Se c on ds ) , X ) ;
Example 9.2 9.2data.sci
1 N C p = 2 5 0 4 ;
2 U = 3 . 2 6 5 + 1 . 8 5 4 ;
3 N a o = 9 . 0 4 4 8 ;4 U A = 3 5 . 8 3 ;
5 d H = - 5 9 0 0 0 0 ;
6 N b o = 3 3 ;
7 t 0 = 5 5 ;
Example 9.2 9.2.sce
1 clc
2 c l ea r a ll
3 // t h i s c o de i s o nl y f o r P a r t C4 exec ( 9. 2 dat a . s c i ) ;5 t = 5 5: 1: 12 1;
6 function w = f ( t , Y )
7
72
-
7/22/2019 Fogler Example COdes
74/105
Figure 9.3: Output graph of S 9.2
73
-
7/22/2019 Fogler Example COdes
75/105
8 w = zeros ( 2 , 1 ) ;
910
11
12 k = . 0 0 0 1 7 * exp ( 1 1 2 7 3 / ( 1 . 9 8 7 ) * ( 1 / 4 6 1 - 1 / Y ( 1 ) ) )
13 Q r = U A *( Y ( 1 ) - 29 8)
14 T h e a t a = N b o / N a o
15 r a = - k * ( N a o * * 2 ) * ( 1 - Y ( 2 ) ) * ( T h e a t a - 2 * Y ( 2 ) ) / ( U * * 2 )
16 r a t e = - r a
17 Q g = r a * U * ( d H )
18 w ( 1 ) = ( Q g - Q r ) / N C p
19 w ( 2 ) = ( - r a ) * U / N a o
20 e n d f u n c t i o n21
22 x = ode ( [ 4 6 7 . 9 9 2 ; 0 . 0 4 2 3 ] , t 0 , t , f ) ;
23
24
25 plot2d ( t , x ( 1 , : ) ) ;
26
27 xtitle ( F i g u r e E92.2 , t , T ( oC ) ) ;
Example 9.3 9.3data.sci
1 v 0 = . 0 0 4 ;
2 C b 0 = 1 ;
3 U A = 3 0 0 0 ;
4 T a = 2 9 0 ;
5 c p = 7 5 2 4 0 ;
6 T 0 = 3 0 0 ;
7 d h = - 7 . 9 0 7 6 e 7 ;
8 C w 0 = 5 5 ;
9 c p a = 1 7 0 7 0 0 ;
10 V i = . 2 ;
11 t 0 = 0 ;
Example 9.3 9.3.sce
74
-
7/22/2019 Fogler Example COdes
76/105
Figure 9.4: Output graph of S 9.3
75
-
7/22/2019 Fogler Example COdes
77/105
Figure 9.5: Output graph of S 9.3
76
-
7/22/2019 Fogler Example COdes
78/105
1 clc
2 c l ea r a ll3 exec ( 9. 3 dat a . s c i ) ;4 t = 0 :1 :3 60 ;
5
6 function w = f ( t , Y )
7
8 w = zeros ( 5 , 1 ) ;
9
10 k = . 3 9 1 7 5 * exp ( 5 4 7 2 . 7 * ( ( 1 / 2 7 3 ) - ( 1 / Y ( 4 ) ) ) ) ;
11 C d = Y ( 3 ) ;
12
13 K c = 1 0 ^ ( 3 8 8 5 . 4 4 / Y ( 4 ) )14 V = V i + v 0 * t ;
15 F b 0 = C b 0 * v 0 ;
16 r a = - k * ( ( Y ( 1 ) * Y ( 2 ) ) - ( ( Y ( 3 ) * C d ) / K c ) ) ;
17 N a = V * Y ( 1 )
18 N b = V * Y ( 2 )
19 N c = V * Y ( 3 )
20 r b = r a
21 r c = - r a
22 N d = V * C d
23 r a t e = - r a
24 N C p = c p * ( N b + N c + N d + Y ( 5 ) ) + c p a * N a ;
25 w ( 1 ) = r a - ( v 0 * Y ( 1 ) ) / V ;
26 w ( 2 ) = r b + ( v 0 *( C b0 - Y ( 2 ) ) / V );
27 w ( 3) = rc - ( Y ( 3) * v 0 ) /V ;
28 w ( 4 ) = ( U A * ( Ta - Y ( 4 ) ) - F b 0 * c p * ( 1 +5 5 ) * ( Y ( 4) - T 0 ) + r a * V * dh )
/ N C p
29 w ( 5) = v 0 * Cw 0
30 e n d f u n c t i o n
31
32 x = ode ( [ 5 ; 0 . 0 0 0 1 ; 0 0 . 0 0 0 1 ; 3 0 0 ; 6 . 1 4 ] , t 0 , t , f ) ;
33 s c f ( 1 )34 plot2d ( t , x ( 4 , : ) ) ;
35
36 xtitle ( F i g u r e E93.1 , t , T ) ;37
77
-
7/22/2019 Fogler Example COdes
79/105
38 s c f ( 2 )
39 l 1 =x ( 1 ,: ) 40 l 2 =x ( 2 ,: )
41 l 3 =x ( 3 ,: )
42 plot2d ( t ,[ l 1 l 2 l 3 ]) ;
43
44 xtitle ( F i g u r e E93.2 , t , Ca , Cb, Cc ) ;45 l e g e n d ( [ Ca ; Cb ; Cc ]) ;
Example 9.4 9.4data.sci
1 F a 0 = 8 0 ;
2 T 0 = 7 5 ;3 V = ( 1 / 7 . 4 8 4 ) * 5 0 0 ;
4 U A = 1 6 0 0 0 ;
5 T a 1 = 6 0 ;
6 F b 0 = 1 0 0 0 ;
7 F m 0 = 1 0 0 ;
8 m c = 1 0 0 0 ;
9 t 0 = 0 ;
Example 9.4 9.4.sce
1 clc
2 c l ea r a ll
3 // e x e c ( 9. 3 dat a . sc i ) ;4 t = 0 : .0 0 01 : 4;
5 t 0 = 0 ;
6 function w = f ( t , Y )
7
8 w = zeros ( 5 , 1 ) ;
9
10 F a 0 = 8 0 ;
11 T 0 = 7 5 ;12 V = ( 1 / 7 . 4 8 4 ) * 5 0 0 ;
13 U A = 1 6 0 0 0 ;
14 T a 1 = 6 0 ;
15 k = 1 6 . 9 6 e 1 2 * exp ( - 3 2 4 0 0 / 1 . 9 8 7 / ( Y ( 5 ) + 4 6 0 ) ) ;
78
-
7/22/2019 Fogler Example COdes
80/105
16 F b 0 = 1 0 0 0 ;
17 F m 0 = 1 0 0 ;18 m c = 1 0 0 0 ;
19 r a = - k * Y ( 1 ) ;
20 r b = - k * Y ( 1 ) ;
21 r c =k * Y (1 ) ;
22 N m = Y ( 4 ) * V ;
23 N a = Y ( 1 ) * V ;
24 N b = Y ( 2 ) * V ;
25 N c = Y ( 3 ) * V ;
26 T h e t a C p = 3 5 + ( F b 0 / F a 0 ) * 1 8 + ( F m 0 / F a 0 ) * 1 9 . 5 ;
27 v 0 = ( F a 0 / 0 . 9 2 3 ) + ( F b 0 / 3 . 4 5 ) + ( F m 0 / 1 . 5 4 ) ;
28 T a2 = Y ( 5 ) - ( Y ( 5 ) - T a1 ) * exp ( - U A / ( 1 8 * m c ) ) ;29 C a 0 = F a 0 / v 0
30 C b 0 = F b 0 / v 0
31 C m 0 = F m 0 / v 0
32 Q = m c * 1 8 * ( T a 1 - T a 2 ) ;
33 t a u = V / v 0 ;
34 N C p = N a * 3 5 + N b * 1 8 + N c * 4 6 + N m * 1 3 . 5 ;
35 w ( 1 ) = ( 1 / t a u ) * ( C a 0 - Y ( 1 ) ) + r a ;
36 w ( 2 ) = ( 1 / t a u ) * ( C b 0 - Y ( 2 ) ) + r b ;
37 w ( 3 ) = ( 1 / t a u ) * ( - Y ( 3 ) ) + r c ;
38 w ( 4 ) = ( 1/ t a u ) * ( C m0 - Y ( 4 ) ) ;
39 w ( 5 ) = ( Q - F a0 * T h e t a C p * ( Y ( 5) - T 0 ) + ( - 3 6 0 00 ) * r a * V ) / N Cp ;
40 e n d f u n c t i o n
41
42 x = ode ( [ 0 ; 3 . 4 5 ; 0 ; 0 ; 7 5 ] , t 0 , t , f ) ;
43 s c f ( 1 )
44 plot2d ( t , x ( 1 , : ) ) ;
45
46 xtitle ( F i g u r e E94.1 , t , Ca ) ;47
48 s c f ( 2 )
49 plot2d ( t , x ( 5 , : ) ) ;50
51 xtitle ( F i g u r e E94.2 , t , T ) ;52 s c f ( 3 )
53 plot2d ( x ( 5 , : ) , x ( 1 , : ) ) ;
79
-
7/22/2019 Fogler Example COdes
81/105
Figure 9.6: Output graph of S 9.4
54
55 xtitle ( F i g u r e E94.3 , T , Ca ) ;
Example 9.8 9.8data.sci
1 C a o = 4 ;
2 v o = 2 4 0 ;
3 t 0 = 0 ;
Example 9.8 9.8.sce
80
-
7/22/2019 Fogler Example COdes
82/105
Figure 9.7: Output graph of S 9.4
81
-
7/22/2019 Fogler Example COdes
83/105
Figure 9.8: Output graph of S 9.4
82
-
7/22/2019 Fogler Example COdes
84/105
1 clc
2 c l ea r a ll3 exec ( 9. 8 dat a . s c i ) ;4 t = 0 : .0 1 :1 . 5;
5
6 function w = f ( t , Y )
7
8 w = zeros ( 4 , 1 ) ;
9
10 k 1 a = 1 . 2 5 * exp ( ( 9 5 0 0 / 1 . 9 8 7 ) * ( ( 1 / 3 2 0 ) - ( 1 / Y ( 4 ) ) ) ) ;
11 k 2 b = 0 . 0 8 * exp ( ( 7 0 0 0 / 1 . 9 8 7 ) * ( ( 1 / 2 9 0 ) - ( 1 / Y ( 4 ) ) ) ) ;
12 r a = - k 1 a * Y ( 1 ) ;
13 V = 1 0 0 + v o * t ;14 r c = 3 * k 2 b * Y ( 2 ) ;
15 r b = k 1 a * ( Y ( 1 ) / 2 ) - k 2 b * Y ( 2 ) ;
16 w ( 1 ) = r a + ( C a o - Y ( 1 ) ) * v o / V ;
17 w ( 2 ) = r b - Y ( 2 ) * v o / V ;
18 w ( 3 ) = rc - Y ( 3 ) * v o / V ; w ( 4 ) = ( 3 50 0 0 *( 2 9 8 - Y ( 4 ) ) - C a o * v o
* 3 0 * ( Y ( 4 ) - 3 05 ) + ( ( - 6 5 0 0) * ( - k 1 a * Y ( 1 ) ) + ( 8 0 0 0 ) * ( - k 2 b *
Y ( 2 ) ) ) * V ) / ( ( Y ( 1 ) * 3 0 + Y ( 2 ) * 6 0 + Y ( 3 ) * 2 0 ) * V + 1 0 0 * 3 5 ) ;
19 e n d f u n c t i o n
20
21 x = ode ( [ 1 ; 0 ; 0 ; 2 9 0 ] , t 0 , t , f ) ;
22
23
24 s c f ( 1 )
25 l 1 =x ( 1 ,: )
26 l 2 =x ( 2 ,: )
27 l 3 =x ( 3 ,: )
28 plot2d ( t ,[ l 1 l 2 l 3 ]) ;
29
30 xtitle ( F i g u r e E98.1 , t , Ca , Cb, Cc ) ;31 l e g e n d ( [ Ca ; Cb ; Cc ]) ;
3233 s c f ( 2 )
34 plot2d ( t , x ( 4 , : ) ) ;
35
36 xtitle ( F i g u r e E98.2 , t , T ) ;
83
-
7/22/2019 Fogler Example COdes
85/105
Figure 9.9: Output graph of S 9.8
84
-
7/22/2019 Fogler Example COdes
86/105
Figure 9.10: Output graph of S 9.8
85
-
7/22/2019 Fogler Example COdes
87/105
Chapter 10
Catalysis and Catalytic
Reactors
10.1 Discussion
When executing the code from the editor, use the Execute File into Scilabtaband not the Load in Scilabtab. The .sci files of the respective problems con-tain the input parameters of the question
10.2 Scilab Code
Example 10.3 10.3data.sci
1 f t O = 5 0
2 k = . 0 0 0 0 0 0 0 1 4 5 * 1 0 0 0 * 6 0 ;
3 k t = 1 . 0 3 8 ;
4 k b = 1 . 3 9 ;
5 a l p h a = 0 . 0 0 0 0 9 8 ;
6 P o = 4 0 ;
7 w 0 = 0 ;
Example 10.3 10.3.sce
1 clc
2 c l ea r a ll
86
-
7/22/2019 Fogler Example COdes
88/105
3 exec ( 10 . 3 dat a . s c i ) ;
4 w = 0 : 10 : 10 0 00 ;5
6 function W = f ( w , x )
7
8 W = zeros ( 1 , 1 ) ;
9
10 p t 0 = . 3 * P o ;
11 y = ( 1 - a l p h a * w ) ^ . 5 ;
12 p h = p t 0 * ( 1 . 5 - x ) * y ;
13 p t = p t 0 * ( 1 - x ) * y ;
14 p b = 2 * p t 0 * x * y ;
15 r t = - k * k t * p h * p t / ( 1 + k b * p b + k t * p t ) ;16 r a t e = - r t ;
17 W ( 1 ) = - r t / f t O ;
18 e n d f u n c t i o n
19 p t 0 = . 3 * P o ;
20 X = ode ( [ 0 ] , w 0 , w , f ) ;
21
22
23 for i =1: length ( X )
24 y ( 1 , i ) = ( 1 - a l p h a * w ( 1 , i ) ) ^ . 5 ;
25 p h ( 1 , i ) = p t 0 * ( 1 . 5 - X ( 1 , i ) ) * y ( 1 , i ) ;
26 p t ( 1 , i ) = p t 0 * ( 1 - X ( 1 , i ) ) * y ( 1 , i ) ;
27 p b ( 1 , i ) = 2 * p t 0 * X ( 1 , i ) * y ( 1 , i )
28 end
29
30 m 1 = X ;
31 m 2 = y ;
32 s c f ( 1 )
33 plot2d ( w ,[ m 1 m 2 ]) ;
34
35 xtitle ( F i g u r e E103.1 , w , x , y ) ;
36 l e g e n d ( [ x ; y ]) ;37
38 s c f ( 2 )
39 l 1 = p h
40 l 2 = p t
87
-
7/22/2019 Fogler Example COdes
89/105
Figure 10.1: Output graph of S 10.5
41 l 3 = p b
42 plot2d ( w ,[ l 1 l 2 l 3 ]) ;
43
44 xtitle ( F i g u r e E103.2 , w , ph , pt , pb ) ;45 l e g e n d ( [ ph ; pt ; pb ]) ;
Example 10.5 10.5data.sci
1 k d = 9 ;
2 C a 0 = . 8 ;
3 t a u = . 0 2
88
-
7/22/2019 Fogler Example COdes
90/105
Figure 10.2: Output graph of S 10.5
89
-
7/22/2019 Fogler Example COdes
91/105
4 k = 4 5 ;
5 C t 0 = 1 ;6 t 0 = 0
Example 10.5 10.5.sce
1 clc
2 c l ea r a ll
3 exec ( 10 . 5 dat a . s c i ) ;4 t = 0 :. 01 :. 5;
5
6 function w = f ( t , Y )
78 w = zeros ( 2 , 1 ) ;
9
10
11 y a 0 = C a 0 / C t 0 ;
12 X = 1 - ( 1 + y a 0 ) / ( 1 + Y ( 2 ) / C t 0 ) * Y ( 2 ) / C a 0 ;
13 w ( 1 ) = - k d * Y ( 1 ) * Y ( 2 ) ;
14 w ( 2 ) = ( C a 0 / t au ) - (( 1+ y a 0 ) / ( 1 +( Y ( 2 ) / C t 0 ) ) + t au * Y ( 1 ) * k )
* Y ( 2 ) / t a u ;
15 e n d f u n c t i o n
16
17 x = ode ( [ 1 ; . 8 ] , t 0 , t , f ) ;
18 C a 0 = . 8 ;
19 C t 0 = 1
20 y a 0 = C a 0 / C t 0 ;
21 for i=1: length ( t )
22 X 1 ( i ) = 1 - ( 1 + y a 0 ) / ( 1 + x ( 2 , i ) / C t 0 ) * x ( 2 , i ) / C a 0 ;
23 end
24
25
26 l 1 =x ( 1 ,: )
27 l 2 =x ( 2 ,: ) 28 l 3 = X 1 ;
29 plot2d ( t ,[ l 1 l 2 l 3 ]) ;
30
31 xtitle ( F i g u r e E105.1 , t , a , Ca , X ) ;
90
-
7/22/2019 Fogler Example COdes
92/105
Figure 10.3: Output graph of S 10.5
32 l e g e n d ( [ a ; Ca ; X ]) ;
Example 10.7 10.7data.sci
1 K a = 0 . 0 5 ;
2 K b = . 1 5 ;
3 P a o = 1 2 ;
4 e p s = 1 ;
5 A = 7 . 6 ;
6 R = 0 . 0 8 2 ;
7 T = 4 0 0 + 2 7 3 ;
91
-
7/22/2019 Fogler Example COdes
93/105
8 K c = . 1 ;
9 r h o = 8 0 ;10 k p r i m e = 0 . 0 0 1 4 ;
11 D = 1 . 5 ;
12 U o = 2 . 5 ;
Example 10.7 10.7.sce
1 clc
2 c l ea r a ll
3 exec ( 10 . 7 dat a . s c i ) ;4 z = 0 :. 1: 10 ;
5 z 0 = 0 ;6 function w = f ( z , X )
7
8 w = zeros ( 1 , 1 ) ;
9
10
11 U = U o * ( 1 + e p s * X )
12 P a = P a o * ( 1 - X ) / ( 1 + e p s * X )
13 P b = P a o * X / ( 1 + e p s * X )
14 v o = U o * 3 . 1 4 1 6 * D * D / 4
15 C a 0 = P a o / R / T
16 K c a = K a * R * T
17 P c = P b
18 a = 1 / ( 1 + A * ( z / U ) * * 0 . 5 )
19 r a p ri m e = a * ( - k p ri m e * P a / ( 1+ K a * P a + Kb * P b + K c * Pc ) )
20 r a = r h o * r a p r i m e ;
21 w ( 1 ) = - r a / U / C a 0
22 e n d f u n c t i o n
23
24 x = ode ( [ 0 ] , z 0 , z , f ) ;
25 for i=1: length ( z )
26 U ( 1 , i ) = U o * ( 1 + e p s * x ( 1 , i ) )27 a ( 1 , i ) = 1 / ( 1 + A * ( z ( 1 , i ) / U ( 1 , i ) ) * * 0 . 5 )
28 end
29
30
92
-
7/22/2019 Fogler Example COdes
94/105
Figure 10.4: Output graph of S 10.7
31 l 1 =x ( 1 ,: )
32 l 2 =a ( 1 ,: )
33
34 plot2d ( z ,[ l 1 l 2 ]) ;
35
36 xtitle ( F i g u r e E107.1 , z , X, a ) ;37 l e g e n d ( [ X ; a ]) ;
93
-
7/22/2019 Fogler Example COdes
95/105
Chapter 11
External Diffusion Effects on
Hetrogeneous Reactions
11.1 Discussion
When executing the code from the editor, use the Execute File into Scilabtaband not the Load in Scilabtab. The .sci files of the respective problems con-tain the input parameters of the question
11.2 Scilab Code
Example 11.1 11.1data.sci
1 D AB = 1 e - 6;
2 C T 0 = . 1 ; //kmol/m33 y A b = . 9 ;
4 y A s = . 2 ;
5 s = 1 e - 6 ;
6 c = . 1 ;
Example 11.1 11.1.sce
1 clc
2 c l ea r a ll
3 exec ( 11 . 1 dat a . s c i ) ;
94
-
7/22/2019 Fogler Example COdes
96/105
4 W A Z 1 = D A B * C T 0 * ( y A b - y A s ) / s ;
5 W A Z 2 = c * D A B * C T 0 * log ( ( 1 - y A s ) / ( 1 - y A b ) ) / s ;6 disp ( W A Z 1 )
7 disp ( W A Z 2 )
Example 11.3 11.3data.sci
1 D = . 0 0 2 5 ; //m2 L = . 0 0 5 ; //m3 p h i = . 3 ;
4 U = 1 5 ; //m/ s ;5 v = 4 . 5 e - 4 ; //m2 / s
6 r = . 0 0 2 5 / 2 ;7 L p = . 0 0 5 ;
8 D A B 0 = . 6 9 e - 4 ;
9 T = 7 5 0 ;
10 T 0 = 2 9 8 ;
11 z = . 0 5 ; //m
Example 11.3 11.3.sce
1 clc
2 c l ea r a ll
3 exec ( 11 . 3 dat a . s c i ) ;4 // t h i s i s o nl y P ar t A o f t he p ro bl e m .5 d p = ( 6 * ( D ^ 2 ) * L / 4 ) ^ ( 1 / 3 ) ;
6 disp ( P a r t i c l e d i a me t er dp = )7 disp ( d p )
8 disp ( m )9 a c = 6 * ( 1 - p h i ) * ( 1 / d p ) ;
10 disp ( S u r f a c e a r e a p er vo lu me o f bed = )11 disp ( a c )
12 disp ( m2/m3 )
13 R e = d p *U / v ;14 Y = ( 2 * r * L p + 2 * r ^ 2 ) / d p ^ 2 ;
15 R e p r i m e = R e / ( ( 1 - p h i ) * Y ) ;
16 D A B = D A B 0 * ( T / T 0 ) ^ ( 1 . 7 5 ) ;
17 S c = v / D A B ;
95
-
7/22/2019 Fogler Example COdes
97/105
18 S h p r i m e = ( ( R e p r i m e ) ^ . 5 ) * S c ^ ( 1 / 3 ) ;
19 k c = D A B * ( 1 - p h i ) * Y * ( S h p r i m e ) / ( d p * p h i ) ;20 X = 1 - exp ( - k c * a c * z / U ) ;
21 disp ( X = )22 disp ( X )
Example 11.4 11.4data.sci
1 X 1 = . 8 6 5 ;
Example 11.4 11.4.sce
1 clc
2 c l ea r a ll
3 exec ( 11 . 4 dat a . s c i )4 X 2 = 1 - ( 1 / exp (( log ( 1 / ( 1 - X 1 ) ) ) * ( 1 / 2 ) * ( ( 2 ) ^ . 5 ) ) ) ;
5 disp ( X2 = )6 disp ( X 2 )
Example 11.5 11.5data.sci
1 X 1 = . 8 6 5 ;
2 T 1 = 6 7 3 ;3 T 2 = 7 7 3 ;
Example 11.5 11.5.sce
1 clc
2 c l ea r a ll
3 exec ( 11 . 5 dat a . s c i )4 X 2 = 1 - ( 1 / exp (( log ( 1 / ( 1 - X 1 ) ) ) * ( ( T 2 / T 1 ) ^ ( 5 / 1 2 ) ) ) ) ;
5 disp ( X2 = )6 disp ( X 2 )
96
-
7/22/2019 Fogler Example COdes
98/105
Chapter 12
Diffusion and Reaction in
Pours Catalysts
12.1 Discussion
When executing the code from the editor, use the Execute File into Scilabtaband not the Load in Scilabtab. The .sci files of the respective problems con-tain the input parameters of the question
12.2 Scilab Code
97
-
7/22/2019 Fogler Example COdes
99/105
Chapter 13
Distributions of Residence
Times for Chemical Reactions
13.1 Discussion
When executing the code from the editor, use the Execute File into Scilabtaband not the Load in Scilabtab. The .sci files of the respective problems con-tain the input parameters of the question
13.2 Scilab Code
Example 13.8 13.8data.sci
1 k = 0 . 0 1
2 c a o = 8 ;
3 z 0 = 0 ;
Example 13.8 13.8.sce
1 clc
2 c l ea r a ll3 exec ( 13 . 8 dat a . s c i ) ;4 z = 0 :1 :2 00 ;
5
6 function w = f ( z , x )
98
-
7/22/2019 Fogler Example COdes
100/105
7
8 w = zeros ( 1 , 1 ) ;9
10 l a m = 2 0 0 - z ;
11 c a = c a o * ( 1 - x )
12 E 1 = 4 . 4 4 6 5 8 e - 1 0 * ( l a m ^ 4 ) - 1 . 18 0 2 e - 7 * ( l a m ^ 3 ) + 1 . 3 5 3 5 8 e
-5*(lam ^2) -.00086
13 5 6 5 2 * l a m + . 0 2 8 0 0 4 ;
14 E 2 = - 2 .6 4 e - 9 * ( l a m ^ 3 ) + 1 . 3 6 1 8 e - 6 * ( l a m ^ 2 ) - . 0 0 0 24 0 6 9 * l a m
+.015011
15 F 1 = 4 . 4 4 6 5 8 e - 1 0 / 5 * ( l a m ^ 5 ) - 1 . 18 0 2 e - 7 / 4 * l a m ^ 4 + 1 . 3 5 3 5 8 e
- 5 / 3 * l a m ^ 3 - . 0 0 0 8 6 5 6 5 2 / 2 * l a m ^ 2 + . 0 2 8 0 0 4 * l a m ;
16 F 2 = - ( - 9 . 3 0 7 6 e - 8 * l a m ^ 3 + 5 . 0 2 8 4 6 e - 5 * l a m ^ 2 - . 0 0 9 4 1 * l a m+ . 6 1 8 2 3 - 1 )
17 r a = - k * c a ^ 2 ;
18 if l am < = 70
19 E = E 1
20 else
21 E = ( E 2 )
22 end
23 if ( lam < = 70 )
24 F = F 1
25 else
26 F = F 2
27 end
28 E F = E / ( 1 - F )
29 w ( 1 ) = - ( r a / c a o + E / ( 1 - F ) * x )
30 e n d f u n c t i o n
31
32 X = ode ( [ 0 ] , z 0 , z , f ) ;
33
34 plot2d ( z , X ) ;
Example 13.9 13.9data.sci
1 k 1 = 1 ;
2 k 2 = 1 ;
3 k 3 = 1 ;
99
-
7/22/2019 Fogler Example COdes
101/105
4 t 0 = 0 ;
Example 13.9 13.8.sce
1 clc
2 c l ea r a ll
3 exec ( 13 . 9 dat a . s c i ) ;4 t = 0 : .1 : 2. 5 2;
5
6 function w = f ( t , Y )
7
8 w = zeros ( 1 0 , 1 ) ;
910 E 1 = - 2 . 1 0 4 * t ^ 4 + 4 . 1 6 7 * t ^ 3 - 1 . 5 9 6 * t ^ 2 + 0 . 3 5 3 * t - . 0 0 4
11 E 2 = - 2 . 1 0 4 * t ^ 4 + 1 7 . 0 3 7 * t ^ 3 - 5 0 . 2 4 7 * t ^ 2 + 6 2 . 9 6 4 * t - 2 7 . 4 0 2
12 r c = k 1 * Y ( 1 ) * Y ( 2 )
13 r e = k 3 * Y ( 2 ) * Y ( 4 )
14 r a = - k 1 * Y ( 1 ) * Y ( 2 ) - k 2 * Y ( 1 )
15 r b = - k 1 * Y ( 1 ) * Y ( 2 ) - k 3 * Y ( 2 ) * Y ( 4 )
16 if t < = 1. 26
17 E = E 1
18 else
19 E = E 2
20 end
21 r d = k 2 * Y ( 1 ) - k 3 * Y ( 2 ) * Y ( 4 )
22
23 w ( 1 ) = r a
24 w ( 2) = r b
25 w ( 3) = r c
26 w ( 6 ) = Y ( 1 ) * E
27 w ( 7 ) = Y ( 2 ) * E
28 w ( 8 ) = Y ( 3 ) * E
29 w ( 4 ) = r d
30 w ( 5) = r e31 w ( 9 ) = Y ( 4 ) * E
32 w ( 1 0 ) = Y ( 5 ) * E
33 e n d f u n c t i o n
34
100
-
7/22/2019 Fogler Example COdes
102/105
35 X = ode ( [ 1 ; 1 ; 0 ; 0 ; 0 ; 0 ; 0 ; 0 ; 0 ; 0 ] , t 0 , t , f ) ;
3637 plot2d ( t , X ( 1 , : ) ) ;
101
-
7/22/2019 Fogler Example COdes
103/105
Chapter 14
Models for Nonideal Reactors
14.1 Discussion
When executing the code from the editor, use the Execute File into Scilabtaband not the Load in Scilabtab. The .sci files of the respective problems con-tain the input parameters of the question
14.2 Scilab Code
Example 14.3 14.3.sce
1 clc
2 c l ea r a ll
3
4 t = 0 :1 0: 20 0;
5
6 function w = f ( t , Y )
7
8 w = zeros ( 2 , 1 ) ;
9
10 C T e 1 = 2 0 0 0 - 5 9 . 6 * t + . 6 4 * t ^ 2 - 0 . 0 0 1 4 6 * t ^ 3 - 1 . 0 4 7 * 1 0 ^ ( - 5 ) * t^4
11 B e t a = . 1
12 C T e 2 = 9 2 1 - 1 7 . 3 * t + . 1 2 9 * t ^ 2 - 0 . 0 0 0 4 3 8 * t ^ 3 + 5 . 6 * 1 0 ^ ( - 7 ) * t
^4
102
-
7/22/2019 Fogler Example COdes
104/105
13 a l p h a = . 8
14 t a u = 4 015 if ( t < 8 0 )
16 C T e = C T e 1
17 else
18 C T e = C T e 2
19 end
20
21 w ( 1 ) = ( B e t a * Y ( 2 ) - (1 + B e t a ) * Y ( 1 ) ) / a l p h a / t a u
22 w ( 2 ) = ( B e t a * Y ( 1 ) - B e t a * Y ( 2 ) ) / ( 1 - a l p h a ) / t a u
23 e n d f u n c t i o n
24
25 X = ode ( [ 2 0 0 0 ; 0 ] , t 0 , t , f ) ;26
27 t = t ;
28 for i =1: length ( t )
29 C T e 1 ( i ) = 2 0 0 0 - 5 9 . 6 * t ( i ) + . 6 4 * ( t ( i ) ^ 2 ) -0 . 0 0 14 6 * ( t ( i ) ^ 3 )
- 1 . 0 4 7 * ( 1 0 ^ ( - 5 ) ) * t ( i ) ^ 4 ;
30 C T e 2 ( i ) = 9 2 1 - 1 7 . 3 * t ( i ) + . 1 2 9 * t ( i ) ^ 2 - 0 . 0 0 0 4 3 8 * t ( i )
^ 3 + 5 . 6 * 1 0 ^ ( - 7 ) * t ( i ) ^ 4
31 if ( t ( i ) < 8 0 )
32 C T e ( i ) = C T e 1 ( i )
33 else
34 C T e ( i ) = C T e 2 ( i )
35 end
36 end
37
38
39 l 1 =X ( 1 ,: ) ;
40 l 2 = C T e ;
41
42 plot2d ( t ,[ l 1 l 2 ]) ;
43
44 xtitle ( F i g u r e E143.1 , t , CT1 , CTe ) ;45 l e g e n d ( [ CT1 ; CTe ]) ;
103
-
7/22/2019 Fogler Example COdes
105/105