Combustion Matlab Code

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

11/4/13

combustion_project2_freddysanchez

% F r e d d yS a n c h e z % I n t r o d u c t i o nt oC o m b u s t i o n % P r o j e c t2 c l e a ra l l % G i v e n : T=1 2 5 0 ; P=2 * 1 0 1 3 2 5 ; R u=8 . 3 1 5 ; % T o t a lc o n c e n t r a t i o n=c o n c % D e n s i t y=r h o % M o l e c u l a rw e i g h t=m w % c o n c=r h o / m w=P / ( R u * T ) c o n c=P / ( R u * T ) ; %M o l ep e r c e n t a g e sg i v e n : X _ N 2=0 . 7 6 6 ; X _ O 2=0 . 1 2 1 ; X _ H 2 O=0 . 0 5 9 ; X _ C O 2=0 . 0 5 2 ; X _ C 8 H 1 8=0 . 0 0 2 ; % N og i v e np e r c e n t a g e sf o rt h ef o l l o w i n g .S o ,m i n i m a lp e r c e n t a g ei sg i v e n % P e r c e n t a g eb ym o l ef o rt h e s es p e c i e si s0 . 1 %o fN 2 X _ C 2 H 4=0 . 0 0 0 0 0 2 ; X _ C O=0 . 0 0 0 0 0 2 ; X _ H 2=0 . 0 0 0 0 0 2 ; % I n i t i a lc o n c e n t r a t i o n s : N 2=( X _ N 2 * c o n c ) ; O 2=( X _ O 2 * c o n c ) ; H 2 O=( X _ H 2 O * c o n c ) ; C O 2=( X _ C O 2 * c o n c ) ; C 8 H 1 8=( X _ C 8 H 1 8 * c o n c ) ; C 2 H 4=( X _ C 2 H 4 * c o n c ) ; C O=( X _ C O * c o n c ) ; H 2=( X _ H 2 * c o n c ) ; % R a t e s k 1=4 . 4 1 2 4 2 8 * 1 0 ^ 8 ; k 2=9 . 0 0 3 3 8 * 1 0 ^ 5 ; k 3=4 . 0 0 5 9 * 1 0 ^ 7 ; k 4=2 . 2 2 6 9 8 4 * 1 0 ^ 6 ; R a t e 1=k 1 * ( C 8 H 1 8 ^ 0 . 5 ) * ( O 2 ^ 1 . 0 7 ) * ( C 2 H 4 ^ 0 . 4 ) ; R a t e 2=k 2 * ( C 2 H 4 ^ 0 . 9 ) * ( O 2 ^ 1 . 1 8 ) * ( C 8 H 1 8 ^ ( 0 . 3 7 ) ) ; R a t e 3=k 3 * C O * ( O 2 ^ 0 . 2 5 ) * ( H 2 O ^ 0 . 5 ) ; R a t e 4=k 4 * ( H 2 ^ 0 . 8 5 ) * ( O 2 ^ 1 . 4 2 ) * ( C 2 H 4 ^ ( 0 . 5 6 ) ) ; % R e a c t i o nR a t e s d C 8 H 1 8=R a t e 1 ; d C 2 H 4=( 4 * R a t e 1 ) R a t e 2 ; d H 2=R a t e 1 + ( 2 * R a t e 2 ) R a t e 4 ; d O 2=R a t e 2 ( 0 . 5 * R a t e 3 ) ( 0 . 5 * R a t e 4 ) ; d C O=( 2 * R a t e 2 ) R a t e 3 ;
file:///C:/Users/Ann/Documents/MATLAB/html/combustion_project2_freddysanchez.html 1/9

11/4/13

combustion_project2_freddysanchez

d C O 2=R a t e 3 ; d H 2 O=R a t e 4 ; d N 2=0 ; % U s i n gf o rl o o pw i t hr u nb a c k w a r d sE u l e rm e t h o d n = 1 0 0 0 0 0 ; h = 1 * 1 0 ^ ( 1 5 ) ;

