声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1385|回复: 2

[求助]matlab运行了10个小时还不出结果

[复制链接]
发表于 2005-12-24 13:52 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
<P>我把几个小程序封装在一起后,运行10个小时却还不出结果,但把ode45改为ode23s结果2分钟就出来了,程序如下:<br>function Simulate</P>
<P>clear all;clc<br>format long</P>
<P>R=8.31434;<br>t=700;                        % 气体温度,t: Temperatre, Celsius<br>T = t + 273.15;               % T: Temperatre, K<br>M=101325/(R*T)                % 第三体浓度M<br>xCH4=0.2;xCO2=1-xCH4;         % xCH4为甲烷的摩尔百分含量<br>cCH4=xCH4*M,cCO2=xCO2*M,<br>Y0=[cCH4 cCO2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0];  % 各物质的初始浓度<br>[t,Y]=ode23(@f,[0:0.005:0.05],Y0,[],T,M);<br>disp('Results by using ode45():')<br>disp([t Y])<br>plot(t,Y),xlabel('t'),ylabel('Y')<br>legend('CH4','CO2','H2','CO','H2O','O2','CH3','CH2','CH','C','H','O','OH','HCO','CH2O','CH3O','HO2')<br>Cbanlance=Y0(1)+Y0(2)-Y(:,1)-Y(:,2)-Y(:,4)-Y(:,7)-Y(:,8)-Y(:,9)-Y(:,10)-Y(:,14)-Y(:,15)-Y(:,16);<br>Hbanlance=4*Y0(1)-4*Y(:,1)-2*Y(:,3)-2*Y(:,5)-3*Y(:,7)-2*Y(:,8)-Y(:,9)-Y(:,11)-Y(:,13)-Y(:,14)-2*Y(:,15)-3*Y(:,16)-Y(:,17);<br>Obanlance=2*Y0(2)-2*Y(:,2)-Y(:,4)-Y(:,5)-2*Y(:,6)-Y(:,12)-Y(:,13)-Y(:,14)-Y(:,15)-Y(:,16)-2*Y(:,17);<br>disp('Cbanlance,Hbanlance,Obanlance:')<br>disp([Cbanlance Hbanlance Obanlance])<br>xlswrite('ode45forSimulate3',[t Y]);<br>%--------------------------------------------------------------------------<br>function dYdt=f(t,Y,T,M)</P>
<P>NA=6.02217e+23;   <br>electronm=9.10956e-31;kb=1.38062e-23;electronC=1.60219e-19;<br>electrondensity=7e+11;Ne=electrondensity*1e+06/NA;   % 电子密度electrondensity<br>Te=2;              % 平均电子温度,单位eV</P>
<P>% -------------------------------------------------------------------------<br>Tch4 = Te*11600;         % T: Temperatre, K<br>% 求甲烷与电子碰撞的反应<br>K01=Krate(5.16e-05,-0.642,169882.6,Tch4);K02=Krate(3.02e-04,-0.781,190073.5,Tch4);<br>K03=Krate(5.75e-04,-0.828,204462.5,Tch4);K04=Krate(6.29e-16,0,0,Tch4);<br>% -------------------------------------------------------------------------</P>
<P>% -------------------------------------------------------------------------<br>% 求二氧化碳与电子碰撞的反应<br>Eth = 1.1e-02;          % 积分下限,单位keV<br>Eupper = 5.0e-02;       % 积分下限,单位keV<br>f3_quadl = quadl(@func,Eth,Eupper,1e-30,[],Eth,Te);<br>K05=((8*electronC/(pi*electronm))^(1/2))*((Te)^(-3/2))*f3_quadl*(1e-4)*NA;<br>% -------------------------------------------------------------------------</P>
<P>% -------------------------------------------------------------------------<br>% 求自由基反应速率常数<br>K1 = rate1(7.23e+14,0.0,14970,T,2);K2 = rate1(4.10e+14,0.0,13970,T,2);K3 = rate1(2.83e+13,0.0,4970,T,2);<br>K4 = rate1(2.60e+28,-5.11,-2627,T,2);K5 = rate1(8.00e+12,0.0,0,T,2);K6 = rate1(8.00e+13,0.0,0,T,2);<br>K7 = rate1(3.40e+11,0.0,8940,T,2);K8 = rate1(2.00e+13,0.0,0,T,2);K9 = rate1(1.00e+12,0.0,400,T,2);<br>K10 = rate1(4.00e+13,0.0,0,T,2);K11 = rate1(1.00e+14,0.0,3700,T,2);K12 = rate1(8.64e+10,0.0,-500,T,2);<br>K13 = rate1(1.59e+12,0.0,1000,T,2);K14 = rate2(2.50e+13,0.00,0.0,T,2);K15 = rate1(2.00e+13,0.0,0,T,2);<br>K16 = rate1(1.00e+13,0.0,0,T,2);K17 = rate1(4.00e+13,0.0,0,T,2);K18 = rate1(5.00e+13,0.0,2100,T,2);<br>K19 = rate1(1.00e+12,0.0,6000,T,2);K20 = rate1(3.50e+13,0.0,3510,T,2);K21 = rate1(2.50e+13,0.0,3990,T,2);<br>K22 = rate1(7.53e+12,0.0,170,T,2);K23 = rate1(1.00e+10,0.5,6000,T,2);K24 = rate1(3.55e+14,0.0,16790,T,2);<br>K25 = rate1(5.00e+13,0.0,0,T,2);K26 = rate1(2.00e+14,0.0,0,T,2);K27 = rate1(3.00e+13,0.0,0,T,2);<br>K28 = rate1(3.00e+13,0.0,0,T,2);K29 = rate1(3.00e+12,0.0,0,T,2);K30 = rate1(5.93e+8,1.05,-613,T,2);<br>K31 = rate1(3.00e+11,0.5,0,T,2);K32 = rate1(2.20e+22,-2.0,0,T,3);K33 = rate1(1.00e+16,0.0,0,T,3);<br>K34 = rate1(4.70e+15,-0.28,0,T,3);K35 = rate1(1.83e+18,-1.0,0,T,3);K36 = rate1(2.30e+18,-0.8,0,T,3);<br>K37 = rate1(1.50e+9,1.14,0,T,2);K38 = rate1(1.00e+13,0.0,0,T,2);K39 = rate1(8.30e+9,1.0,6950,T,2);<br>K40 = rate1(1.80e+10,1.0,8910,T,2);K41 = rate1(4.40e+6,1.5,-740,T,2);K42 = rate1(1.20e+9,1.3,3630,T,2);<br>K43 = rate1(1.50e+14,0.84,1000,T,2);K44 = rate1(2.50e+13,0.0,700,T,2);K45 = rate1(2.00e+13,0.0,0,T,2);<br>K46 = rate1(1.50e+13,0.0,0,T,2);K47 = rate3(6.3e+11,0.5,0,T,2);K48 = rate3(6.3e+11,0.5,0,T,2);<br>K49 = rate2(4.80e+01,3.22,-13.5,T,2);<br>%--------------------------------------------------------------------------<br>% 解常微分方程组<br>f1=K4*Y(7)*Y(11)+K9*Y(7)*Y(17)+K23*Y(15)*Y(7)+K31*Y(14)*Y(7)-(K01+K02+K03+K04)*Y(1)*Ne-K1*Y(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Y(15)*Y(12)+K27*Y(14)*Y(12)+K33*Y(12)*Y(11)*M+K40*Y(3)*Y(12)+2*K43*Y(17)*Y(11)+K45*Y(17)*Y(12)-K3*Y(1)*Y(13)-K5*Y(7)*Y(13)-K14*Y(8)*Y(13)-K22*Y(15)*Y(13)-K25*Y(14)*Y(13)-K32*Y(13)*Y(11)*M-2*K37*Y(13)*Y(13)-K38*Y(12)*Y(13)-K39*Y(11)*Y(13)-K41*Y(4)*Y(13)-K42*Y(13)*Y(3)-K46*Y(17)*Y(13)-K48*Y(10)*Y(13);<br>f14=K11*Y(8)*Y(6)+K16*Y(9)*Y(6)+K20*Y(15)*Y(12)+K21*Y(15)*Y(11)+K22*Y(15)*Y(13)+K23*Y(15)*Y(7)+K49*Y(2)*Y(9)-K24*Y(14)*M-K25*Y(14)*Y(13)-K26*Y(14)*Y(11)-K27*Y(14)*Y(12)-K28*Y(14)*Y(12)-K29*Y(14)*Y(6)-K30*Y(14)*Y(17)-K31*Y(14)*Y(7);<br>f15=K5*Y(7)*Y(13)+K6*Y(7)*Y(12)+K7*Y(7)*Y(6)+K14*Y(8)*Y(13)+K18*Y(16)*M+K19*Y(16)*Y(6)+K30*Y(14)*Y(17)-K20*Y(15)*Y(12)-K21*Y(15)*Y(11)-K22*Y(15)*Y(13)-K23*Y(15)*Y(7);<br>f16=K8*Y(7)*Y(17)-K18*Y(16)*M-K19*Y(16)*Y(6);<br>f17=K19*Y(16)*Y(6)+K29*Y(14)*Y(6)+K36*Y(11)*Y(6)*M-K8*Y(7)*Y(17)-K9*Y(7)*Y(17)-K30*Y(14)*Y(17)-K43*Y(17)*Y(11)-K44*Y(17)*Y(11)-K45*Y(17)*Y(12)-K46*Y(17)*Y(13);<br>dYdt=[f1;f2;f3;f4;f5;f6;f7;f8;f9;f10;f11;f12;f13;f14;f15;f16;f17];</P>
<P>% -------------------------------------------------------------------------<br>function K0 = Krate(A,B,C,T)<br>NA=6.02217e+23;<br>% T: Temperatre, K<br>K0 = A*T^B*exp(-C/T)*NA*1e-06;  </P>
<P>% -------------------------------------------------------------------------<br>function Kco2 = func(Eev,Eth,Te)  <br>sigma=1e-16;Rydberg=1.361e-2;<br>E1=Eev-Eth;           % Eev和Eth单位为keV<br>c1=3.160e-1;c2=1.046;c3=1.210e-2;c4=1.320e-1;c5=5.140e-2;c6=9.300e-1;<br>f1=sigma*c1*((E1./Rydberg).^c2);<br>f3=f1./(1+((E1./c3).^(c2+c4))+((E1./c5).^(c2+c6)));<br>Kco2=1e+6*Eev.*f3.*exp(-1000*Eev./Te);<br>% -------------------------------------------------------------------------<br>function K1= rate1(A,b,E,T,n)<br>% T: Temperatre, K<br>j=4.1840;R=8.31434;<br>K1 = A*T^b*exp(-E*j/(R*T))*(1e-6)^(n-1); <br>% -------------------------------------------------------------------<br>function K2= rate2(A,b,E,T,n)<br>% T: Temperatre, K<br>R=8.31434;<br>K2 = A*T^b*exp(-E*1000/(R*T))*(1e-6)^(n-1); <br>% -------------------------------------------------------------------<br>function K3= rate3(A,B,EdR,T,n)<br>% T: Temperatre, K<br>K3 = A*T^B*exp(-EdR/T)*(1e-6)^(n-1); </P>

[此贴子已经被作者于2005-12-24 13:54:52编辑过]

回复
分享到:

使用道具 举报

发表于 2005-12-24 14:37 | 显示全部楼层
不爱看程序,不过给个建议,<BR>看下帮助是不是2个ode实现过程的要求不一样<BR>也即其收敛条件不一样
发表于 2005-12-25 08:42 | 显示全部楼层

回复:(mathtype)[求助]matlab运行了10个小时还不出...

估计你的方程是刚性的,ode45适合求解非刚性方程,ode23s适合求解刚性方程
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-21 01:35 , Processed in 0.058354 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表