例题3.2
一、程序:
function BatchReactor
clear all;clc
k1=2; % Reaction rate constants,1/h
k2=0.5; % Reaction rate constants,1/h
C0=[2 0 0]; tspan=[0,3]; % C0:Initial Concentration C0(i),kmol/m^3
[t,C]=ode45(@MassEquations ,tspan,C0,[],k1,k2)
% 绘图
plot(t,C(:,1),'r-^',t,C(:,2),'k--',t,C(:,3),'b-.');
xlabel('Time(h)'); ylabel('Concentration(kmol/m^3)'); legend('A','P','Q')
CPmax=max(C(:,2)); % CPmax:the maximum concentration of P ,kmol/m^3
yPmax=CPmax/C0(1); % yPmax:the maximum yield of P
index=find(C(:,2)==CPmax);
t_opt=t(index) % t_opt:the optimum batch time,h
% ~
function dCdt=MassEquations(t,C,k1,k2)
rA=-k1*C(1)-2*k2*C(1)^2;
rP=k1*C(1);rQ=k2*C(1)^2;
dCdt=[rA;rP;rQ]; % Mass balances
二、运行结果:
t =
0
0.0000
0.0000
0.0000
0.0001
0.0001
0.0002
0.0002
0.0003
0.0006
0.0009
0.0012
0.0016
0.0031
0.0047
0.0063
0.0078
0.0157
0.0235
0.0314
0.0392
0.0668
0.0943
0.1219
0.1494
0.1880
0.2266
0.2651
0.3037
0.3578
0.4119
0.4660
0.5201
0.5874
0.6547
0.7219
0.7892
0.8642
0.9392
1.0142
1.0892
1.1642
1.2392
1.3142
1.3892
1.4642
1.5392
1.6142
1.6892
1.7642reaction mass
1.8392
1.9142
1.9892
2.0642
2.1392
2.2142
2.2892
2.3642
2.4392
2.5142
2.5892
2.6642
2.7392
2.8142
2.8892
2.9169
2.9446
2.9723
3.0000
C =
2.0000 0 0
1.9999 0.0001 0.0000
1.9998 0.0001 0.0001
1.9997 0.0002 0.0001
1.9996 0.0002 0.0001
1.9991 0.0005 0.0002
1.9986 0.0007 0.0004
1.9981 0.0010 0.0005
1.9976 0.0012 0.0006
1.9951 0.0025 0.0012
1.9926 0.0037 0.0019
1.9901 0.0050 0.0025
1.9876 0.0062 0.0031
1.9752 0.0124 0.0062
1.9629 0.0186 0.0092
1.9508 0.0248 0.0122
1.9387 0.0309 0.0152
1.8802 0.0608 0.0295
1.8242 0.0899 0.0430
1.7706 0.1181 0.0556
1.7193 0.1455 0.0676
1.5554 0.2357 0.1045
1.4131 0.3174 0.1348
1.2886 0.3917 0.1599
1.1788 0.4596 0.1808
1.0455 0.5453 0.2046
0.9317 0.6214 0.2234
0.8338 0.6894 0.2384
0.7488 0.7503 0.2504
0.6471 0.8257 0.2636
0.5621 0.8911 0.2734
0.4904 0.9479 0.2809
0.4294 0.9975 0.2865
0.3654 1.0509 0.2918
0.3122 1.0964 0.2957
0.2677 1.1353 0.2985
0.2302 1.1687 0.3006
0.1950 1.2005 0.3022
0.1656 1.2275 0.3035
0.1409 1.2504 0.3043
0.1201 1.2699 0.3050
0.1025 1.2866 0.3054
0.0876 1.3008 0.3058
0.0750 1.3130 0.3060
0.0642 1.3234 0.3062
0.0550 1.3323 0.3063
0.0472 1.3400 0.3064
0.0405 1.3465 0.3065
0.0347 1.3522 0.3065
0.0298 1.3570 0.3066
0.0256 1.3612 0.3066
0.0220 1.3647 0.3066
0.0189 1.3678 0.3067
0.0163 1.3704 0.3067
0.0140 1.3727 0.3067
0.0120 1.3746 0.3067
0.0103 1.3763 0.3067
0.0089 1.3777 0.3067
0.0076 1.3790 0.3067
0.0066 1.3800 0.3067
0.0057 1.3810 0.3067
0.0049 1.3817 0.3067
0.0042 1.3824 0.3067
0.0036 1.3830 0.3067
0.0031 1.3835 0.3067
0.0029 1.3837 0.3067
0.0028 1.3838 0.3067
0.0026 1.3840 0.3067
0.0025 1.3841 0.3067
t_opt =
3
三、绘图:
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论