Please include comments & output to the following: Consider the system of ordina
ID: 3553220 • Letter: P
Question
Please include comments & output to the following:
Consider the system of ordinary differential equations x1 = - k1x1x2 - 2k2x - k3x1x5 x2 = -k1x1x2 - k4x2x3 x3 = k3x1x5 - k4x2x3 x4 = k4x2x3 x5 = -k3x1x5 + k1x1x2 x6 = 2kA2 where xi are the concentration of species in a chemical reaction and k's are the rate constants. The rate constants are given by k1 = .13 times 10 -l0, k2 = .39 times 10 -11, k3 = .14 times 10 -12, k1 = .4 times 10 -l0. The initial concentrations are given by x1(0) = 1. times 10 +11, x2(0) = 1.times 10 +11, x3(0) = x4(0) = x5(0) = x6(0) = 0. [RK = Runge-Kutta] Use two different methods to integrate the equations forward untill the reaction is complete ( x = 0). Use the RK-Fehlberg and use a lower order RK method. Study the accuray of the schemes at equilibrium. How close is it to zero, (i.e, x = 0 or f(x) = 0 at final time.) Plot the time history of the concentrations as a function of time.Explanation / Answer
%Define constants
k1=0.13*10^(-10);
k2=0.39*10^(-11);
k3=0.14*10^(-12);
k4=0.4*10^(-10);
x1(1)=0;
x2(1)=0;
x3(1)=0;
x4(1)=0;
x5(1)=0;
x6(1)=0;
x1(1)=1*10^(11);
x2(1)=1*10^(11);
x3(1)=0;
x4(1)=0;
x5(1)=0;
x6(1)=0;
%Iterate for RK method
for i=1:100
x1(i+1)=-k1.*x1(i).*x2(i)-2.*k2.*x1(i).^2-k3.*x1(i).*x5(i);
x2(i+1)=-k1.*x1(i).*x2(i)-k4.*x2(i).*x3(i);
x3(i+1)=k3.*x1(i).*x5(i)-k4.*x2(i).*x3(i);
x4(i+1)=k4.*x2(i).*x3(i);
x5(i+1)=-k3.*x1(i).*x5(i)+k1.*x1(i).*x2(i);
x6(i+1)=2.*k2.*x1(i).^2;
end