f o ri=1 : n i fi = = 1 C 8 H 1 8 ( i )=C 8 H 1 8 ; C 2 H 4 ( i )=C 2 H 4 ; H 2 ( i )=H 2 ; O 2 ( i )=O 2 ; C O ( i )=C O ; C O 2 ( i )=C O 2 ; H 2 O ( i )=H 2 O ; N 2 ( i )=N 2 ; d C 8 H 1 8 ( i )=d C 8 H 1 8 ; d C 2 H 4 ( i )=d C 2 H 4 ; d H 2 ( i )=d H 2 ; d O 2 ( i )=d O 2 ; d C O ( i )=d C O ; d C O 2 ( i )=d C O 2 ; d H 2 O ( i )=d H 2 O ; d N 2 ( i )=d N 2 ; e l s e C 8 H 1 8 ( i )=C 8 H 1 8 ( i 1 ) + h * d C 8 H 1 8 ( i 1 ) ; C 2 H 4 ( i )=C 2 H 4 ( i 1 ) + h * d C 2 H 4 ( i 1 ) ; H 2 ( i )=H 2 ( i 1 ) + h * d H 2 ( i 1 ) ; O 2 ( i )=O 2 ( i 1 ) + h * d O 2 ( i 1 ) ; C O ( i )=C O ( i 1 ) + h * d C O ( i 1 ) ; C O 2 ( i )=C O 2 ( i 1 ) + h * d C O 2 ( i 1 ) ; H 2 O ( i )=H 2 O ( i 1 ) + h * d H 2 O ( i 1 ) ; N 2 ( i )=N 2 ( i 1 ) + h * d N 2 ( i 1 ) ; R a t e 1 ( i )=k 1 * ( ( C 8 H 1 8 ( i ) ) ^ 0 . 5 ) * ( ( O 2 ( i ) ) ^ 1 . 0 7 ) * ( ( C 2 H 4 ( i ) ) ^ 0 . 4 ) ; R a t e 2 ( i )=k 2 * ( ( C 2 H 4 ( i ) ) ^ 0 . 9 ) * ( ( O 2 ( i ) ) ^ 1 . 1 8 ) * ( ( C 8 H 1 8 ( i ) ) ^ ( 0 . 3 7 ) ) ; R a t e 3 ( i )=k 3 * ( C O ( i ) ) * ( ( O 2 ( i ) ) ^ 0 . 2 5 ) * ( ( H 2 O ( i ) ) ^ 0 . 5 ) ; R a t e 4 ( i )=k 4 * ( ( H 2 ( i ) ) ^ 0 . 8 5 ) * ( ( O 2 ( i ) ) ^ 1 . 4 2 ) * ( ( C 2 H 4 ( i ) ) ^ ( 0 . 5 6 ) ) ; d C 8 H 1 8 ( i )=R a t e 1 ( i ) ; d C 2 H 4 ( i )=( 4 * ( R a t e 1 ( i ) ) ) R a t e 2 ( i ) ; d H 2 ( i )=R a t e 1 ( i ) + ( 2 * ( R a t e 2 ( i ) ) ) R a t e 4 ( i ) ; d O 2 ( i )=R a t e 2 ( i ) ( 0 . 5 * ( R a t e 3 ( i ) ) ) ( 0 . 5 * ( R a t e 4 ( i ) ) ) ; d C O ( i )=( 2 * ( R a t e 2 ( i ) ) ) R a t e 3 ( i ) ; d C O 2 ( i )=R a t e 3 ( i ) ; d H 2 O ( i )=R a t e 4 ( i ) ; d N 2 ( i )=0 ; d C 8 H 1 8 ( i 1 )=d C 8 H 1 8 ( i ) ; d C 2 H 4 ( i 1 )=d C 2 H 4 ( i ) ; d H 2 ( i 1 )=d H 2 ( i ) ; d O 2 ( i 1 )=d O 2 ( i ) ;
file:///C:/Users/Ann/Documents/MATLAB/html/combustion_project2_freddysanchez.html 2/9

11/4/13

combustion_project2_freddysanchez

d C O ( i 1 )=d C O ( i ) ; d C O 2 ( i 1 )=d C O 2 ( i ) ; d H 2 O ( i 1 )=d H 2 O ( i ) ; d N 2 ( i 1 )=d N 2 ( i ) ; e n d

e n d

