Imaginary numbers when solving ode (ode15s)
显示 更早的评论
I tried solving 4 first-order differential equations simultaneously using ode15s. 2 of them are mass balance equations in a counter-current moving bed reactor, while the other 2 accounts for the heat balance.
1 function file is used containing the 4 ODEs and relevant values. 1 script file was used to run the function file to solve the ODEs.
Function file:
function dvar= movingbed_scaleupFR (z, var)
Xgf= var(1) ; Xsf= var(2); Tgf= var(3); Tsf= var(4);
%Xgf= CH4 conversion in the FR; Xsf= Solid conversion in the FR
%Tgf= CH4 temp in the FR; Tsf= Solid temp in the FR
Cgf= Cgofuel*(1-Xgf)*Tgofuel/((1+e*Xgf)*Tgf); %methane concentration in the FR
n= 0.681; %order of reaction
%solve for Sm
Np= rhobulk/mp; %number of particles per unit volume
Sm= Np*Ap; %surface area per unit volume
%%%%%% Sm solved %%%%%%%
%Cp equations
%solving for the ODEs
dXgfdz=(A/Fgofuel)*(rhos/b)*kf*Cgf^n;
dXsfdz=(A/Fsofuel)*(-1*rhos*kf)*Cgf^n;
dvar=[dXgfdz; dXsfdz; dTgfdz; dTsfdz];
end
Script:
function to_run_movingbed_scaleupFR
var0= [0, 1, 1223, 1223]; %Initial conditions for [Xgf, Xsf, Tgf, Tsf]
bedheight= [0 20]; %setting bed height
[z,y]= ode15s(@movingbed_scaleupFR, bedheight, var0);
%Graphing plotting
yyaxis left
hold on
plot(z,(y(:,1)),'-r','displayname','Xgf')
plot(z,(y(:,2)),'-b','displayname','Xsf')
legend;
ylabel('conversion');
xlabel('Length/m');
hold off
end
Running the script, i get imaginary parts as shown below.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
> In to_run_movingbed_scaleupFR (line 11)
Warning: Imaginary parts of complex X and/or Y arguments ignored.
> In to_run_movingbed_scaleupFR (line 12)
Warning: Imaginary parts of complex X and/or Y arguments ignored.
> In to_run_movingbed_scaleupFR (line 20)
Warning: Imaginary parts of complex X and/or Y arguments ignored.
> In to_run_movingbed_scaleupFR (line 21)
Final bed height whereby complete conversion occurs seemed wonky too, I was expecting bed height with a much longer length. So I assume the imaginary numbers along the way affected the output thereafter.
I'm not sure where I did wrong, I've checked the equations and values multiple times and can't find any mistakes.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!