Systes of Linear First Order Ordinary Differential Equations Eaple Probles David Keffer Departent of Cheial Engineering University of Tennessee Knoville, TN 79 Last Updated: Septeber 4, Eaple. Transient Behavior of a Bath Reator Eaple. Transient Behavior of a Continuous Stirred-Tan Reator 6 Eaple. Transient Vibrational Behavior of Carbon Dioide
D. Keffer, ChE 55, Dept. of Cheial Engineering, University of Tennessee, Septeber, Eaple. Transient Behavior of a Bath Reator Consider that you have a three-oponent reative iture in a bath reator, all undergoing reversible reations, as pitured below: In this piture, the s are onentrations of the three speies and the s are rate onstants. n eaple of this syste is the ineti equilibriu between para-, eta-, and ortho-ylene. Now suppose we want to now what the onentration is as a funtion of tie. We an write the ass balanes for eah oponent. There are no in and out ters (the reator is a bath reator. There is only the auulation ter and the reation ters. lso, assue eah reation is first order in onentration. d d d + + + + + + (. We an gather lie ters and rearrange the right hand side: d d d ( + ( + + + ( + + + (. and we hange this syste of equations into atri & vetor for:
D. Keffer, ChE 55, Dept. of Cheial Engineering, University of Tennessee, Septeber, d X (. where ( + X ( + ( + (.4 The atri X is singular. It has a deterinant of zero and a ran of. Therefore, it has one zero value eigenvalue. Nevertheless, the atri has three distint real eigenvalues, λ, λ, λ. Corresponding to eah of these eigenvalues is a real, distint eigenvetor, w,,w,, w,. The eigenvetors of X are nown as the eigenrows of X: w r,,w r,, wr,. The solution is then: ( t ( wr,i o ( w w w,i ep[ λi( t to ] r,i,i n i (.5 In order to obtain nuerial values for this proble, we would have to first obtain the eigenvalues, eigenvetors, and eigenrows. This an be done nuerially, using routines disussed in the setion on nuerial ethods for solving systes of linear algebrai equations. We provide a Matlab ode to solve this proble on the following page.
D. Keffer, ChE 55, Dept. of Cheial Engineering, University of Tennessee, Septeber, Matlab ode to solve Eaple. % % Solution to the Bath Reator Proble % % David Keffer % Departent of Cheial Engineering % University of Tennessee % Knoville Tennessee % Septeber, % % input.5;.5;.;.5;.;.5; [ (--,, ;, (--, ;,, (--]; yo [./.;./.;./.]; to.; tf.; n a(size(; % eigenvalues and eigenvetors [wol,labda] eig(; wolinv inv(wol; % set up disretized solution grid npoints ; (tf-to/npoints; for i ::npoints+ tp(i (i-* +to; % alulate solution eplabda zeros(n,n; yp zeros(n,npoints; for i ::npoints+ for j :n eplabda(j,j ep(labda(j,j*(tp(i - to ; yp(:,i wol*eplabda*wolinv*yo; %plot for j ::n if (j plot (tp,yp(j,:,'g-', label( 't', ylabel ( 'y' elseif (j plot (tp,yp(j,:,'r-', label( 't', ylabel ( 'y' elseif (j plot (tp,yp(j,:,'b-', label( 't', ylabel ( 'y' hold on hold off
D. Keffer, ChE 55, Dept. of Cheial Engineering, University of Tennessee, Septeber, Plot of Solution to Eaple : Transient Behavior in a Bath Reator.6.55.5 ole fration.45.4.5..5..5. 4 5 6 7 8 9 tie (s Coents: t all ties, the su of the ole frations is unity. The initial ondition is y o [/ / /]. The steady state equilibriu appears to be about y [.4.86.57]. 4
D. Keffer, ChE 55, Dept. of Cheial Engineering, University of Tennessee, Septeber,.9.8 ole fration.7.6.5.4... 4 6 8 4 6 8 tie (s Coents: t all ties, the su of the ole frations is unity. The initial ondition is y o [ ]. The steady state equilibriu appears to be about y [.4.86.57]. This is the sae steady state oposition as was obtained for the other initial ondition, plotted on the previous page. The equilibriu oposition is indepent of the initial oposition, in this ase. This is generally true, eept where ultiple steady states eist. 5
D. Keffer, ChE 55, Dept. of Cheial Engineering, University of Tennessee, Septeber, Eaple. Cheial Reation Equilibria with addition/deletion of oponents b( We an add onstant flowrates to our syste by adding a onstant ter to the ODEs. d d d ( + ( + + + ( + + + + F + F + F (4. The flowrates an either be feed or effluent, deping upon the sign. To eep the proble siple, let's enfore onservation of volue by stipulating that i F i (4. and we hange this syste of equations into atri & vetor for: d (4. X + F We now the solution to the nonhoogeneous equation is ( t W ep Λ( t [ ] ep[ Λ( t ] W u(t + u(t o o o nh (4.4 The only question is the for of u. u [ Λ( ] W b( d ep (. [ ] Sine, for this proble, b is a onstant, all the funtionality lies in ep Λ( u ( t ep Λ( [ ] dw b t (4.5 6
D. Keffer, ChE 55, Dept. of Cheial Engineering, University of Tennessee, Septeber, u ( t Λ ep Λ( t [ ] W b (4.6 Plugging ba into the solution we find nh [ ] ( t W ep Λ( t ep Λ [ ( ] Λ to W o + Λ ep Λ( t o ep [ ] W b [ (] Λ t W b (4.7 opliation arises beause one of the eigenvalues is zero. Thus there is no -depeny in the eponential beause there is no eponential. Then we would have a ter of the for u t t (4.8 ( t ep[ ] dw b dw b [] t W b tw b so that we would have u ( t UW b (4.9 ep λ U [ λ( t ] ep [ λ( t ] λ for the ase where we had three eigenvalues, the first two of whih are non-zero. t (4. We provide a Matlab ode to solve this proble on the following page. 7
D. Keffer, ChE 55, Dept. of Cheial Engineering, University of Tennessee, Septeber, Matlab ode to solve Eaple. % % Solution to the Continuous Stirred Tan Reator Proble % % David Keffer % Departent of Cheial Engineering % University of Tennessee % Knoville Tennessee % Septeber, % tol.e-4; % input.5;.5;.;.5;.;.5; [ (--,, ;, (--, ;,, (--]; n a(size(; yo [./.;./.;./.]; %yo [.;.;.]; % onstant ters in ODE b [-.; -.;.]; to.; tf.; % eigenvalues and eigenvetors [wol,labda] eig(; wolinv inv(wol; % alulate ep (-labda*to atri eplabdano zeros(n,n; for j ::di eplabdano(j,j ep(-labda(j,j*to; % alulate u(to uo zeros(n,n; for j ::n if (abs(labda(j,j > tol uo(j,j -eplabdano(j,j/labda(j,j; else uo(j,j to; % set up disretized solution grid nintervals ; npoints nintervals + ; (tf-to/nintervals; for i ::npoints tp(i (i-* +to; % alulate solution yp zeros(n,npoints; for i ::npoints eplabdan zeros(n,n; eplabda zeros(n,n; for j ::di eplabdan(j,j ep(-labda(j,j*tp(i; 8
D. Keffer, ChE 55, Dept. of Cheial Engineering, University of Tennessee, Septeber, eplabda(j,j ep(labda(j,j*tp(i; % alulate u(t u zeros(n,n; for j ::n if (abs(labda(j,j > tol u(j,j -eplabdan(j,j/labda(j,j; else u(j,j tp(i; ter eplabdano*wolinv*yo; ter (u-uo*wolinv*b; yp(:,i wol*eplabda*(ter + ter; %plot for j ::n if (j plot (tp,yp(j,:,'g-', label( 't', ylabel ( 'y' elseif (j plot (tp,yp(j,:,'r-', label( 't', ylabel ( 'y' elseif (j plot (tp,yp(j,:,'b-', label( 't', ylabel ( 'y' hold on hold off label('tie (s'; ylabel('ole fration'; leg(' ',' ', ' '; 9
D. Keffer, ChE 55, Dept. of Cheial Engineering, University of Tennessee, Septeber,.8.7.6 ole fration.5.4... 4 6 8 4 6 8 tie (s Coents: t all ties, the su of the ole frations is unity. The initial ondition is y o [/ / /]. The steady state equilibriu appears to be about y [..6.65]. The flowrates for eah oponent are b[-...].
D. Keffer, ChE 55, Dept. of Cheial Engineering, University of Tennessee, Septeber,.7.6.5 ole fration.4... 4 6 8 4 6 8 tie (s Coents: t all ties, the su of the ole frations is unity. The initial ondition is y o [/ / ]. The steady state equilibriu appears to be about y [..6.65]. The flowrates for eah oponent are b[-...]. This is the sae steady state oposition as was obtained for the other initial ondition, plotted on the previous page. The equilibriu oposition is indepent of the initial oposition, in this ase. This is generally true, eept where ultiple steady states eist.
D. Keffer, ChE 55, Dept. of Cheial Engineering, University of Tennessee, Septeber, Eaple. Transient Vibrational Behavior of Carbon Dioide Consider that we want to investigate the vibrational properties of arbon dioide, CO. Our odel of the oleule loos lie this: spring ( spring ( O C O,,, We odel the interation between oleules as Hooian springs. For a Hooian spring, the potential energy, U, is U ( (5. and the fore, F, is F ( (5. where is the spring onstant (units of g/s, is the equilibriu displaeent, and is the atual displaeent. When both s of the spring are obile we an write, for the spring that onnets ass and : U (5. (( and we an write, for the spring that onnets ass and : U (5.4 ((
D. Keffer, ChE 55, Dept. of Cheial Engineering, University of Tennessee, Septeber, The fores are then: (( U F (( (( U F + (5.5 (( U F With only a slight sleight of hand, we redefine our variables to be: + (5.6 This eliinates the equilibriu bond distanes fro the alulation. So, with this definition, (5.7 at equilibriu. This does not affet our equations of otion beause the derivatives of our variables before and after the transforation of the variables are the sae. Our fores beoe: ( U F ( ( U F + (5.8 ( U F We an write Newton s equations of otion for the three oleules: ( ( ( ( O C O F a F a F a + (5.9 We an generalized this to a non-syetri linear tri-atoi oleule by writing:
D. Keffer, ChE 55, Dept. of Cheial Engineering, University of Tennessee, Septeber, a a a F F F ( ( + ( ( (5. Knowing that the aeleration is the seond derivative of the position, we an rewrite the above equations in atri for as (first divide both side of all of the equations by the asses d (5. where (5. Solving this syste of seond order linear differential equations yields the integrated equations of otion for arbon dioide. We an onvert the three seond order ODEs into si first order ODEs as shown below. Tae ato nuber one. whih we write as ( a F (5. d ( (5.4 Now we an rewrite that seond order ODE as two first order ODEs. d 4 (5.5 4
D. Keffer, ChE 55, Dept. of Cheial Engineering, University of Tennessee, Septeber, 5 ( 4 d (5.6 We an write analogous equation for the other two atos, to oe with ODEs for variables 5 and 6. Of ourse, variables,, and are still the positions of the atos. Variables 4, 5, and 6 are now the veloities of the atos. ll of these equations are hoogeneous. Our atri beoes a 66 atri: (5.7 where the solution vetor,, is now defined as: 6 5 4 & & & (5.8 Now, learly, we an solve this proble eatly as we solve any syste of hoogeneous linear first order ODEs. The solution will be given as ( ( [ ] o o h W t t ep W t Λ (.4 We provide a Matlab ode to solve this proble on the following page. The only quantitative differene between this ode and the ode for eaple, is that this proble has iaginary eigenvalues, whih eventually yield real solutions via the Euler Identities. Near the of the ode, we eliinate any residual round-off errors of the iaginary oponent of the solution.
D. Keffer, ChE 55, Dept. of Cheial Engineering, University of Tennessee, Septeber, Matlab ode to solve Eaple. % % Solution to vibrational odes of CO Proble % % David Keffer % Departent of Cheial Engineering % University of Tennessee % Knoville Tennessee % Septeber, % lear all; lose all; % tol.e-4; % input ass( 6; ass( ; ass( 6; 48; 48; [ -/ass( /ass( /ass( (--/ass( /ass( /ass( -/ass( ]; n a(size(; yo [.;.; -.5;.;.;.]; % onstant ters in ODE b zeros(n,; to.; tf.; % eigenvalues and eigenvetors [wol,labda] eig(; wolinv inv(wol; % alulate ep (-labda*to atri eplabdano zeros(n,n; for j ::n eplabdano(j,j ep(-labda(j,j*to; 6
D. Keffer, ChE 55, Dept. of Cheial Engineering, University of Tennessee, Septeber, % alulate u(to uo zeros(n,n; for j ::n if (abs(labda(j,j > tol uo(j,j -eplabdano(j,j/labda(j,j; else uo(j,j to; % set up disretized solution grid nintervals ; npoints nintervals + ; (tf-to/nintervals; for i ::npoints tp(i (i-* +to; % alulate solution yp zeros(n,npoints; for i ::npoints eplabdan zeros(n,n; eplabda zeros(n,n; for j ::n eplabdan(j,j ep(-labda(j,j*tp(i; eplabda(j,j ep(labda(j,j*tp(i; % alulate u(t u zeros(n,n; for j ::n if (abs(labda(j,j > tol u(j,j -eplabdan(j,j/labda(j,j; else u(j,j tp(i; ter eplabdano*wolinv*yo; ter (u-uo*wolinv*b; yp(:,i wol*eplabda*(ter + ter; % reove residual iaginary oponents due to round-off for i ::npoints for j ::n 7
D. Keffer, ChE 55, Dept. of Cheial Engineering, University of Tennessee, Septeber, if (iag(yp(j,i < tol yp(j,i real( yp(j,i ; %plot for j ::n if (j plot (tp,yp(j,:,'g-' elseif (j plot (tp,yp(j,:,'r-' elseif (j plot (tp,yp(j,:,'b-' elseif (j4 plot (tp,yp(j,:,'g:' elseif (j5 plot (tp,yp(j,:,'r:' elseif (j6 plot (tp,yp(j,:,'b:' hold on hold off label('tie '; ylabel('position & veloity '; leg('pos O','pos C', 'pos O','vel O','vel C', 'vel O'; 8
D. Keffer, ChE 55, Dept. of Cheial Engineering, University of Tennessee, Septeber,.5.5 position & veloity -.5 - -.5 pos O pos C pos O vel O vel C vel O - 4 5 6 7 8 9 tie Coents: The initial ondition is y o [.5 ]. Clearly periodi behavior is observed. lso observe visually that the veloities do indeed orrespond to the tie derivatives of the positions. There is no net enter of ass otion, sine in the initial ondition there was no enter of ass otion, and onservation of oentu is a onsequene of Newton s equations of otion. 9
D. Keffer, ChE 55, Dept. of Cheial Engineering, University of Tennessee, Septeber, 5 4 pos O pos C pos O vel O vel C vel O position & veloity - - 4 5 6 7 8 9 tie Coents: The initial ondition is y o [ ]. Clearly periodi behavior is observed. lso observe visually that the veloities do indeed orrespond to the tie derivatives of the positions. There is a net enter of ass otion, sine in the initial ondition there was a enter of ass otion, and onservation of oentu is a onsequene of Newton s equations of otion.