d i s p( ' [ C 8 H 1 8 ]i s ' ) C 8 H 1 8 ( i ) d i s p( ' [ C 2 H 4 ]i s ' ) C 2 H 4 ( i ) d i s p( ' [ H 2 ]i s ' ) H 2 ( i ) d i s p( ' [ O 2 ]i s ' ) O 2 ( i ) d i s p( ' [ C O ]i s ' ) C O ( i ) d i s p( ' [ C O 2 ]i s ' ) C O 2 ( i ) d i s p( ' [ H 2 O ]i s ' ) H 2 O ( i ) d i s p( ' [ N 2 ]i s ' ) N 2 ( i ) x=n ; f i g u r e p l o t ( 1 : x , C 8 H 1 8 , ' k : ' ) h o l do n p l o t ( 1 : x , C 2 H 4 , ' r ' ) h o l do n p l o t ( 1 : x , H 2 , ' g ' ) h o l do n p l o t ( 1 : x , O 2 , ' m ' ) h o l do n p l o t ( 1 : x , C O , ' m ' ) h o l do n p l o t ( 1 : x , C O 2 , ' c : ' ) h o l do n p l o t ( 1 : x , H 2 O , ' b ' ) l e g e n d ( ' [ C 8 H 1 8 ] ' , ' [ C 2 H 4 ] ' , ' [ H 2 ] ' , ' [ O 2 ] ' , ' [ C O ] ' , ' [ C O 2 ] ' , ' [ H 2 O ] ' )

f i g u r e p l o t ( 1 : x , C 8 H 1 8 , ' k : ' ) l e g e n d ( ' [ C 8 H 1 8 ] ' ) f i g u r e p l o t ( 1 : x , C 2 H 4 , ' r ' ) l e g e n d ( ' [ C 2 H 4 ] ' ) f i g u r e


file:///C:/Users/Ann/Documents/MATLAB/html/combustion_project2_freddysanchez.html 3/9

11/4/13

combustion_project2_freddysanchez

p l o t ( 1 : x , H 2 , ' g ' ) l e g e n d ( ' [ H 2 ] ' ) ; f i g u r e p l o t ( 1 : x , O 2 , ' m ' ) l e g e n d ( ' [ O 2 ] ' ) f i g u r e p l o t ( 1 : x , C O , ' m ' ) l e g e n d ( ' [ C O ] ' ) f i g u r e p l o t ( 1 : x , C O 2 , ' c ' ) l e g e n d ( ' [ C O 2 ] ' ) f i g u r e p l o t ( 1 : x , H 2 O , ' b ' ) l e g e n d ( ' [ H 2 O ] ' )

[ C 8 H 1 8 ]i s a n s= 0 . 0 3 7 1 [ C 2 H 4 ]i s a n s= 0 . 0 0 7 7 [ H 2 ]i s a n s= 0 . 0 0 1 9 [ O 2 ]i s a n s= 2 . 3 5 9 1 [ C O ]i s a n s= 4 . 7 5 6 9 e 0 5 [ C O 2 ]i s a n s= 1 . 0 1 3 9

file:///C:/Users/Ann/Documents/MATLAB/html/combustion_project2_freddysanchez.html

4/9

11/4/13

combustion_project2_freddysanchez

[ H 2 O ]i s a n s= 1 . 1 5 0 4 [ N 2 ]i s a n s= 1 4 . 9 3 4 9

file:///C:/Users/Ann/Documents/MATLAB/html/combustion_project2_freddysanchez.html

5/9

11/4/13

combustion_project2_freddysanchez

file:///C:/Users/Ann/Documents/MATLAB/html/combustion_project2_freddysanchez.html

6/9

11/4/13

combustion_project2_freddysanchez

file:///C:/Users/Ann/Documents/MATLAB/html/combustion_project2_freddysanchez.html

7/9

11/4/13

combustion_project2_freddysanchez

file:///C:/Users/Ann/Documents/MATLAB/html/combustion_project2_freddysanchez.html

8/9

11/4/13

combustion_project2_freddysanchez

Published with MATLAB 7.14

file:///C:/Users/Ann/Documents/MATLAB/html/combustion_project2_freddysanchez.html

9/9

You might also like