|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
代码如下;6 N/ u2 x' F& {5 w. }" r% q( j
function Kinetics4
3 T! w+ |8 h6 b4 S# k1 \' lclear all
5 N+ O) I% } [1 K% Uclc
* P# l( C7 T+ w2 Yk0 = [2.159*10^8 4.734*10^6 174686 149892 0.99 0.7 0.5 0.78];%参数初值,其实是不知道的 1 `" c# W' L) J7 Q3 p& M# m3 w. C
lb = [-inf -inf -inf -inf -inf -inf -inf -inf]; % 参数下限! h" Y- j4 d7 E/ Q$ o/ m
ub = [inf inf inf inf inf inf inf inf]; % 参数上限
4 |: N F' a2 Iu0 = [0,0]; %y初值; b- Q' i! ^6 O( }7 p
a=[0;0.06680583;0.192617534;0.301693824;0.419783943;0.527041818;0.598345407;0.65055108;0.6876854;0;0.0295189820000000;0.0760025420000000;0.143652564000000;0.303435528000000;0.419715167000000;0.525496977000000;0.565069320000000;0.743536298000000;0;0.0411725930000000;0.0608472370000000;0.0986899250000000;0.241132264000000;0.324760943000000;0.466871464000000;0.531688237000000;0.683614442000000];2 M( ?9 y2 r) S+ u. d- q7 d- P
b=[0;0.2378;0.3288;0.3556;0.39;0.3877;0.3766;0.3580;0.3384;0;0.1373;0.2123;0.2755;0.3561;0.3549;0.3475;0.3486;0.2518;0;0.115879961000000;0.178182567000000;0.219982937000000;0.315058656000000;0.339244190000000;0.348664305000000;0.351963292000000;0.313743618000000];
- S! A- ~: V' g1 [6 S! Pyexp=[a,b];5 v- p7 _; v9 y& g# Z! \
% 使用函数lsqnonlin()进行参数估计
! `! l! T( `$ J6 }) Y4 a+ p, _/ s6 q/ _2 @) w: ^9 n6 i
[k,resnorm,residual,exitflag,output,lambda,jacobian] = ...
! X1 J* @2 d3 P lsqnonlin(@ObjFunc4LNL,k0,lb,ub,[],u0,yexp); / ?* O3 j* W- c" `; r; k0 {6 }
ci = nlparci(k,residual,jacobian);
& K6 k6 d/ s* l9 [; vfprintf('\tk1 = %.4f ± %.4f\n',k(1),ci(1,2)-k(1)); [8 ?; W s/ L3 x- B
fprintf('\tk2 = %.4f ± %.4f\n',k(2),ci(2,2)-k(2))9 `% p. k: Y* D$ A
fprintf('\tk3 = %.4f ± %.4f\n',k(3),ci(3,2)-k(3)) " l3 N _2 ^3 ^; s, J* Q, A' A) m
fprintf('\tk4 = %.4f ± %.4f\n',k(4),ci(4,2)-k(4))
* r. z3 ?$ h* m6 W! Efprintf('\tk5 = %.4f ± %.4f\n',k(5),ci(5,2)-k(5))8 X2 B( D0 U' X0 u# a& i
fprintf('\tk6 = %.4f ± %.4f\n',k(6),ci(6,2)-k(6))/ N, z8 u3 M* g7 X
fprintf('\tk7 = %.4f ± %.4f\n',k(7),ci(7,2)-k(7))( A0 S5 V+ ~$ z- Z
fprintf('\tk8 = %.4f ± %.4f\n',k(8),ci(8,2)-k(8))
0 n- Z5 G" P8 ]* t7 X( L7 H0 Wfprintf(' The sum of the squares is: %.1e\n\n',resnorm)
2 m% u, W0 c8 ofprintf('\n\n使用函数lsqnonlin()估计得到的参数值为:\n')
( l+ r3 I. a( m%目标函数* i. G* ]) `( Q2 [9 t& @7 d5 M
function f =ObjFunc4LNL(k,u0,yexp)
6 j# T0 o/ x( h$ Vglobal theta Pt Ac R T Fa0
' `" {+ _) g5 k. @1 {9 wtheta=zeros(5,1);
% H7 o& ^0 V2 c: Qr0= 1.24*10^-3; % Outer diameter of the membrane, [m]2 g' v: z- j) }6 G$ N
ri= 9.4*10^-4;% Inner diameter of the membrane, [m]
! ?6 _# l3 @7 or=(r0-ri)/log(r0/ri);% equivalent diameter ,[m]6 X# P" L8 u9 t
Pi=3.14159;1 L k9 u9 ]( y7 ^' f! o
L=0.05;% membrane length,[m]
* r1 p2 S) w4 K, r$ h" d1 I. Q) KAc=Pi*r*L;% membrane area [m^2]
4 F) ?/ \: q3 J2 _) ~. |9 }- @ ]R=8.314; % [J/K.mol]
, _1 _! t$ \* w' _/ T( bPt=101.325;. r( g7 o3 M6 j) G0 K
Ftot=[2.678*10^-2;2.678*10^-2*1.5;2.678*10^-2*2];
3 U0 g) }" j$ VKmax=length(Ftot);
?, C' b4 @: h; R; ]/ }( ]! N
2 i, K" R. P5 T9 t jT0=600+273;% Inlet temperature [K]/ r. N0 N3 ]0 p
nmax=9;! L+ S6 P2 X& ?5 x( P. K. T/ w
X1=zeros(nmax,Kmax);X2=zeros(nmax,Kmax);
: x5 ]2 Q# P6 }7 s* [% s+ mfor K=1:Kmax
! o4 P- | Q U) A ]Fa0=Ftot(K); % If Pt is the parameter/Matrix: B+ B U) m# p) r! J @3 ^8 g, c
%Pt=Pt0+(k-1)*1; % If Pt is an axis
- Q: ~; y' X" F: c+ z%L=Lsize(k); % If L is the parameter/Matrix
0 J/ j, Q' g$ R5 m$ b%theta(2)=H2Oratio+(k-1)*1; % If m is the parameter/Matrix3 E- J" Z7 c0 g# n7 n9 w
theta(2)=3; % F0(H2O)/F0(CH4)3 ^+ I" @) Q7 }+ @$ ? m+ K/ \2 m% l
theta(3)=0; % F0(CO)/F0(CH4)
, \+ v4 K, d# p7 B$ z( Ctheta(4)=0; % F0(CO2)/F0(CH4)4 }- A( f3 o$ V6 U
theta(5)=0; % F0(H2)/F0(CH4)! D. |7 c6 f, A7 z, `( p
for n=1:nmax+ e5 g/ ]3 U( W8 f3 M6 R/ h
%delta=delta0+(n-1)*1e-6; % If delta is the parameter/Matrix5 j8 ~9 i6 @: J* l
%rit=r0+delta; % inner tube radius [m], h p6 A1 K5 ~2 B0 N7 q* V
%sweep=s0+(n-1); % If sweep is the parameter/Matrix
0 |3 z- U# J/ d+ H2 F+ O _%T=T0; % If T is a constant
; i7 }4 E7 z! PT=T0+(n-1)*50;- h* ~& D) Q5 N# p: ?: Y8 m
ksispan=(0:0.1:1); % precision
8 w2 o$ a2 i& }( e* @5 l% j5 U% ~9 H[ksi,S1]=ode23s(@KineticEqs,ksispan,u0,[],k); % PBR reactor' I8 P) `2 B7 g/ v- _
X1(n,Kmax)=real(S1(end,1)); % methane finale conversion
0 h! `4 ?% t: p$ V% KX2(n,Kmax)=real(S1(end,2)); % carbon dioxide finale conversion2 X M$ ?+ k: ^
end( `, n3 [* \# a2 ] s
end: J( D8 z" Q6 j9 w$ H. V7 i- D1 t
f1=X1(n,Kmax)-yexp(:,1);
7 b- h6 [! @: a7 g {: D: Q, If2=X2(n,Kmax)-yexp(:,2);
2 ?3 Q6 w) W$ E a+ j2 u3 t3 K: uf=[f1;f2];
' `: d1 }8 F- F3 r1 H%T0=T0-273.15;T=T-273.15; % Temperature expressed in Celsius ' K* s8 X6 [) n* F2 k
%Tspan=(T0:1:T);$ l) M; v( I8 |3 O2 v& ]9 T- p% U
%Pspan=(Pt0:1 t);
* U& J% k, T6 W9 \# D3 X: k%DSPan=(delta0*1e6:1:delta*1e6);: P, | S+ x4 J" _% _" n, d
%Sspan=(s0:1:sweep);7 I% O% D2 |3 S& v
%D(:, =X3(:, -X1(:, ; % Delta = XCH4(MR) - XCH4(PBR)
. C) J6 y3 W, X" t! F3 ~9 N
. Z8 g, D9 c& V' Qfunction diff=KineticEqs(ksi,u,k)
7 h+ v0 o+ ?5 c: c% ~global theta Pt Ac Fa0 T R" d9 M F; \ d ], {$ G
S=Pt/(1+theta(2)+theta(3)+theta(4)+theta(5)+2*(u(1)+u(2)));
A6 m( }7 Q4 _; wP(1)=(1-u(1)-u(2))*S;( W- \3 B2 f t$ i% f' N6 B
P(2)=(theta(2)-u(1)-2*u(2))*S;: o7 \9 R% p% q( [3 K( Y
P(3)=(theta(3)+u(1))*S;! S1 A0 Z7 A0 t5 y
P(4)=(theta(4)+u(2))*S;0 l# G* G1 D( P0 X+ M6 i' }
P(5)=(theta(5)+3*(u(1)+u(2))+u(2))*S;
4 w$ U/ {# i& u( _; l& _" O9 q% Differential System( s6 i2 s5 T$ @
diff1=Ac/Fa0*k(1)*exp(-k(3)/R/T)*P(1)^k(5)*P(2)^k(7);
; i7 m% X* N! s' x7 R3 L3 zdiff2=Ac/Fa0*k(2)*exp(-k(4)/R/T)*P(1)^k(6)*P(2)^k(8);; A* ?7 w8 A8 G8 ~' [
diff=[diff1 diff2]';
! `8 c; M5 w- v* F) p
k- @2 x% r$ q2 u7 w0 Y' ~运行结果:* ?9 w' i1 @ {. U( E
In nlparci (line 104)
6 L6 D( q) O! s# K/ N' c In Kinetics4 (line 15)# x6 r. }) U+ [- j' e" D ^" J# Q
警告: 矩阵为奇异工作精度。, K& O! V( M- W
k1 = 215900000.0000 ± NaN
5 ^" U& q2 X$ \2 B9 `- a k2 = 4734000.0000 ± NaN
3 j1 D6 l6 Q$ j' y k3 = 174686.0000 ± NaN
- G3 r6 |: o* V6 [ k4 = 149892.0000 ± NaN" `6 B, ~; t; x2 X! g ^7 @' E
k5 = 1.2381 ± NaN
7 C( f3 m/ s6 g7 i% v% M9 c' |) {% U k6 = 0.5426 ± NaN
: v# c( q6 y+ {) p! f k7 = -0.3426 ± NaN
1 Q5 V, C* a4 c2 T8 X: U; h" X k8 = 0.4455 ± NaN
* s. A; a) `3 m i) ~( ? The sum of the squares is: 2.0e+002 o& m2 L* h: P8 P
|
|