I am getting error:Warning: Failure at t=0.000000e+00. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (7.905050e-323)
36 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
This is my code
clc
clear
global datei Temp c0
datei='input_data.m';
run(datei);
zspan=[0 V/A_hc];
%intergration of the system
options=odeset('RelTol',1e-12,'AbsTol',1e-12);%,'NonNegative',2:7);
for n=1:size(c,1)
switch dataset
case 1
name=[experiment ' ' num2str(y0_nh3_scr(n,2)) ' ppm NH3 ' num2str(y0_nh3_scr(n,1)) ' vol NO ' num2str(y0_nh3_scr(n,5)) '% O2' ];
case 2
name=[experiment ' ' num2str(y0_nh3_ox(n,2)) ' ppm NH3 ' num2str(y0_nh3_ox(n,5)) ' vol O2'];
case 3
name=[experiment ' ' num2str(y0_hcho_ox(n,3)) ' ppm HCHO ' num2str(y0_hcho_ox(n,5)) ' vol O2'];
end
results=zeros(length(T),size(c,2)+2);
for m=1:length(T)
c0=c(n,1:4).*T_N./T(m);
c_o2=c0_o2(n).*T_N./T(m);
p_o2=p0_o2(n);
y0=[c0 0];
Temp=T(m);
tic
disp(['Calculating Step ' num2str(m) ' of ' num2str(length(T))])
[t,y]=ode15s(@massbalance,zspan,y0,options);
toc
results(m,:)=[T(m)-273.15 y(end,:)];
end
end
results(:,2:5)=results(:,2:5).*Vm.*1e6.*(results(:,1)+273.15)./T_N;
switch dataset
case 1
results(:,2:3)=(1-results(:,2:3)./y0_nh3_scr(n,1:2)).*100;
case 2
results(:,3)=(1-results(:,3)./y0_nh3_ox(n,2)).*100;
case 3
results(:,4)=(1-results(:,4)./y0_hcho_ox(n,3)).*100;
end
name=[name ' ' char(num2str(fix(clock)))];
save(name,'results','-double','-ascii')
plot(results(:,1),results(:,2),'b',results(:,1),results(:,3),'r',results(:,1),results(:,6),'g')
xlabel('T / ^oC')
ylabel('y / ppm')
legend('NO','NH3','N2O')
function dy_dz = massbalance(takt,y)
global datei Temp c0
run(datei)
F=F*Temp/T_N;
u=F/A_hc;
if c0(1)==0
kin=kin_ox;
else
kin=kin_scr;
end
r1=kin(1,1).*exp(-kin(1,2)./R.*(1/Temp-1/kin(1,3))).*y(2).*(1-y(5));
r2=kin(2,1).*exp(-(kin(2,2)-y(5).*kin(2,3))./(R.*Temp)).*y(5);
r3=kin(3,1).*exp(-kin(3,2)./(R.*Temp)).*y(1).*y(5);
r4=kin(4,1).*exp(-kin(4,2)./(R.*Temp)).*y(5);
r5=kin(5,1).*exp(-kin(5,2)./(R.*Temp)).*y(4);
r6=kin(6,1).*exp(-kin(6,2.)/(R.*Temp)).*y(3);
%% mass balances
dy_dz=[1/u*(-r3)
1/u*(-r1+r2)
1/u*(-r6)
1/u*(-r5)
(r1-r2-r3-r4)/(u*gam)];
end
I am not able to figure out where I am making a mistake. I appricate all the help in advance.
0 Commenti
Risposta accettata
Torsten
il 21 Apr 2024
Modificato: Torsten
il 21 Apr 2024
If you remove the semicolon behind
%% mass balances
dy_dz=[1/u*(-r3)
1/u*(-r1+r2)
1/u*(-r6)
1/u*(-r5)
(r1-r2-r3-r4)/(u*gam)];
and execute the code, you will see from what MATLAB writes to screen that the vector dy_dz contains NaN values right from the beginning of the integration.
And remember the time MATLAB needs to run "input_data.m" each time the function "massbalance" is called. Run "input_data.m" once as you already do in your script and pass the necessary parameters and arrays to "massbalance" via your call to ode15s:
[t,y] = ode15s(@(t,y)massbalance(t,y,parameter1,parameter2,...,array1,array2,...),zspan,y0,options);
...
function dy = massbalance(t,y,parameter1,parameter2,...,array1,array2,...)
...
end
0 Commenti
Più risposte (1)
Joshua Levin Kurniawan
il 21 Apr 2024
Error "Unable to meet integration tolerances without reducing the step size below the smallest value allowed " usually appears when there is a sudden discontinuities/sharp profile in the reference signal. We cannot avoid this error unless you set the relative and absolute tolerance to a bigger value.
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!